Skip to content

Commit

Permalink
Separate run_auto_tests into a library
Browse files Browse the repository at this point in the history
  • Loading branch information
zugz authored and JFreegman committed Jan 25, 2022
1 parent 5a88159 commit 1157e4e
Show file tree
Hide file tree
Showing 23 changed files with 814 additions and 726 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
- run: *apt_install
- checkout
- run: infer --no-progress-bar -- cc
auto_tests/auto_test_support.c
auto_tests/lossless_packet_test.c
testing/misc_tools.c
toxav/*.c
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ jobs:
-o send_message_test
-Wall -Werror
-bench -g
auto_tests/auto_test_support.c
auto_tests/send_message_test.c
testing/misc_tools.c
toxav/*.c
Expand All @@ -117,6 +118,7 @@ jobs:
- name: Build amalgamation file with TCC
run:
other/make_single_file
auto_tests/auto_test_support.c
auto_tests/send_message_test.c
testing/misc_tools.c |
tcc -
Expand All @@ -141,6 +143,7 @@ jobs:
-Wno-unknown-pragmas
-Wno-unused-variable
-fstruct-passing -fno-unprototyped -g
auto_tests/auto_test_support.c
auto_tests/send_message_test.c
testing/misc_tools.c
toxav/*.c
Expand Down
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -391,11 +391,18 @@ endif()

option(AUTOTEST "Enable autotests (mainly for CI)" OFF)

if(AUTOTEST)
add_library(auto_test_support
auto_tests/auto_test_support.c
auto_tests/auto_test_support.h)
target_link_modules(auto_test_support toxcore misc_tools)
endif()

function(auto_test target)
if(AUTOTEST AND NOT (MSVC AND ARGV1 STREQUAL "MSVC_DONT_BUILD"))
add_executable(auto_${target}_test ${CPUFEATURES}
auto_tests/${target}_test.c)
target_link_modules(auto_${target}_test toxcore misc_tools)
target_link_modules(auto_${target}_test toxcore misc_tools auto_test_support)
if(NOT ARGV1 STREQUAL "DONT_RUN")
add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} auto_${target}_test)
set_tests_properties(${target} PROPERTIES TIMEOUT "${TEST_TIMEOUT_SECONDS}")
Expand Down
14 changes: 11 additions & 3 deletions auto_tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@ cc_library(
)

cc_library(
name = "run_auto_test",
name = "auto_test_support",
testonly = True,
hdrs = ["run_auto_test.h"],
srcs = ["auto_test_support.c"],
hdrs = ["auto_test_support.h"],
deps = [
":check_compat",
"//c-toxcore/testing:misc_tools",
"//c-toxcore/toxcore:Messenger",
"//c-toxcore/toxcore:mono_time",
"//c-toxcore/toxcore",
],
)

flaky_tests = {
Expand All @@ -33,7 +41,7 @@ flaky_tests = {
),
deps = [
":check_compat",
":run_auto_test",
":auto_test_support",
"//c-toxcore/testing:misc_tools",
"//c-toxcore/toxav",
"//c-toxcore/toxcore",
Expand Down
7 changes: 6 additions & 1 deletion auto_tests/Makefile.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
if BUILD_TESTS

noinst_LTLIBRARIES += libauto_test_support.la
libauto_test_support_la_SOURCES = ../auto_tests/auto_test_support.c ../auto_tests/auto_test_support.h
libauto_test_support_la_LIBADD = libmisc_tools.la libtoxcore.la

TESTS = \
conference_double_invite_test \
conference_invite_merge_test \
Expand Down Expand Up @@ -51,6 +55,7 @@ AUTOTEST_LDADD = \
$(LIBSODIUM_LDFLAGS) \
$(NACL_LDFLAGS) \
libmisc_tools.la \
libauto_test_support.la \
libtoxcore.la \
libtoxencryptsave.la \
$(LIBSODIUM_LIBS) \
Expand Down Expand Up @@ -239,4 +244,4 @@ endif
EXTRA_DIST += \
$(top_srcdir)/auto_tests/data/save.tox \
$(top_srcdir)/auto_tests/check_compat.h \
$(top_srcdir)/auto_tests/run_auto_test.h
$(top_srcdir)/auto_tests/auto_test_support.h
Loading

0 comments on commit 1157e4e

Please sign in to comment.