Skip to content

Commit f37a98b

Browse files
authoredDec 3, 2021
cmake: change how test files are build when cross compiling
* When cross compiling gnuradio, change how the test files are built. Normally, the gnuradio QA code expects to run in the build tree. For the cross compilng case, we cannot run the QA code during the build process. The changes here allow the creation of an additional package that can be installed on a target that will run the QA code against the installed libraries. Major changes are not using full paths to test files (since they include paths that only exist on the build machine) and not setting environment variables in the shell files to force the QA code to use code in the build tree. This patch disables the C++ only tests, these need some work and then they can be added back for the cross compile case. Signed-off-by: Philip Balister <[email protected]>
1 parent 76cdd1c commit f37a98b

File tree

20 files changed

+72
-9
lines changed

20 files changed

+72
-9
lines changed
 

‎cmake/Modules/GrTest.cmake

+11-7
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,13 @@ function(GR_ADD_TEST test_name)
9898
endif(CMAKE_CROSSCOMPILING)
9999
set(sh_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.sh)
100100
file(WRITE ${sh_file} "#!${SHELL}\n")
101-
#each line sets an environment variable
102-
foreach(environ ${environs})
103-
file(APPEND ${sh_file} "export ${environ}\n")
104-
endforeach(environ)
105-
#load the command to run with its arguments
101+
if (NOT CMAKE_CROSSCOMPILING)
102+
#each line sets an environment variable
103+
foreach(environ ${environs})
104+
file(APPEND ${sh_file} "export ${environ}\n")
105+
endforeach(environ)
106+
#load the command to run with its arguments
107+
endif(CMAKE_CROSSCOMPILING)
106108
foreach(arg ${ARGN})
107109
file(APPEND ${sh_file} "${arg} ")
108110
endforeach(arg)
@@ -111,7 +113,7 @@ function(GR_ADD_TEST test_name)
111113
#make the shell file executable
112114
execute_process(COMMAND chmod +x ${sh_file})
113115

114-
add_test(${test_name} ${SHELL} ${sh_file})
116+
add_test(${test_name} ${SHELL} ${test_name}_test.sh)
115117
endif(UNIX)
116118

117119
if(WIN32)
@@ -161,5 +163,7 @@ function(GR_ADD_CPP_TEST test_name test_source)
161163
set_target_properties(${test_name}
162164
PROPERTIES COMPILE_DEFINITIONS "BOOST_TEST_DYN_LINK;BOOST_TEST_MAIN"
163165
)
164-
GR_ADD_TEST(${test_name} ${test_name})
166+
IF (NOT CMAKE_CROSSCOMPILING)
167+
GR_ADD_TEST(${test_name} ${test_name})
168+
ENDIF(CMAKE_CROSSCOMPILING)
165169
endfunction(GR_ADD_CPP_TEST)

‎gnuradio-runtime/python/gnuradio/gr/CMakeLists.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ if(ENABLE_TESTING)
5151

5252
foreach(py_qa_test_file ${py_qa_test_files})
5353
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
54-
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${CMAKE_CURRENT_SOURCE_DIR}/${py_qa_test_file})
54+
if (CMAKE_CROSSCOMPILING)
55+
get_filename_component(py_qa_test_file ${py_qa_test_file} NAME)
56+
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
57+
else()
58+
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${CMAKE_CURRENT_SOURCE_DIR}/${py_qa_test_file})
59+
endif(CMAKE_CROSSCOMPILING)
5560
endforeach(py_qa_test_file)
5661
endif(ENABLE_TESTING)
5762

‎gnuradio-runtime/python/pmt/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ foreach(py_qa_test_file ${py_qa_test_files})
2828
${CMAKE_BINARY_DIR}/gnuradio-runtime/python
2929
)
3030
set(GR_TEST_TARGET_DEPS gnuradio-runtime)
31+
if (CMAKE_CROSSCOMPILING)
32+
get_filename_component(py_qa_test_file ${py_qa_test_file} NAME)
33+
endif(CMAKE_CROSSCOMPILING)
3134
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
3235
endforeach(py_qa_test_file)
3336
endif(ENABLE_TESTING)

‎gr-analog/python/analog/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ if(ENABLE_TESTING)
4141
file(GLOB py_qa_test_files "qa_*.py")
4242
foreach(py_qa_test_file ${py_qa_test_files})
4343
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
44+
if (CMAKE_CROSSCOMPILING)
45+
get_filename_component(py_qa_test_file ${py_qa_test_file} NAME)
46+
endif(CMAKE_CROSSCOMPILING)
4447
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
4548
endforeach(py_qa_test_file)
4649
endif(ENABLE_TESTING)

‎gr-audio/python/audio/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ if(ENABLE_TESTING)
2929
file(GLOB py_qa_test_files "qa_*.py")
3030
foreach(py_qa_test_file ${py_qa_test_files})
3131
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
32+
if (CMAKE_CROSSCOMPILING)
33+
get_filename_component(py_qa_test_file ${py_qa_test_file} NAME)
34+
endif(CMAKE_CROSSCOMPILING)
3235
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
3336
endforeach(py_qa_test_file)
3437
endif(ENABLE_TESTING)

‎gr-blocks/python/blocks/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ if(ENABLE_TESTING)
5353

5454
foreach(py_qa_test_file ${py_qa_test_files})
5555
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
56+
if (CMAKE_CROSSCOMPILING)
57+
get_filename_component(py_qa_test_file ${py_qa_test_file} NAME)
58+
endif(CMAKE_CROSSCOMPILING)
5659
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
5760
endforeach(py_qa_test_file)
5861

‎gr-channels/python/channels/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ if(ENABLE_TESTING)
3838
file (GLOB py_qa_test_files "qa_*.py")
3939
foreach(py_qa_test_file ${py_qa_test_files})
4040
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
41+
if (CMAKE_CROSSCOMPILING)
42+
get_filename_component(py_qa_test_file ${py_qa_test_file} NAME)
43+
endif(CMAKE_CROSSCOMPILING)
4144
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
4245
endforeach(py_qa_test_file)
4346
endif(ENABLE_TESTING)

‎gr-digital/python/digital/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ if(ENABLE_TESTING)
5858
file(GLOB py_qa_test_files "qa_*.py")
5959
foreach(py_qa_test_file ${py_qa_test_files})
6060
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
61+
if (CMAKE_CROSSCOMPILING)
62+
get_filename_component(py_qa_test_file ${py_qa_test_file} NAME)
63+
endif(CMAKE_CROSSCOMPILING)
6164
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
6265
endforeach(py_qa_test_file)
6366
endif(ENABLE_TESTING)

‎gr-dtv/python/dtv/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ if(ENABLE_TESTING)
3232
file(GLOB py_qa_test_files "qa_*.py")
3333
foreach(py_qa_test_file ${py_qa_test_files})
3434
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
35+
if (CMAKE_CROSSCOMPILING)
36+
get_filename_component(py_qa_test_file ${py_qa_test_file} NAME)
37+
endif(CMAKE_CROSSCOMPILING)
3538
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
3639
endforeach(py_qa_test_file)
3740
endif(ENABLE_TESTING)

‎gr-fec/python/fec/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ endif(NOT GSL_FOUND)
5454

5555
foreach(py_qa_test_file ${py_qa_test_files})
5656
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
57+
if (CMAKE_CROSSCOMPILING)
58+
get_filename_component(py_qa_test_file ${py_qa_test_file} NAME)
59+
endif(CMAKE_CROSSCOMPILING)
5760
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
5861
endforeach(py_qa_test_file)
5962

‎gr-fft/python/fft/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ if(ENABLE_TESTING)
3030
file(GLOB py_qa_test_files "qa_*.py")
3131
foreach(py_qa_test_file ${py_qa_test_files})
3232
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
33+
if (CMAKE_CROSSCOMPILING)
34+
get_filename_component(py_qa_test_file ${py_qa_test_file} NAME)
35+
endif(CMAKE_CROSSCOMPILING)
3336
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
3437
endforeach(py_qa_test_file)
3538
endif(ENABLE_TESTING)

‎gr-filter/python/filter/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ if(ENABLE_TESTING)
3434
file(GLOB py_qa_test_files "qa_*.py")
3535
foreach(py_qa_test_file ${py_qa_test_files})
3636
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
37+
if (CMAKE_CROSSCOMPILING)
38+
get_filename_component(py_qa_test_file ${py_qa_test_file} NAME)
39+
endif(CMAKE_CROSSCOMPILING)
3740
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
3841
endforeach(py_qa_test_file)
3942
endif(ENABLE_TESTING)

‎gr-qtgui/python/qtgui/CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ if(ENABLE_TESTING)
5757
file(GLOB py_qa_test_files "qa_*.py")
5858
foreach(py_qa_test_file ${py_qa_test_files})
5959
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
60-
GR_ADD_TEST(${py_qa_test_name} ${QA_DISPLAY_SERVER} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
60+
if (CMAKE_CROSSCOMPILING)
61+
get_filename_component(py_qa_test_file ${py_qa_test_file} NAME)
62+
endif(CMAKE_CROSSCOMPILING)
63+
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
6164
endforeach(py_qa_test_file)
6265
endif(ENABLE_TESTING)
6366

‎gr-trellis/python/trellis/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ if(ENABLE_TESTING)
3232
file(GLOB py_qa_test_files "qa_*.py")
3333
foreach(py_qa_test_file ${py_qa_test_files})
3434
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
35+
if (CMAKE_CROSSCOMPILING)
36+
get_filename_component(py_qa_test_file ${py_qa_test_file} NAME)
37+
endif(CMAKE_CROSSCOMPILING)
3538
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
3639
endforeach(py_qa_test_file)
3740
endif(ENABLE_TESTING)

‎gr-uhd/python/uhd/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ include(GrTest)
3232
file(GLOB py_qa_test_files "qa_*.py")
3333
foreach(py_qa_test_file ${py_qa_test_files})
3434
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
35+
if (CMAKE_CROSSCOMPILING)
36+
get_filename_component(py_qa_test_file ${py_qa_test_file} NAME)
37+
endif(CMAKE_CROSSCOMPILING)
3538
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
3639
endforeach(py_qa_test_file)
3740
endif(ENABLE_TESTING)

‎gr-utils/modtool/tests/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ if(ENABLE_TESTING)
2424

2525
foreach(py_qa_test_file ${py_qa_test_files})
2626
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
27+
if (CMAKE_CROSSCOMPILING)
28+
get_filename_component(py_qa_test_file ${py_qa_test_file} NAME)
29+
endif(CMAKE_CROSSCOMPILING)
2730
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
2831
endforeach(py_qa_test_file)
2932

‎gr-video-sdl/python/video_sdl/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ if(ENABLE_TESTING)
3131
file(GLOB py_qa_test_files "qa_*.py")
3232
foreach(py_qa_test_file ${py_qa_test_files})
3333
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
34+
if (CMAKE_CROSSCOMPILING)
35+
get_filename_component(py_qa_test_file ${py_qa_test_file} NAME)
36+
endif(CMAKE_CROSSCOMPILING)
3437
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
3538
endforeach(py_qa_test_file)
3639
endif(ENABLE_TESTING)

‎gr-vocoder/python/vocoder/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ if(ENABLE_TESTING)
4949
endif()
5050
foreach(py_qa_test_file ${py_qa_test_files})
5151
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
52+
if (CMAKE_CROSSCOMPILING)
53+
get_filename_component(py_qa_test_file ${py_qa_test_file} NAME)
54+
endif(CMAKE_CROSSCOMPILING)
5255
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${CMAKE_CURRENT_SOURCE_DIR}/${py_qa_test_file})
5356
endforeach(py_qa_test_file)
5457
endif(ENABLE_TESTING)

‎gr-wavelet/python/wavelet/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ if(ENABLE_TESTING)
2929
file(GLOB py_qa_test_files "qa_*.py")
3030
foreach(py_qa_test_file ${py_qa_test_files})
3131
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
32+
if (CMAKE_CROSSCOMPILING)
33+
get_filename_component(py_qa_test_file ${py_qa_test_file} NAME)
34+
endif(CMAKE_CROSSCOMPILING)
3235
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
3336
endforeach(py_qa_test_file)
3437
endif(ENABLE_TESTING)

‎gr-zeromq/python/zeromq/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ if(ENABLE_TESTING)
3939
file(GLOB py_qa_test_files "qa_*.py")
4040
foreach(py_qa_test_file ${py_qa_test_files})
4141
get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
42+
if (CMAKE_CROSSCOMPILING)
43+
get_filename_component(py_qa_test_file ${py_qa_test_file} NAME)
44+
endif(CMAKE_CROSSCOMPILING)
4245
GR_ADD_TEST(${py_qa_test_name} ${QA_PYTHON_EXECUTABLE} -B ${py_qa_test_file})
4346
endforeach(py_qa_test_file)
4447
endif(ENABLE_TESTING)

0 commit comments

Comments
 (0)
Please sign in to comment.