From 3bbdb535438951ffb8eac78abbf4152dcfa2185d Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Wed, 20 Feb 2019 15:24:47 +0100 Subject: lib/tests: Use ARRAY_SIZE Except in igt_simulation.c where we use tricks and intentionally only want part of the array in some cases. Suggested-by: Arkadiusz Hiler Cc: Arkadiusz Hiler Reviewed-by: Arkadiusz Hiler Signed-off-by: Daniel Vetter --- lib/tests/igt_assert.c | 3 ++- lib/tests/igt_exit_handler.c | 3 ++- lib/tests/igt_fork.c | 3 ++- lib/tests/igt_invalid_subtest_name.c | 5 +++-- lib/tests/igt_list_only.c | 2 +- lib/tests/igt_no_exit.c | 4 ++-- lib/tests/igt_no_subtest.c | 2 +- lib/tests/igt_segfault.c | 4 +--- 8 files changed, 14 insertions(+), 12 deletions(-) (limited to 'lib/tests') diff --git a/lib/tests/igt_assert.c b/lib/tests/igt_assert.c index 632e1597..1caf5d88 100644 --- a/lib/tests/igt_assert.c +++ b/lib/tests/igt_assert.c @@ -34,6 +34,7 @@ #include #include "igt_core.h" +#include "drmtest.h" #include "igt_tests_common.h" @@ -63,7 +64,7 @@ static int do_fork(void) case -1: internal_assert(0); case 0: - argc = 1; + argc = ARRAY_SIZE(argv_run); igt_simple_init(argc, argv_run); test_to_run(); igt_exit(); diff --git a/lib/tests/igt_exit_handler.c b/lib/tests/igt_exit_handler.c index f8a74786..892a7f14 100644 --- a/lib/tests/igt_exit_handler.c +++ b/lib/tests/igt_exit_handler.c @@ -26,6 +26,7 @@ #include #include #include "igt_core.h" +#include "drmtest.h" #include "igt_tests_common.h" @@ -63,7 +64,7 @@ static int testfunc(enum test_type test_type) { char prog[] = "igt_no_exit"; char *fake_argv[] = {prog}; - int fake_argc = 1; + int fake_argc = ARRAY_SIZE(fake_argv); pid_t pid; int status; char tmp = 0; diff --git a/lib/tests/igt_fork.c b/lib/tests/igt_fork.c index 10003120..7e8b4f9b 100644 --- a/lib/tests/igt_fork.c +++ b/lib/tests/igt_fork.c @@ -30,6 +30,7 @@ #include #include "igt_core.h" +#include "drmtest.h" #include "igt_tests_common.h" @@ -93,7 +94,7 @@ static int do_fork(void (*test_to_run)(void)) case -1: internal_assert(0); case 0: - argc = 1; + argc = ARRAY_SIZE(argv_run); igt_simple_init(argc, argv_run); test_to_run(); igt_exit(); diff --git a/lib/tests/igt_invalid_subtest_name.c b/lib/tests/igt_invalid_subtest_name.c index f962e0df..92e767ab 100644 --- a/lib/tests/igt_invalid_subtest_name.c +++ b/lib/tests/igt_invalid_subtest_name.c @@ -25,6 +25,7 @@ #include #include "igt_core.h" +#include "drmtest.h" #include "igt_tests_common.h" @@ -32,7 +33,7 @@ static void invalid_subtest_name(void) { char prog[] = "igt_no_exit"; char *fake_argv[] = {prog}; - int fake_argc = 1; + int fake_argc = ARRAY_SIZE(fake_argv); igt_subtest_init(fake_argc, fake_argv); @@ -49,7 +50,7 @@ static void nonexisting_subtest(void) char arg1[] = "--run-subtest"; char arg2[] = "invalid-subtest"; char *fake_argv[] = {prog, arg1, arg2}; - int fake_argc = 3; + int fake_argc = ARRAY_SIZE(fake_argv); igt_subtest_init(fake_argc, fake_argv); diff --git a/lib/tests/igt_list_only.c b/lib/tests/igt_list_only.c index 65fa9da6..b18d13d3 100644 --- a/lib/tests/igt_list_only.c +++ b/lib/tests/igt_list_only.c @@ -32,7 +32,7 @@ int main(int argc, char **argv) char prog[] = "igt_list_only"; char arg[] = "--list-subtests"; char *fake_argv[] = {prog, arg}; - int fake_argc = 2; + int fake_argc = ARRAY_SIZE(fake_argv); igt_subtest_init(fake_argc, fake_argv); diff --git a/lib/tests/igt_no_exit.c b/lib/tests/igt_no_exit.c index 4a777412..82f00b52 100644 --- a/lib/tests/igt_no_exit.c +++ b/lib/tests/igt_no_exit.c @@ -36,7 +36,7 @@ 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; + int fake_argc = ARRAY_SIZE(fake_argv); igt_subtest_init(fake_argc, fake_argv); @@ -48,7 +48,7 @@ static void no_exit(void) { char prog[] = "igt_no_exit"; char *fake_argv[] = {prog}; - int fake_argc = 1; + int fake_argc = ARRAY_SIZE(fake_argv); igt_subtest_init(fake_argc, fake_argv); diff --git a/lib/tests/igt_no_subtest.c b/lib/tests/igt_no_subtest.c index 1ae62cfd..92e6c277 100644 --- a/lib/tests/igt_no_subtest.c +++ b/lib/tests/igt_no_subtest.c @@ -31,7 +31,7 @@ int main(int argc, char **argv) { char prog[] = "igt_no_exit"; char *fake_argv[] = {prog}; - int fake_argc = 1; + int fake_argc = ARRAY_SIZE(fake_argv); igt_subtest_init(fake_argc, fake_argv); diff --git a/lib/tests/igt_segfault.c b/lib/tests/igt_segfault.c index 2a24531a..0d872f67 100644 --- a/lib/tests/igt_segfault.c +++ b/lib/tests/igt_segfault.c @@ -65,15 +65,13 @@ static int do_fork(void) case -1: internal_assert(0); case 0: + argc = ARRAY_SIZE(argv_run); if (simple) { - argc = 1; igt_simple_init(argc, argv_run); crashme(); igt_exit(); } else { - - argc = 1; igt_subtest_init(argc, argv_run); if(runa) -- cgit v1.2.3