[Libguestfs] [PATCH] tests: simple test for execstack supermin

Pino Toscano ptoscano at redhat.com
Fri May 2 12:47:11 UTC 2014


Add a simple test which uses scanelf or readelf to detect whether the
supermin executable is really not executable.

Kind of followup of commit c9f7a7998021e1cbe22a8ec325d43e2bdc3eff5a.
---
 tests/Makefile.am       |  1 +
 tests/test-execstack.sh | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)
 create mode 100755 tests/test-execstack.sh

diff --git a/tests/Makefile.am b/tests/Makefile.am
index dc73737..4dc5958 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -23,6 +23,7 @@ EXTRA_DIST = \
 
 TESTS = \
 	test-basic.sh \
+	test-execstack.sh \
 	test-build-bash.sh \
 	test-binaries-exist.sh \
 	test-harder.sh
diff --git a/tests/test-execstack.sh b/tests/test-execstack.sh
new file mode 100755
index 0000000..a9cb5e0
--- /dev/null
+++ b/tests/test-execstack.sh
@@ -0,0 +1,32 @@
+#!/bin/bash -
+# supermin
+# (C) Copyright 2014 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+set -e
+
+if scanelf --help >/dev/null 2>&1; then
+    echo "using scanelf"
+    scanelf -e ../src/supermin
+    test `scanelf -qe ../src/supermin | wc -l` -eq 0
+elif readelf --help >/dev/null 2>&1; then
+    echo "using readelf"
+    readelf -lW ../src/supermin | grep GNU_STACK
+    ! readelf -lW ../src/supermin | grep GNU_STACK | grep 'E ' >/dev/null 2>&1
+else
+    echo "$0: test skipped because none of the following tools is installed: scanelf, readelf"
+    exit 77
+fi
-- 
1.9.0




More information about the Libguestfs mailing list