Skip to contentSkip to conversation

Add a new test suite called Functional.busybox.

PATCH In review Wang Mingyu 2 participants 3 messages May 24, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add a new test suite called Functional.busybox.

---
 engine/tests/Functional.busybox/fuego_test.sh | 51 +++++++++++++++++++++++++++
 engine/tests/Functional.busybox/parser.py     | 22 ++++++++++++
 engine/tests/Functional.busybox/spec.json     |  7 ++++
 3 files changed, 80 insertions(+)
 create mode 100755 engine/tests/Functional.busybox/fuego_test.sh
 create mode 100755 engine/tests/Functional.busybox/parser.py
 create mode 100644 engine/tests/Functional.busybox/spec.json
engine/tests/Functional.busybox/fuego_test.sh new file +51 -0
new file mode 100755
index 0000000..0b8ea54
@@ -0,0 +1,51 @@
+# $1: string with tests to skip separated by spaces
+# $2: absolute path to the skipfile (default: ${LOGDIR}/skiplist.txt)
+function skip_tests {
+    # split $1 on whitespace, without file globbing
+    set -f
+    local TESTS=($1)
+    local SKIPFILE="${LOGDIR}/skiplist.txt"
+    set +f
+    echo "Skipping tests: ${TESTS[@]}."
+    for testname in "${TESTS[@]}"; do
+        echo "$testname" >> ${SKIPFILE}
+    done
+}
+
+# $1: command/program to look for
+# $2: string with busybox test names separated by spaces
+# $3: This function may also be used in other tests, which can be considered as a general function of fuego.
+function skip_if_command_unavailable {
+    local PROGRAM="$1"
+    local TESTS="$2"
+    export FOUND=""
+
+    is_on_target_path ${PROGRAM} FOUND
+    if [ -z "${FOUND}" ]; then
+        echo "WARNING: ${PROGRAM} is not installed on the target."
+        skip_tests "${TESTS}"
+    fi
+}
+
+function test_pre_check {
+    echo "Tests skipped depending on the availability of a command on the target"
+    touch ${LOGDIR}/skiplist.txt
+    skip_if_command_unavailable expect "busybox_ash.sh"
+}
+
+function test_deploy {
+    put $TEST_HOME/busybox_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+    put ${LOGDIR}/skiplist.txt $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    export test_tcpip_host=$SRV_IP;\
+    export test_port_host=$SRV_PORT;\
+    sh -v busybox_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "4" "TEST-PASS" "p"
+}
engine/tests/Functional.busybox/parser.py new file +22 -0
new file mode 100755
index 0000000..d85abd7
@@ -0,0 +1,22 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+
+sys.path.insert(0, os.environ['FUEGO_CORE'] + '/engine/scripts/parser')
+import common as plib
+
+measurements = {}
+measurements = collections.OrderedDict()
+
+regex_string = '^ -> (.*): TEST-(.*)$'
+matches = plib.parse_log(regex_string)
+
+if matches:
+    for m in matches:
+        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
+
+# split the output for each testcase
+plib.split_output_per_testcase(regex_string, measurements)
+
+sys.exit(plib.process(measurements))
engine/tests/Functional.busybox/spec.json new file +7 -0
new file mode 100644
index 0000000..a71218a
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.busybox",
+    "specs": {
+        "default": {}
+    }
+}
+
Signature · 1 line
1.8.3.1
#1 lore raw

Applied and pushed, with a fixup patch applied on top.

Comments on what I changed are inline below.

Quoted 42 lines

-----Original Message-----
From: Wang Mingyu

---
 engine/tests/Functional.busybox/fuego_test.sh | 51
+++++++++++++++++++++++++++
 engine/tests/Functional.busybox/parser.py     | 22 ++++++++++++
 engine/tests/Functional.busybox/spec.json     |  7 ++++
 3 files changed, 80 insertions(+)
 create mode 100755 engine/tests/Functional.busybox/fuego_test.sh
 create mode 100755 engine/tests/Functional.busybox/parser.py
 create mode 100644 engine/tests/Functional.busybox/spec.json
engine/tests/Functional.busybox/fuego_test.sh new file +17 -0
new file mode 100755
index 0000000..0b8ea54
@@ -0,0 +1,51 @@
+# $1: string with tests to skip separated by spaces
+# $2: absolute path to the skipfile (default: ${LOGDIR}/skiplist.txt)
+function skip_tests {
+    # split $1 on whitespace, without file globbing
+    set -f
+    local TESTS=($1)
+    local SKIPFILE="${LOGDIR}/skiplist.txt"
+    set +f
+    echo "Skipping tests: ${TESTS[@]}."
+    for testname in "${TESTS[@]}"; do
+        echo "$testname" >> ${SKIPFILE}
+    done
+}
+
+# $1: command/program to look for
+# $2: string with busybox test names separated by spaces
+# $3: This function may also be used in other tests, which can be considered

as a general function of fuego.

engine/tests/Functional.busybox/fuego_test.sh new file +3 -0
+function skip_if_command_unavailable {
+    local PROGRAM="$1"
+    local TESTS="$2"

engine/tests/Functional.busybox/fuego_test.sh line 30

Quoted 10 lines
engine/tests/Functional.busybox/fuego_test.sh new file +10 -0
+    export FOUND=""
+
+    is_on_target_path ${PROGRAM} FOUND
+    if [ -z "${FOUND}" ]; then
+        echo "WARNING: ${PROGRAM} is not installed on the target."
+        skip_tests "${TESTS}"
+    fi
+}
+
+function test_pre_check {

I added the following here:
is_on_target_path busybox PROGRAM_BUSYBOX
assert_define PROGRAM_BUSYBOX "Missing 'busybox' program on target board"
This aborts the whole test is busybox is not on the board.

Quoted 6 lines

+ echo "Tests skipped depending on the availability of a command on the
target"

engine/tests/Functional.busybox/fuego_test.sh new file +4 -0
+    touch ${LOGDIR}/skiplist.txt
+    skip_if_command_unavailable expect "busybox_ash.sh"
+}
+

engine/tests/Functional.busybox/fuego_test.sh line 45

Quoted 10 lines
engine/tests/Functional.busybox/fuego_test.sh new file +10 -0
+function test_deploy {
+    put $TEST_HOME/busybox_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+    put ${LOGDIR}/skiplist.txt $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    export test_tcpip_host=$SRV_IP;\
+    export test_port_host=$SRV_PORT;\

I added a default value here for SRV_PORT:
export test_port_host=${SRV_PORT:=8080};

Quoted 1 line

+ sh -v busybox_test.sh"

I indented these lines 1 more indent (4 spaces).

engine/tests/Functional.busybox/fuego_test.sh line 50

Quoted 4 lines
engine/tests/Functional.busybox/fuego_test.sh new file +4 -0
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "4" "TEST-PASS" "p"

I switched this to a "negative" compare. That will make is so that if tests are skipped, the log_compare still works. Otherwise, if a test is skipped, the number of PASSes is not right. Also, as tests are added, this line doesn't need to be updated.

The new line is:
log_compare "$TESTDIR" "0" "TEST-FAIL" "n"

Quoted 45 lines
engine/tests/Functional.busybox/fuego_test.sh new file +1 -0
+}
engine/tests/Functional.busybox/parser.py new file +22 -0
new file mode 100755
index 0000000..d85abd7
@@ -0,0 +1,22 @@
+#!/usr/bin/python
+# See common.py for description of command-line arguments
+
+import os, sys, collections
+
+sys.path.insert(0, os.environ['FUEGO_CORE'] + '/engine/scripts/parser')
+import common as plib
+
+measurements = {}
+measurements = collections.OrderedDict()
+
+regex_string = '^ -> (.*): TEST-(.*)$'
+matches = plib.parse_log(regex_string)
+
+if matches:
+    for m in matches:
+        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
+
+# split the output for each testcase
+plib.split_output_per_testcase(regex_string, measurements)
+
+sys.exit(plib.process(measurements))
engine/tests/Functional.busybox/spec.json new file +7 -1
new file mode 100644
index 0000000..a71218a
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.busybox",
+    "specs": {
+        "default": {}
+    }
+}
+
--
Quoted 1 line

1.8.3.1

You may want to pull my latest fuego-core, and see the fixup patch I did.

This test helped me find a bug in ov_transport_put (for TRANSPORT 'local')! That was a nice find. :-)

Thanks!
-- Tim

#2 lore raw
Quoted 4 lines

-----Original Message-----
This aborts the whole test is busybox is not on the board.

Should be:

... if busybox is not on the board.

('if', not 'is', for the word before 'busybox').
-- Tim