Skip to content

Commit c53dc76

Browse files
committed
add "make test" for cmake
1 parent 437e0d8 commit c53dc76

File tree

3 files changed

+58
-5
lines changed

3 files changed

+58
-5
lines changed

.github/workflows/cmake-multi-platform.yml

+10-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ jobs:
4141
- name: Test
4242
working-directory: ${{ github.workspace }}
4343
run: |
44-
echo "TODO"
44+
cd build
45+
make test
4546
4647
test-on-ubuntu-2004:
4748
name: test-on-ubuntu-20.04
@@ -72,7 +73,8 @@ jobs:
7273
- name: Test
7374
working-directory: ${{ github.workspace }}
7475
run: |
75-
echo "TODO"
76+
cd build
77+
make test
7678
7779
test-on-ubuntu-1804:
7880
name: test-on-ubuntu-18.04
@@ -103,7 +105,8 @@ jobs:
103105
- name: Test
104106
working-directory: ${{ github.workspace }}
105107
run: |
106-
echo "TODO"
108+
cd build
109+
make test
107110
108111
test-on-centos-792009:
109112
name: test-on-centos-7.9.2009
@@ -133,7 +136,8 @@ jobs:
133136
- name: Test
134137
working-directory: ${{ github.workspace }}
135138
run: |
136-
echo "TODO"
139+
cd build
140+
make test
137141
138142
test-on-centos-731611:
139143
name: test-on-centos-7.3.1611
@@ -163,4 +167,5 @@ jobs:
163167
- name: Test
164168
working-directory: ${{ github.workspace }}
165169
run: |
166-
echo "TODO"
170+
cd build
171+
make test

CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,7 @@ INSTALL(TARGETS qlibc LIBRARY DESTINATION lib)
101101
INSTALL(TARGETS qlibcext LIBRARY DESTINATION lib)
102102
INSTALL(TARGETS qlibc-static ARCHIVE DESTINATION lib)
103103
INSTALL(TARGETS qlibcext-static ARCHIVE DESTINATION lib)
104+
105+
# add test
106+
ENABLE_TESTING()
107+
ADD_SUBDIRECTORY(${qlibc_SOURCE_DIR}/tests)

tests/CMakeLists.txt

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/qlibc)
2+
SET(test_list
3+
test_qstring
4+
test_qhashtbl
5+
test_qhasharr
6+
test_qhasharr_darkdh
7+
test_qtreetbl
8+
test_qlist
9+
test_qvector
10+
test_qqueue
11+
test_qstack
12+
test_qhash
13+
)
14+
15+
SET(test_file_list
16+
test_qhash_data_1.bin
17+
test_qhash_data_2.bin
18+
test_qhash_data_3.bin
19+
test_qhash_data_4.bin
20+
)
21+
22+
# build test
23+
FOREACH(element IN LISTS test_list)
24+
MESSAGE(STATUS "set build test: ${element}")
25+
ADD_EXECUTABLE(${element} ${element}.c)
26+
TARGET_LINK_LIBRARIES(${element} qlibc qlibcext)
27+
ENDFOREACH()
28+
29+
# copy test file
30+
FOREACH(element IN LISTS test_file_list)
31+
ADD_CUSTOM_TARGET(cpoy_${element} ALL
32+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
33+
${CMAKE_CURRENT_SOURCE_DIR}/${element}
34+
${CMAKE_CURRENT_BINARY_DIR}/${element}
35+
COMMENT "Copying ${element} to ${CMAKE_CURRENT_BINARY_DIR}"
36+
VERBATIM
37+
)
38+
ENDFOREACH()
39+
40+
# run test
41+
FOREACH(element IN LISTS test_list)
42+
MESSAGE(STATUS "set run test: ${element}")
43+
ADD_TEST(NAME ${element} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/launcher.sh ${element})
44+
ENDFOREACH()

0 commit comments

Comments
 (0)