Skip to content

Commit f0f6412

Browse files
committed
Reorganize the auparse tests
auparse: integrate tests with automake Run the auparse tests directly through Automake’s TESTS list. Wrapper scripts (run_auparse_test.sh and run_auparselol_test.sh) handle log copying and comparisons so each test shows up in the testsuite summary. The old check-local logic is removed and configure.ac transforms the run-*.sh scripts.
1 parent 161dfec commit f0f6412

File tree

5 files changed

+63
-25
lines changed

5 files changed

+63
-25
lines changed

auparse/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# Richard Guy Briggs <[email protected]>
2323
#
2424

25-
SUBDIRS = test
25+
SUBDIRS = . test
2626
EXTRA_DIST = expression-design.txt
2727
CLEANFILES = $(BUILT_SOURCES)
2828
CONFIG_CLEAN_FILES = *.loT *.rej *.orig

auparse/test/Makefile.am

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@
2121
#
2222

2323
CONFIG_CLEAN_FILES = *.loT *.rej *.orig *.cur
24-
check_PROGRAMS = auparse_test auparselol_test lookup_test databuf_test
25-
dist_check_SCRIPTS = auparse_test.py
26-
EXTRA_DIST = auparse_test.ref auparse_test.ref.py test.log test2.log test3.log test4.log auditd_raw.sed
24+
noinst_PROGRAMS = auparse_test auparselol_test lookup_test databuf_test
25+
TESTS = run_auparse_tests.sh run_auparselol_test.sh lookup_test databuf_test
26+
dist_check_SCRIPTS = run_auparse_tests.sh run_auparselol_test.sh
27+
if USE_PYTHON3
28+
TESTS += auparse_test.py
29+
dist_check_SCRIPTS += auparse_test.py
30+
endif
31+
EXTRA_DIST = auparse_test.ref auparse_test.ref.py test.log test2.log test3.log test4.log auditd_raw.sed run_auparse_tests.sh auparse_test.py run_auparselol_test.sh
32+
CLEANFILES = run_auparse_tests.sh run_auparselol_test.sh
2733

2834
AM_CPPFLAGS = -I${top_srcdir}/auparse -I${top_srcdir}/lib
2935

@@ -53,26 +59,6 @@ databuf_test_DEPENDENCIES = ${top_builddir}/auparse/libauparse.la ${top_builddir
5359

5460
drop_srcdir = sed 's,$(srcdir)/test,test,'
5561

56-
check-local: auparse_test auparselol_test lookup_test databuf_test
57-
test "$(top_srcdir)" = "$(top_builddir)" || \
58-
cp $(top_srcdir)/auparse/test/test*.log .
59-
LC_ALL=C \
60-
./auparse_test > auparse_test.cur
61-
diff -u $(top_srcdir)/auparse/test/auparse_test.ref auparse_test.cur
62-
./auparselol_test -f test3.log --check | sort > auparse_test.cur
63-
sed -f $(top_srcdir)/auparse/test/auditd_raw.sed test3.log | sort > auparse_test.raw
64-
diff -u auparse_test.raw auparse_test.cur
65-
if USE_PYTHON3
66-
cp ${top_builddir}/bindings/swig/python3/.libs/_audit.so ${top_builddir}/bindings/swig/python3
67-
PYTHONPATH=${top_builddir}/bindings/python/python3/.libs/ \
68-
PYTHONDONTWRITEBYTECODE=1 \
69-
LD_LIBRARY_PATH=${top_builddir}/auparse/.libs \
70-
srcdir=$(srcdir) $(srcdir)/auparse_test.py \
71-
| $(drop_srcdir) > auparse_test.cur
72-
diff -u $(top_srcdir)/auparse/test/auparse_test.ref.py auparse_test.cur
73-
endif
74-
./lookup_test
75-
echo -e "===================\nAuparse Test Passes\n==================="
7662

7763
diffcheck: auparse_test auparselol_test
7864
./auparse_test > auparse_test.cur
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
set -e
3+
srcdir="@srcdir@"
4+
top_builddir="@top_builddir@"
5+
use_python3="@use_python3@"
6+
# copy logs when build dir != srcdir
7+
if [ "$srcdir" != "." ]; then
8+
cp "$srcdir"/test*.log .
9+
fi
10+
LC_ALL=C ./auparse_test > auparse_test.cur
11+
diff -u "$srcdir"/auparse_test.ref auparse_test.cur
12+
./auparselol_test -f test3.log --check | sort > auparse_test.cur
13+
sed -f "$srcdir"/auditd_raw.sed test3.log | sort > auparse_test.raw
14+
diff -u auparse_test.raw auparse_test.cur
15+
if [ "$use_python3" = "yes" ]; then
16+
cp "$top_builddir"/bindings/swig/python3/.libs/_audit.so "$top_builddir"/bindings/swig/python3
17+
PYTHONPATH="$top_builddir"/bindings/python/python3/.libs/ \
18+
PYTHONDONTWRITEBYTECODE=1 \
19+
LD_LIBRARY_PATH="$top_builddir"/auparse/.libs \
20+
srcdir=$srcdir "$srcdir"/auparse_test.py | sed "s,$srcdir/test,test," > auparse_test.cur
21+
diff -u "$srcdir"/auparse_test.ref.py auparse_test.cur
22+
fi
23+
./lookup_test
24+
# databuf_test is built but not run
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
set -e
3+
4+
srcdir="@srcdir@"
5+
if [ "$srcdir" != "." ]; then
6+
cp "$srcdir"/test3.log .
7+
fi
8+
./auparselol_test -f test3.log --check | sort > auparse_test.cur
9+
sed -f "$srcdir"/auditd_raw.sed test3.log | sort > auparse_test.raw
10+
diff -u auparse_test.raw auparse_test.cur

configure.ac

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,11 @@ else
158158
AC_SUBST(PYTHON3_CFLAGS)
159159
AC_SUBST(PYTHON3_LIBS)
160160
AC_SUBST(PYTHON3_INCLUDES)
161+
AC_SUBST(use_python3)
161162
fi
162163
fi
163164
AM_CONDITIONAL(USE_PYTHON3, test ${use_python3} = "yes")
165+
AC_SUBST(use_python3)
164166

165167
if test "x$use_python3" = "xyes" ; then
166168
AC_CHECK_PROG([SWIG],[swig],[swig], [no])
@@ -420,7 +422,23 @@ AC_SUBST(DEBUG)
420422
AC_SUBST(LIBWRAP_LIBS)
421423
#AC_SUBST(libev_LIBS)
422424

423-
AC_CONFIG_FILES(Makefile common/Makefile lib/Makefile lib/audit.pc lib/test/Makefile auplugin/Makefile auplugin/test/Makefile auparse/Makefile auparse/test/Makefile auparse/auparse.pc src/Makefile src/libev/Makefile src/test/Makefile docs/Makefile rules/Makefile init.d/Makefile audisp/Makefile audisp/plugins/Makefile audisp/plugins/af_unix/Makefile audisp/plugins/remote/Makefile audisp/plugins/zos-remote/Makefile audisp/plugins/syslog/Makefile audisp/plugins/filter/Makefile audisp/plugins/ids/Makefile audisp/plugins/ids/rules/Makefile audisp/plugins/statsd/Makefile bindings/Makefile bindings/python/Makefile bindings/python/python3/Makefile bindings/golang/Makefile bindings/swig/Makefile bindings/swig/src/Makefile bindings/swig/python3/Makefile tools/Makefile tools/aulast/Makefile tools/aulastlog/Makefile tools/ausyscall/Makefile m4/Makefile)
425+
AC_CONFIG_FILES([Makefile common/Makefile lib/Makefile lib/audit.pc
426+
lib/test/Makefile auplugin/Makefile
427+
auplugin/test/Makefile auparse/Makefile
428+
auparse/test/Makefile auparse/test/run_auparse_tests.sh
429+
auparse/test/run_auparselol_test.sh
430+
auparse/auparse.pc src/Makefile src/libev/Makefile src/test/Makefile
431+
docs/Makefile rules/Makefile init.d/Makefile audisp/Makefile
432+
audisp/plugins/Makefile audisp/plugins/af_unix/Makefile
433+
audisp/plugins/remote/Makefile audisp/plugins/zos-remote/Makefile
434+
audisp/plugins/syslog/Makefile audisp/plugins/filter/Makefile
435+
audisp/plugins/ids/Makefile audisp/plugins/ids/rules/Makefile
436+
audisp/plugins/statsd/Makefile bindings/Makefile bindings/python/Makefile
437+
bindings/python/python3/Makefile bindings/golang/Makefile
438+
bindings/swig/Makefile bindings/swig/src/Makefile
439+
bindings/swig/python3/Makefile tools/Makefile tools/aulast/Makefile
440+
tools/aulastlog/Makefile tools/ausyscall/Makefile m4/Makefile],
441+
[chmod +x auparse/test/run_auparse_tests.sh auparse/test/run_auparselol_test.sh])
424442
AC_OUTPUT
425443

426444
echo .

0 commit comments

Comments
 (0)