Commit 1f96796c authored by Arkadiusz Hiler's avatar Arkadiusz Hiler

igt/core: Disallow igt_require/skip in non-main threads

Handling magic control blocks and longjmp() out of them  in threads is

The test should state the requirements before it starts spinning
Signed-off-by: default avatarArkadiusz Hiler <>
Reviewed-by: Petri Latvala's avatarPetri Latvala <>
parent d2e4cb0c
Pipeline #165181 passed with stages
in 13 minutes and 33 seconds
......@@ -1475,6 +1475,9 @@ void __igt_skip_check(const char *file, const int line,
int err = errno;
char *err_str = NULL;
if (!igt_thread_is_main())
assert(!"igt_require/skip allowed only in the main thread!");
if (err)
igt_assert_neq(asprintf(&err_str, "Last errno: %i, %s\n", err, strerror(err)),
......@@ -43,6 +43,12 @@ static void *failure_thread(void *data)
return NULL;
static void *require_thread(void *data)
return NULL;
static void one_subtest_fail(void) {
igt_subtest_init(fake_argc, fake_argv);
......@@ -103,10 +109,21 @@ static void simple_failure(void) {
static void require_non_main_thread(void) {
pthread_t thread;
igt_simple_init(fake_argc, fake_argv);
pthread_create(&thread, 0, require_thread, NULL);
pthread_join(thread, NULL);
int main(int argc, char **argv)
int status;
int outfd;
int outfd, errfd;
pid_t pid;
/* failing should be limited just to a single subtest */ {
......@@ -190,5 +207,20 @@ int main(int argc, char **argv)
/* require in a thread should SIGABRT */ {
static char err[4096];
pid = do_fork_bg_with_pipes(require_non_main_thread, NULL, &errfd);
read_whole_pipe(errfd, err, sizeof(err));
internal_assert(safe_wait(pid, &status) != -1);
internal_assert_wsignaled(status, SIGABRT);
internal_assert(strstr(err, "allowed only in the main thread"));
return 0;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment