commit 267d5dbe4f79b8ebff8588700b2a8c0d1e56fc97
parent 1122a7b8d9ab1c6ea030fac11495fc75aae07d42
Author: jvoisin <julien.voisin@dustri.org>
Date: Sun, 17 Sep 2023 16:02:08 +0200
Add more dynamic tests
Diffstat:
7 files changed, 118 insertions(+), 4 deletions(-)
diff --git a/tests/Makefile b/tests/Makefile
@@ -75,22 +75,28 @@ TARGETS= \
test_send_static \
test_sendto_dynamic \
test_sendto_static \
+ test_stpcpy_dynamic_write \
test_stpcpy_overwrite_over \
test_stpcpy_overwrite_under \
test_stpcpy_static_write \
- test_stpcpy_dynamic_write \
+ test_stpncpy_dynamic_write \
test_stpncpy_overwrite_over \
test_stpncpy_overwrite_under \
test_stpncpy_static_write \
test_strcat_static_write \
test_strchr_dynamic_read \
test_strchr_static_read \
+ test_strcpy_dynamic_write \
test_strcpy_overwrite_over \
test_strcpy_overwrite_under \
test_strcpy_static_write \
- test_strcpy_dynamic_write \
- test_strncat_static_write \
+ test_strlcat_dynamic_write \
+ test_strlcat_static_write \
+ test_strlcpy_dynamic_write \
+ test_strlcpy_static_write \
test_strncat_dynamic_write \
+ test_strncat_static_write \
+ test_strncpy_dynamic_write \
test_strncpy_overwrite_over \
test_strncpy_overwrite_under \
test_strncpy_static_write \
@@ -104,8 +110,8 @@ TARGETS= \
test_vsprintf \
test_wcscat_static_write \
test_wcscpy_static_write \
- test_wcsncpy_static_write \
test_wcsncat_static_write \
+ test_wcsncpy_static_write \
test_wmemcpy_dynamic_write \
test_wmemcpy_static_write \
test_wmemmove_dynamic_write \
diff --git a/tests/test_stpncpy_dynamic_write.c b/tests/test_stpncpy_dynamic_write.c
@@ -0,0 +1,16 @@
+#include "common.h"
+
+#include <string.h>
+
+int main(int argc, char** argv) {
+ char buffer[8] = {0};
+ stpncpy(buffer, "1234567", 5);
+ puts(buffer);
+
+ CHK_FAIL_START
+ stpncpy(buffer, argv[1], argc);
+ CHK_FAIL_END
+
+ puts(buffer);
+ return ret;
+}
diff --git a/tests/test_strlcat_dynamic_write.c b/tests/test_strlcat_dynamic_write.c
@@ -0,0 +1,19 @@
+#define _GNU_SOURCE
+#define _BSD_SOURCE
+
+#include "common.h"
+
+#include <string.h>
+
+int main(int argc, char** argv) {
+ char buffer[8] = {0};
+ strlcat(buffer, "1234567", sizeof(buffer));
+ puts(buffer);
+
+ CHK_FAIL_START
+ strlcat(buffer, argv[1], argc);
+ CHK_FAIL_END
+
+ puts(buffer);
+ return ret;
+}
diff --git a/tests/test_strlcat_static_write.c b/tests/test_strlcat_static_write.c
@@ -0,0 +1,19 @@
+#define _GNU_SOURCE
+#define _BSD_SOURCE
+
+#include "common.h"
+
+#include <string.h>
+
+int main(int argc, char** argv) {
+ char buffer[8] = {0};
+ strlcat(buffer, "1234567", sizeof(buffer));
+ puts(buffer);
+
+ CHK_FAIL_START
+ strlcat(buffer, "1234567890", 10);
+ CHK_FAIL_END
+
+ puts(buffer);
+ return ret;
+}
diff --git a/tests/test_strlcpy_dynamic_write.c b/tests/test_strlcpy_dynamic_write.c
@@ -0,0 +1,19 @@
+#define _GNU_SOURCE
+#define _BSD_SOURCE
+
+#include "common.h"
+
+#include <string.h>
+
+int main(int argc, char** argv) {
+ char buffer[8] = {0};
+ strlcpy(buffer, "1234567", sizeof(buffer));
+ puts(buffer);
+
+ CHK_FAIL_START
+ strlcpy(buffer, argv[1], argc);
+ CHK_FAIL_END
+
+ puts(buffer);
+ return ret;
+}
diff --git a/tests/test_strlcpy_static_write.c b/tests/test_strlcpy_static_write.c
@@ -0,0 +1,19 @@
+#define _GNU_SOURCE
+#define _BSD_SOURCE
+
+#include "common.h"
+
+#include <string.h>
+
+int main(int argc, char** argv) {
+ char buffer[8] = {0};
+ strlcpy(buffer, "1234567", sizeof(buffer));
+ puts(buffer);
+
+ CHK_FAIL_START
+ strlcpy(buffer, "1234567890", 10);
+ CHK_FAIL_END
+
+ puts(buffer);
+ return ret;
+}
diff --git a/tests/test_strncpy_dynamic_write.c b/tests/test_strncpy_dynamic_write.c
@@ -0,0 +1,16 @@
+#include "common.h"
+
+#include <string.h>
+
+int main(int argc, char** argv) {
+ char buffer[8] = {0};
+ strncpy(buffer, "1234567", 5);
+ puts(buffer);
+
+ CHK_FAIL_START
+ strncpy(buffer, argv[1], argc);
+ CHK_FAIL_END
+
+ puts(buffer);
+ return ret;
+}