14 #include "include/config.h"
15 #include "libcli/util/ntstatus.h"
16 #include "lib/util/samba_modules.h"
18 static int teardown(void **state
)
20 unsetenv("UNITTEST_DUMMY_MODULE_LOADED");
25 static void test_samba_module_probe_dummy(void **state
)
27 const char *module_env
;
30 status
= smb_probe_module("rpc", "test_dummy_module");
31 assert_true(NT_STATUS_IS_OK(status
));
33 module_env
= getenv("UNITTEST_DUMMY_MODULE_LOADED");
34 assert_non_null(module_env
);
35 assert_string_equal(module_env
, "TRUE");
38 static void test_samba_module_probe_slash(void **state
)
40 char dummy_module_path
[4096] = {0};
41 const char *module_env
;
44 snprintf(dummy_module_path
,
45 sizeof(dummy_module_path
),
46 "%s/bin/modules/rpc/test_dummy_module.so",
49 status
= smb_probe_module("rpc", dummy_module_path
);
50 assert_true(NT_STATUS_IS_ERR(status
));
52 module_env
= getenv("UNITTEST_DUMMY_MODULE_LOADED");
53 assert_null(module_env
);
57 const struct CMUnitTest tests
[] = {
58 cmocka_unit_test_teardown(test_samba_module_probe_dummy
,
60 cmocka_unit_test_teardown(test_samba_module_probe_slash
,
64 cmocka_set_message_output(CM_OUTPUT_SUBUNIT
);
65 return cmocka_run_group_tests(tests
, NULL
, NULL
);