LCOV - code coverage report
Current view: top level - tests/src - test0016.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 52 52
Test Date: 2026-07-12 01:01:34 Functions: 100.0 % 1 1
Branches: - 0 0

             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 :         m_create(char,pattern,MEMORY_STRING);
      13                 :             : 
      14                 :             :         // Create memory for the result
      15                 :           2 :         m_create(char,result,MEMORY_STRING);
      16                 :           2 :         m_create(char,chunk,MEMORY_STRING);
      17                 :             : 
      18                 :             :         // Preparation for the test
      19                 :           2 :         const char *diff1_fixture_path = "tests/fixtures/diffs/diff1";
      20                 :           2 :         ASSERT(SUCCESS == prepare_mutable_fixture(diff1_fixture_path));
      21                 :             : 
      22                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
      23                 :             : 
      24                 :           2 :         ASSERT(SUCCESS == runit("--start-device-only --database=database1.db tests/fixtures/diffs/diff1",chunk,NULL,COMPLETED,ALLOW_BOTH));
      25                 :           2 :         ASSERT(SUCCESS == m_copy(result,chunk));
      26                 :             : 
      27                 :           2 :         ASSERT(SUCCESS == copy_path("database1.db","database2.db"));
      28                 :             : 
      29                 :           2 :         ASSERT(SUCCESS == add_string_to("PWOEUNVSODNLKUHGE","tests/fixtures/diffs/diff1/1/AAA/BCB/CCC/a.txt"));
      30                 :             : 
      31                 :           2 :         ASSERT(SUCCESS == delete_path("tests/fixtures/diffs/diff1/path2/AAA/ZAW/D/e/f/b_file.txt"));
      32                 :             : 
      33                 :             :         // Bump file mtime by a nanosecond delta without changing file content
      34                 :           2 :         ASSERT(SUCCESS == touch_file_mtime_with_reference_delta_ns(NULL,"tests/fixtures/diffs/diff1/2/AAA/BBB/CZC/a.txt",999));
      35                 :             : 
      36                 :           2 :         ASSERT(SUCCESS == runit("--update --check-level=QUICK --database=database1.db tests/fixtures/diffs/diff1",chunk,NULL,COMPLETED,ALLOW_BOTH));
      37                 :           2 :         ASSERT(SUCCESS == m_concat_strings(result,chunk));
      38                 :             : 
      39                 :           2 :         const char *compare_arguments = "--compare database1.db database2.db";
      40                 :           2 :         ASSERT(SUCCESS == runit(compare_arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
      41                 :           2 :         ASSERT(SUCCESS == m_concat_strings(result,chunk));
      42                 :             : 
      43                 :           2 :         ASSERT(SUCCESS == copy_path("database2.db","database1.db"));
      44                 :             : 
      45                 :           2 :         const char *watch_update_arguments = "--watch-timestamps --update --database=database1.db tests/fixtures/diffs/diff1";
      46                 :           2 :         ASSERT(SUCCESS == runit(watch_update_arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
      47                 :           2 :         ASSERT(SUCCESS == m_concat_strings(result,chunk));
      48                 :             : 
      49                 :           2 :         ASSERT(SUCCESS == runit(compare_arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
      50                 :           2 :         ASSERT(SUCCESS == m_concat_strings(result,chunk));
      51                 :             : 
      52                 :           2 :         const char *filename = "templates/0016_001_1.txt";
      53                 :           2 :         ASSERT(SUCCESS == get_file_content(filename,pattern));
      54                 :           2 :         ASSERT(SUCCESS == match_pattern(result,pattern,filename));
      55                 :             : 
      56                 :             :         // Clean to use it iteratively
      57                 :           2 :         m_del(pattern);
      58                 :           2 :         m_del(result);
      59                 :           2 :         m_del(chunk);
      60                 :             : 
      61                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","false"));
      62                 :             : 
      63                 :           2 :         ASSERT(SUCCESS == copy_path("database2.db","database1.db"));
      64                 :             : 
      65                 :           2 :         ASSERT(SUCCESS == runit("--update --database=database1.db tests/fixtures/diffs/diff1",chunk,NULL,COMPLETED,ALLOW_BOTH));
      66                 :           2 :         ASSERT(SUCCESS == m_copy(result,chunk));
      67                 :             : 
      68                 :           2 :         ASSERT(SUCCESS == runit(compare_arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
      69                 :           2 :         ASSERT(SUCCESS == m_concat_strings(result,chunk));
      70                 :             : 
      71                 :           2 :         ASSERT(SUCCESS == copy_path("database2.db","database1.db"));
      72                 :             : 
      73                 :           2 :         ASSERT(SUCCESS == runit(watch_update_arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
      74                 :           2 :         ASSERT(SUCCESS == m_concat_strings(result,chunk));
      75                 :             : 
      76                 :           2 :         ASSERT(SUCCESS == runit(compare_arguments,chunk,NULL,COMPLETED,ALLOW_BOTH));
      77                 :           2 :         ASSERT(SUCCESS == m_concat_strings(result,chunk));
      78                 :             : 
      79                 :           2 :         filename = "templates/0016_001_2.txt";
      80                 :           2 :         ASSERT(SUCCESS == get_file_content(filename,pattern));
      81                 :           2 :         ASSERT(SUCCESS == match_pattern(result,pattern,filename));
      82                 :             : 
      83                 :             :         // Clean to use it iteratively
      84                 :           2 :         m_del(pattern);
      85                 :           2 :         m_del(result);
      86                 :           2 :         m_del(chunk);
      87                 :             : 
      88                 :             :         // Clean up test results
      89                 :           2 :         ASSERT(SUCCESS == delete_path("database1.db"));
      90                 :           2 :         ASSERT(SUCCESS == delete_path("database2.db"));
      91                 :           2 :         ASSERT(SUCCESS == restore_mutable_fixture(diff1_fixture_path));
      92                 :             : 
      93                 :           2 :         RETURN_STATUS;
      94                 :             : }
        

Generated by: LCOV version 2.0-1