[Pdbg] [PATCH 4/4] tests: Add target selection tests

Amitay Isaacs amitay at ozlabs.org
Mon Aug 13 13:05:06 AEST 2018


Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
 Makefile.am             |   8 +-
 tests/test_selection.sh | 496 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 502 insertions(+), 2 deletions(-)
 create mode 100755 tests/test_selection.sh

diff --git a/Makefile.am b/Makefile.am
index d7254ff..571660d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -6,7 +6,10 @@ GIT_SHA1 ?= `git --work-tree=$(top_srcdir) --git-dir=$(top_srcdir)/.git describe
 bin_PROGRAMS = pdbg
 check_PROGRAMS = optcmd_test
 
-TESTS = optcmd_test
+PDBG_TESTS = \
+	tests/test_selection.sh
+
+TESTS = optcmd_test $(PDBG_TESTS)
 
 TEST_EXTENSIONS = .sh
 SH_LOG_DRIVER = $(SHELL) $(srcdir)/tests/run_test.sh
@@ -31,7 +34,8 @@ EXTRA_DIST = \
 	generate_dt_header.sh \
 	tests/driver.sh \
 	tests/run_test.sh \
-	tests/test_driver.sh
+	tests/test_driver.sh \
+	$(PDBG_TESTS)
 
 if TARGET_ARM
 DT_ARM = p8-fsi.dts p8-i2c.dts \
diff --git a/tests/test_selection.sh b/tests/test_selection.sh
new file mode 100755
index 0000000..606b99c
--- /dev/null
+++ b/tests/test_selection.sh
@@ -0,0 +1,496 @@
+#!/bin/sh
+
+. $(dirname "$0")/driver.sh
+
+test_group "target selection tests"
+
+arch=$(arch 2>/dev/null)
+
+do_skip ()
+{
+	if [ "$arch" != "x86_64" ] ; then
+		test_skip
+	fi
+}
+
+test_result 0 <<EOF
+
+Note that only selected targets will be shown above. If none are shown
+try adding '-a' to select all targets
+EOF
+
+do_skip
+test_run pdbg -b fake probe
+
+
+test_result 0 <<EOF
+p0: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c1: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c2: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c3: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+p1: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c1: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c2: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c3: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+p2: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c1: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c2: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c3: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+p3: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c1: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c2: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c3: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+p4: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c1: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c2: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c3: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+p5: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c1: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c2: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c3: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+p6: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c1: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c2: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c3: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+p7: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c1: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c2: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c3: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+
+Note that only selected targets will be shown above. If none are shown
+try adding '-a' to select all targets
+EOF
+
+do_skip
+test_run pdbg -b fake -a probe
+
+
+test_result 0 <<EOF
+p0: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c1: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c2: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+    c3: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+
+Note that only selected targets will be shown above. If none are shown
+try adding '-a' to select all targets
+EOF
+
+do_skip
+test_run pdbg -b fake -p0 -a probe
+
+
+test_result 0 <<EOF
+p0: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+p1: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+p2: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+p3: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+p4: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+p5: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+p6: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+p7: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+
+Note that only selected targets will be shown above. If none are shown
+try adding '-a' to select all targets
+EOF
+
+do_skip
+test_run pdbg -b fake -c0 -a probe
+
+
+test_result 0 <<EOF
+p0: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+    c1: Fake Core
+        t0: Fake Thread
+    c2: Fake Core
+        t0: Fake Thread
+    c3: Fake Core
+        t0: Fake Thread
+p1: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+    c1: Fake Core
+        t0: Fake Thread
+    c2: Fake Core
+        t0: Fake Thread
+    c3: Fake Core
+        t0: Fake Thread
+p2: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+    c1: Fake Core
+        t0: Fake Thread
+    c2: Fake Core
+        t0: Fake Thread
+    c3: Fake Core
+        t0: Fake Thread
+p3: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+    c1: Fake Core
+        t0: Fake Thread
+    c2: Fake Core
+        t0: Fake Thread
+    c3: Fake Core
+        t0: Fake Thread
+p4: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+    c1: Fake Core
+        t0: Fake Thread
+    c2: Fake Core
+        t0: Fake Thread
+    c3: Fake Core
+        t0: Fake Thread
+p5: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+    c1: Fake Core
+        t0: Fake Thread
+    c2: Fake Core
+        t0: Fake Thread
+    c3: Fake Core
+        t0: Fake Thread
+p6: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+    c1: Fake Core
+        t0: Fake Thread
+    c2: Fake Core
+        t0: Fake Thread
+    c3: Fake Core
+        t0: Fake Thread
+p7: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+    c1: Fake Core
+        t0: Fake Thread
+    c2: Fake Core
+        t0: Fake Thread
+    c3: Fake Core
+        t0: Fake Thread
+
+Note that only selected targets will be shown above. If none are shown
+try adding '-a' to select all targets
+EOF
+
+do_skip
+test_run pdbg -b fake -t0 -a probe
+
+
+test_result 0 <<EOF
+p0: Fake PIB
+    c2: Fake Core
+        t0: Fake Thread
+        t1: Fake Thread
+
+Note that only selected targets will be shown above. If none are shown
+try adding '-a' to select all targets
+EOF
+
+do_skip
+test_run pdbg -b fake -p0 -c2 -a probe
+
+
+test_result 0 <<EOF
+p0: Fake PIB
+    c2: Fake Core
+        t1: Fake Thread
+
+Note that only selected targets will be shown above. If none are shown
+try adding '-a' to select all targets
+EOF
+
+do_skip
+test_run pdbg -b fake -p0 -c2 -t1 -a probe
+
+
+test_result 0 <<EOF
+p1: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+p2: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+p3: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+p5: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+p6: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+
+Note that only selected targets will be shown above. If none are shown
+try adding '-a' to select all targets
+
+EOF
+
+do_skip
+test_run pdbg -b fake -p1-3,5,5-6 -c0 -t0 probe
+
+
+test_result 0 <<EOF
+p0: Fake PIB
+
+Note that only selected targets will be shown above. If none are shown
+try adding '-a' to select all targets
+EOF
+
+do_skip
+test_run pdbg -b fake -p0 probe
+
+
+test_result 1 <<EOF
+No processor(s) selected
+Use -p or -a to select processor(s)
+EOF
+
+do_skip
+test_run pdbg -b fake -c0 probe
+
+
+test_result 1 <<EOF
+No processor(s) selected
+Use -p or -a to select processor(s)
+EOF
+
+do_skip
+test_run pdbg -b fake -t0 probe
+
+
+test_result 1 <<EOF
+No processor(s) selected
+Use -p or -a to select processor(s)
+EOF
+
+do_skip
+test_run pdbg -b fake -c0 -t0 probe
+
+
+test_result 1 <<EOF
+No chip(s) selected
+Use -c or -a to select chip(s)
+EOF
+
+do_skip
+test_run pdbg -b fake -t0 -p0 probe
+
+
+test_result 0 <<EOF
+p0: Fake PIB
+    c0: Fake Core
+
+Note that only selected targets will be shown above. If none are shown
+try adding '-a' to select all targets
+EOF
+
+do_skip
+test_run pdbg -b fake -c0 -p0 probe
+
+
+test_result 0 <<EOF
+p0: Fake PIB
+    c0: Fake Core
+        t0: Fake Thread
+
+Note that only selected targets will be shown above. If none are shown
+try adding '-a' to select all targets
+EOF
+
+do_skip
+test_run pdbg -b fake -t0 -c0 -p0 probe
+
+
+test_result 0 <<EOF
+p1: Fake PIB
+    c1: Fake Core
+        t0: Fake Thread
+    c3: Fake Core
+        t0: Fake Thread
+p3: Fake PIB
+    c1: Fake Core
+        t0: Fake Thread
+    c3: Fake Core
+        t0: Fake Thread
+p5: Fake PIB
+    c1: Fake Core
+        t0: Fake Thread
+    c3: Fake Core
+        t0: Fake Thread
+p7: Fake PIB
+    c1: Fake Core
+        t0: Fake Thread
+    c3: Fake Core
+        t0: Fake Thread
+
+Note that only selected targets will be shown above. If none are shown
+try adding '-a' to select all targets
+EOF
+
+do_skip
+test_run pdbg -b fake -p1,3,5,7,9 -c1,3,5 -t0,2 probe
+
+
+test_result 0 <<EOF
+p1: Fake PIB
+    c1: Fake Core
+        t1: Fake Thread
+    c3: Fake Core
+        t1: Fake Thread
+p3: Fake PIB
+    c1: Fake Core
+        t1: Fake Thread
+    c3: Fake Core
+        t1: Fake Thread
+p5: Fake PIB
+    c1: Fake Core
+        t1: Fake Thread
+    c3: Fake Core
+        t1: Fake Thread
+p7: Fake PIB
+    c1: Fake Core
+        t1: Fake Thread
+    c3: Fake Core
+        t1: Fake Thread
+
+Note that only selected targets will be shown above. If none are shown
+try adding '-a' to select all targets
+EOF
+
+do_skip
+test_run pdbg -b fake -p1,3 -p5 -p7-9 -c1 -c3 -c5 -t1 probe
+
+
+test_result 1 <<EOF
+Value 100 larger than max 63
+Failed to parse '-p 100'
+EOF
+
+do_skip
+test_run pdbg -b fake -p100 probe
+
+
+test_result 1 <<EOF
+Value 100 larger than max 23
+Failed to parse '-c 100'
+EOF
+
+do_skip
+test_run pdbg -b fake -c100 probe
+
+
+test_result 1 <<EOF
+Value 100 larger than max 7
+Failed to parse '-t 100'
+EOF
+
+do_skip
+test_run pdbg -b fake -t100 probe
-- 
2.17.1



More information about the Pdbg mailing list