From 49f180a36c247100dc246379ace84833b91f4038 Mon Sep 17 00:00:00 2001 From: Pranav Rathi <4427674+pranavrth@users.noreply.github.com> Date: Tue, 15 Aug 2023 23:47:28 +0530 Subject: [PATCH] Added new environment variable to tests - TESTS_SKIP_BEFORE (#4317) --- tests/README.md | 4 ++++ tests/test.c | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/tests/README.md b/tests/README.md index b0d99b0bbc..4d2c011ad3 100644 --- a/tests/README.md +++ b/tests/README.md @@ -186,6 +186,10 @@ be it `make`, `run-test.sh`, `until-fail.sh`, etc. with `TESTS=0000`. See [../src/rdunittest.c](../src/rdunittest.c) for unit test names. + * `TESTS_SKIP_BEFORE=0nnn` - skip tests before this test. Tests are skipped + even if they are part of `TESTS` variable. + Usage: `TESTS_SKIP_BEFORE=0030`. All the tests + until test 0030 are skipped. Let's say that you run the full test suite and get a failure in test 0061, diff --git a/tests/test.c b/tests/test.c index 06ade264eb..000e3badab 100644 --- a/tests/test.c +++ b/tests/test.c @@ -77,6 +77,7 @@ int test_rusage = 0; /**< Check resource usage */ * <1.0: CPU is faster than base line system. */ double test_rusage_cpu_calibration = 1.0; static const char *tests_to_run = NULL; /* all */ +static const char *skip_tests_till = NULL; /* all */ static const char *subtests_to_run = NULL; /* all */ static const char *tests_to_skip = NULL; /* none */ int test_write_report = 0; /**< Write test report file */ @@ -1341,6 +1342,13 @@ static void run_tests(int argc, char **argv) { skip_silent = rd_true; } else if (tests_to_skip && strstr(tests_to_skip, testnum)) skip_reason = "included in TESTS_SKIP list"; + else if (skip_tests_till) { + if (!strcmp(skip_tests_till, testnum)) + skip_tests_till = NULL; + else + skip_reason = + "ignoring test before TESTS_SKIP_BEFORE"; + } if (!skip_reason) { run_test(test, argc, argv); @@ -1666,6 +1674,8 @@ int main(int argc, char **argv) { subtests_to_run = test_getenv("SUBTESTS", NULL); tests_to_skip = test_getenv("TESTS_SKIP", NULL); tmpver = test_getenv("TEST_KAFKA_VERSION", NULL); + skip_tests_till = test_getenv("TESTS_SKIP_BEFORE", NULL); + if (!tmpver) tmpver = test_getenv("KAFKA_VERSION", test_broker_version_str); test_broker_version_str = tmpver; @@ -1840,11 +1850,14 @@ int main(int argc, char **argv) { if (test_concurrent_max > 1) test_timeout_multiplier += (double)test_concurrent_max / 3; - TEST_SAY("Tests to run : %s\n", tests_to_run ? tests_to_run : "all"); + TEST_SAY("Tests to run : %s\n", + tests_to_run ? tests_to_run : "all"); if (subtests_to_run) - TEST_SAY("Sub tests : %s\n", subtests_to_run); + TEST_SAY("Sub tests : %s\n", subtests_to_run); if (tests_to_skip) - TEST_SAY("Skip tests : %s\n", tests_to_skip); + TEST_SAY("Skip tests : %s\n", tests_to_skip); + if (skip_tests_till) + TEST_SAY("Skip tests before: %s\n", skip_tests_till); TEST_SAY("Test mode : %s%s%s\n", test_quick ? "quick, " : "", test_mode, test_on_ci ? ", CI" : ""); TEST_SAY("Test scenario: %s\n", test_scenario);