[Open-scap] [PATCH 08/11] Reworking test orchestration

Marshall Miller mmiller at tresys.com
Wed May 11 19:31:27 UTC 2011


From: Francisco Slavin <fslavin at tresys.com>

Using autoconf & automake to determine which probes to test.
Use autoconf to determine if commands exist because the 'which' on Solaris does not return 1 when a command does not exist.
If configure is told to not build certain probes, the test infrastructure should not try to test those probes.
---
 configure.ac                                       |   13 +++++++
 tests/Makefile.am                                  |    6 +++-
 tests/probes/Makefile.am                           |   34 +++++++++++---------
 .../test_probes_environmentvariable.sh             |    6 ---
 tests/probes/vgtest/test_probes_vg.sh              |    5 ---
 5 files changed, 37 insertions(+), 27 deletions(-)

diff --git a/configure.ac b/configure.ac
index 6a8a68b..05a0452 100644
--- a/configure.ac
+++ b/configure.ac
@@ -130,6 +130,17 @@ if test "x${HAVE_CURL_CONFIG}" != "xyes"; then
 fi
 
 #
+# env
+#
+AC_CHECK_PROG(
+  [HAVE_ENV],
+  [env],
+  [yes],,,
+)
+
+AM_CONDITIONAL(ENV_PRESENT, [test x"${HAVE_ENV}" = xyes])
+
+#
 # Valgrind
 #
 AC_CHECK_PROG(
@@ -138,6 +149,8 @@ AC_CHECK_PROG(
   [yes],,,
 )
 
+AM_CONDITIONAL(VALGRIND_PRESENT, [test x"${HAVE_VALGRIND}" = xyes])
+
 # Checks for libraries.
 
 #
diff --git a/tests/Makefile.am b/tests/Makefile.am
index fe9c878..d320627 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1 +1,5 @@
-SUBDIRS = API probes
+if WANT_PROBES
+PROBE_SUBDIRS = probes
+endif
+SUBDIRS = API $(PROBE_SUBDIRS)
+
diff --git a/tests/probes/Makefile.am b/tests/probes/Makefile.am
index 0fec643..214f21e 100644
--- a/tests/probes/Makefile.am
+++ b/tests/probes/Makefile.am
@@ -1,18 +1,22 @@
-if WANT_PROBES
+if WANT_PROBES_INDEPENDENT
+INDEPENDENT_SUBDIRS = family filehash textfilecontent54 sysinfo
+endif
+
+if WANT_PROBES_UNIX
+UNIX_SUBDIRS = file uname shadow process password runlevel interface
+endif
+
+if WANT_PROBES_LINUX
+LINUX_SUBDIRS = rpminfo
+endif
 
-SUBDIRS = file \
-          uname \
-	  vgtest \
-          family \
-	  shadow \
-	  rpminfo \
-	  sysinfo \
-          process \
-	  runlevel \
-	  filehash \
-	  password \
-	  interface \
-          textfilecontent54 \
-          environmentvariable 
+if VALGRIND_PRESENT
+VALGRIND_SUBDIRS = vgtest
+endif
 
+if ENV_PRESENT
+ENV_SUBDIRS = environmentvariable 
 endif
+
+SUBDIRS = $(INDEPENDENT_SUBDIRS) $(UNIX_SUBDIRS) $(LINUX_SUBDIRS) $(VALGRIND_SUBDIRS) $(ENV_SUBDIRS)
+
diff --git a/tests/probes/environmentvariable/test_probes_environmentvariable.sh b/tests/probes/environmentvariable/test_probes_environmentvariable.sh
index af2b9cb..dffba08 100755
--- a/tests/probes/environmentvariable/test_probes_environmentvariable.sh
+++ b/tests/probes/environmentvariable/test_probes_environmentvariable.sh
@@ -22,12 +22,6 @@ function test_probes_environmentvariable {
     local DEFFILE="test_probes_environmentvariable.xml"
     local RESFILE="results.xml"
 
-    eval "which env  > /dev/null 2>&1"    
-    if [ ! $? -eq 0 ]; then		
-	echo -e "No env found in $PATH!\n" 
-	return 255; # Test is not applicable.
-    fi
-
     [ -f $RESFILE ] && rm -f $RESFILE
 
     bash ${srcdir}/test_probes_environmentvariable.xml.sh > $DEFFILE
diff --git a/tests/probes/vgtest/test_probes_vg.sh b/tests/probes/vgtest/test_probes_vg.sh
index 807bf44..64fe32e 100755
--- a/tests/probes/vgtest/test_probes_vg.sh
+++ b/tests/probes/vgtest/test_probes_vg.sh
@@ -17,11 +17,6 @@
 
 function test_probes_vg {
     
-    if ! which valgrind; then
-	echo "No valgrind installed, skipping" 
-	return 255
-    fi
-
     VGTEST_TMPDIR="/tmp/vgtest"
 
     if [[ ! -d "$VGTEST_TMPDIR" ]]; then
-- 
1.6.2.5




More information about the Open-scap-list mailing list