mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-13 02:46:23 +00:00
lib/igt.cocci: Add s/assert/igt_assert/
People use it way too often, and it upsets the test library. The only valid places to use this is of igt infrastructure self-tests where you need to check something _without_ all the other abi use checks igt_fail and friends do. For those tests just #define an internal assert to hide it. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
43784baa13
commit
428060c555
@ -84,3 +84,10 @@ expression pipe;
|
|||||||
+ for_each_pipe (display, pipe) {
|
+ for_each_pipe (display, pipe) {
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tests really shouldn't use plain assert!
|
||||||
|
@@
|
||||||
|
expression E;
|
||||||
|
@@
|
||||||
|
- assert(E);
|
||||||
|
+ igt_assert(E);
|
||||||
|
@ -34,6 +34,14 @@
|
|||||||
#include "drmtest.h"
|
#include "drmtest.h"
|
||||||
#include "igt_core.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
|
||||||
|
|
||||||
bool simple;
|
bool simple;
|
||||||
bool list_subtests;
|
bool list_subtests;
|
||||||
bool in_fixture;
|
bool in_fixture;
|
||||||
@ -50,7 +58,7 @@ static int do_fork(void)
|
|||||||
|
|
||||||
switch (pid = fork()) {
|
switch (pid = fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
assert(0);
|
internal_assert(0);
|
||||||
case 0:
|
case 0:
|
||||||
if (simple) {
|
if (simple) {
|
||||||
igt_simple_init(1, argv_run);
|
igt_simple_init(1, argv_run);
|
||||||
@ -84,7 +92,7 @@ static int do_fork(void)
|
|||||||
errno == EINTR)
|
errno == EINTR)
|
||||||
;
|
;
|
||||||
|
|
||||||
assert(WIFEXITED(status));
|
internal_assert(WIFEXITED(status));
|
||||||
|
|
||||||
return WEXITSTATUS(status);
|
return WEXITSTATUS(status);
|
||||||
}
|
}
|
||||||
@ -94,63 +102,63 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
/* simple tests */
|
/* simple tests */
|
||||||
simple = true;
|
simple = true;
|
||||||
assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
|
internal_assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
|
||||||
assert(do_fork() == IGT_EXIT_SKIP);
|
internal_assert(do_fork() == IGT_EXIT_SKIP);
|
||||||
|
|
||||||
assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
|
internal_assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
|
||||||
assert(do_fork() == IGT_EXIT_SUCCESS);
|
internal_assert(do_fork() == IGT_EXIT_SUCCESS);
|
||||||
|
|
||||||
/* subtests, list mode */
|
/* subtests, list mode */
|
||||||
simple = false;
|
simple = false;
|
||||||
list_subtests = true;
|
list_subtests = true;
|
||||||
|
|
||||||
in_fixture = false;
|
in_fixture = false;
|
||||||
assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
|
internal_assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
|
||||||
assert(do_fork() == IGT_EXIT_SUCCESS);
|
internal_assert(do_fork() == IGT_EXIT_SUCCESS);
|
||||||
|
|
||||||
assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
|
internal_assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
|
||||||
assert(do_fork() == IGT_EXIT_SUCCESS);
|
internal_assert(do_fork() == IGT_EXIT_SUCCESS);
|
||||||
|
|
||||||
in_fixture = true;
|
in_fixture = true;
|
||||||
assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
|
internal_assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
|
||||||
assert(do_fork() == IGT_EXIT_SUCCESS);
|
internal_assert(do_fork() == IGT_EXIT_SUCCESS);
|
||||||
|
|
||||||
assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
|
internal_assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
|
||||||
assert(do_fork() == IGT_EXIT_SUCCESS);
|
internal_assert(do_fork() == IGT_EXIT_SUCCESS);
|
||||||
|
|
||||||
in_fixture = false;
|
in_fixture = false;
|
||||||
in_subtest = true;
|
in_subtest = true;
|
||||||
assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
|
internal_assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
|
||||||
assert(do_fork() == IGT_EXIT_SUCCESS);
|
internal_assert(do_fork() == IGT_EXIT_SUCCESS);
|
||||||
|
|
||||||
assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
|
internal_assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
|
||||||
assert(do_fork() == IGT_EXIT_SUCCESS);
|
internal_assert(do_fork() == IGT_EXIT_SUCCESS);
|
||||||
|
|
||||||
/* subtest, run mode */
|
/* subtest, run mode */
|
||||||
simple = false;
|
simple = false;
|
||||||
list_subtests = false;
|
list_subtests = false;
|
||||||
|
|
||||||
in_fixture = false;
|
in_fixture = false;
|
||||||
assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
|
internal_assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
|
||||||
assert(do_fork() == IGT_EXIT_SKIP);
|
internal_assert(do_fork() == IGT_EXIT_SKIP);
|
||||||
|
|
||||||
assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
|
internal_assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
|
||||||
assert(do_fork() == IGT_EXIT_SUCCESS);
|
internal_assert(do_fork() == IGT_EXIT_SUCCESS);
|
||||||
|
|
||||||
in_fixture = true;
|
in_fixture = true;
|
||||||
assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
|
internal_assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
|
||||||
assert(do_fork() == IGT_EXIT_SKIP);
|
internal_assert(do_fork() == IGT_EXIT_SKIP);
|
||||||
|
|
||||||
assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
|
internal_assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
|
||||||
assert(do_fork() == IGT_EXIT_SUCCESS);
|
internal_assert(do_fork() == IGT_EXIT_SUCCESS);
|
||||||
|
|
||||||
in_fixture = false;
|
in_fixture = false;
|
||||||
in_subtest = true;
|
in_subtest = true;
|
||||||
assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
|
internal_assert(setenv("INTEL_SIMULATION", "1", 1) == 0);
|
||||||
assert(do_fork() == IGT_EXIT_SKIP);
|
internal_assert(do_fork() == IGT_EXIT_SKIP);
|
||||||
|
|
||||||
assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
|
internal_assert(setenv("INTEL_SIMULATION", "0", 1) == 0);
|
||||||
assert(do_fork() == IGT_EXIT_SUCCESS);
|
internal_assert(do_fork() == IGT_EXIT_SUCCESS);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user