@@ -615,3 +615,53 @@ void no_famous_last_words(void **state)
615
615
assert_int_equal (code , ZONE_SUCCESS );
616
616
assert_true (count == 0 );
617
617
}
618
+
619
+ /*!cmocka */
620
+ void the_include_that_wasnt (void * * state )
621
+ {
622
+ (void )state ;
623
+
624
+ int32_t code ;
625
+ size_t count = 0 ;
626
+
627
+ char * path = generate_include (" " );
628
+ assert_non_null (path );
629
+ char dummy [16 ];
630
+ int length = snprintf (dummy , sizeof (dummy ), "$INCLUDE \"%s\"\n" , path );
631
+ assert_true (length > 0 && length < INT_MAX - ZONE_PADDING_SIZE );
632
+ char * include = malloc ((size_t )length + 1 + ZONE_PADDING_SIZE );
633
+ assert_non_null (include );
634
+ (void )snprintf (include , (size_t )length + 1 , "$INCLUDE \"%s\"\n" , path );
635
+ remove_include (path );
636
+ free (path );
637
+ code = parse (include , & count );
638
+ free (include );
639
+ assert_int_equal (code , ZONE_READ_ERROR );
640
+ }
641
+
642
+ /*!cmocka */
643
+ void been_there_done_that (void * * state )
644
+ {
645
+ (void )state ;
646
+
647
+ int32_t code ;
648
+ size_t count = 0 ;
649
+
650
+ char * path = generate_include (" " );
651
+ assert_non_null (path );
652
+ FILE * handle = fopen (path , "wb" );
653
+ assert_non_null (handle );
654
+ char dummy [16 ];
655
+ int length = snprintf (dummy , sizeof (dummy ), "$INCLUDE \"%s\"\n" , path );
656
+ assert_true (length > 0 && length < INT_MAX - ZONE_PADDING_SIZE );
657
+ char * include = malloc ((size_t )length + 1 + ZONE_PADDING_SIZE );
658
+ assert_non_null (include );
659
+ (void )snprintf (include , (size_t )length + 1 , "$INCLUDE \"%s\"\n" , path );
660
+ int result = fputs (include , handle );
661
+ assert_true (result >= 0 );
662
+ (void )fclose (handle );
663
+ free (path );
664
+ code = parse (include , & count );
665
+ free (include );
666
+ assert_int_equal (code , ZONE_SYNTAX_ERROR );
667
+ }
0 commit comments