X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=tests%2Fregression%2Fkernel%2Fselect_poll_epoll.cpp;h=32cecddbb13409c2e1551385c47eb7043142538b;hb=fbf606d77e98bd46d953a40331f039730cfdf532;hp=abedc0aa929557c7aa859e76788d71d53e0f0cb4;hpb=d40c26206a44d9e247bbcdc01afb34c41d0c490d;p=lttng-tools.git diff --git a/tests/regression/kernel/select_poll_epoll.cpp b/tests/regression/kernel/select_poll_epoll.cpp index abedc0aa9..32cecddbb 100644 --- a/tests/regression/kernel/select_poll_epoll.cpp +++ b/tests/regression/kernel/select_poll_epoll.cpp @@ -5,27 +5,36 @@ * */ -#include +/* + * This test voluntarily does buffer overflows and stack overruns, disable + * source fortification. + */ +#ifdef _FORTIFY_SOURCE +#undef _FORTIFY_SOURCE +#endif + +#include +#include #include +#include +#include #include -#include -#include -#include -#include -#include +#include +#include #include #include -#include -#include #include -#include -#include -#include -#include -#include #include -#include -#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include #define BUF_SIZE 256 #define NB_FD 1 @@ -58,7 +67,8 @@ static void epoll_pwait_concurrent_munmap(FILE *validation_output_file); typedef void (*test_case_cb)(FILE *output_file); -static const struct test_case { +namespace { +const struct test_case { test_case_cb run; bool produces_validation_info; int timeout; @@ -66,21 +76,22 @@ static const struct test_case { { { .run = run_working_cases, .produces_validation_info = true, .timeout = -1 }, { .run = run_working_cases, .produces_validation_info = true, .timeout = 1 }, - { .run = pselect_invalid_fd, .produces_validation_info = false }, - { .run = test_ppoll_big, .produces_validation_info = false }, - { .run = ppoll_fds_buffer_overflow, .produces_validation_info = false }, - { .run = pselect_invalid_pointer, .produces_validation_info = false }, - { .run = ppoll_fds_ulong_max, .produces_validation_info = false }, - { .run = epoll_pwait_invalid_pointer, .produces_validation_info = true }, - { .run = epoll_pwait_int_max, .produces_validation_info = true }, - { .run = ppoll_concurrent_write, .produces_validation_info = false }, - { .run = epoll_pwait_concurrent_munmap, .produces_validation_info = true }, + { .run = pselect_invalid_fd, .produces_validation_info = false, .timeout = 0 }, + { .run = test_ppoll_big, .produces_validation_info = false, .timeout = 0 }, + { .run = ppoll_fds_buffer_overflow, .produces_validation_info = false, .timeout = 0 }, + { .run = pselect_invalid_pointer, .produces_validation_info = false, .timeout = 0 }, + { .run = ppoll_fds_ulong_max, .produces_validation_info = false, .timeout = 0 }, + { .run = epoll_pwait_invalid_pointer, .produces_validation_info = true, .timeout = 0 }, + { .run = epoll_pwait_int_max, .produces_validation_info = true, .timeout = 0 }, + { .run = ppoll_concurrent_write, .produces_validation_info = false, .timeout = 0 }, + { .run = epoll_pwait_concurrent_munmap, .produces_validation_info = true, .timeout = 0 }, }; struct ppoll_thread_data { struct pollfd *ufds; int value; }; +} /* namespace */ static void test_select_big(void) @@ -242,7 +253,7 @@ void test_ppoll(void) } static -void test_ppoll_big(FILE *validation_output_file) +void test_ppoll_big(FILE *validation_output_file __attribute__((unused))) { struct pollfd ufds[MAX_FDS]; char buf[BUF_SIZE]; @@ -443,7 +454,8 @@ end: * The event should contain an array of 100 FDs filled with garbage. */ static -void ppoll_fds_buffer_overflow(FILE *validation_output_file) +void ppoll_fds_buffer_overflow( + FILE *validation_output_file __attribute__((unused))) { struct pollfd ufds[NB_FD]; char buf[BUF_SIZE]; @@ -470,7 +482,7 @@ void ppoll_fds_buffer_overflow(FILE *validation_output_file) * The event should contain an empty array of FDs and overflow = 1. */ static -void ppoll_fds_ulong_max(FILE *validation_output_file) +void ppoll_fds_ulong_max(FILE *validation_output_file __attribute__((unused))) { struct pollfd ufds[NB_FD]; char buf[BUF_SIZE]; @@ -495,7 +507,7 @@ void ppoll_fds_ulong_max(FILE *validation_output_file) * -EBADF. The recorded event should contain a "ret = -EBADF (-9)". */ static -void pselect_invalid_fd(FILE *validation_output_file) +void pselect_invalid_fd(FILE *validation_output_file __attribute__((unused))) { fd_set rfds; int ret; @@ -538,7 +550,8 @@ error: * with 0 FDs. */ static -void pselect_invalid_pointer(FILE *validation_output_file) +void pselect_invalid_pointer( + FILE *validation_output_file __attribute__((unused))) { fd_set rfds; int ret; @@ -753,7 +766,8 @@ end: * ppoll should work as expected and the trace should be readable at the end. */ static -void ppoll_concurrent_write(FILE *validation_output_file) +void ppoll_concurrent_write( + FILE *validation_output_file __attribute__((unused))) { int i, ret, fds[MAX_FDS]; @@ -932,7 +946,7 @@ int main(int argc, const char **argv) { "validation-file", 'o', POPT_ARG_STRING, &test_validation_output_file_path, 0, "Test case output", NULL }, POPT_AUTOHELP - { NULL, 0, 0, NULL, 0 } + { NULL, 0, 0, NULL, 0, NULL, NULL } }; const struct test_case *test_case;