LCOV - code coverage report
Current view: top level - tests/src - test0029.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 58 58
Test Date: 2026-03-31 13:51:38 Functions: 100.0 % 3 3
Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : #include "sute.h"
       2                 :             : 
       3                 :             : /**
       4                 :             :  * "inaccessible" message of file_show() function
       5                 :             :  */
       6                 :           2 : static Return test0029_1(void)
       7                 :             : {
       8                 :           2 :         INITTEST;
       9                 :             : 
      10                 :             :         // Create memory for the result
      11                 :           2 :         create(char,result);
      12                 :           2 :         create(char,pattern);
      13                 :           2 :         const char *command = NULL;
      14                 :             : 
      15                 :             :         // Preparation for tests
      16                 :           2 :         ASSERT(SUCCESS == move_path("tests/fixtures/diffs/diff1","tests/fixtures/diff1_backup"));
      17                 :           2 :         ASSERT(SUCCESS == copy_path("tests/fixtures/diff1_backup","tests/fixtures/diffs/diff1"));
      18                 :             : 
      19                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","false"));
      20                 :             : 
      21                 :           2 :         const char *arguments = "--silent --database=database1.db tests/fixtures/diffs/diff1";
      22                 :             : 
      23                 :           2 :         ASSERT(SUCCESS == runit(arguments,result,NULL,COMPLETED,ALLOW_BOTH));
      24                 :             : 
      25                 :           2 :         ASSERT(result->length == 0);
      26                 :             : 
      27                 :           2 :         command = "cd ${TMPDIR};"
      28                 :             :                 "chmod 000 tests/fixtures/diffs/diff1/1/AAA/ZAW/D/e/f/b_file.txt;"
      29                 :             :                 "chmod 000 tests/fixtures/diffs/diff1/2/AAA/BBB/CZC;"; // Change directory permitions
      30                 :             : 
      31                 :           2 :         ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
      32                 :             : 
      33                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
      34                 :             : 
      35                 :           2 :         arguments = "--update --database=database1.db tests/fixtures/diffs/diff1";
      36                 :             : 
      37                 :           2 :         ASSERT(SUCCESS == runit(arguments,result,NULL,COMPLETED,ALLOW_BOTH));
      38                 :             : 
      39                 :           2 :         const char *filename = "templates/0029_001.txt";
      40                 :             : 
      41                 :           2 :         ASSERT(SUCCESS == get_file_content(filename,pattern));
      42                 :           2 :         ASSERT(SUCCESS == match_pattern(result,pattern,filename));
      43                 :             : 
      44                 :           2 :         del(pattern);
      45                 :           2 :         del(result);
      46                 :             : 
      47                 :             :         // Clean up test results
      48                 :           2 :         ASSERT(SUCCESS == delete_path("database1.db"));
      49                 :             : 
      50                 :           2 :         command = "cd ${TMPDIR} && "
      51                 :             :                 "chmod -R a+rwX tests/fixtures/diffs/diff1";
      52                 :           2 :         ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
      53                 :           2 :         ASSERT(SUCCESS == delete_path("tests/fixtures/diffs/diff1"));
      54                 :           2 :         ASSERT(SUCCESS == move_path("tests/fixtures/diff1_backup","tests/fixtures/diffs/diff1"));
      55                 :             : 
      56                 :           2 :         RETURN_STATUS;
      57                 :             : }
      58                 :             : 
      59                 :             : /**
      60                 :             :  * --db-drop-inaccessible option. Dropping DB records for inaccessible paths
      61                 :             :  */
      62                 :           2 : static Return test0029_2(void)
      63                 :             : {
      64                 :           2 :         INITTEST;
      65                 :             : 
      66                 :             :         // Create memory for the result
      67                 :           2 :         create(char,result);
      68                 :           2 :         create(char,pattern);
      69                 :             : 
      70                 :             :         // Preparation for tests
      71                 :           2 :         ASSERT(SUCCESS == move_path("tests/fixtures/diffs/diff1","tests/fixtures/diff1_backup"));
      72                 :           2 :         ASSERT(SUCCESS == copy_path("tests/fixtures/diff1_backup","tests/fixtures/diffs/diff1"));
      73                 :             : 
      74                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","false"));
      75                 :             : 
      76                 :           2 :         const char *arguments = "--silent --database=database2.db tests/fixtures/diffs/diff1";
      77                 :             : 
      78                 :           2 :         ASSERT(SUCCESS == runit(arguments,result,NULL,COMPLETED,ALLOW_BOTH));
      79                 :             : 
      80                 :           2 :         ASSERT(result->length == 0);
      81                 :             : 
      82                 :           2 :         const char *command = "cd ${TMPDIR};"
      83                 :             :                 "chmod 000 tests/fixtures/diffs/diff1/1/AAA/ZAW/D/e/f/b_file.txt;"
      84                 :             :                 "chmod 000 tests/fixtures/diffs/diff1/2/AAA/BBB/CZC;"; // Change directory permitions
      85                 :             : 
      86                 :           2 :         ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
      87                 :             : 
      88                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
      89                 :             : 
      90                 :           2 :         arguments = "--update --db-drop-inaccessible --database=database2.db "
      91                 :             :                 "tests/fixtures/diffs/diff1";
      92                 :             : 
      93                 :           2 :         ASSERT(SUCCESS == runit(arguments,result,NULL,COMPLETED,ALLOW_BOTH));
      94                 :             : 
      95                 :           2 :         const char *filename = "templates/0029_002.txt";
      96                 :             : 
      97                 :           2 :         ASSERT(SUCCESS == get_file_content(filename,pattern));
      98                 :           2 :         ASSERT(SUCCESS == match_pattern(result,pattern,filename));
      99                 :             : 
     100                 :           2 :         del(pattern);
     101                 :           2 :         del(result);
     102                 :             : 
     103                 :             :         // Clean up test results
     104                 :           2 :         ASSERT(SUCCESS == delete_path("database2.db"));
     105                 :             : 
     106                 :           2 :         command = "cd ${TMPDIR} && "
     107                 :             :                 "chmod -R a+rwX tests/fixtures/diffs/diff1";
     108                 :           2 :         ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
     109                 :           2 :         ASSERT(SUCCESS == delete_path("tests/fixtures/diffs/diff1"));
     110                 :           2 :         ASSERT(SUCCESS == move_path("tests/fixtures/diff1_backup","tests/fixtures/diffs/diff1"));
     111                 :             : 
     112                 :           2 :         RETURN_STATUS;
     113                 :             : }
     114                 :             : 
     115                 :             : /**
     116                 :             :  *
     117                 :             :  * Testing how the application behaves with inaccessible files
     118                 :             :  *
     119                 :             :  */
     120                 :           2 : Return test0029(void)
     121                 :             : {
     122                 :           2 :         INITTEST;
     123                 :             : 
     124                 :           2 :         TEST(test0029_1,"\"inaccessible\" message of file_show() function…");
     125                 :           2 :         TEST(test0029_2,"--db-drop-inaccessible option. Dropping DB records for inaccessible paths…");
     126                 :             : 
     127                 :           2 :         RETURN_STATUS;
     128                 :             : }
        

Generated by: LCOV version 2.0-1