public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/elfix:master commit in: /, tests/gnustack/, tests/pxtpax/
@ 2012-12-13  4:05 Anthony G. Basile
  0 siblings, 0 replies; only message in thread
From: Anthony G. Basile @ 2012-12-13  4:05 UTC (permalink / raw
  To: gentoo-commits

commit:     845ef1babaea9aa26aec68cb162b2693f79bbe5f
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 13 04:04:40 2012 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Thu Dec 13 04:05:09 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=845ef1ba

tests/{gnustack,pxtpax}: return success/failure, reduce vebosity

---
 configure.ac                   |    2 +
 tests/gnustack/Makefile.am     |   16 ++-----
 tests/gnustack/gnustacktest.sh |   27 ++++++++++++
 tests/pxtpax/Makefile.am       |   11 ++++-
 tests/pxtpax/daemontest.sh     |   89 ++++++++++++++++++++++++++++++++++++++++
 tests/pxtpax/dotest.sh         |   43 -------------------
 6 files changed, 130 insertions(+), 58 deletions(-)

diff --git a/configure.ac b/configure.ac
index 7c7e3f7..a06a23b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -111,6 +111,8 @@ if [test "x$enable_ptpax" = "xno" -a  "x$enable_xtpax" = "xno" ]; then
 	AC_MSG_ERROR(["You must enable either ptpax or xtpax"])
 fi
 
+AM_CONDITIONAL([DUALTEST],[test "x$enable_ptpax" = "xyes" -a  "x$enable_xtpax" = "xyes"])
+
 # Ready to configure our files
 AC_CONFIG_FILES([
 	Makefile

diff --git a/tests/gnustack/Makefile.am b/tests/gnustack/Makefile.am
index 6f5f569..783e956 100644
--- a/tests/gnustack/Makefile.am
+++ b/tests/gnustack/Makefile.am
@@ -7,18 +7,10 @@ bad-gnustack.s: bad-gnustack.c
 bad-gnustack: bad-gnustack.s
 	$(CC) -o $@ $<
 
-check_SCRIPTS = test.sh
+check_SCRIPTS = gnustacktest
 TEST = $(check_SCRIPTS)
 
-test.sh:
-	@echo "================================================================================"
-	@echo
-	@echo "Before GNU_STACK Elf: "
-	@../../src/fix-gnustack -f bad-gnustack
-	@echo
-	@echo "After GNU_STACK Elf: "
-	@../../src/fix-gnustack bad-gnustack
-	@echo
-	@echo "================================================================================"
+gnustacktest:
+	./gnustacktest.sh 0
 
-CLEANFILES = *.o *.s test.sh
+CLEANFILES = *.o *.s

diff --git a/tests/gnustack/gnustacktest.sh b/tests/gnustack/gnustacktest.sh
new file mode 100755
index 0000000..518f4c5
--- /dev/null
+++ b/tests/gnustack/gnustacktest.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+verbose=${1-0}
+
+echo "================================================================================"
+echo
+echo " RUNNING GNU_STACK TEST"
+before=$(../../src/fix-gnustack -f bad-gnustack)
+before=$(echo ${before} | awk '{ print $2 }')
+after=$(../../src/fix-gnustack bad-gnustack)
+after=$(echo ${after} | awk '{ print $2 }')
+rm bad-gnustack
+if [ "${verbose}" != 0 ]; then
+	echo " BEFRE=${before}"
+	echo " AFTER=${after}"
+fi
+if [ "${before}" = "RWX" -a "${after}" = "RW" ]; then
+	echo " OK"
+	ret=0
+else
+	echo " NOT OKAY"
+	ret=1
+fi
+echo
+echo "================================================================================"
+
+exit $ret

diff --git a/tests/pxtpax/Makefile.am b/tests/pxtpax/Makefile.am
index 55f9957..1072252 100644
--- a/tests/pxtpax/Makefile.am
+++ b/tests/pxtpax/Makefile.am
@@ -3,10 +3,15 @@ daemon_SOURCES = daemon.c
 
 EXTRA_DIST = init.sh dotest.sh
 
-check_SCRIPTS = test.sh
+check_SCRIPTS = daemontest
 TEST = $(check_SCRIPTS)
 
-test.sh:
-	./dotest.sh
+if DUALTEST
+daemontest:
+	./daemontest.sh 1 0
+else
+daemontest:
+	./daemontest.sh 0 0
+endif
 
 CLEANFILES = daemon.pid

diff --git a/tests/pxtpax/daemontest.sh b/tests/pxtpax/daemontest.sh
new file mode 100755
index 0000000..c5d079d
--- /dev/null
+++ b/tests/pxtpax/daemontest.sh
@@ -0,0 +1,89 @@
+#!/bin/bash
+
+# dotest = 0 -> do only XT_PAX or PT_PAX test
+# dotest = 1 -> do both
+dotest=${1-0}
+verbose=${2-0}
+
+PWD=$(pwd)
+INITSH="${PWD}"/init.sh
+DAEMON="${PWD}"/daemon
+PIDFILE="${PWD}"/daemon.pid
+PAXCTLNG="../../src/paxctl-ng"
+
+${PAXCTLNG} -cv ${DAEMON} 2>&1 1>/dev/null
+
+count=0
+
+echo "================================================================================"
+echo
+echo " RUNNIG DAEMON TEST"
+
+for pf in "p" "P" "-"; do
+  for ef in "e" "E" "-"; do
+    for mf in "m" "M" "-"; do
+      for rf in "r" "R" "-"; do
+        for sf in "s" "S" "-"; do
+
+          pflags="${pf}${ef}${mf}${rf}${sf}"
+          if [ "${verbose}" != 0 ] ;then
+            echo "SET TO :" ${pflags}
+          fi
+
+          flags="${pf/-/Pp}${ef/-/Ee}${mf/-/Mm}${rf/-/Rr}${sf/-/Ss}"
+          ${PAXCTLNG} -"${flags}" ${DAEMON} >/dev/null 2>&1
+
+          if [ "${verbose}" != 0 ] ;then
+            sflags=$(${PAXCTLNG} -v ${DAEMON})
+            if [ "${dotest}" = "0" ]; then
+              sflags=$(echo ${sflags} | awk '{print $3}')
+              echo "GOT    :"  ${sflags}
+            else
+              ptsflags=$(echo ${sflags} | awk '{print $3}')
+              xtsflags=$(echo ${sflags} | awk '{print $5}')
+              echo "PT_PAX :"  ${ptsflags}
+              echo "XT_PAX :"  ${xtsflags}
+            fi
+          fi
+
+          ${INITSH} start
+          if [ -f "${PIDFILE}" ]
+          then
+            rflags=$(cat /proc/$(cat ${PIDFILE})/status | grep ^PaX | awk '{ print $2 }')
+            if [ "${verbose}" != 0 ] ;then
+              echo "RUNNING: "${rflags}
+            fi
+            ${INITSH} stop
+          else
+            if [ "${verbose}" != 0 ] ;then
+              echo "RUNNING: no daemon"
+            fi
+            rflags="-----"
+          fi
+
+          # Skip i = 4 which is S which is not set
+          for i in 0 1 2 3; do
+            p=${pflags:$i:1}
+            r=${rflags:$i:1}
+            if [ $p != "-" ]; then
+              if [ $p != $r -a $r != "-" ]; then
+                (( count = count + 1 ))
+                echo "Mismatch: ${pflags} ${rflags}"
+              fi
+            fi
+          done
+          if [ "${verbose}" != 0 ] ;then
+            echo
+          fi
+
+        done
+      done
+    done
+  done
+done
+
+echo " Mismatches = ${count}"
+echo
+echo "================================================================================"
+
+exit $count

diff --git a/tests/pxtpax/dotest.sh b/tests/pxtpax/dotest.sh
deleted file mode 100755
index 4e7c371..0000000
--- a/tests/pxtpax/dotest.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/bash
-
-PWD=$(pwd)
-INITSH="${PWD}"/init.sh
-DAEMON="${PWD}"/daemon
-PIDFILE="${PWD}"/daemon.pid
-PAXCTLNG="../../src/paxctl-ng"
-
-${PAXCTLNG} -cv ${DAEMON} 2>&1 1>/dev/null
-
-for pf in "p" "P" "-"; do
-  for ef in "e" "E" "-"; do
-    for mf in "m" "M" "-"; do
-      for rf in "r" "R" "-"; do
-        for sf in "s" "S" "-"; do
-
-          pflags="${pf}${ef}${mf}${rf}${sf}"
-          echo "SET TO :" ${pflags}
-
-          flags="${pf/-/Pp}${ef/-/Ee}${mf/-/Mm}${rf/-/Rr}${sf/-/Ss}"
-          ${PAXCTLNG} -"${flags}" ${DAEMON} >/dev/null 2>&1
-
-          sflags=$(${PAXCTLNG} -v ${DAEMON})
-          sflags=$(echo ${sflags} | awk '{print $3}')
-          echo "GOT    :"  ${sflags}
-
-          ${INITSH} start
-          if [ -f "${PIDFILE}" ]
-          then
-            rflags=$(cat /proc/$(cat ${PIDFILE})/status | grep ^PaX | awk '{ print $2 }')
-            echo -n "RUNNING: "${rflags}
-            ${INITSH} stop
-          else
-            echo -n "RUNNING: no daemon"
-          fi
-
-          echo
-          echo
-        done
-      done
-    done
-  done
-done


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2012-12-13  4:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-13  4:05 [gentoo-commits] proj/elfix:master commit in: /, tests/gnustack/, tests/pxtpax/ Anthony G. Basile

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox