diff options
| author | jvoisin | 2023-09-17 16:02:08 +0200 |
|---|---|---|
| committer | jvoisin | 2023-09-17 16:02:08 +0200 |
| commit | 267d5dbe4f79b8ebff8588700b2a8c0d1e56fc97 (patch) | |
| tree | 0932aa51a0842ed3393e1d5610c285fd47a07300 | |
| parent | 1122a7b8d9ab1c6ea030fac11495fc75aae07d42 (diff) | |
Add more dynamic tests
| -rw-r--r-- | tests/Makefile | 14 | ||||
| -rw-r--r-- | tests/test_stpncpy_dynamic_write.c | 16 | ||||
| -rw-r--r-- | tests/test_strlcat_dynamic_write.c | 19 | ||||
| -rw-r--r-- | tests/test_strlcat_static_write.c | 19 | ||||
| -rw-r--r-- | tests/test_strlcpy_dynamic_write.c | 19 | ||||
| -rw-r--r-- | tests/test_strlcpy_static_write.c | 19 | ||||
| -rw-r--r-- | tests/test_strncpy_dynamic_write.c | 16 |
7 files changed, 118 insertions, 4 deletions
diff --git a/tests/Makefile b/tests/Makefile index 3a57eb5..b14fd6b 100644 --- a/tests/Makefile +++ b/tests/Makefile | |||
| @@ -75,22 +75,28 @@ TARGETS= \ | |||
| 75 | test_send_static \ | 75 | test_send_static \ |
| 76 | test_sendto_dynamic \ | 76 | test_sendto_dynamic \ |
| 77 | test_sendto_static \ | 77 | test_sendto_static \ |
| 78 | test_stpcpy_dynamic_write \ | ||
| 78 | test_stpcpy_overwrite_over \ | 79 | test_stpcpy_overwrite_over \ |
| 79 | test_stpcpy_overwrite_under \ | 80 | test_stpcpy_overwrite_under \ |
| 80 | test_stpcpy_static_write \ | 81 | test_stpcpy_static_write \ |
| 81 | test_stpcpy_dynamic_write \ | 82 | test_stpncpy_dynamic_write \ |
| 82 | test_stpncpy_overwrite_over \ | 83 | test_stpncpy_overwrite_over \ |
| 83 | test_stpncpy_overwrite_under \ | 84 | test_stpncpy_overwrite_under \ |
| 84 | test_stpncpy_static_write \ | 85 | test_stpncpy_static_write \ |
| 85 | test_strcat_static_write \ | 86 | test_strcat_static_write \ |
| 86 | test_strchr_dynamic_read \ | 87 | test_strchr_dynamic_read \ |
| 87 | test_strchr_static_read \ | 88 | test_strchr_static_read \ |
| 89 | test_strcpy_dynamic_write \ | ||
| 88 | test_strcpy_overwrite_over \ | 90 | test_strcpy_overwrite_over \ |
| 89 | test_strcpy_overwrite_under \ | 91 | test_strcpy_overwrite_under \ |
| 90 | test_strcpy_static_write \ | 92 | test_strcpy_static_write \ |
| 91 | test_strcpy_dynamic_write \ | 93 | test_strlcat_dynamic_write \ |
| 92 | test_strncat_static_write \ | 94 | test_strlcat_static_write \ |
| 95 | test_strlcpy_dynamic_write \ | ||
| 96 | test_strlcpy_static_write \ | ||
| 93 | test_strncat_dynamic_write \ | 97 | test_strncat_dynamic_write \ |
| 98 | test_strncat_static_write \ | ||
| 99 | test_strncpy_dynamic_write \ | ||
| 94 | test_strncpy_overwrite_over \ | 100 | test_strncpy_overwrite_over \ |
| 95 | test_strncpy_overwrite_under \ | 101 | test_strncpy_overwrite_under \ |
| 96 | test_strncpy_static_write \ | 102 | test_strncpy_static_write \ |
| @@ -104,8 +110,8 @@ TARGETS= \ | |||
| 104 | test_vsprintf \ | 110 | test_vsprintf \ |
| 105 | test_wcscat_static_write \ | 111 | test_wcscat_static_write \ |
| 106 | test_wcscpy_static_write \ | 112 | test_wcscpy_static_write \ |
| 107 | test_wcsncpy_static_write \ | ||
| 108 | test_wcsncat_static_write \ | 113 | test_wcsncat_static_write \ |
| 114 | test_wcsncpy_static_write \ | ||
| 109 | test_wmemcpy_dynamic_write \ | 115 | test_wmemcpy_dynamic_write \ |
| 110 | test_wmemcpy_static_write \ | 116 | test_wmemcpy_static_write \ |
| 111 | test_wmemmove_dynamic_write \ | 117 | test_wmemmove_dynamic_write \ |
diff --git a/tests/test_stpncpy_dynamic_write.c b/tests/test_stpncpy_dynamic_write.c new file mode 100644 index 0000000..8fbfe7e --- /dev/null +++ b/tests/test_stpncpy_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 | stpncpy(buffer, "1234567", 5); | ||
| 8 | puts(buffer); | ||
| 9 | |||
| 10 | CHK_FAIL_START | ||
| 11 | stpncpy(buffer, argv[1], argc); | ||
| 12 | CHK_FAIL_END | ||
| 13 | |||
| 14 | puts(buffer); | ||
| 15 | return ret; | ||
| 16 | } | ||
diff --git a/tests/test_strlcat_dynamic_write.c b/tests/test_strlcat_dynamic_write.c new file mode 100644 index 0000000..c4b3a90 --- /dev/null +++ b/tests/test_strlcat_dynamic_write.c | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | #define _GNU_SOURCE | ||
| 2 | #define _BSD_SOURCE | ||
| 3 | |||
| 4 | #include "common.h" | ||
| 5 | |||
| 6 | #include <string.h> | ||
| 7 | |||
| 8 | int main(int argc, char** argv) { | ||
| 9 | char buffer[8] = {0}; | ||
| 10 | strlcat(buffer, "1234567", sizeof(buffer)); | ||
| 11 | puts(buffer); | ||
| 12 | |||
| 13 | CHK_FAIL_START | ||
| 14 | strlcat(buffer, argv[1], argc); | ||
| 15 | CHK_FAIL_END | ||
| 16 | |||
| 17 | puts(buffer); | ||
| 18 | return ret; | ||
| 19 | } | ||
diff --git a/tests/test_strlcat_static_write.c b/tests/test_strlcat_static_write.c new file mode 100644 index 0000000..7ec70fe --- /dev/null +++ b/tests/test_strlcat_static_write.c | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | #define _GNU_SOURCE | ||
| 2 | #define _BSD_SOURCE | ||
| 3 | |||
| 4 | #include "common.h" | ||
| 5 | |||
| 6 | #include <string.h> | ||
| 7 | |||
| 8 | int main(int argc, char** argv) { | ||
| 9 | char buffer[8] = {0}; | ||
| 10 | strlcat(buffer, "1234567", sizeof(buffer)); | ||
| 11 | puts(buffer); | ||
| 12 | |||
| 13 | CHK_FAIL_START | ||
| 14 | strlcat(buffer, "1234567890", 10); | ||
| 15 | CHK_FAIL_END | ||
| 16 | |||
| 17 | puts(buffer); | ||
| 18 | return ret; | ||
| 19 | } | ||
diff --git a/tests/test_strlcpy_dynamic_write.c b/tests/test_strlcpy_dynamic_write.c new file mode 100644 index 0000000..3a96551 --- /dev/null +++ b/tests/test_strlcpy_dynamic_write.c | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | #define _GNU_SOURCE | ||
| 2 | #define _BSD_SOURCE | ||
| 3 | |||
| 4 | #include "common.h" | ||
| 5 | |||
| 6 | #include <string.h> | ||
| 7 | |||
| 8 | int main(int argc, char** argv) { | ||
| 9 | char buffer[8] = {0}; | ||
| 10 | strlcpy(buffer, "1234567", sizeof(buffer)); | ||
| 11 | puts(buffer); | ||
| 12 | |||
| 13 | CHK_FAIL_START | ||
| 14 | strlcpy(buffer, argv[1], argc); | ||
| 15 | CHK_FAIL_END | ||
| 16 | |||
| 17 | puts(buffer); | ||
| 18 | return ret; | ||
| 19 | } | ||
diff --git a/tests/test_strlcpy_static_write.c b/tests/test_strlcpy_static_write.c new file mode 100644 index 0000000..0628a1b --- /dev/null +++ b/tests/test_strlcpy_static_write.c | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | #define _GNU_SOURCE | ||
| 2 | #define _BSD_SOURCE | ||
| 3 | |||
| 4 | #include "common.h" | ||
| 5 | |||
| 6 | #include <string.h> | ||
| 7 | |||
| 8 | int main(int argc, char** argv) { | ||
| 9 | char buffer[8] = {0}; | ||
| 10 | strlcpy(buffer, "1234567", sizeof(buffer)); | ||
| 11 | puts(buffer); | ||
| 12 | |||
| 13 | CHK_FAIL_START | ||
| 14 | strlcpy(buffer, "1234567890", 10); | ||
| 15 | CHK_FAIL_END | ||
| 16 | |||
| 17 | puts(buffer); | ||
| 18 | return ret; | ||
| 19 | } | ||
diff --git a/tests/test_strncpy_dynamic_write.c b/tests/test_strncpy_dynamic_write.c new file mode 100644 index 0000000..6af18a7 --- /dev/null +++ b/tests/test_strncpy_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 | strncpy(buffer, "1234567", 5); | ||
| 8 | puts(buffer); | ||
| 9 | |||
| 10 | CHK_FAIL_START | ||
| 11 | strncpy(buffer, argv[1], argc); | ||
| 12 | CHK_FAIL_END | ||
| 13 | |||
| 14 | puts(buffer); | ||
| 15 | return ret; | ||
| 16 | } | ||
