From patchwork Wed Apr 29 15:28:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Matthias_M=C3=A4nnich?= X-Patchwork-Id: 39178 From: maennich@google.com (Matthias Maennich) Date: Wed, 29 Apr 2020 17:28:12 +0200 Subject: [PATCH 1/2] test-types-stability: parallelize test case alternatives Message-ID: <20200429152812.217166-1-maennich@google.com> Commit a9f5fb408946 ("Add --no-write-default-sizes option.") introduced a new test variant for test-types-stability that is actually independent of the original test case in terms of execution. Hence it can be expressed as a separate test case. So, do that by parametrizing the test_task struct with a new no_default_sizes flag and schedule a separate test case in the main loop. That test runs now ~twice as fast dropping from roughly 20s on my machine to 10s. That effectively removes it from the critical path of make check, which is now back to about 15s on my machine with my configuration. * tests/test-types-stability.cc (test_task): add field no_default_sizes (test_task::perform) Switch on the new flag to test a different behaviour. (main): Schedule an additional test case to test with the new flag. Cc: Mark Wielaard Signed-off-by: Matthias Maennich --- tests/test-types-stability.cc | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/tests/test-types-stability.cc b/tests/test-types-stability.cc index bc3d4d6e2e8b..1c1a5312b600 100644 --- a/tests/test-types-stability.cc +++ b/tests/test-types-stability.cc @@ -70,7 +70,8 @@ const char* elf_paths[] = /// passed to the constructor of the task. struct test_task : public abigail::workers::task { - string path; + const string path; + const bool no_default_sizes; string error_message; bool is_ok; @@ -78,8 +79,9 @@ struct test_task : public abigail::workers::task /// /// @param elf_path the path to the elf binary on which we are /// supposed to launch abidw --abidiff. - test_task(const string& elf_path) + test_task(const string& elf_path, bool no_default_sizes) : path(elf_path), + no_default_sizes(no_default_sizes), is_ok(true) {} @@ -96,18 +98,14 @@ struct test_task : public abigail::workers::task string abidw = string(get_build_dir()) + "/tools/abidw"; string elf_path = string(get_src_dir()) + "/tests/" + path; - string cmd = abidw + " --abidiff " + elf_path; + string cmd = abidw + " --abidiff " + + (no_default_sizes ? "--no-write-default-sizes " : "") + + elf_path; if (system(cmd.c_str())) { - error_message = "IR stability issue detected for binary " + elf_path; - is_ok = false; - } - - cmd = abidw + " --abidiff --no-write-default-sizes " + elf_path; - if (system(cmd.c_str())) - { - error_message = "IR stability issue detected for binary " + elf_path - + " with --no-write-default-sizes"; + error_message = + "IR stability issue detected for binary " + elf_path + + (no_default_sizes ? " with --no-write-default-sizes" : ""); is_ok = false; } } @@ -129,7 +127,7 @@ main() /// Create a task queue. The max number of worker threads of the /// queue is the number of the concurrent threads supported by the /// processor of the machine this code runs on. - const size_t num_tests = sizeof(elf_paths) / sizeof (char*) - 1; + const size_t num_tests = (sizeof(elf_paths) / sizeof(char*) - 1) * 2; size_t num_workers = std::min(get_number_of_threads(), num_tests); queue task_queue(num_workers); @@ -138,7 +136,10 @@ main() /// a worker thread that starts working on the task. for (const char** p = elf_paths; p && *p; ++p) { - test_task_sptr t(new test_task(*p)); + test_task_sptr t(new test_task(*p, false)); + ABG_ASSERT(task_queue.schedule_task(t)); + + t.reset(new test_task(*p, true)); ABG_ASSERT(task_queue.schedule_task(t)); }