Testing memcmp and memcpy from TF-A libc
Removing previously used c-picker based tests and fully testing memcmp
and memcpy functions from the TF-A libc by linking them directly to the
test binary.
Change-Id: Ic343094603a563beda43ccda737d0e6f89f254e4
Signed-off-by: Imre Kis <imre.kis@arm.com>
diff --git a/tests/lib/libc/test_memcpy.cpp b/tests/lib/libc/test_memcpy.cpp
index 64f02c2..3e436ef 100644
--- a/tests/lib/libc/test_memcpy.cpp
+++ b/tests/lib/libc/test_memcpy.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -9,10 +9,26 @@
#include "lib/libc/string.h"
}
-TEST_GROUP(memcpy) {
+#define BUFFER_SIZE (16)
+TEST_GROUP(memcpy) {
+ TEST_SETUP() {
+ for (int i = 0; i < BUFFER_SIZE; i++) {
+ dst[i] = 0;
+ src[i] = 0;
+ }
+ }
+
+ uint8_t dst[BUFFER_SIZE];
+ uint8_t src[BUFFER_SIZE];
};
-TEST(memcpy, empty) {
- LONGS_EQUAL(0, memcpy(NULL, NULL, 0))
+TEST(memcpy, zero_length) {
+ POINTERS_EQUAL(dst, memcpy(dst, src, 0));
+ MEMCMP_EQUAL(src, dst, sizeof(dst));
+}
+
+TEST(memcpy, copy_all) {
+ POINTERS_EQUAL(dst, memcpy(dst, src, sizeof(dst)));
+ MEMCMP_EQUAL(src, dst, sizeof(dst));
}