[igt-dev] [PATCH i-g-t 1/3] lib/tests: Use ARRAY_SIZE
Daniel Vetter
daniel.vetter at ffwll.ch
Wed Feb 20 14:24:47 UTC 2019
Except in igt_simulation.c where we use tricks and intentionally only
want part of the array in some cases.
Suggested-by: Arkadiusz Hiler <arkadiusz.hiler at intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler at intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
---
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(-)
diff --git a/lib/tests/igt_assert.c b/lib/tests/igt_assert.c
index 632e15978978..1caf5d885ddb 100644
--- a/lib/tests/igt_assert.c
+++ b/lib/tests/igt_assert.c
@@ -34,6 +34,7 @@
#include <sys/wait.h>
#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 f8a747862c01..892a7f141e90 100644
--- a/lib/tests/igt_exit_handler.c
+++ b/lib/tests/igt_exit_handler.c
@@ -26,6 +26,7 @@
#include <sys/types.h>
#include <sys/wait.h>
#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 100031207461..7e8b4f9b5477 100644
--- a/lib/tests/igt_fork.c
+++ b/lib/tests/igt_fork.c
@@ -30,6 +30,7 @@
#include <sys/wait.h>
#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 f962e0df0121..92e767abe06f 100644
--- a/lib/tests/igt_invalid_subtest_name.c
+++ b/lib/tests/igt_invalid_subtest_name.c
@@ -25,6 +25,7 @@
#include <sys/wait.h>
#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 65fa9da66362..b18d13d3ddef 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 4a777412b6a9..82f00b5220b1 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 1ae62cfd8027..92e6c277e60b 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 2a24531aaa8c..0d872f67850a 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)
--
2.20.1
More information about the igt-dev
mailing list