LCOV - code coverage report
Current view: top level - tests/src - test0027.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 32 32
Test Date: 2026-01-12 05:34:38 Functions: 100.0 % 2 2

            Line data    Source code
       1              : #include "sute.h"
       2              : 
       3              : /**
       4              :  *
       5              :  * Attempt to modify files protected by the --lock-checksum
       6              :  *
       7              :  */
       8            2 : static Return test0027_1_lock_checksum(void)
       9              : {
      10            2 :         INITTEST;
      11              : 
      12            2 :         create(char,result);
      13            2 :         create(char,pattern);
      14              : 
      15            2 :         const char *command = "cd ${TMPDIR};"
      16              :                 "mv tests/examples/ tests/examples_backup/;"
      17              :                 "cp -a tests/examples_backup/ tests/examples/;";
      18              : 
      19              :         // Preparation for tests
      20            2 :         ASSERT(SUCCESS == external_call(command,COMPLETED,ALLOW_BOTH));
      21              : 
      22            2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
      23              : 
      24            2 :         const char *arguments = "--database=lock.db --lock-checksum=\"^diff1/1/.*\" --lock-checksum=\"^diff2/path1/.*\" tests/examples/diffs";
      25              : 
      26            2 :         ASSERT(SUCCESS == runit(arguments,result,COMPLETED,ALLOW_BOTH));
      27              : 
      28            2 :         const char *filename = "templates/0027_001_1.txt";
      29              : 
      30            2 :         ASSERT(SUCCESS == get_file_content(filename,pattern));
      31              : 
      32            2 :         arguments = "--update --database=lock.db --lock-checksum=\"^diff1/1/.*\" --lock-checksum=\"^diff2/path1/.*\" tests/examples/diffs";
      33              : 
      34            2 :         ASSERT(SUCCESS == runit(arguments,result,COMPLETED,ALLOW_BOTH));
      35              : 
      36            2 :         filename = "templates/0027_001_2.txt";
      37              : 
      38            2 :         ASSERT(SUCCESS == get_file_content(filename,pattern));
      39              : 
      40            2 :         ASSERT(SUCCESS == match_pattern(result,pattern,filename));
      41              : 
      42            2 :         filename = "templates/0027_001_3.txt";
      43              : 
      44            2 :         ASSERT(SUCCESS == get_file_content(filename,pattern));
      45              : 
      46            2 :         command = "cd ${TMPDIR};"
      47              :                 "echo 'corrupted' >> tests/examples/diffs/diff1/1/AAA/ZAW/A/b/c/a_file.txt;"
      48              :                 "echo 'corrupted' >> tests/examples/diffs/diff2/path1/AAA/BCB/CCC/b.txt;"
      49              :                 "echo 'changed' >> tests/examples/diffs/diff2/3/AAA/BBB/CCC/a.txt;"
      50              :                 "touch tests/examples/diffs/diff2/2/AAA/BBB/CZC/a.txt";
      51              : 
      52            2 :         ASSERT(SUCCESS == external_call(command,COMPLETED,ALLOW_BOTH));
      53              : 
      54            2 :         arguments = "--progress --update --database=lock.db --lock-checksum=\"^diff1/1/.*\" --lock-checksum=\"^diff2/path1/.*\" tests/examples/diffs";
      55              : 
      56            2 :         ASSERT(SUCCESS == runit(arguments,result,WARNING,ALLOW_BOTH));
      57              : 
      58            2 :         ASSERT(SUCCESS == match_pattern(result,pattern,filename));
      59              : 
      60              :         // Clean up test results
      61            2 :         command = "cd ${TMPDIR} && "
      62              :                 "rm lock.db && "
      63              :                 "rm -rf tests/examples/ && "
      64              :                 "mv tests/examples_backup/ tests/examples/";
      65              : 
      66            2 :         ASSERT(SUCCESS == external_call(command,COMPLETED,ALLOW_BOTH));
      67              : 
      68            2 :         del(result);
      69            2 :         del(pattern);
      70              : 
      71            2 :         RETURN_STATUS;
      72              : }
      73              : 
      74            2 : Return test0027(void)
      75              : {
      76            2 :         INITTEST;
      77              : 
      78            2 :         TEST(test0027_1_lock_checksum,"Attempt to modify files protected by the --lock-checksum…");
      79              : 
      80            2 :         RETURN_STATUS;
      81              : }
        

Generated by: LCOV version 2.0-1