diff options
| -rw-r--r-- | tests/Makefile | 12 | ||||
| -rw-r--r-- | tests/test_memmove_dynamic_read.c | 16 | ||||
| -rw-r--r-- | tests/test_memmove_dynamic_write.c | 16 | ||||
| -rw-r--r-- | tests/test_memmove_static_read.c | 16 | ||||
| -rw-r--r-- | tests/test_memmove_static_write.c | 16 |
5 files changed, 72 insertions, 4 deletions
diff --git a/tests/Makefile b/tests/Makefile index c48d0b0..1f80c32 100644 --- a/tests/Makefile +++ b/tests/Makefile | |||
| @@ -1,10 +1,14 @@ | |||
| 1 | CC=../x86_64-linux-musl-native/bin/gcc | 1 | CC=../x86_64-linux-musl-native/bin/gcc |
| 2 | CFLAGS=-I../include/ -D_FORTIFY_SOURCE=3 -static -O2 | 2 | CFLAGS=-I../include/ -D_FORTIFY_SOURCE=3 -static -O2 |
| 3 | 3 | ||
| 4 | TARGETS=test_memcpy_static_write \ | 4 | TARGETS=test_memcpy_static_write \ |
| 5 | test_memcpy_dynamic_write \ | 5 | test_memcpy_dynamic_write \ |
| 6 | test_memcpy_static_read \ | 6 | test_memcpy_static_read \ |
| 7 | test_memcpy_dynamic_read | 7 | test_memcpy_dynamic_read \ |
| 8 | test_memmove_static_write \ | ||
| 9 | test_memmove_dynamic_write \ | ||
| 10 | test_memmove_static_read \ | ||
| 11 | test_memmove_dynamic_read | ||
| 8 | 12 | ||
| 9 | .SILENT: | 13 | .SILENT: |
| 10 | 14 | ||
diff --git a/tests/test_memmove_dynamic_read.c b/tests/test_memmove_dynamic_read.c new file mode 100644 index 0000000..1a01925 --- /dev/null +++ b/tests/test_memmove_dynamic_read.c | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | #include "common.h" | ||
| 2 | |||
| 3 | #include <string.h> | ||
| 4 | |||
| 5 | int main(int argc, char** argv) { | ||
| 6 | char buffer[12] = {0}; | ||
| 7 | memmove(buffer, "1234567890", sizeof(buffer) - 1); | ||
| 8 | puts(buffer); | ||
| 9 | |||
| 10 | CHK_FAIL_START | ||
| 11 | memmove(buffer, "123456", argc); | ||
| 12 | CHK_FAIL_END | ||
| 13 | |||
| 14 | puts(buffer); | ||
| 15 | return ret; | ||
| 16 | } | ||
diff --git a/tests/test_memmove_dynamic_write.c b/tests/test_memmove_dynamic_write.c new file mode 100644 index 0000000..b62c01f --- /dev/null +++ b/tests/test_memmove_dynamic_write.c | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | #include "common.h" | ||
| 2 | |||
| 3 | #include <string.h> | ||
| 4 | |||
| 5 | int main(int argc, char** argv) { | ||
| 6 | char buffer[8] = {0}; | ||
| 7 | memmove(buffer, "1234567890", sizeof(buffer) - 1); | ||
| 8 | puts(buffer); | ||
| 9 | |||
| 10 | CHK_FAIL_START | ||
| 11 | memmove(buffer, "1234567890", argc); | ||
| 12 | CHK_FAIL_END | ||
| 13 | |||
| 14 | puts(buffer); | ||
| 15 | return ret; | ||
| 16 | } | ||
diff --git a/tests/test_memmove_static_read.c b/tests/test_memmove_static_read.c new file mode 100644 index 0000000..fb128a6 --- /dev/null +++ b/tests/test_memmove_static_read.c | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | #include "common.h" | ||
| 2 | |||
| 3 | #include <string.h> | ||
| 4 | |||
| 5 | int main(int argc, char** argv) { | ||
| 6 | char buffer[8] = {0}; | ||
| 7 | memmove(buffer, "123456", 4); | ||
| 8 | puts(buffer); | ||
| 9 | |||
| 10 | CHK_FAIL_START | ||
| 11 | memmove(buffer, "123456", sizeof(buffer)); | ||
| 12 | CHK_FAIL_END | ||
| 13 | |||
| 14 | puts(buffer); | ||
| 15 | return ret; | ||
| 16 | } | ||
diff --git a/tests/test_memmove_static_write.c b/tests/test_memmove_static_write.c new file mode 100644 index 0000000..711f449 --- /dev/null +++ b/tests/test_memmove_static_write.c | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | #include "common.h" | ||
| 2 | |||
| 3 | #include <string.h> | ||
| 4 | |||
| 5 | int main(int argc, char** argv) { | ||
| 6 | char buffer[8] = {0}; | ||
| 7 | memmove(buffer, "1234567890", sizeof(buffer) - 1); | ||
| 8 | puts(buffer); | ||
| 9 | |||
| 10 | CHK_FAIL_START | ||
| 11 | memmove(buffer, "1234567890", sizeof(buffer) + 1); | ||
| 12 | CHK_FAIL_END | ||
| 13 | |||
| 14 | puts(buffer); | ||
| 15 | return ret; | ||
| 16 | } | ||
