LCOV - code coverage report
Current view: top level - mockatests/vhd - test-canonpath.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 16 16
Test Date: 2026-06-26 00:00:00 Functions: 100.0 % 1 1
Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /*
       2                 :             :  * Copyright (c) 2020, Citrix Systems, Inc.
       3                 :             :  *
       4                 :             :  * All rights reserved.
       5                 :             :  *
       6                 :             :  * Redistribution and use in source and binary forms, with or without
       7                 :             :  * modification, are permitted provided that the following conditions are met:
       8                 :             :  *
       9                 :             :  *  1. Redistributions of source code must retain the above copyright
      10                 :             :  *     notice, this list of conditions and the following disclaimer.
      11                 :             :  *  2. Redistributions in binary form must reproduce the above copyright
      12                 :             :  *     notice, this list of conditions and the following disclaimer in the
      13                 :             :  *     documentation and/or other materials provided with the distribution.
      14                 :             :  *  3. Neither the name of the copyright holder nor the names of its
      15                 :             :  *     contributors may be used to endorse or promote products derived from
      16                 :             :  *     this software without specific prior written permission.
      17                 :             :  *
      18                 :             :  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
      19                 :             :  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
      20                 :             :  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
      21                 :             :  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
      22                 :             :  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
      23                 :             :  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
      24                 :             :  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
      25                 :             :  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
      26                 :             :  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
      27                 :             :  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
      28                 :             :  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
      29                 :             :  */
      30                 :             : #include <stddef.h>
      31                 :             : #include <stdarg.h>
      32                 :             : #include <setjmp.h>
      33                 :             : #include <cmocka.h>
      34                 :             : #include <errno.h>
      35                 :             : #include <wrappers.h>
      36                 :             : #include <limits.h>
      37                 :             : 
      38                 :             : #include "test-suites.h"
      39                 :             : #include "libvhd.h"
      40                 :             : #include "vhd-wrappers.h"
      41                 :             : 
      42                 :             : char *
      43                 :             : __real_canonpath(const char *path, char *resolved_path);
      44                 :             : 
      45                 :           1 : void test_vhd_util_canon_path_relative_success(void **state)
      46                 :             : {
      47                 :           1 :         char *ppath, __ppath[PATH_MAX];
      48                 :           1 :         char *pname = "6f95a71c-4961-4af0-aec4-58bc3bbef254.vhd";
      49                 :           1 :         char *test_dir = "/run/sr-mount/test";
      50                 :           1 :         char *test_path = "/run/sr-mount/test/6f95a71c-4961-4af0-aec4-58bc3bbef254.vhd";
      51                 :             : 
      52                 :           1 :         char *dir_name_return = test_malloc(strlen(test_dir) + 1);
      53                 :           1 :         strncpy(dir_name_return, test_dir, strlen(test_dir) + 1);
      54                 :             : 
      55                 :           1 :         char *realpath_return = test_malloc(strlen(test_path) + 1);
      56                 :           1 :         strncpy(realpath_return, test_path, strlen(test_path) + 1);
      57                 :             : 
      58                 :           1 :         will_return(__wrap_get_current_dir_name, dir_name_return);
      59                 :           1 :         will_return(__wrap_realpath, realpath_return);
      60                 :             : 
      61                 :             :         /* Have to call __real_canonpath here to bypass the wrapping
      62                 :             :            done for testing the snapshot commands.
      63                 :             :          */
      64                 :           1 :         ppath = __real_canonpath(pname, __ppath);
      65                 :             : 
      66                 :           1 :         fprintf(stderr, "ppath %s\n", ppath);
      67                 :             : 
      68                 :           1 :         assert_non_null(ppath);
      69                 :           1 :         test_free(ppath);
      70                 :           1 : }
        

Generated by: LCOV version 2.0-1