root/lib/common/tests/io/pcmk__full_path_test.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. full_path
  2. main

   1 /*
   2  * Copyright 2020-2021 the Pacemaker project contributors
   3  *
   4  * The version control history for this file may have further details.
   5  *
   6  * This source code is licensed under the GNU Lesser General Public License
   7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
   8  */
   9 
  10 #include <crm_internal.h>
  11 
  12 #include <stdarg.h>
  13 #include <stddef.h>
  14 #include <stdint.h>
  15 #include <string.h>
  16 #include <stdlib.h>
  17 #include <setjmp.h>
  18 #include <cmocka.h>
  19 
  20 static void
  21 full_path(void **state)
     /* [previous][next][first][last][top][bottom][index][help] */
  22 {
  23     char *path = NULL;
  24 
  25     path = pcmk__full_path("file", "/dir");
  26     assert_int_equal(strcmp(path, "/dir/file"), 0);
  27     free(path);
  28 
  29     path = pcmk__full_path("/full/path", "/dir");
  30     assert_int_equal(strcmp(path, "/full/path"), 0);
  31     free(path);
  32 
  33     path = pcmk__full_path("../relative/path", "/dir");
  34     assert_int_equal(strcmp(path, "/dir/../relative/path"), 0);
  35     free(path);
  36 }
  37 
  38 int
  39 main(int argc, char **argv)
     /* [previous][next][first][last][top][bottom][index][help] */
  40 {
  41     const struct CMUnitTest tests[] = {
  42         cmocka_unit_test(full_path),
  43     };
  44 
  45     cmocka_set_message_output(CM_OUTPUT_TAP);
  46     return cmocka_run_group_tests(tests, NULL, NULL);
  47 }

/* [previous][next][first][last][top][bottom][index][help] */