LCOV - code coverage report
Current view: top level - tests/src - test0016.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 61 61
Test Date: 2026-03-01 04:31:48 Functions: 100.0 % 1 1
Branches: 49.3 % 134 66

             Branch data     Line data    Source code
       1                 :             : #include "sute.h"
       2                 :             : 
       3                 :             : /**
       4                 :             :  *
       5                 :             :  * --watch-timestamps argument testing
       6                 :             :  *
       7                 :             :  */
       8                 :           2 : Return test0016(void)
       9                 :             : {
      10                 :           2 :         INITTEST;
      11                 :             : 
      12                 :           2 :         create(char,pattern);
      13                 :             : 
      14                 :             :         // Create memory for the result
      15                 :           2 :         create(char,result);
      16                 :           2 :         create(char,chunk);
      17                 :             : 
      18                 :           2 :         const char *command = "cd ${TMPDIR};"
      19                 :             :                 "mv tests/fixtures/diffs/diff1 tests/fixtures/diff1_backup;"
      20                 :             :                 "cp -a tests/fixtures/diff1_backup tests/fixtures/diffs/diff1;";
      21                 :             : 
      22                 :             :         // Preparation for the test
      23   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
      24                 :             : 
      25                 :           2 :         const char *filename = "templates/0016_001_1.txt";
      26                 :             : 
      27   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
      28                 :             : 
      29                 :           2 :         const char *arguments = "--start-device-only --database=database1.db "
      30                 :             :                 "tests/fixtures/diffs/diff1";
      31                 :             : 
      32   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
      33   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == copy(result,chunk));
      34                 :             : 
      35                 :           2 :         command = "cd ${TMPDIR} && "
      36                 :             :                 "cp -a database1.db database2.db";
      37                 :             : 
      38   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
      39                 :             : 
      40                 :           2 :         command = "cd ${TMPDIR} && "
      41                 :             :                 "echo -n 'PWOEUNVSODNLKUHGE' >> tests/fixtures/diffs/diff1/1/AAA/BCB/CCC/a.txt && "
      42                 :             :                 "touch tests/fixtures/diffs/diff1/2/AAA/BBB/CZC/a.txt && "
      43                 :             :                 "rm tests/fixtures/diffs/diff1/path2/AAA/ZAW/D/e/f/b_file.txt";
      44                 :             : 
      45   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
      46                 :             : 
      47                 :           2 :         arguments = "--update --check-level=QUICK --database=database1.db "
      48                 :             :                 "tests/fixtures/diffs/diff1";
      49                 :             : 
      50   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
      51   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == concat_strings(result,chunk));
      52                 :             : 
      53                 :           2 :         arguments = "--compare database1.db database2.db";
      54                 :             : 
      55   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
      56   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == concat_strings(result,chunk));
      57                 :             : 
      58                 :           2 :         command = "cd ${TMPDIR} && "
      59                 :             :                 "cp -a database2.db database1.db";
      60   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
      61                 :             : 
      62                 :           2 :         arguments = "--watch-timestamps --update --database=database1.db "
      63                 :             :                 "tests/fixtures/diffs/diff1";
      64                 :             : 
      65   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
      66   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == concat_strings(result,chunk));
      67                 :             : 
      68                 :           2 :         arguments = "--compare database1.db database2.db";
      69                 :             : 
      70   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
      71   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == concat_strings(result,chunk));
      72                 :             : 
      73   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == get_file_content(filename,pattern));
      74   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == match_pattern(result,pattern,filename));
      75                 :             : 
      76                 :             :         // Clean to use it iteratively
      77                 :           2 :         del(pattern);
      78                 :           2 :         del(result);
      79                 :           2 :         del(chunk);
      80                 :             : 
      81                 :           2 :         filename = "templates/0016_001_2.txt";
      82   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","false"));
      83                 :             : 
      84                 :           2 :         command = "cd ${TMPDIR} && "
      85                 :             :                 "cp -a database2.db database1.db";
      86                 :             : 
      87   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
      88                 :             : 
      89                 :           2 :         arguments = "--update --database=database1.db tests/fixtures/diffs/diff1";
      90                 :             : 
      91   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
      92   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == copy(result,chunk));
      93                 :             : 
      94                 :           2 :         arguments = "--compare database1.db database2.db";
      95                 :             : 
      96   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
      97   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == concat_strings(result,chunk));
      98                 :             : 
      99                 :           2 :         command = "cd ${TMPDIR} && "
     100                 :             :                 "cp -a database2.db database1.db";
     101   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
     102                 :             : 
     103                 :           2 :         arguments = "--watch-timestamps --update --database=database1.db "
     104                 :             :                 "tests/fixtures/diffs/diff1";
     105                 :             : 
     106   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
     107   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == concat_strings(result,chunk));
     108                 :             : 
     109                 :           2 :         arguments = "--compare database1.db database2.db";
     110                 :             : 
     111   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == runit(arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
     112   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == concat_strings(result,chunk));
     113                 :             : 
     114   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == get_file_content(filename,pattern));
     115   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == match_pattern(result,pattern,filename));
     116                 :             : 
     117                 :             :         // Clean to use it iteratively
     118                 :           2 :         del(pattern);
     119                 :           2 :         del(result);
     120                 :           2 :         del(chunk);
     121                 :             : 
     122                 :             :         // Clean up test results
     123                 :           2 :         command = "cd ${TMPDIR} && "
     124                 :             :                 "rm database1.db && "
     125                 :             :                 "rm database2.db && "
     126                 :             :                 "rm -rf tests/fixtures/diffs/diff1 && "
     127                 :             :                 "mv tests/fixtures/diff1_backup tests/fixtures/diffs/diff1";
     128                 :             : 
     129   [ +  -  +  - ]:           2 :         ASSERT(SUCCESS == external_call(command,NULL,NULL,COMPLETED,ALLOW_BOTH));
     130                 :             : 
     131   [ +  -  -  +  :           2 :         RETURN_STATUS;
          -  -  -  +  +  
                      - ]
     132                 :             : }
        

Generated by: LCOV version 2.0-1