LCOV - code coverage report
Current view: top level - ccache/test - util.c (source / functions) Hit Total Coverage
Test: ccache.lcov.info Lines: 10 11 90.9 %
Date: 2015-06-29 Functions: 3 3 100.0 %
Branches: 5 10 50.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (C) 2010 Joel Rosdahl
       3                 :            :  *
       4                 :            :  * This program is free software; you can redistribute it and/or modify it
       5                 :            :  * under the terms of the GNU General Public License as published by the Free
       6                 :            :  * Software Foundation; either version 3 of the License, or (at your option)
       7                 :            :  * any later version.
       8                 :            :  *
       9                 :            :  * This program is distributed in the hope that it will be useful, but WITHOUT
      10                 :            :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      11                 :            :  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
      12                 :            :  * more details.
      13                 :            :  *
      14                 :            :  * You should have received a copy of the GNU General Public License along with
      15                 :            :  * this program; if not, write to the Free Software Foundation, Inc., 51
      16                 :            :  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
      17                 :            :  */
      18                 :            : 
      19                 :            : #include "system.h"
      20                 :            : #include "test/util.h"
      21                 :            : 
      22                 :            : #ifdef _WIN32
      23                 :            : #    define lstat(a,b) stat(a,b)
      24                 :            : #endif
      25                 :            : 
      26                 :            : bool
      27                 :          2 : path_exists(const char *path)
      28                 :            : {
      29                 :            :         struct stat st;
      30                 :          2 :         return lstat(path, &st) == 0;
      31                 :            : }
      32                 :            : 
      33                 :            : bool
      34                 :          1 : is_symlink(const char *path)
      35                 :            : {
      36                 :            : #ifdef _WIN32
      37                 :            :         (void) path;
      38                 :            :         return 0;
      39                 :            : #else
      40                 :            :         struct stat st;
      41 [ +  - ][ +  - ]:          1 :         return lstat(path, &st) == 0 && S_ISLNK(st.st_mode);
      42                 :            : #endif
      43                 :            : }
      44                 :            : 
      45                 :            : void
      46                 :         38 : create_file(const char *path, const char *content)
      47                 :            : {
      48                 :         38 :         FILE *f = fopen(path, "w");
      49 [ +  - ][ -  + ]:         38 :         if (!f || fputs(content, f) < 0) {
      50                 :          0 :                 fprintf(stderr, "create_file: %s: %s\n", path, strerror(errno));
      51                 :            :         }
      52         [ +  - ]:         38 :         if (f) {
      53                 :         38 :                 fclose(f);
      54                 :            :         }
      55                 :         38 : }

Generated by: LCOV version 1.9