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(void **state
)
29 status
= smb_probe_module("auth", "skel");
30 assert_true(NT_STATUS_IS_OK(status
));
33 static void test_samba_module_probe_dummy(void **state
)
35 const char *module_env
;
38 status
= smb_probe_module("rpc", "test_dummy_module");
39 assert_true(NT_STATUS_IS_OK(status
));
41 module_env
= getenv("UNITTEST_DUMMY_MODULE_LOADED");
42 assert_non_null(module_env
);
43 assert_string_equal(module_env
, "TRUE");
46 static void test_samba_module_probe_slash(void **state
)
48 char dummy_module_path
[4096] = {0};
49 const char *module_env
;
52 snprintf(dummy_module_path
,
53 sizeof(dummy_module_path
),
54 "%s/bin/modules/rpc/test_dummy_module.so",
57 status
= smb_probe_module("rpc", dummy_module_path
);
58 assert_true(NT_STATUS_IS_ERR(status
));
60 module_env
= getenv("UNITTEST_DUMMY_MODULE_LOADED");
61 assert_null(module_env
);
65 const struct CMUnitTest tests
[] = {
66 cmocka_unit_test_teardown(test_samba_module_probe
,
68 cmocka_unit_test_teardown(test_samba_module_probe_dummy
,
70 cmocka_unit_test_teardown(test_samba_module_probe_slash
,
74 cmocka_set_message_output(CM_OUTPUT_SUBUNIT
);
75 return cmocka_run_group_tests(tests
, NULL
, NULL
);