Add fortify memcpy_chk happy path tests.

This catches subtly-broken __memcpy_chk() implementations that fail on
the boundary condition where the requested size is exactly the size of
the destination buffer; this can be validated by changing the x86
__memcpy_chk comparison opcode from `ja` to `jae` and ensuring the test
fails.

Additionally, a test that exercises the non-failure path where the
requested size is less than the buffer size is added, since this wasn't
explicitly tested previously.

Bug: 389669171
Test: ./tests/run-on-host.sh 32 --gtest_filter='*memcpy*'
Test: ./tests/run-on-host.sh 64 --gtest_filter='*memcpy*'
Change-Id: Icd47731f237574b4f8275616137fca8a2d8bb94c
diff --git a/tests/fortify_test.cpp b/tests/fortify_test.cpp
index 64194c8..216eaa0 100644
--- a/tests/fortify_test.cpp
+++ b/tests/fortify_test.cpp
@@ -956,6 +956,40 @@
 
 extern "C" void* __memcpy_chk(void*, const void*, size_t, size_t);
 
+TEST(TEST_NAME, memcpy_chk_smaller) {
+  char buf[10] = "XXXXXXXXX";
+  size_t n = atoi("5");
+  void* res = __memcpy_chk(buf, "012346578", n, sizeof(buf));
+  ASSERT_EQ((void*)buf, res);
+  ASSERT_EQ('0',  buf[0]);
+  ASSERT_EQ('1',  buf[1]);
+  ASSERT_EQ('2',  buf[2]);
+  ASSERT_EQ('3',  buf[3]);
+  ASSERT_EQ('4',  buf[4]);
+  ASSERT_EQ('X',  buf[5]);
+  ASSERT_EQ('X',  buf[6]);
+  ASSERT_EQ('X',  buf[7]);
+  ASSERT_EQ('X',  buf[8]);
+  ASSERT_EQ('\0', buf[9]);
+}
+
+TEST(TEST_NAME, memcpy_chk_exact_size) {
+  char buf[10] = "XXXXXXXXX";
+  size_t n = atoi("10");
+  void* res = __memcpy_chk(buf, "012345678", n, sizeof(buf));
+  ASSERT_EQ((void*)buf, res);
+  ASSERT_EQ('0',  buf[0]);
+  ASSERT_EQ('1',  buf[1]);
+  ASSERT_EQ('2',  buf[2]);
+  ASSERT_EQ('3',  buf[3]);
+  ASSERT_EQ('4',  buf[4]);
+  ASSERT_EQ('5',  buf[5]);
+  ASSERT_EQ('6',  buf[6]);
+  ASSERT_EQ('7',  buf[7]);
+  ASSERT_EQ('8',  buf[8]);
+  ASSERT_EQ('\0', buf[9]);
+}
+
 TEST(TEST_NAME, memcpy_chk_max_int_size) {
   char buf[10];
   size_t buf_size = atoi("-1");