2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-08-22 10:07:12 +00:00

This patch adds a couple of additional lineno reporting testcases:

* a non-include related syntax error (errors/modefail.sd)
  * multiple successful includes followed by a failed include
    (errors/multi_include.sd)

It also fixes two issues with the parser's line counting:

  * the count began at 0 (demonstrated by the first testcase's error
    being reporting on one line less than it should be), and

  * an extra line increment when includes were detected (demonstrated
    by the second testcase's error being reported at a line beyond the
    correct linenumber.

The existing testcases did not catch these because they were all
based on the first include in the file failing and so the start of
the count from 0 counteracted the extra counted line.
This commit is contained in:
Steve Beattie 2010-06-25 12:43:48 -07:00
parent d744377f4a
commit 2d2897f426
5 changed files with 26 additions and 3 deletions

View File

@ -284,7 +284,7 @@ static void start_include_position(char *filename)
if (current_filename)
free(current_filename);
current_filename = strdup(filename ? filename : "stdin");
current_lineno = 0;
current_lineno = 1;
}
void push_include_stack(char *filename)

View File

@ -49,7 +49,7 @@
#endif
#define NPDEBUG(fmt, args...) /* Do nothing */
int current_lineno = 0;
int current_lineno = 1;
char *current_filename = NULL;
struct ignored_suffix_t {
@ -427,7 +427,6 @@ LT_EQUAL <=
#include/.*\r?\n { /* include */
PDEBUG("Matched #include\n");
current_lineno++;
BEGIN(INCLUDE);
}

View File

@ -20,6 +20,10 @@ error_output: $(PARSER)
grep -q "AppArmor parser error for errors/single.sd in errors/single.sd at line 3: Could not open 'failure'"
LANG=C $(PARSER) -S -I errors 2>&1 >/dev/null errors/double.sd | \
grep -q "AppArmor parser error for errors/double.sd in errors/includes/busted at line 67: Could not open 'does-not-exist'"
LANG=C $(PARSER) -S -I errors 2>&1 >/dev/null errors/modefail.sd | \
grep -q "AppArmor parser error for errors/modefail.sd in errors/modefail.sd at line 6: syntax error"
LANG=C $(PARSER) -S -I errors 2>&1 >/dev/null errors/multi_include.sd | \
grep -q "AppArmor parser error for errors/multi_include.sd in errors/multi_include.sd at line 12: Could not open 'failure'"
@echo "Error Output: PASS"
parser_sanity: $(PARSER)

View File

@ -0,0 +1,7 @@
# 1
# 2
# 3
/does/not/exist { # 4
/lib/lib*.so rm, # 5
/fail abcdefgh, # 6
} # 7

View File

@ -0,0 +1,13 @@
#
#
#
/does/not/exist {
#include <includes/base>
#include <includes/base>
#include <includes/base>
#include <includes/base>
/bin/true rix,
#include <failure>
}