2 #include "../../src/net.h"
3 #include "../../src/script.h"
5 static environment_t *device_env = NULL;
7 // silence -Wmissing-prototypes
8 void __wrap_environment_init(environment_t *env);
9 void __wrap_environment_exit(environment_t *env);
10 bool __wrap_execute_script(const char *name, environment_t *env);
12 void __wrap_environment_init(environment_t *env) {
14 assert_null(device_env);
18 void __wrap_environment_exit(environment_t *env) {
19 assert_ptr_equal(device_env, env);
23 bool __wrap_execute_script(const char *name, environment_t *env) {
26 check_expected_ptr(name);
28 // Used instead of mock_type(bool) to silence clang warning
29 return mock() ? true : false;
32 static void run_device_enable_disable(void (*device_func)(void),
34 expect_string(__wrap_execute_script, name, script);
35 will_return(__wrap_execute_script, true);
40 static void test_device_enable_calls_tinc_up(void **state) {
43 run_device_enable_disable(&device_enable, "tinc-up");
46 static void test_device_disable_calls_tinc_down(void **state) {
49 run_device_enable_disable(&device_disable, "tinc-down");
53 const struct CMUnitTest tests[] = {
54 cmocka_unit_test(test_device_enable_calls_tinc_up),
55 cmocka_unit_test(test_device_disable_calls_tinc_down),
57 return cmocka_run_group_tests(tests, NULL, NULL);