summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2023-07-11 00:14:13 +0200
committerjvoisin2023-07-11 00:18:32 +0200
commit8b6129312db7b2405f883c4080b835c69a855627 (patch)
tree3fae0f94c33537db91c4c8488e78f467371f12b0
parent759cb4697e9bba06a5aabad9899d0700f57051da (diff)
Add more dynamic tests
-rw-r--r--tests/Makefile18
-rw-r--r--tests/test_fgets_dynamic.c15
-rw-r--r--tests/test_fgets_static.c (renamed from tests/test_fgets.c)0
-rw-r--r--tests/test_fread_overwrite_dynamic.c18
-rw-r--r--tests/test_fread_overwrite_static.c (renamed from tests/test_fread_overwrite.c)0
-rw-r--r--tests/test_fwrite_overwrite_dynamic.c18
-rw-r--r--tests/test_fwrite_overwrite_static.c (renamed from tests/test_fwrite_overwrite.c)0
-rw-r--r--tests/test_poll_dynamic.c14
-rw-r--r--tests/test_poll_static.c (renamed from tests/test_poll.c)0
-rw-r--r--tests/test_ppoll_dynamic.c15
-rw-r--r--tests/test_ppoll_static.c (renamed from tests/test_ppoll.c)0
-rw-r--r--tests/test_vsnprintf_dynamic.c28
-rw-r--r--tests/test_vsnprintf_static.c (renamed from tests/test_vsnprintf.c)0
13 files changed, 120 insertions, 6 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 855d2ac..b6183ce 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -13,11 +13,14 @@ TARGETS= \
13 test_bzero_static_write \ 13 test_bzero_static_write \
14 test_confstr_dynamic \ 14 test_confstr_dynamic \
15 test_confstr_static \ 15 test_confstr_static \
16 test_fgets \ 16 test_fgets_dynamic \
17 test_fgets_static \
17 test_fread_int_overflow \ 18 test_fread_int_overflow \
18 test_fread_overwrite \ 19 test_fread_overwrite_dynamic \
20 test_fread_overwrite_static \
19 test_fwrite_int_overflow \ 21 test_fwrite_int_overflow \
20 test_fwrite_overwrite \ 22 test_fwrite_overwrite_dynamic \
23 test_fwrite_overwrite_static \
21 test_getcwd_dynamic \ 24 test_getcwd_dynamic \
22 test_getcwd_static \ 25 test_getcwd_static \
23 test_getdomainname_dynamic \ 26 test_getdomainname_dynamic \
@@ -45,8 +48,10 @@ TARGETS= \
45 test_mempcpy_static_write \ 48 test_mempcpy_static_write \
46 test_memset_dynamic_write \ 49 test_memset_dynamic_write \
47 test_memset_static_write \ 50 test_memset_static_write \
48 test_poll \ 51 test_poll_dynamic \
49 test_ppoll \ 52 test_poll_static \
53 test_ppoll_dynamic \
54 test_ppoll_static \
50 test_pread_dynamic \ 55 test_pread_dynamic \
51 test_pread_static \ 56 test_pread_static \
52 test_read_dynamic \ 57 test_read_dynamic \
@@ -77,7 +82,8 @@ TARGETS= \
77 test_strncpy_static_write \ 82 test_strncpy_static_write \
78 test_ttyname_r_dynamic \ 83 test_ttyname_r_dynamic \
79 test_ttyname_r_static \ 84 test_ttyname_r_static \
80 test_vsnprintf \ 85 test_vsnprintf_dynamic \
86 test_vsnprintf_static \
81 test_vsprintf \ 87 test_vsprintf \
82 test_write_dynamic \ 88 test_write_dynamic \
83 test_write_static \ 89 test_write_static \
diff --git a/tests/test_fgets_dynamic.c b/tests/test_fgets_dynamic.c
new file mode 100644
index 0000000..88c9e6f
--- /dev/null
+++ b/tests/test_fgets_dynamic.c
@@ -0,0 +1,15 @@
1#include "common.h"
2
3#define _GNU_SOURCE
4#include <poll.h>
5
6int main(int argc, char** argv) {
7 char buffer[8] = {0};
8
9 CHK_FAIL_START
10 fgets(buffer, argc, NULL);
11 CHK_FAIL_END
12
13 puts(buffer);
14 return ret;
15}
diff --git a/tests/test_fgets.c b/tests/test_fgets_static.c
index f01d7c6..f01d7c6 100644
--- a/tests/test_fgets.c
+++ b/tests/test_fgets_static.c
diff --git a/tests/test_fread_overwrite_dynamic.c b/tests/test_fread_overwrite_dynamic.c
new file mode 100644
index 0000000..b02d22c
--- /dev/null
+++ b/tests/test_fread_overwrite_dynamic.c
@@ -0,0 +1,18 @@
1#include <assert.h>
2
3#include "common.h"
4
5#include <stdio.h>
6
7int main(int argc, char** argv) {
8 char buffer[12] = {0};
9
10 assert(sizeof(buffer - 2) * argc > sizeof(buffer));
11
12 CHK_FAIL_START
13 fread(buffer, sizeof(buffer) - 2, argc, NULL);
14 CHK_FAIL_END
15
16 puts(buffer);
17 return ret;
18}
diff --git a/tests/test_fread_overwrite.c b/tests/test_fread_overwrite_static.c
index 2710d24..2710d24 100644
--- a/tests/test_fread_overwrite.c
+++ b/tests/test_fread_overwrite_static.c
diff --git a/tests/test_fwrite_overwrite_dynamic.c b/tests/test_fwrite_overwrite_dynamic.c
new file mode 100644
index 0000000..e5545f3
--- /dev/null
+++ b/tests/test_fwrite_overwrite_dynamic.c
@@ -0,0 +1,18 @@
1#include <assert.h>
2
3#include "common.h"
4
5#include <stdio.h>
6
7int main(int argc, char** argv) {
8 char buffer[12] = {0};
9
10 assert(sizeof(buffer - 2) * argc > sizeof(buffer));
11
12 CHK_FAIL_START
13 fwrite(buffer, sizeof(buffer) - 2, argc, NULL);
14 CHK_FAIL_END
15
16 puts(buffer);
17 return ret;
18}
diff --git a/tests/test_fwrite_overwrite.c b/tests/test_fwrite_overwrite_static.c
index b3767f8..b3767f8 100644
--- a/tests/test_fwrite_overwrite.c
+++ b/tests/test_fwrite_overwrite_static.c
diff --git a/tests/test_poll_dynamic.c b/tests/test_poll_dynamic.c
new file mode 100644
index 0000000..284ceee
--- /dev/null
+++ b/tests/test_poll_dynamic.c
@@ -0,0 +1,14 @@
1#include "common.h"
2
3#include <poll.h>
4
5int main(int argc, char** argv) {
6 struct pollfd buffer[8] = {0};
7
8 CHK_FAIL_START
9 poll(buffer, argc, 0);
10 CHK_FAIL_END
11
12 puts((const char*)buffer);
13 return ret;
14}
diff --git a/tests/test_poll.c b/tests/test_poll_static.c
index b3dfd50..b3dfd50 100644
--- a/tests/test_poll.c
+++ b/tests/test_poll_static.c
diff --git a/tests/test_ppoll_dynamic.c b/tests/test_ppoll_dynamic.c
new file mode 100644
index 0000000..7b049d1
--- /dev/null
+++ b/tests/test_ppoll_dynamic.c
@@ -0,0 +1,15 @@
1#include "common.h"
2
3#define _GNU_SOURCE
4#include <poll.h>
5
6int main(int argc, char** argv) {
7 struct pollfd buffer[8] = {0};
8
9 CHK_FAIL_START
10 ppoll(buffer, argc, NULL, NULL);
11 CHK_FAIL_END
12
13 puts((const char*)buffer);
14 return ret;
15}
diff --git a/tests/test_ppoll.c b/tests/test_ppoll_static.c
index 186bafe..186bafe 100644
--- a/tests/test_ppoll.c
+++ b/tests/test_ppoll_static.c
diff --git a/tests/test_vsnprintf_dynamic.c b/tests/test_vsnprintf_dynamic.c
new file mode 100644
index 0000000..5d99081
--- /dev/null
+++ b/tests/test_vsnprintf_dynamic.c
@@ -0,0 +1,28 @@
1#include "common.h"
2
3#include <stdarg.h>
4#include <unistd.h>
5
6char buffer[8] = {0};
7
8int msg_valid(int n, const char * format, ... ) {
9 va_list args;
10 va_start (args, format);
11 vsnprintf(buffer, n, format, args);
12 va_end (args);
13}
14
15int msg(int n, const char * format, ... ) {
16 va_list args;
17 va_start (args, format);
18 CHK_FAIL_START
19 vsnprintf(buffer, n, format, args);
20 CHK_FAIL_END
21 va_end (args);
22 return ret;
23}
24
25int main(int argc, char** argv) {
26 msg_valid(sizeof(buffer), "%s", "1234567890ABCDEF");
27 return msg(argc, "%s", "1234567890ABCDEF");
28}
diff --git a/tests/test_vsnprintf.c b/tests/test_vsnprintf_static.c
index f1263a8..f1263a8 100644
--- a/tests/test_vsnprintf.c
+++ b/tests/test_vsnprintf_static.c