1 dep_cmocka = dependency('cmocka', required: opt_tests)
2 if not dep_cmocka.found()
6 can_wrap = cc.has_link_argument('-Wl,--wrap=func')
8 message('linker has no support for function wrapping, mocked tests will not run')
11 link_tinc = { 'lib': lib_tinc, 'dep': deps_tinc }
12 link_tincd = { 'lib': lib_tincd, 'dep': deps_tincd }
14 # Test definition format:
16 # 'free-form test name': {
17 # 'code': 'test1.c', // or ['test1.c', 'test1_util.c']
18 # 'mock': ['foo', 'bar'], // list of functions to mock (default: empty)
19 # 'link': link_tinc, // which binary to link with (default: tincd)
20 # 'fail': true, // whether the test should fail (default: false)
25 'code': 'test_random.c',
28 'code': 'test_random_noinit.c',
32 'code': 'test_netutl.c',
36 'mock': ['execute_script', 'environment_init', 'environment_exit'],
39 'code': 'test_subnet.c',
42 'code': 'test_protocol.c',
45 'code': 'test_utils.c',
48 'code': 'test_splay_tree.c',
53 env = ['CMOCKA_MESSAGE_OUTPUT=TAP']
55 foreach test, data : tests
59 mocks = data.get('mock', [])
61 args += ',--wrap='.join(['-Wl'] + mocks)
65 libs = data.get('link', link_tincd)
67 exe = executable(test,
68 sources: data['code'],
70 dependencies: [libs['dep'], dep_cmocka],
71 link_with: libs['lib'],
72 implicit_include_directories: false,
73 include_directories: inc_conf,
74 build_by_default: false)
76 must_fail = data.get('fail', false)
82 protocol: must_fail ? 'exitcode' : 'tap',
84 should_fail: must_fail)