* [igt-dev] [PATCH i-g-t 1/6] lib/tests: Add header for common helpers
@ 2019-02-15 9:54 Daniel Vetter
2019-02-15 9:54 ` [igt-dev] [PATCH i-g-t 2/6] lib/tests: add internal_assert_wexited/wsignaled Daniel Vetter
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Daniel Vetter @ 2019-02-15 9:54 UTC (permalink / raw)
To: IGT development; +Cc: Daniel Vetter
Start with internal_assert, more will follow. While at it, use
internal_assert everywhere (except where we check exit status, those
will get dedicated assert checks).
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
lib/tests/igt_assert.c | 9 +-------
lib/tests/igt_can_fail.c | 12 +++++------
lib/tests/igt_can_fail_simple.c | 4 ++--
lib/tests/igt_exit_handler.c | 21 +++++++++---------
lib/tests/igt_fork.c | 9 +-------
lib/tests/igt_segfault.c | 9 +-------
lib/tests/igt_simulation.c | 9 +-------
lib/tests/igt_subtest_group.c | 19 +++++++++--------
lib/tests/igt_tests_common.h | 38 +++++++++++++++++++++++++++++++++
9 files changed, 71 insertions(+), 59 deletions(-)
create mode 100644 lib/tests/igt_tests_common.h
diff --git a/lib/tests/igt_assert.c b/lib/tests/igt_assert.c
index 0082fda14851..e3c1ec49daf2 100644
--- a/lib/tests/igt_assert.c
+++ b/lib/tests/igt_assert.c
@@ -22,7 +22,6 @@
*
*/
-#include <assert.h>
#include <errno.h>
#include <float.h>
#include <limits.h>
@@ -36,13 +35,7 @@
#include "igt_core.h"
-/*
- * We need to hide assert from the cocci igt test refactor spatch.
- *
- * IMPORTANT: Test infrastructure tests are the only valid places where using
- * assert is allowed.
- */
-#define internal_assert assert
+#include "igt_tests_common.h"
char test[] = "test";
char *argv_run[] = { test };
diff --git a/lib/tests/igt_can_fail.c b/lib/tests/igt_can_fail.c
index 566682422b64..1e3d9558728f 100644
--- a/lib/tests/igt_can_fail.c
+++ b/lib/tests/igt_can_fail.c
@@ -22,23 +22,23 @@
*
*/
-#include <assert.h>
#include "igt_core.h"
+#include "igt_tests_common.h"
igt_main
{
- assert(igt_can_fail() == false);
+ internal_assert(igt_can_fail() == false);
igt_fixture {
- assert(igt_can_fail());
+ internal_assert(igt_can_fail());
}
- assert(igt_can_fail() == false);
+ internal_assert(igt_can_fail() == false);
igt_subtest("subtest") {
- assert(igt_can_fail());
+ internal_assert(igt_can_fail());
}
- assert(igt_can_fail() == false);
+ internal_assert(igt_can_fail() == false);
}
diff --git a/lib/tests/igt_can_fail_simple.c b/lib/tests/igt_can_fail_simple.c
index 0d9f6dd4076c..8ff43d15fa6b 100644
--- a/lib/tests/igt_can_fail_simple.c
+++ b/lib/tests/igt_can_fail_simple.c
@@ -22,11 +22,11 @@
*
*/
-#include <assert.h>
#include "igt_core.h"
+#include "igt_tests_common.h"
igt_simple_main
{
- assert(igt_can_fail());
+ internal_assert(igt_can_fail());
}
diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c
index f2997bd13633..7546fde6d6f8 100644
--- a/lib/tests/igt_exit_handler.c
+++ b/lib/tests/igt_exit_handler.c
@@ -21,19 +21,20 @@
* IN THE SOFTWARE.
*/
-#include <assert.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "igt_core.h"
+#include "igt_tests_common.h"
+
int test;
int pipes[2];
static void exit_handler1(int sig)
{
- assert(test == 1);
+ internal_assert(test == 1);
test++;
}
@@ -42,12 +43,12 @@ static void exit_handler2(int sig)
char tmp = 1;
/* ensure exit handlers are called in reverse */
- assert(test == 0);
+ internal_assert(test == 0);
test++;
/* we need to get a side effect to the parent to make sure exit handlers
* actually run. */
- assert(write(pipes[1], &tmp, 1) == 1);
+ internal_assert(write(pipes[1], &tmp, 1) == 1);
}
enum test_type {
@@ -67,7 +68,7 @@ static int testfunc(enum test_type test_type)
int status;
char tmp = 0;
- assert(pipe2(pipes, O_NONBLOCK) == 0);
+ internal_assert(pipe2(pipes, O_NONBLOCK) == 0);
pid = fork();
@@ -100,10 +101,10 @@ static int testfunc(enum test_type test_type)
igt_exit();
}
- assert(waitpid(pid, &status, 0) != -1);
+ internal_assert(waitpid(pid, &status, 0) != -1);
- assert(read(pipes[0], &tmp, 1) == 1);
- assert(tmp == 1);
+ internal_assert(read(pipes[0], &tmp, 1) == 1);
+ internal_assert(tmp == 1);
return status;
}
@@ -112,9 +113,9 @@ int main(int argc, char **argv)
{
int status;
- assert(testfunc(SUC) == 0);
+ internal_assert(testfunc(SUC) == 0);
- assert(testfunc(NORMAL) == 0);
+ internal_assert(testfunc(NORMAL) == 0);
status = testfunc(FAIL);
assert(WIFEXITED(status) && WEXITSTATUS(status) == 1);
diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c
index fa5bb7701c09..38c55d11f7ec 100644
--- a/lib/tests/igt_fork.c
+++ b/lib/tests/igt_fork.c
@@ -22,7 +22,6 @@
*
*/
-#include <assert.h>
#include <errno.h>
#include <stdint.h>
#include <stdlib.h>
@@ -32,13 +31,7 @@
#include "igt_core.h"
-/*
- * We need to hide assert from the cocci igt test refactor spatch.
- *
- * IMPORTANT: Test infrastructure tests are the only valid places where using
- * assert is allowed.
- */
-#define internal_assert assert
+#include "igt_tests_common.h"
char test[] = "test";
char *argv_run[] = { test };
diff --git a/lib/tests/igt_segfault.c b/lib/tests/igt_segfault.c
index 86fee5354d67..bfbbff564fac 100644
--- a/lib/tests/igt_segfault.c
+++ b/lib/tests/igt_segfault.c
@@ -38,19 +38,12 @@
#include <stdlib.h>
#include <sys/wait.h>
#include <sys/types.h>
-#include <assert.h>
#include <errno.h>
#include "drmtest.h"
#include "igt_core.h"
-/*
- * We need to hide assert from the cocci igt test refactor spatch.
- *
- * IMPORTANT: Test infrastructure tests are the only valid places where using
- * assert is allowed.
- */
-#define internal_assert assert
+#include "igt_tests_common.h"
bool simple;
bool runa;
diff --git a/lib/tests/igt_simulation.c b/lib/tests/igt_simulation.c
index 2efccac4e390..3f3cd88fd058 100644
--- a/lib/tests/igt_simulation.c
+++ b/lib/tests/igt_simulation.c
@@ -28,19 +28,12 @@
#include <stdlib.h>
#include <sys/wait.h>
#include <sys/types.h>
-#include <assert.h>
#include <errno.h>
#include "drmtest.h"
#include "igt_core.h"
-/*
- * We need to hide assert from the cocci igt test refactor spatch.
- *
- * IMPORTANT: Test infrastructure tests are the only valid places where using
- * assert is allowed.
- */
-#define internal_assert assert
+#include "igt_tests_common.h"
bool simple;
bool list_subtests;
diff --git a/lib/tests/igt_subtest_group.c b/lib/tests/igt_subtest_group.c
index c2364d799f36..7783d021e5a2 100644
--- a/lib/tests/igt_subtest_group.c
+++ b/lib/tests/igt_subtest_group.c
@@ -22,9 +22,10 @@
*
*/
-#include <assert.h>
#include "igt_core.h"
+#include "igt_tests_common.h"
+
igt_main
{
bool t1 = false;
@@ -41,7 +42,7 @@ igt_main
}
igt_subtest("not-run") {
- assert(0);
+ internal_assert(0);
}
igt_subtest_group {
@@ -49,35 +50,35 @@ igt_main
* restore to "run testcases" when an outer
* group is already in SKIP state. */
igt_subtest("still-not-run") {
- assert(0);
+ internal_assert(0);
}
}
}
igt_subtest("run") {
t1 = true;
- assert(1);
+ internal_assert(1);
}
}
igt_subtest_group {
igt_fixture {
- assert(t2 == 0);
+ internal_assert(t2 == 0);
t2 = 1;
}
igt_subtest("run-again") {
- assert(t2 == 1);
+ internal_assert(t2 == 1);
t2 = 2;
}
igt_fixture {
- assert(t2 == 2);
+ internal_assert(t2 == 2);
t2 = 3;
}
}
- assert(t1);
- assert(t2 == 3);
+ internal_assert(t1);
+ internal_assert(t2 == 3);
}
diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h
new file mode 100644
index 000000000000..9b347a4565d9
--- /dev/null
+++ b/lib/tests/igt_tests_common.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright © 2019 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+#ifndef IGT_LIB_TESTS_COMMON_H
+#define IGT_LIB_TESTS_COMMON_H
+
+#include <assert.h>
+
+/*
+ * We need to hide assert from the cocci igt test refactor spatch.
+ *
+ * IMPORTANT: Test infrastructure tests are the only valid places where using
+ * assert is allowed.
+ */
+#define internal_assert assert
+
+#endif
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [igt-dev] [PATCH i-g-t 2/6] lib/tests: add internal_assert_wexited/wsignaled
2019-02-15 9:54 [igt-dev] [PATCH i-g-t 1/6] lib/tests: Add header for common helpers Daniel Vetter
@ 2019-02-15 9:54 ` Daniel Vetter
2019-02-15 9:54 ` [igt-dev] [PATCH i-g-t 3/6] tests: drop invalid name build checks Daniel Vetter
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2019-02-15 9:54 UTC (permalink / raw)
To: IGT development
And convert everything over.
igt_segfault needed a bit of care to differentiate between a real
death-by-signal and igt_exit mapping a child process signal death to
an exit code.
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
lib/tests/igt_assert.c | 4 ++--
lib/tests/igt_exit_handler.c | 6 +++---
lib/tests/igt_fork.c | 10 +++++-----
lib/tests/igt_segfault.c | 14 +++++---------
lib/tests/igt_tests_common.h | 11 +++++++++++
5 files changed, 26 insertions(+), 19 deletions(-)
diff --git a/lib/tests/igt_assert.c b/lib/tests/igt_assert.c
index e3c1ec49daf2..632e15978978 100644
--- a/lib/tests/igt_assert.c
+++ b/lib/tests/igt_assert.c
@@ -151,7 +151,7 @@ igt_main
test_to_run = test_cmpint_negative;
ret = do_fork();
igt_subtest("igt_cmpint_negative")
- internal_assert(WEXITSTATUS(ret) == IGT_EXIT_FAILURE);
+ internal_assert_wexited(ret, IGT_EXIT_FAILURE);
igt_subtest("igt_assert_fd")
test_fd();
@@ -159,5 +159,5 @@ igt_main
test_to_run = test_fd_negative;
ret = do_fork();
igt_subtest("igt_assert_fd_negative")
- internal_assert(WEXITSTATUS(ret) == IGT_EXIT_FAILURE);
+ internal_assert_wexited(ret, IGT_EXIT_FAILURE);
}
diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c
index 7546fde6d6f8..f8a747862c01 100644
--- a/lib/tests/igt_exit_handler.c
+++ b/lib/tests/igt_exit_handler.c
@@ -118,11 +118,11 @@ int main(int argc, char **argv)
internal_assert(testfunc(NORMAL) == 0);
status = testfunc(FAIL);
- assert(WIFEXITED(status) && WEXITSTATUS(status) == 1);
+ internal_assert_wexited(status, 1);
status = testfunc(SKIP);
- assert(WIFEXITED(status) && WEXITSTATUS(status) == IGT_EXIT_SKIP);
+ internal_assert_wexited(status, IGT_EXIT_SKIP);
status = testfunc(SIG);
- assert(WIFSIGNALED(status) && WTERMSIG(status) == SIGTERM);
+ internal_assert_wsignaled(status, SIGTERM);
}
diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c
index 38c55d11f7ec..100031207461 100644
--- a/lib/tests/igt_fork.c
+++ b/lib/tests/igt_fork.c
@@ -113,21 +113,21 @@ int main(int argc, char **argv)
/* check that igt_assert is forwarded */
ret = do_fork(igt_fork_vs_assert);
- internal_assert(WEXITSTATUS(ret) == IGT_EXIT_FAILURE);
+ internal_assert_wexited(ret, IGT_EXIT_FAILURE);
/* check that igt_skip within a fork blows up */
ret = do_fork(igt_fork_vs_skip);
- internal_assert(WEXITSTATUS(ret) == SIGABRT + 128);
+ internal_assert_wexited(ret, SIGABRT + 128);
/* check that failure to clean up fails */
ret = do_fork(igt_fork_leak);
- internal_assert(WTERMSIG(ret) == SIGABRT);
+ internal_assert_wsignaled(ret, SIGABRT);
/* check that igt_waitchildren_timeout cleans up*/
ret = do_fork(igt_fork_timeout_leak);
- internal_assert(WEXITSTATUS(ret) == SIGKILL + 128);
+ internal_assert_wexited(ret, SIGKILL + 128);
/* check that any other process leaks are caught*/
ret = do_fork(plain_fork_leak);
- internal_assert(WTERMSIG(ret) == SIGABRT);
+ internal_assert_wsignaled(ret, SIGABRT);
}
diff --git a/lib/tests/igt_segfault.c b/lib/tests/igt_segfault.c
index bfbbff564fac..2a24531aaa8c 100644
--- a/lib/tests/igt_segfault.c
+++ b/lib/tests/igt_segfault.c
@@ -94,10 +94,7 @@ static int do_fork(void)
errno == EINTR)
;
- if(WIFSIGNALED(status))
- return WTERMSIG(status) + 128;
-
- return WEXITSTATUS(status);
+ return status;
}
}
@@ -109,20 +106,20 @@ int main(int argc, char **argv)
runc=false;
igt_info("Simple test.\n");
fflush(stdout);
- internal_assert(WTERMSIG(do_fork()) == SIGSEGV);
+ internal_assert_wsignaled(do_fork(), SIGSEGV);
/* Test crash in a single subtest is reported */
simple = false;
igt_info("Single subtest.\n");
fflush(stdout);
- internal_assert(WTERMSIG(do_fork()) == SIGSEGV);
+ internal_assert_wexited(do_fork(), SIGSEGV + 128);
/* Test crash in a subtest following a pass is reported */
simple = false;
runa=true;
igt_info("Passing then crashing subtest.\n");
fflush(stdout);
- internal_assert(WTERMSIG(do_fork()) == SIGSEGV);
+ internal_assert_wexited(do_fork(), SIGSEGV + 128);
/* Test crash in a subtest preceeding a pass is reported */
simple = false;
@@ -130,8 +127,7 @@ int main(int argc, char **argv)
runc=true;
igt_info("Crashing then passing subtest.\n");
fflush(stdout);
- internal_assert(WTERMSIG(do_fork()) == SIGSEGV);
+ internal_assert_wexited(do_fork(), SIGSEGV + 128);
return 0;
}
-
diff --git a/lib/tests/igt_tests_common.h b/lib/tests/igt_tests_common.h
index 9b347a4565d9..e66ee37c0331 100644
--- a/lib/tests/igt_tests_common.h
+++ b/lib/tests/igt_tests_common.h
@@ -35,4 +35,15 @@
*/
#define internal_assert assert
+static inline void internal_assert_wexited(int wstatus, int exitcode)
+{
+ internal_assert(WIFEXITED(wstatus) &&
+ WEXITSTATUS(wstatus) == exitcode);
+}
+
+static inline void internal_assert_wsignaled(int wstatus, int signal)
+{
+ internal_assert(WIFSIGNALED(wstatus) &&
+ WTERMSIG(wstatus) == signal);
+}
#endif
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [igt-dev] [PATCH i-g-t 3/6] tests: drop invalid name build checks
2019-02-15 9:54 [igt-dev] [PATCH i-g-t 1/6] lib/tests: Add header for common helpers Daniel Vetter
2019-02-15 9:54 ` [igt-dev] [PATCH i-g-t 2/6] lib/tests: add internal_assert_wexited/wsignaled Daniel Vetter
@ 2019-02-15 9:54 ` Daniel Vetter
2019-02-15 9:54 ` [igt-dev] [PATCH i-g-t 4/6] lib/tests: Convert no_exit tests into positive tests Daniel Vetter
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2019-02-15 9:54 UTC (permalink / raw)
To: IGT development; +Cc: Petri Latvala, Daniel Vetter
They're causing troubles because this runs all the igt_fixtures, and
doing that on a build machine is at best surprising.
The main aim for this is catching testcases which fail to call
igt_exit. But just enumerating subtests does that too, and we have
library unit tests to make sure that's the case (with igt_no_exit and
igt_no_exit_list_only).
Cc: Petri Latvala <petri.latvala@intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
tests/igt_command_line.sh | 4 ----
1 file changed, 4 deletions(-)
diff --git a/tests/igt_command_line.sh b/tests/igt_command_line.sh
index e05ec34ce321..92643c4d5e16 100755
--- a/tests/igt_command_line.sh
+++ b/tests/igt_command_line.sh
@@ -94,10 +94,6 @@ check_test ()
fail $test
fi
fi
-
- # check invalid subtest handling
- echo " Checking invalid subtest handling..."
- ./$test --run-subtest invalid-subtest > /dev/null 2>&1 && fail $test
}
TESTLISTFILE="$tests_dir/test-list.txt"
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [igt-dev] [PATCH i-g-t 4/6] lib/tests: Convert no_exit tests into positive tests
2019-02-15 9:54 [igt-dev] [PATCH i-g-t 1/6] lib/tests: Add header for common helpers Daniel Vetter
2019-02-15 9:54 ` [igt-dev] [PATCH i-g-t 2/6] lib/tests: add internal_assert_wexited/wsignaled Daniel Vetter
2019-02-15 9:54 ` [igt-dev] [PATCH i-g-t 3/6] tests: drop invalid name build checks Daniel Vetter
@ 2019-02-15 9:54 ` Daniel Vetter
2019-02-15 9:54 ` [igt-dev] [PATCH i-g-t 5/6] lib/tests: Add testcase for nonexisting subtest name Daniel Vetter
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2019-02-15 9:54 UTC (permalink / raw)
To: IGT development; +Cc: Daniel Vetter
This way we can make sure they die with an assert, which is what we
want.
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
lib/tests/igt_no_exit.c | 50 ++++++++++++++++++++++++++++++-
lib/tests/igt_no_exit_list_only.c | 41 -------------------------
lib/tests/meson.build | 17 +++++------
3 files changed, 57 insertions(+), 51 deletions(-)
delete mode 100644 lib/tests/igt_no_exit_list_only.c
diff --git a/lib/tests/igt_no_exit.c b/lib/tests/igt_no_exit.c
index dc89b8302a71..4a777412b6a9 100644
--- a/lib/tests/igt_no_exit.c
+++ b/lib/tests/igt_no_exit.c
@@ -25,9 +25,26 @@
*
*/
+#include <sys/wait.h>
+
#include "drmtest.h"
-int main(int argc, char **argv)
+#include "igt_tests_common.h"
+
+static void no_exit_list_only(void)
+{
+ char prog[] = "igt_list_only";
+ char arg[] = "--list-subtests";
+ char *fake_argv[] = {prog, arg};
+ int fake_argc = 2;
+
+ igt_subtest_init(fake_argc, fake_argv);
+
+ igt_subtest("A")
+ ;
+}
+
+static void no_exit(void)
{
char prog[] = "igt_no_exit";
char *fake_argv[] = {prog};
@@ -38,3 +55,34 @@ int main(int argc, char **argv)
igt_subtest("A")
;
}
+
+static int do_fork(void (*test_to_run)(void))
+{
+ int pid, status;
+
+ switch (pid = fork()) {
+ case -1:
+ internal_assert(0);
+ case 0:
+ test_to_run();
+ default:
+ while (waitpid(pid, &status, 0) == -1 &&
+ errno == EINTR)
+ ;
+
+ return status;
+ }
+}
+
+int main(int argc, char **argv)
+{
+ int ret;
+
+ ret = do_fork(no_exit);
+ internal_assert_wsignaled(ret, SIGABRT);
+
+ ret = do_fork(no_exit_list_only);
+ internal_assert_wsignaled(ret, SIGABRT);
+
+ return 0;
+}
diff --git a/lib/tests/igt_no_exit_list_only.c b/lib/tests/igt_no_exit_list_only.c
deleted file mode 100644
index add3fc257e66..000000000000
--- a/lib/tests/igt_no_exit_list_only.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright © 2013 Intel Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
- * IN THE SOFTWARE.
- *
- * Authors:
- * Daniel Vetter <daniel.vetter@ffwll.ch>
- *
- */
-
-#include "drmtest.h"
-
-int main(int argc, char **argv)
-{
- char prog[] = "igt_list_only";
- char arg[] = "--list-subtests";
- char *fake_argv[] = {prog, arg};
- int fake_argc = 2;
-
- igt_subtest_init(fake_argc, fake_argv);
-
- igt_subtest("A")
- ;
-}
diff --git a/lib/tests/meson.build b/lib/tests/meson.build
index 665ad4a0fbcc..776b63ed1fd4 100644
--- a/lib/tests/meson.build
+++ b/lib/tests/meson.build
@@ -1,21 +1,20 @@
lib_tests = [
- 'igt_fork_helper',
+ 'igt_assert',
+ 'igt_can_fail',
+ 'igt_can_fail_simple',
+ 'igt_exit_handler',
'igt_fork',
+ 'igt_fork_helper',
+ 'igt_hdmi_inject',
'igt_list_only',
+ 'igt_no_exit',
+ 'igt_segfault',
'igt_simulation',
'igt_stats',
- 'igt_segfault',
'igt_subtest_group',
- 'igt_assert',
- 'igt_exit_handler',
- 'igt_hdmi_inject',
- 'igt_can_fail',
- 'igt_can_fail_simple',
]
lib_fail_tests = [
- 'igt_no_exit',
- 'igt_no_exit_list_only',
'igt_no_subtest',
'igt_simple_test_subtests',
'igt_timeout',
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [igt-dev] [PATCH i-g-t 5/6] lib/tests: Add testcase for nonexisting subtest name
2019-02-15 9:54 [igt-dev] [PATCH i-g-t 1/6] lib/tests: Add header for common helpers Daniel Vetter
` (2 preceding siblings ...)
2019-02-15 9:54 ` [igt-dev] [PATCH i-g-t 4/6] lib/tests: Convert no_exit tests into positive tests Daniel Vetter
@ 2019-02-15 9:54 ` Daniel Vetter
2019-02-15 9:54 ` [igt-dev] [PATCH i-g-t 6/6] lib/core_auth: mount namespace magic to make the test work everywhere Daniel Vetter
2019-02-15 15:48 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/6] lib/tests: Add header for common helpers Patchwork
5 siblings, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2019-02-15 9:54 UTC (permalink / raw)
To: IGT development; +Cc: Daniel Vetter
While at it, convert the existing testcase for invalid subtest names
to a positive one.
This is the only thing the invalid subtest checking for all tests did
cover, which wasn't covered through some other checks already.
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
lib/tests/igt_invalid_subtest_name.c | 62 +++++++++++++++++++++++++++-
lib/tests/meson.build | 2 +-
2 files changed, 62 insertions(+), 2 deletions(-)
diff --git a/lib/tests/igt_invalid_subtest_name.c b/lib/tests/igt_invalid_subtest_name.c
index 418071da0591..f962e0df0121 100644
--- a/lib/tests/igt_invalid_subtest_name.c
+++ b/lib/tests/igt_invalid_subtest_name.c
@@ -21,11 +21,71 @@
* IN THE SOFTWARE.
*/
+#include <errno.h>
+#include <sys/wait.h>
+
#include "igt_core.h"
-igt_main
+#include "igt_tests_common.h"
+
+static void invalid_subtest_name(void)
{
+ char prog[] = "igt_no_exit";
+ char *fake_argv[] = {prog};
+ int fake_argc = 1;
+
+ igt_subtest_init(fake_argc, fake_argv);
+
igt_subtest("# invalid name !") {
igt_info("Invalid subtest name test\n");
}
+
+ igt_exit();
+}
+
+static void nonexisting_subtest(void)
+{
+ char prog[] = "igt_no_exit";
+ char arg1[] = "--run-subtest";
+ char arg2[] = "invalid-subtest";
+ char *fake_argv[] = {prog, arg1, arg2};
+ int fake_argc = 3;
+
+ igt_subtest_init(fake_argc, fake_argv);
+
+ igt_subtest("some-subtest")
+ ;
+
+ igt_exit();
+}
+
+static int do_fork(void (*test_to_run)(void))
+{
+ int pid, status;
+
+ switch (pid = fork()) {
+ case -1:
+ internal_assert(0);
+ case 0:
+ test_to_run();
+ default:
+ while (waitpid(pid, &status, 0) == -1 &&
+ errno == EINTR)
+ ;
+
+ return status;
+ }
+}
+
+int main(int argc, char **argv)
+{
+ int ret;
+
+ ret = do_fork(invalid_subtest_name);
+ internal_assert_wsignaled(ret, SIGABRT);
+
+ ret = do_fork(nonexisting_subtest);
+ internal_assert_wexited(ret, IGT_EXIT_INVALID);
+
+ return 0;
}
diff --git a/lib/tests/meson.build b/lib/tests/meson.build
index 776b63ed1fd4..74efce396cec 100644
--- a/lib/tests/meson.build
+++ b/lib/tests/meson.build
@@ -7,6 +7,7 @@ lib_tests = [
'igt_fork_helper',
'igt_hdmi_inject',
'igt_list_only',
+ 'igt_invalid_subtest_name',
'igt_no_exit',
'igt_segfault',
'igt_simulation',
@@ -18,7 +19,6 @@ lib_fail_tests = [
'igt_no_subtest',
'igt_simple_test_subtests',
'igt_timeout',
- 'igt_invalid_subtest_name',
]
foreach lib_test : lib_tests
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [igt-dev] [PATCH i-g-t 6/6] lib/core_auth: mount namespace magic to make the test work everywhere
2019-02-15 9:54 [igt-dev] [PATCH i-g-t 1/6] lib/tests: Add header for common helpers Daniel Vetter
` (3 preceding siblings ...)
2019-02-15 9:54 ` [igt-dev] [PATCH i-g-t 5/6] lib/tests: Add testcase for nonexisting subtest name Daniel Vetter
@ 2019-02-15 9:54 ` Daniel Vetter
2019-02-15 15:48 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/6] lib/tests: Add header for common helpers Patchwork
5 siblings, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2019-02-15 9:54 UTC (permalink / raw)
To: IGT development; +Cc: Daniel Vetter, Emil Velikov
We're creating our own namespace and then create a copy of the chardev
that anyone can access before dropping root. Should hopefully work on
any system.
This way we're also guaranteed to open the right device again.
v2: mount(2) instead of mount(3).
Cc: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
tests/core_auth.c | 35 +++++++++++++++++++++--------------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/tests/core_auth.c b/tests/core_auth.c
index 0b9073cb0fce..bc2754ec30af 100644
--- a/tests/core_auth.c
+++ b/tests/core_auth.c
@@ -36,6 +36,8 @@
#include <fcntl.h>
#include <inttypes.h>
#include <errno.h>
+#include <sched.h>
+#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/time.h>
@@ -243,17 +245,24 @@ static void test_unauth_vs_render(int master)
{
int slave;
uint32_t handle;
+ struct stat statbuf;
+ bool has_render;
- /*
- * FIXME: when drm_open_driver() fails to open() a node (insufficient
- * permissions or otherwise, it will igt_skip.
- * As of today, igt_skip and igt_fork do not work together.
- */
- slave = __drm_open_driver(DRIVER_ANY);
- /*
- * FIXME: relate to the master fd passed with the above open and fix
- * all of IGT.
- */
+ /* need to check for render nodes before we wreak the filesystem */
+ has_render = has_render_node(master);
+
+ /* create a card node matching master which (only) we can access as
+ * non-root */
+ do_or_die(fstat(master, &statbuf));
+ do_or_die(unshare(CLONE_NEWNS));
+ do_or_die(mount(NULL, "/", NULL, MS_PRIVATE | MS_REC, NULL));
+ do_or_die(mount("none", "/dev/dri", "tmpfs", 0, NULL));
+ umask(0);
+ do_or_die(mknod("/dev/dri/card", S_IFCHR | 0777, statbuf.st_rdev));
+
+ igt_drop_root();
+
+ slave = open("/dev/dri/card", O_RDWR);
igt_assert(slave >= 0);
@@ -276,7 +285,7 @@ static void test_unauth_vs_render(int master)
* Note: We are _not_ interested in the FD2HANDLE specific errno,
* yet the EBADF check is added on the explicit request by danvet.
*/
- if (has_render_node(slave))
+ if (has_render)
igt_assert(errno == EBADF);
else
igt_assert(errno == EACCES);
@@ -330,10 +339,8 @@ igt_main
igt_subtest("unauth-vs-render") {
check_auth_sanity(master);
- igt_fork(child, 1) {
- igt_drop_root();
+ igt_fork(child, 1)
test_unauth_vs_render(master);
- }
igt_waitchildren();
}
}
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/6] lib/tests: Add header for common helpers
2019-02-15 9:54 [igt-dev] [PATCH i-g-t 1/6] lib/tests: Add header for common helpers Daniel Vetter
` (4 preceding siblings ...)
2019-02-15 9:54 ` [igt-dev] [PATCH i-g-t 6/6] lib/core_auth: mount namespace magic to make the test work everywhere Daniel Vetter
@ 2019-02-15 15:48 ` Patchwork
5 siblings, 0 replies; 7+ messages in thread
From: Patchwork @ 2019-02-15 15:48 UTC (permalink / raw)
To: igt-dev
== Series Details ==
Series: series starting with [i-g-t,1/6] lib/tests: Add header for common helpers
URL : https://patchwork.freedesktop.org/series/56715/
State : failure
== Summary ==
Applying: lib/tests: Add header for common helpers
Applying: lib/tests: add internal_assert_wexited/wsignaled
Applying: tests: drop invalid name build checks
Applying: lib/tests: Convert no_exit tests into positive tests
Applying: lib/tests: Add testcase for nonexisting subtest name
Applying: lib/core_auth: mount namespace magic to make the test work everywhere
Using index info to reconstruct a base tree...
M tests/core_auth.c
Falling back to patching base and 3-way merge...
Auto-merging tests/core_auth.c
CONFLICT (content): Merge conflict in tests/core_auth.c
Patch failed at 0006 lib/core_auth: mount namespace magic to make the test work everywhere
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-02-15 15:48 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-15 9:54 [igt-dev] [PATCH i-g-t 1/6] lib/tests: Add header for common helpers Daniel Vetter
2019-02-15 9:54 ` [igt-dev] [PATCH i-g-t 2/6] lib/tests: add internal_assert_wexited/wsignaled Daniel Vetter
2019-02-15 9:54 ` [igt-dev] [PATCH i-g-t 3/6] tests: drop invalid name build checks Daniel Vetter
2019-02-15 9:54 ` [igt-dev] [PATCH i-g-t 4/6] lib/tests: Convert no_exit tests into positive tests Daniel Vetter
2019-02-15 9:54 ` [igt-dev] [PATCH i-g-t 5/6] lib/tests: Add testcase for nonexisting subtest name Daniel Vetter
2019-02-15 9:54 ` [igt-dev] [PATCH i-g-t 6/6] lib/core_auth: mount namespace magic to make the test work everywhere Daniel Vetter
2019-02-15 15:48 ` [igt-dev] ✗ Fi.CI.BAT: failure for series starting with [i-g-t,1/6] lib/tests: Add header for common helpers Patchwork
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox