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

             Branch data     Line data    Source code
       1                 :             : #include "sute.h"
       2                 :             : 
       3                 :             : /**
       4                 :             :  * @brief Verify `--maxdepth` behavior for initial traversal and later update
       5                 :             :  *
       6                 :             :  * @return Return status code
       7                 :             :  */
       8                 :           2 : Return test0018_1(void)
       9                 :             : {
      10                 :           2 :         INITTEST;
      11                 :             : 
      12                 :             :         /* File system traversal with a maximum depth of 3 */
      13                 :           2 :         create(char,result);
      14                 :             : 
      15                 :           2 :         create(char,pattern);
      16                 :             : 
      17                 :           2 :         const char *filename = "templates/0018_001_1.txt";
      18                 :             : 
      19                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
      20                 :             : 
      21                 :           2 :         const char *arguments = "--maxdepth=3 --database=database3.db "
      22                 :             :                 "$TMPDIR/tests/fixtures/levels";
      23                 :             : 
      24                 :           2 :         ASSERT(SUCCESS == runit(arguments,result,NULL,COMPLETED,ALLOW_BOTH));
      25                 :             : 
      26                 :           2 :         ASSERT(SUCCESS == get_file_content(filename,pattern));
      27                 :             : 
      28                 :             :         // Match the result against the pattern
      29                 :           2 :         ASSERT(SUCCESS == match_pattern(result,pattern,filename));
      30                 :             : 
      31                 :             :         // Clean to use it iteratively
      32                 :           2 :         del(pattern);
      33                 :           2 :         del(result);
      34                 :             : 
      35                 :             :         #if 0
      36                 :             :         echo(STDOUT,"%s\n",getcstring(result));
      37                 :             :         #endif
      38                 :             : 
      39                 :             :         /* File system traversal with unlimited depth */
      40                 :           2 :         filename = "templates/0018_001_2.txt";
      41                 :             : 
      42                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
      43                 :             : 
      44                 :           2 :         arguments = "--database=database4.db "
      45                 :             :                 "$TMPDIR/tests/fixtures/levels";
      46                 :             : 
      47                 :           2 :         ASSERT(SUCCESS == runit(arguments,result,NULL,COMPLETED,ALLOW_BOTH));
      48                 :             : 
      49                 :           2 :         ASSERT(SUCCESS == get_file_content(filename,pattern));
      50                 :             : 
      51                 :             :         // Match the result against the pattern
      52                 :           2 :         ASSERT(SUCCESS == match_pattern(result,pattern,filename));
      53                 :             : 
      54                 :             :         // Clean to use it iteratively
      55                 :           2 :         del(pattern);
      56                 :           2 :         del(result);
      57                 :             : 
      58                 :             :         // Clean up test results
      59                 :           2 :         ASSERT(SUCCESS == delete_path("database4.db"));
      60                 :             : 
      61                 :           2 :         RETURN_STATUS;
      62                 :             : }
      63                 :             : 
      64                 :             : /**
      65                 :             :  * @brief Verify update output after rerunning the maxdepth fixture without the depth limit
      66                 :             :  *
      67                 :             :  * @return Return status code
      68                 :             :  */
      69                 :           2 : Return test0018_2(void)
      70                 :             : {
      71                 :           2 :         INITTEST;
      72                 :             : 
      73                 :             :         /* File system traversal with a maximum depth of 3 */
      74                 :           2 :         create(char,result);
      75                 :           2 :         create(char,pattern);
      76                 :             : 
      77                 :             :         /* File system traversal with unlimited depth */
      78                 :           2 :         const char *filename = "templates/0018_002.txt";
      79                 :             : 
      80                 :           2 :         ASSERT(SUCCESS == set_environment_variable("TESTING","true"));
      81                 :             : 
      82                 :           2 :         const char *arguments = "--update --database=database3.db "
      83                 :             :                 "$TMPDIR/tests/fixtures/levels";
      84                 :             : 
      85                 :           2 :         ASSERT(SUCCESS == runit(arguments,result,NULL,COMPLETED,ALLOW_BOTH));
      86                 :             : 
      87                 :           2 :         ASSERT(SUCCESS == get_file_content(filename,pattern));
      88                 :             : 
      89                 :             :         // Match the result against the pattern
      90                 :           2 :         ASSERT(SUCCESS == match_pattern(result,pattern,filename));
      91                 :             : 
      92                 :             :         // Clean to use it iteratively
      93                 :           2 :         del(pattern);
      94                 :           2 :         del(result);
      95                 :             : 
      96                 :             :         // Clean up test results
      97                 :           2 :         ASSERT(SUCCESS == delete_path("database3.db"));
      98                 :             : 
      99                 :           2 :         RETURN_STATUS;
     100                 :             : }
     101                 :             : 
     102                 :             : 
     103                 :           2 : Return test0018_3(void)
     104                 :             : {
     105                 :           2 :         INITTEST;
     106                 :             : 
     107                 :           2 :         create(char,text1);
     108                 :           2 :         create(char,text2);
     109                 :           2 :         create(char,pattern);
     110                 :           2 :         create(char,diff_buffer);
     111                 :           2 :         char *diff = NULL;
     112                 :             : 
     113                 :             :         /* 0018 001 */
     114                 :           2 :         ASSERT(SUCCESS == get_file_content("templates/0018_001_1.txt",text1));
     115                 :             : 
     116                 :           2 :         ASSERT(SUCCESS == get_file_content("templates/0018_001_2.txt",text2));
     117                 :             : 
     118                 :           2 :         ASSERT(SUCCESS == compare_strings(&diff,getcstring(text1),getcstring(text2)));
     119                 :             : 
     120                 :           2 :         const char *filename = "templates/0018_003.txt";
     121                 :             : 
     122                 :           2 :         ASSERT(SUCCESS == get_file_content(filename,pattern));
     123                 :           2 :         ASSERT(SUCCESS == copy_literal(diff_buffer,diff));
     124                 :           2 :         ASSERT(SUCCESS == match_pattern(diff_buffer,pattern,filename));
     125                 :             : 
     126                 :           2 :         del(text1);
     127                 :           2 :         del(text2);
     128                 :           2 :         del(pattern);
     129                 :           2 :         del(diff_buffer);
     130                 :           2 :         reset(&diff);
     131                 :             : 
     132                 :           2 :         RETURN_STATUS;
     133                 :             : }
     134                 :             : 
     135                 :           2 : Return test0018_4(void)
     136                 :             : {
     137                 :           2 :         INITTEST;
     138                 :             : 
     139                 :           2 :         create(char,text1);
     140                 :           2 :         create(char,text2);
     141                 :           2 :         create(char,pattern);
     142                 :           2 :         create(char,diff_buffer);
     143                 :           2 :         char *diff = NULL;
     144                 :             : 
     145                 :             :         /* 0018 001 */
     146                 :           2 :         ASSERT(SUCCESS == get_file_content("templates/0018_001_1.txt",text1));
     147                 :             : 
     148                 :           2 :         ASSERT(SUCCESS == get_file_content("templates/0018_002.txt",text2));
     149                 :             : 
     150                 :           2 :         ASSERT(SUCCESS == compare_strings(&diff,getcstring(text1),getcstring(text2)));
     151                 :             : 
     152                 :           2 :         const char *filename = "templates/0018_004.txt";
     153                 :             : 
     154                 :           2 :         ASSERT(SUCCESS == get_file_content(filename,pattern));
     155                 :           2 :         ASSERT(SUCCESS == copy_literal(diff_buffer,diff));
     156                 :           2 :         ASSERT(SUCCESS == match_pattern(diff_buffer,pattern,filename));
     157                 :             : 
     158                 :           2 :         del(text1);
     159                 :           2 :         del(text2);
     160                 :           2 :         del(pattern);
     161                 :           2 :         del(diff_buffer);
     162                 :           2 :         reset(&diff);
     163                 :             : 
     164                 :           2 :         RETURN_STATUS;
     165                 :             : }
     166                 :             : 
     167                 :             : /**
     168                 :             :  *
     169                 :             :  * --maxdepth argument testing
     170                 :             :  *
     171                 :             :  */
     172                 :           2 : Return test0018(void)
     173                 :             : {
     174                 :           2 :         INITTEST;
     175                 :             : 
     176                 :           2 :         TEST(test0018_1,"Traversal with limited depth…");
     177                 :           2 :         TEST(test0018_2,"Update DB w/o depth limits…");
     178                 :           2 :         TEST(test0018_3,"Comparing templates w/ and w/o depth limits…")
     179                 :           2 :         TEST(test0018_4,"Comparing templates after update w/o depth limits…")
     180                 :             : 
     181                 :           2 :         RETURN_STATUS;
     182                 :             : }
        

Generated by: LCOV version 2.0-1