s4-selftest/drs: Confirm GetNCChanges full replication works with a DummyDN and real...
[Samba.git] / testsuite / unittests / test_lib_util_modules.c
blob647fc1fb82d1ecb9cbf95a04bf21ed5adc9c4242
1 #include <stdarg.h>
2 #include <stddef.h>
3 #include <setjmp.h>
4 #include <cmocka.h>
6 #include <errno.h>
7 #include <stdio.h>
8 #include <stdint.h>
9 #include <stdbool.h>
10 #include <unistd.h>
11 #include <sys/stat.h>
12 #include <talloc.h>
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");
22 return 0;
25 static void test_samba_module_probe_dummy(void **state)
27 const char *module_env;
28 NTSTATUS status;
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;
42 NTSTATUS status;
44 snprintf(dummy_module_path,
45 sizeof(dummy_module_path),
46 "%s/bin/modules/rpc/test_dummy_module.so",
47 SRCDIR);
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);
56 int main(void) {
57 const struct CMUnitTest tests[] = {
58 cmocka_unit_test_teardown(test_samba_module_probe_dummy,
59 teardown),
60 cmocka_unit_test_teardown(test_samba_module_probe_slash,
61 teardown),
64 cmocka_set_message_output(CM_OUTPUT_SUBUNIT);
65 return cmocka_run_group_tests(tests, NULL, NULL);