This source file includes following definitions.
- function_asserts
- 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 pcmk__assert_asserts(
23 {
24 pcmk__mock_strdup = true;
25 expect_string(__wrap_strdup, s, "/full/path");
26 pcmk__full_path("/full/path", "/dir");
27 pcmk__mock_strdup = false;
28 }
29 );
30 }
31
32 static void
33 full_path(void **state)
34 {
35 char *path = NULL;
36
37 path = pcmk__full_path("file", "/dir");
38 assert_int_equal(strcmp(path, "/dir/file"), 0);
39 free(path);
40
41 path = pcmk__full_path("/full/path", "/dir");
42 assert_int_equal(strcmp(path, "/full/path"), 0);
43 free(path);
44
45 path = pcmk__full_path("../relative/path", "/dir");
46 assert_int_equal(strcmp(path, "/dir/../relative/path"), 0);
47 free(path);
48 }
49
50 PCMK__UNIT_TEST(NULL, NULL,
51 cmocka_unit_test(function_asserts),
52 cmocka_unit_test(full_path))