WHATSNEW: Add release notes for Samba 4.7.0rc3.
[Samba.git] / testsuite / unittests / test_sambafs_srv_pipe.c
blob553f5309928502b0f34d9ad2ab5fb72865bccec6
1 #include <errno.h>
2 #include <stdarg.h>
3 #include <stddef.h>
4 #include <setjmp.h>
5 #include <stdint.h>
6 #include <unistd.h>
7 #include <sys/stat.h>
8 #include <cmocka.h>
10 #include "include/config.h"
11 #include "librpc/gen_ndr/ndr_samr.h"
12 #include "source3/rpc_server/srv_pipe.h"
13 #include "librpc/gen_ndr/srv_samr.h"
15 static int setup_samr(void **state)
17 rpc_samr_init(NULL);
19 return 0;
22 static int teardown(void **state)
24 unsetenv("UNITTEST_DUMMY_MODULE_LOADED");
26 return 0;
29 static int teardown_samr(void **state)
31 rpc_samr_shutdown();
33 teardown(state);
35 return 0;
38 static void test_is_known_pipename(void **state)
40 struct ndr_syntax_id syntax_id = ndr_table_samr.syntax_id;
41 bool is_pipename_ok;
43 is_pipename_ok = is_known_pipename("samr", &syntax_id);
44 assert_true(is_pipename_ok);
47 static void test_is_known_pipename_slash(void **state)
49 struct ndr_syntax_id syntax_id = ndr_table_samr.syntax_id;
50 bool is_pipename_ok;
51 char dummy_module_path[4096] = {0};
52 const char *module_env;
54 snprintf(dummy_module_path,
55 sizeof(dummy_module_path),
56 "%s/bin/modules/rpc/test_dummy_module.so",
57 SRCDIR);
59 is_pipename_ok = is_known_pipename(dummy_module_path, &syntax_id);
60 assert_false(is_pipename_ok);
62 module_env = getenv("UNITTEST_DUMMY_MODULE_LOADED");
63 assert_null(module_env);
66 int main(void) {
67 const struct CMUnitTest tests[] = {
68 cmocka_unit_test_setup_teardown(test_is_known_pipename,
69 setup_samr,
70 teardown_samr),
71 cmocka_unit_test_teardown(test_is_known_pipename_slash,
72 teardown),
75 cmocka_set_message_output(CM_OUTPUT_SUBUNIT);
76 return cmocka_run_group_tests(tests, NULL, NULL);