unittests: Add missing stdint.h include
[sfrench/samba-autobuild/.git] / testsuite / unittests / test_sambafs_srv_pipe.c
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>
9
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"
14
15 static int setup_samr(void **state)
16 {
17         rpc_samr_init(NULL);
18
19         return 0;
20 }
21
22 static int teardown(void **state)
23 {
24         unsetenv("UNITTEST_DUMMY_MODULE_LOADED");
25
26         return 0;
27 }
28
29 static int teardown_samr(void **state)
30 {
31         rpc_samr_shutdown();
32
33         teardown(state);
34
35         return 0;
36 }
37
38 static void test_is_known_pipename(void **state)
39 {
40         struct ndr_syntax_id syntax_id = ndr_table_samr.syntax_id;
41         bool is_pipename_ok;
42
43         is_pipename_ok = is_known_pipename("samr", &syntax_id);
44         assert_true(is_pipename_ok);
45 }
46
47 static void test_is_known_pipename_slash(void **state)
48 {
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;
53
54         snprintf(dummy_module_path,
55                  sizeof(dummy_module_path),
56                  "%s/bin/modules/rpc/test_dummy_module.so",
57                  SRCDIR);
58
59         is_pipename_ok = is_known_pipename(dummy_module_path, &syntax_id);
60         assert_false(is_pipename_ok);
61
62         module_env = getenv("UNITTEST_DUMMY_MODULE_LOADED");
63         assert_null(module_env);
64 }
65
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),
73         };
74
75         cmocka_set_message_output(CM_OUTPUT_SUBUNIT);
76         return cmocka_run_group_tests(tests, NULL, NULL);
77 }