diff mbox

[i-g-t,7/7] tests: add a check for command line handling

Message ID 1413478193-7970-8-git-send-email-thomas.wood@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Thomas Wood Oct. 16, 2014, 4:49 p.m. UTC
Check that command line handling works consistently across all tests.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
---
 tests/Makefile.sources    |  6 +++++
 tests/igt_command_line.sh | 61 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+)
 create mode 100755 tests/igt_command_line.sh
diff mbox

Patch

diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index 89596e6..88bb854 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -202,8 +202,13 @@  TESTS_testsuite = \
 	igt_simulation \
 	$(NULL)
 
+TESTS_testsuite_scripts = \
+	igt_command_line.sh \
+	$(NULL)
+
 TESTS = \
 	$(TESTS_testsuite) \
+	$(TESTS_testsuite_scripts) \
 	$(NULL)
 
 # Test that exercise specific asserts in the test framework library and are
@@ -229,6 +234,7 @@  scripts = \
 	ddx_intel_after_fbdev \
 	debugfs_wedged \
 	drm_lib.sh \
+	igt_command_line.sh \
 	$(NULL)
 
 IMAGES = pass.png 1080p-left.png 1080p-right.png
diff --git a/tests/igt_command_line.sh b/tests/igt_command_line.sh
new file mode 100755
index 0000000..075f1d5
--- /dev/null
+++ b/tests/igt_command_line.sh
@@ -0,0 +1,61 @@ 
+#!/bin/sh
+#
+# Copyright © 2014 Intel Corporation
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+#
+# Check that command line handling works consistently across all tests
+#
+
+for test in `cat single-tests.txt multi-tests.txt`; do
+
+	if [ "$test" = "TESTLIST" -o "$test" = "END" ]; then
+		continue
+	fi
+
+	# if the test is a script, it will be in $srcdir
+	if [ ! -x $test ]; then
+		if [ -x $srcdir/$test ]; then
+			test=$srcdir/$test
+		fi
+	fi
+
+	echo "$test:"
+
+	# check invalid option handling
+	echo "  Checking invalid option handling..."
+	./$test --invalid-option 2> /dev/null && exit 99
+
+	# check valid options succeed
+	echo "  Checking valid option handling..."
+	./$test --help > /dev/null || exit 99
+
+	# check --list-subtests works correctly
+	echo "  Checking subtest enumeration..."
+	./$test --list-subtests > /dev/null
+	if [ $? -ne 0 -a $? -ne 79 ]; then
+		exit 99
+	fi
+
+	# check invalid subtest handling
+	echo "  Checking invalid subtest handling..."
+	./$test --run-subtest invalid-subtest > /dev/null 2>&1 && exit 99
+done