aboutsummaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2015-06-24 13:23:12 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-06-24 13:23:12 +1000
commitb8677f6a97a978e11017736a280bc948bb1a85fe (patch)
tree79957c6a8686389308c700d5c63888641a066c76 /libc
parent82d60cae3f53317dc7a3e84de00656bdd03a504a (diff)
downloadskiboot-b8677f6a97a978e11017736a280bc948bb1a85fe.zip
skiboot-b8677f6a97a978e11017736a280bc948bb1a85fe.tar.gz
skiboot-b8677f6a97a978e11017736a280bc948bb1a85fe.tar.bz2
add tests for libc memcmp
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'libc')
-rw-r--r--libc/test/run-memops-test.c6
-rw-r--r--libc/test/run-memops.c4
2 files changed, 10 insertions, 0 deletions
diff --git a/libc/test/run-memops-test.c b/libc/test/run-memops-test.c
index 7212d76..c848a1d 100644
--- a/libc/test/run-memops-test.c
+++ b/libc/test/run-memops-test.c
@@ -45,6 +45,7 @@
int test_memset(char* buf, int c, size_t s);
int test_memchr(const void *ptr, int c, size_t n, void* expected);
+int test_memcmp(const void *ptr1, const void *ptr2, size_t n, int expected);
int test_memset(char* buf, int c, size_t s)
{
@@ -63,3 +64,8 @@ int test_memchr(const void *ptr, int c, size_t n, void* expected)
{
return(expected == memchr(ptr, c, n));
}
+
+int test_memcmp(const void *ptr1, const void *ptr2, size_t n, int expected)
+{
+ return(expected == memcmp(ptr1, ptr2, n));
+}
diff --git a/libc/test/run-memops.c b/libc/test/run-memops.c
index cc107f7..ded21ae 100644
--- a/libc/test/run-memops.c
+++ b/libc/test/run-memops.c
@@ -23,6 +23,7 @@
int test_memset(char* buf, int c, size_t s);
int test_memchr(const void *ptr, int c, size_t n, void* expected);
+int test_memcmp(const void *ptr1, const void *ptr2, size_t n, int expected);
int main(void)
{
@@ -45,6 +46,9 @@ int main(void)
strncpy(buf, "Hello World!", 20);
assert(test_memchr(buf, 'o', strlen(buf), buf+4));
assert(test_memchr(buf, 'a', strlen(buf), NULL));
+
+ assert(test_memcmp(buf, "Hello World!", strlen(buf), 0));
+ assert(test_memcmp(buf, "Hfllow World", strlen(buf), -1));
free(buf);
return 0;