Skip to content

Commit 675211a

Browse files
committed
tests: build integration.py targets with cmake
1 parent d2caaf2 commit 675211a

File tree

4 files changed

+35
-34
lines changed

4 files changed

+35
-34
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ option(STATIC_LINK "Statically link oid" OFF)
2323
option(ASAN "Enable address sanitizer" OFF)
2424
option(CODE_COVERAGE "Enable code coverage" OFF)
2525
option(WITH_TESTS "Build with tests" Off)
26+
option(WITH_FLAKY_TESTS "Build with flaky tests" OFF)
2627
option(FORCE_BOOST_STATIC "Build with static boost" On)
2728
option(FORCE_LLVM_STATIC "Build with static llvm and clang" On)
2829

@@ -123,6 +124,7 @@ FetchContent_Populate(folly)
123124

124125
add_library(folly_headers INTERFACE)
125126
target_include_directories(folly_headers SYSTEM INTERFACE ${folly_SOURCE_DIR})
127+
target_link_libraries(folly_headers INTERFACE Boost::headers)
126128

127129
### bison & flex (for oid_parser)
128130
find_package(BISON 3.5 REQUIRED)

test/CMakeLists.txt

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,15 @@ function(cpp_unittest)
3737
gtest_discover_tests(${TEST_NAME} PROPERTIES ${TEST_PROPERTIES})
3838
endfunction()
3939

40-
# Integration tests
41-
# These tests can't be run in parallel with the other tests.
42-
# There is some sort of conflict triggering the following error:
43-
# dwfl_linux_proc_report: bzip2 decompression failed
44-
# The integration tests are now triggered by the main Makefile.
45-
#add_test(
46-
# NAME integration
47-
# COMMAND make test-integration
48-
# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
49-
#)
40+
add_executable(integration_mttest
41+
integration_mttest.cpp
42+
)
43+
target_link_libraries(integration_mttest folly_headers)
44+
45+
add_executable(integration_sleepy
46+
integration_sleepy.cpp
47+
)
48+
target_link_libraries(integration_sleepy folly_headers)
5049

5150
# Unit tests
5251
cpp_unittest(
@@ -61,5 +60,19 @@ cpp_unittest(
6160
DEPS oicore
6261
)
6362

63+
# Integration tests
64+
if (WITH_FLAKY_TESTS)
65+
add_test(
66+
NAME integration_py
67+
COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/integration.py
68+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
69+
)
70+
set_tests_properties(integration_py PROPERTIES
71+
TIMEOUT 90
72+
ENVIRONMENT "OID=$<TARGET_FILE:oid>"
73+
)
74+
endif()
75+
6476
include_directories("${PROJECT_SOURCE_DIR}/extern/drgn/build")
6577
add_subdirectory("integration")
78+

test/Makefile

Lines changed: 0 additions & 13 deletions
This file was deleted.

test/integration.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,25 +41,21 @@ def setUp(self):
4141
self.oid_source_dir = os.path.dirname(
4242
os.path.dirname(os.path.abspath(__file__))
4343
)
44+
# Assume we started in the CMake build directory
45+
self.build_dir = self.original_working_directory
4446

4547
# This needs to be a class variable, otherwise it won't be referenced
4648
# by any object alive by the end of this class method's execution and
4749
# and the directory will be automatically removed before executing the
4850
# tests themselves.
49-
self.temp = tempfile.TemporaryDirectory(
50-
dir=os.path.join(self.oid_source_dir, "build/")
51-
)
51+
self.temp = tempfile.TemporaryDirectory(dir=self.build_dir)
5252
os.chdir(self.temp.name)
5353

54-
self.oid = os.path.join(self.oid_source_dir, "build/oid")
55-
self.oid_conf = os.path.join(self.oid_source_dir, "build/testing.oid.toml")
54+
self.oid = os.getenv("OID")
55+
self.oid_conf = os.path.join(self.build_dir, "..", "testing.oid.toml")
5656

57-
self.binary_path = os.path.join(
58-
self.oid_source_dir, "test", "integration_mttest"
59-
)
60-
self.sleepy_binary_path = os.path.join(
61-
self.oid_source_dir, "test", "integration_sleepy"
62-
)
57+
self.binary_path = os.path.join(self.build_dir, "integration_mttest")
58+
self.sleepy_binary_path = os.path.join(self.build_dir, "integration_sleepy")
6359

6460
self.custom_generated_code_file = os.path.join(
6561
self.temp.name, "custom_oid_output.cpp"
@@ -150,6 +146,9 @@ def test_attach_more_than_once_works(self):
150146
self.assertEqual(output[0]["dynamicSize"], 76)
151147
self.assertEqual(len(output[0]["members"]), 25)
152148

149+
@unittest.skip(
150+
"https://github.com/facebookexperimental/object-introspection/issues/53"
151+
)
153152
def test_data_segment_size_change(self):
154153
with subprocess.Popen(
155154
f"{self.binary_path} 1000",

0 commit comments

Comments
 (0)