From 37bc11e707d3f29fa81675bcc41610ab65c2b314 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 28 Sep 2021 15:12:48 +0200 Subject: Refactor QTEST*_MAIN() implementations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The various variants duplicated some rather complex code around varying setup in the middle. Rework in terms of a macro that defines main() and takes the setup code as a parameter. That setup code also had some common structure, so package that in a setup macro that takes the class to be used. Reworked various testlib selftests that were using QTEST_MAIN_IMPL(); change to use the new QTEST_MAIN_WRAPPER() and TEST_MAIN_SETUP(). These might be better dealt with by supporting a second form of the initMain() test-setup function in the test classes, that takes references for argc and argv, to let a test massage its command-line options. Change-Id: I7fb16b38d51c80ba2f5c9c82f3b7a37ffc636795 Reviewed-by: Tor Arne Vestbø --- .../testlib/selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'tests/auto/testlib/selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp') diff --git a/tests/auto/testlib/selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp b/tests/auto/testlib/selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp index 353a7f5018..b3cf623375 100644 --- a/tests/auto/testlib/selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp +++ b/tests/auto/testlib/selftests/benchlibcallgrind/tst_benchlibcallgrind.cpp @@ -78,8 +78,7 @@ void tst_BenchlibCallgrind::twoHundredMillionInstructions() #endif } -int main(int argc, char *argv[]) -{ +QTEST_MAIN_WRAPPER(tst_BenchlibCallgrind, std::vector args(argv, argv + argc); // Add the -callgrind argument unless (it's there anyway or) we're the // recursive invocation with -callgrindchild passed. @@ -92,9 +91,7 @@ int main(int argc, char *argv[]) argc = args.size(); argv = const_cast(&args[0]); } - - QTEST_MAIN_IMPL(tst_BenchlibCallgrind) -} + QTEST_MAIN_SETUP()) #undef HAVE_VALGRIND_H #include "tst_benchlibcallgrind.moc" -- cgit v1.2.3