apparmor/parser/tst/Makefile
Steve Beattie 5c2bea1b4f parser - add simple valgrind wrapper tests
This patch adds a test wrapper that runs valgrind on the parser over the
simple_tests tree (or other directory tree if passed on the command
line). An alternate parser location can also be passed on the command
line.

Like the libapparmor python bindings test, this test uses a bit of magic
to generate tests that doesn't work with auto-detecting test utilities
like nose.

Running valgrind on the parser over all 69000+ testcases takes several
hours, so while this patch includes a make target 'make valgrind', it
does not add it to the set of tests run when 'make check' is called.
Perhaps a 'make extra-tests' target is in order.

Patch history:
  v1: - initial version.
  v2: - add some valgrind suppressions for overaggressive 4 byte reads
        past the end of allocated storage (not completed).
  v3: - add ability to dump valgrind suppressions to stdout, to use
        diagnosis runs of valgrind for determining whether a given
        failure is a false positive or not.
      - correctly return 0 on a successful run and an error code if one
        or more test cases fail.
      - point LD_LIBRARY_PATH at the in-tree libapparmor build.
      - split out some utility functions into testlib.py, for possible
        use by other to be written test scripts
  v4: - convert optparse to argparse

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: Tyler Hicks <tyhicks@canonical.com> (for v2 version)
2013-10-15 17:06:26 -07:00

60 lines
1.9 KiB
Makefile

#
PROVE=/usr/bin/prove
TESTS=simple.pl
PARSER_DIR=..
PARSER_BIN=apparmor_parser
PARSER=$(PARSER_DIR)/$(PARSER_BIN)
PROVE_ARG=-f
ifeq ($(VERBOSE),1)
PROVE_ARG+=-v
endif
all: tests
.PHONY: tests error_output gen_xtrans parser_sanity caching minimize equality
tests: error_output gen_xtrans gen_dbus parser_sanity caching minimize equality
GEN_TRANS_DIRS=simple_tests/generated_x/ simple_tests/generated_perms_leading/ simple_tests/generated_perms_safe/ simple_tests/generated_dbus
gen_xtrans: $(GEN_TRANS_DIRS)
./gen-xtrans.pl
$(GEN_TRANS_DIRS):
mkdir $@
gen_dbus: $(GEN_TRANS_DIRS)
./gen-dbus.pl
error_output: $(PARSER)
LANG=C $(PARSER) -S -I errors >/dev/null errors/okay.sd
LANG=C $(PARSER) -S -I errors 2>&1 >/dev/null errors/single.sd | \
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 66: 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)
$(Q)LANG=C APPARMOR_PARSER="$(PARSER)" ${PROVE} ${PROVE_ARG} ${TESTS}
caching: $(PARSER)
LANG=C APPARMOR_PARSER="$(PARSER)" ./caching.sh
minimize: $(PARSER)
LANG=C APPARMOR_PARSER="$(PARSER)" ./minimize.sh
equality: $(PARSER)
LANG=C APPARMOR_PARSER="$(PARSER)" ./equality.sh
valgrind: $(PARSER)
LANG=C ./valgrind_simple.py -p "$(PARSER)" -v simple_tests
$(PARSER):
make -C $(PARSER_DIR) $(PARSER_BIN)
clean:
find $(GEN_TRANS_DIRS) -type f | xargs rm -f