]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
debug: Adapt fortify tests to libsupport
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 21 Dec 2023 18:59:15 +0000 (15:59 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 29 Dec 2023 13:57:03 +0000 (10:57 -0300)
Checked on aarch64, armhf, x86_64, and i686.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
debug/test-stpcpy_chk.c
debug/test-strcpy_chk.c
debug/tst-fortify.c
debug/tst-longjmp_chk.c
debug/tst-longjmp_chk2.c
debug/tst-longjmp_chk3.c

index 938f3c0cebdd1091c96a195e5612ed5a9c2192cc..0b9fed49ccefea09fcdb54b269514f7674aae84b 100644 (file)
@@ -19,7 +19,7 @@
 #define STRCPY_RESULT(dst, len) ((dst) + (len))
 #define TEST_MAIN
 #define TEST_NAME "stpcpy_chk"
-#include "../string/test-string.h"
+#include <string/test-string.h>
 
 extern void __attribute__ ((noreturn)) __chk_fail (void);
 char *simple_stpcpy_chk (char *, const char *, size_t);
index 792e789e1ed6c55d36ff9bd6fa63beb1a515bd18..684e0bdd9bb714da0f6fd98373691b7e4d3b0548 100644 (file)
@@ -20,7 +20,7 @@
 # define STRCPY_RESULT(dst, len) dst
 # define TEST_MAIN
 # define TEST_NAME "strcpy_chk"
-# include "../string/test-string.h"
+# include <string/test-string.h>
 
 /* This test case implicitly tests the availability of the __chk_fail
    symbol, which is part of the public ABI and may be used
index 3744aadad4481a1b9dfe1eb66f2a4bb1963c6a5e..20e926751ac25d4179f80bf3fed84e5f19546eb8 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <assert.h>
 #include <fcntl.h>
+#include <limits.h>
 #include <locale.h>
 #include <obstack.h>
 #include <setjmp.h>
 #include <sys/select.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+#include <paths.h>
+
+#include <support/temp_file.h>
+#include <support/support.h>
 
 #ifndef _GNU_SOURCE
 # define MEMPCPY memcpy
 #define obstack_chunk_alloc malloc
 #define obstack_chunk_free free
 
-char *temp_filename;
-static void do_prepare (void);
-static int do_test (void);
-#define PREPARE(argc, argv) do_prepare ()
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+static char *temp_filename;
 
 static void
-do_prepare (void)
+do_prepare (int argc, char *argv[])
 {
   int temp_fd = create_temp_file ("tst-chk1.", &temp_filename);
   if (temp_fd == -1)
@@ -77,10 +77,11 @@ do_prepare (void)
       exit (1);
     }
 }
+#define PREPARE do_prepare
 
-volatile int chk_fail_ok;
-volatile int ret;
-jmp_buf chk_fail_buf;
+static volatile int chk_fail_ok;
+static volatile int ret;
+static jmp_buf chk_fail_buf;
 
 static void
 handler (int sig)
@@ -102,22 +103,22 @@ wchar_t wbuf[10];
 #define buf_size sizeof (buf)
 #endif
 
-volatile size_t l0;
-volatile char *p;
-volatile wchar_t *wp;
-const char *str1 = "JIHGFEDCBA";
-const char *str2 = "F";
-const char *str3 = "%s%n%s%n";
-const char *str4 = "Hello, ";
-const char *str5 = "World!\n";
-const wchar_t *wstr1 = L"JIHGFEDCBA";
-const wchar_t *wstr2 = L"F";
-const wchar_t *wstr3 = L"%s%n%s%n";
-const wchar_t *wstr4 = L"Hello, ";
-const wchar_t *wstr5 = L"World!\n";
-char buf2[10] = "%s";
-int num1 = 67;
-int num2 = 987654;
+static volatile size_t l0;
+static volatile char *p;
+static volatile wchar_t *wp;
+static const char *str1 = "JIHGFEDCBA";
+static const char *str2 = "F";
+static const char *str3 = "%s%n%s%n";
+static const char *str4 = "Hello, ";
+static const char *str5 = "World!\n";
+static const wchar_t *wstr1 = L"JIHGFEDCBA";
+static const wchar_t *wstr2 = L"F";
+static const wchar_t *wstr3 = L"%s%n%s%n";
+static const wchar_t *wstr4 = L"Hello, ";
+static const wchar_t *wstr5 = L"World!\n";
+static char buf2[10] = "%s";
+static int num1 = 67;
+static int num2 = 987654;
 
 #define FAIL() \
   do { printf ("Failure on line %d\n", __LINE__); ret = 1; } while (0)
@@ -1815,3 +1816,5 @@ do_test (void)
 
   return ret;
 }
+
+#include <support/test-driver.c>
index e4e93d2a36b537d9b4e1e21d40c7d35eb71c02bb..37f858606be4c4a22dbb648cddf24d471dfbdd84 100644 (file)
 #include <stdlib.h>
 #include <unistd.h>
 
-
-static int do_test(void);
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
-
+#include <support/support.h>
 
 static jmp_buf b;
 
@@ -76,3 +72,5 @@ do_test (void)
   puts ("second longjmp returned");
   return 1;
 }
+
+#include <support/test-driver.c>
index 1810ab44d7e7bf9855c988fff08266052203b8b3..7e1ee3edc591a399edd42e4f8058fbb62102f568 100644 (file)
@@ -10,9 +10,7 @@
 #include <sys/resource.h>
 #include <unistd.h>
 
-static int do_test (void);
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/support.h>
 
 static jmp_buf mainloop;
 static sigset_t mainsigset;
@@ -126,3 +124,5 @@ do_test (void)
 
   return 0;
 }
+
+#include <support/test-driver.c>
index f1e576ad5be3533c367b37be1f506f775f04ee2e..3050806c443da1311b20bf92fce9c99aedac5b7f 100644 (file)
 #include <signal.h>
 #include <string.h>
 
-static int do_test (void);
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
-
 static char buf[SIGSTKSZ * 4];
 static jmp_buf jb;
 
@@ -83,3 +79,5 @@ do_test (void)
   puts ("longjmp returned and shouldn't");
   return 1;
 }
+
+#include <support/test-driver.c>