This source file includes following definitions.
- function_asserts
- function_exits
- full_path
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <crm/common/unittest_internal.h>
13
14 #include "mock_private.h"
15
16 static void
17 function_asserts(void **state)
18 {
19 pcmk__assert_asserts(pcmk__full_path(NULL, "/dir"));
20 pcmk__assert_asserts(pcmk__full_path("file", NULL));
21 }
22
23 static void
24 function_exits(void **state)
25 {
26 pcmk__assert_exits(
27 CRM_EX_OSERR,
28 {
29 pcmk__mock_strdup = true;
30 expect_string(__wrap_strdup, s, "/full/path");
31 pcmk__full_path("/full/path", "/dir");
32 pcmk__mock_strdup = false;
33 }
34 );
35 }
36
37 static void
38 full_path(void **state)
39 {
40 char *path = NULL;
41
42 path = pcmk__full_path("file", "/dir");
43 assert_int_equal(strcmp(path, "/dir/file"), 0);
44 free(path);
45
46 path = pcmk__full_path("/full/path", "/dir");
47 assert_int_equal(strcmp(path, "/full/path"), 0);
48 free(path);
49
50 path = pcmk__full_path("../relative/path", "/dir");
51 assert_int_equal(strcmp(path, "/dir/../relative/path"), 0);
52 free(path);
53 }
54
55 PCMK__UNIT_TEST(NULL, NULL,
56 cmocka_unit_test(function_asserts),
57 cmocka_unit_test(function_exits),
58 cmocka_unit_test(full_path))