From 618a6cf7375066832b29c1ca18e3613e0304d8fe Mon Sep 17 00:00:00 2001 From: Simon Kagstrom Date: Tue, 16 Jul 2024 09:18:18 +0200 Subject: [PATCH 1/2] tests: Try to make the solib test less fickle --- tests/shared-library/solib.c | 3 +++ tests/tools/test_compiled.py | 4 ++-- tests/tools/test_compiled_basic.py | 5 ++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/shared-library/solib.c b/tests/shared-library/solib.c index 571d5539..5dce07ef 100644 --- a/tests/shared-library/solib.c +++ b/tests/shared-library/solib.c @@ -7,7 +7,10 @@ int vobb(int a) a = a + 1; if (a > 2) + { + printf("a is greater than 2\n"); return 1; + } return 0; } diff --git a/tests/tools/test_compiled.py b/tests/tools/test_compiled.py index ff2a3054..3006c349 100644 --- a/tests/tools/test_compiled.py +++ b/tests/tools/test_compiled.py @@ -498,7 +498,7 @@ def runTest(self): assert cobertura.hitsPerLine(dom, "dlopen.cc", 11) == 1 assert cobertura.hitsPerLine(dom, "dlopen.cc", 12) == 0 assert cobertura.hitsPerLine(dom, "solib.c", 5) == 1 - assert cobertura.hitsPerLine(dom, "solib.c", 12) == 0 + assert cobertura.hitsPerLine(dom, "solib.c", 15) == 0 class dlopen_in_ignored_source_file(libkcov.TestCase): @@ -516,7 +516,7 @@ def runTest(self): dom = cobertura.parseFile(self.outbase + "/kcov/dlopen/cobertura.xml") assert cobertura.hitsPerLine(dom, "dlopen-main.cc", 10) == 1 assert cobertura.hitsPerLine(dom, "solib.c", 5) == 1 - assert cobertura.hitsPerLine(dom, "solib.c", 12) == 0 + assert cobertura.hitsPerLine(dom, "solib.c", 15) == 0 class daemon_no_wait_for_last_child(libkcov.TestCase): diff --git a/tests/tools/test_compiled_basic.py b/tests/tools/test_compiled_basic.py index bc8fc7b2..6d60a687 100644 --- a/tests/tools/test_compiled_basic.py +++ b/tests/tools/test_compiled_basic.py @@ -35,11 +35,10 @@ def runTest(self): + "/shared_library_test", False, ) - self.skipTest("Fickle test, ignoring") assert rv == 0 dom = cobertura.parseFile(self.outbase + "/kcov/shared_library_test/cobertura.xml") - assert cobertura.hitsPerLine(dom, "main.c", 9) == 1 + assert cobertura.hitsPerLine(dom, "main.c", 9) >= 1 assert cobertura.hitsPerLine(dom, "solib.c", 5) is None @@ -74,7 +73,7 @@ def runTest(self): dom = cobertura.parseFile(self.outbase + "/kcov/shared_library_test/cobertura.xml") assert cobertura.hitsPerLine(dom, "main.c", 9) == 1 assert cobertura.hitsPerLine(dom, "solib.c", 5) == 1 - assert cobertura.hitsPerLine(dom, "solib.c", 10) == 1 + assert cobertura.hitsPerLine(dom, "solib.c", 11) >= 1 class MainTestBase(libkcov.TestCase): From 85c5117e02aaa0a65a30e83d06734029d5ce0ce0 Mon Sep 17 00:00:00 2001 From: Simon Kagstrom Date: Tue, 16 Jul 2024 09:47:02 +0200 Subject: [PATCH 2/2] tests: Warn that shared_library_test is a PIE --- tests/CMakeLists.txt | 2 ++ tests/tools/test_compiled_basic.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 59c06fc7..272df959 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -133,6 +133,8 @@ target_link_libraries(multi_fork "${M_LIBRARY}") add_executable(shared_library_test ${shared_library_test_SRCS}) target_link_libraries(shared_library_test shared_library) +# This doesn't appear to work, unfortunately, but will be needed for the --skip-solibs test +set_target_properties (shared_library_test PROPERTIES POSITION_INDEPENDENT_CODE False) add_executable(argv_dependent ${argv_dependent_SRCS}) add_executable(test_popen ${test_popen_SRCS}) diff --git a/tests/tools/test_compiled_basic.py b/tests/tools/test_compiled_basic.py index 6d60a687..69b6d741 100644 --- a/tests/tools/test_compiled_basic.py +++ b/tests/tools/test_compiled_basic.py @@ -35,6 +35,8 @@ def runTest(self): + "/shared_library_test", False, ) + # Fickle since the binary is built as a PIE by default, not sure how to disable it + self.skipTest("Fickle test, ignoring") assert rv == 0 dom = cobertura.parseFile(self.outbase + "/kcov/shared_library_test/cobertura.xml")