mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-24 05:50:14 +00:00
debug: Adapt fortify tests to libsupport
Checked on aarch64, armhf, x86_64, and i686. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
This commit is contained in:
parent
fce5528fcb
commit
9556acd249
@ -19,7 +19,7 @@
|
|||||||
#define STRCPY_RESULT(dst, len) ((dst) + (len))
|
#define STRCPY_RESULT(dst, len) ((dst) + (len))
|
||||||
#define TEST_MAIN
|
#define TEST_MAIN
|
||||||
#define TEST_NAME "stpcpy_chk"
|
#define TEST_NAME "stpcpy_chk"
|
||||||
#include "../string/test-string.h"
|
#include <string/test-string.h>
|
||||||
|
|
||||||
extern void __attribute__ ((noreturn)) __chk_fail (void);
|
extern void __attribute__ ((noreturn)) __chk_fail (void);
|
||||||
char *simple_stpcpy_chk (char *, const char *, size_t);
|
char *simple_stpcpy_chk (char *, const char *, size_t);
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
# define STRCPY_RESULT(dst, len) dst
|
# define STRCPY_RESULT(dst, len) dst
|
||||||
# define TEST_MAIN
|
# define TEST_MAIN
|
||||||
# define TEST_NAME "strcpy_chk"
|
# 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
|
/* This test case implicitly tests the availability of the __chk_fail
|
||||||
symbol, which is part of the public ABI and may be used
|
symbol, which is part of the public ABI and may be used
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <obstack.h>
|
#include <obstack.h>
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
@ -36,6 +37,10 @@
|
|||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
|
#include <paths.h>
|
||||||
|
|
||||||
|
#include <support/temp_file.h>
|
||||||
|
#include <support/support.h>
|
||||||
|
|
||||||
#ifndef _GNU_SOURCE
|
#ifndef _GNU_SOURCE
|
||||||
# define MEMPCPY memcpy
|
# define MEMPCPY memcpy
|
||||||
@ -52,15 +57,10 @@
|
|||||||
#define obstack_chunk_alloc malloc
|
#define obstack_chunk_alloc malloc
|
||||||
#define obstack_chunk_free free
|
#define obstack_chunk_free free
|
||||||
|
|
||||||
char *temp_filename;
|
static 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 void
|
static void
|
||||||
do_prepare (void)
|
do_prepare (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int temp_fd = create_temp_file ("tst-chk1.", &temp_filename);
|
int temp_fd = create_temp_file ("tst-chk1.", &temp_filename);
|
||||||
if (temp_fd == -1)
|
if (temp_fd == -1)
|
||||||
@ -77,10 +77,11 @@ do_prepare (void)
|
|||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#define PREPARE do_prepare
|
||||||
|
|
||||||
volatile int chk_fail_ok;
|
static volatile int chk_fail_ok;
|
||||||
volatile int ret;
|
static volatile int ret;
|
||||||
jmp_buf chk_fail_buf;
|
static jmp_buf chk_fail_buf;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handler (int sig)
|
handler (int sig)
|
||||||
@ -102,22 +103,22 @@ wchar_t wbuf[10];
|
|||||||
#define buf_size sizeof (buf)
|
#define buf_size sizeof (buf)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
volatile size_t l0;
|
static volatile size_t l0;
|
||||||
volatile char *p;
|
static volatile char *p;
|
||||||
volatile wchar_t *wp;
|
static volatile wchar_t *wp;
|
||||||
const char *str1 = "JIHGFEDCBA";
|
static const char *str1 = "JIHGFEDCBA";
|
||||||
const char *str2 = "F";
|
static const char *str2 = "F";
|
||||||
const char *str3 = "%s%n%s%n";
|
static const char *str3 = "%s%n%s%n";
|
||||||
const char *str4 = "Hello, ";
|
static const char *str4 = "Hello, ";
|
||||||
const char *str5 = "World!\n";
|
static const char *str5 = "World!\n";
|
||||||
const wchar_t *wstr1 = L"JIHGFEDCBA";
|
static const wchar_t *wstr1 = L"JIHGFEDCBA";
|
||||||
const wchar_t *wstr2 = L"F";
|
static const wchar_t *wstr2 = L"F";
|
||||||
const wchar_t *wstr3 = L"%s%n%s%n";
|
static const wchar_t *wstr3 = L"%s%n%s%n";
|
||||||
const wchar_t *wstr4 = L"Hello, ";
|
static const wchar_t *wstr4 = L"Hello, ";
|
||||||
const wchar_t *wstr5 = L"World!\n";
|
static const wchar_t *wstr5 = L"World!\n";
|
||||||
char buf2[10] = "%s";
|
static char buf2[10] = "%s";
|
||||||
int num1 = 67;
|
static int num1 = 67;
|
||||||
int num2 = 987654;
|
static int num2 = 987654;
|
||||||
|
|
||||||
#define FAIL() \
|
#define FAIL() \
|
||||||
do { printf ("Failure on line %d\n", __LINE__); ret = 1; } while (0)
|
do { printf ("Failure on line %d\n", __LINE__); ret = 1; } while (0)
|
||||||
@ -1815,3 +1816,5 @@ do_test (void)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <support/test-driver.c>
|
||||||
|
@ -10,11 +10,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <support/support.h>
|
||||||
static int do_test(void);
|
|
||||||
#define TEST_FUNCTION do_test ()
|
|
||||||
#include "../test-skeleton.c"
|
|
||||||
|
|
||||||
|
|
||||||
static jmp_buf b;
|
static jmp_buf b;
|
||||||
|
|
||||||
@ -76,3 +72,5 @@ do_test (void)
|
|||||||
puts ("second longjmp returned");
|
puts ("second longjmp returned");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <support/test-driver.c>
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
static int do_test (void);
|
#include <support/support.h>
|
||||||
#define TEST_FUNCTION do_test ()
|
|
||||||
#include "../test-skeleton.c"
|
|
||||||
|
|
||||||
static jmp_buf mainloop;
|
static jmp_buf mainloop;
|
||||||
static sigset_t mainsigset;
|
static sigset_t mainsigset;
|
||||||
@ -126,3 +124,5 @@ do_test (void)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <support/test-driver.c>
|
||||||
|
@ -20,10 +20,6 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static int do_test (void);
|
|
||||||
#define TEST_FUNCTION do_test ()
|
|
||||||
#include "../test-skeleton.c"
|
|
||||||
|
|
||||||
static char buf[SIGSTKSZ * 4];
|
static char buf[SIGSTKSZ * 4];
|
||||||
static jmp_buf jb;
|
static jmp_buf jb;
|
||||||
|
|
||||||
@ -83,3 +79,5 @@ do_test (void)
|
|||||||
puts ("longjmp returned and shouldn't");
|
puts ("longjmp returned and shouldn't");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <support/test-driver.c>
|
||||||
|
Loading…
Reference in New Issue
Block a user