This source file includes following definitions.
- calloc_fails
- strdup_fails
- success
1
2
3
4
5
6
7
8
9
10 #include <crm_internal.h>
11
12 #include <crm/common/unittest_internal.h>
13 #include <crm/common/cmdline_internal.h>
14
15 #include "mock_private.h"
16
17 #include <glib.h>
18
19 static void
20 calloc_fails(void **state)
21 {
22 pcmk__assert_exits(CRM_EX_OSERR,
23 {
24 pcmk__mock_calloc = true;
25 expect_value(__wrap_calloc, nmemb, 1);
26 expect_value(__wrap_calloc, size, sizeof(pcmk__common_args_t));
27 pcmk__new_common_args("boring summary");
28 pcmk__mock_calloc = false;
29 }
30 );
31 }
32
33 static void
34 strdup_fails(void **state)
35 {
36 pcmk__assert_exits(CRM_EX_OSERR,
37 {
38 pcmk__mock_strdup = true;
39 expect_string(__wrap_strdup, s, "boring summary");
40 pcmk__new_common_args("boring summary");
41 pcmk__mock_strdup = false;
42 }
43 );
44 }
45
46 static void
47 success(void **state)
48 {
49 pcmk__common_args_t *args = pcmk__new_common_args("boring summary");
50 assert_string_equal(args->summary, "boring summary");
51 assert_null(args->output_as_descr);
52 assert_false(args->version);
53 assert_false(args->quiet);
54 assert_int_equal(args->verbosity, 0);
55 assert_null(args->output_ty);
56 assert_null(args->output_dest);
57 }
58
59 PCMK__UNIT_TEST(NULL, NULL,
60 cmocka_unit_test(calloc_fails),
61 cmocka_unit_test(strdup_fails),
62 cmocka_unit_test(success))