Skip to contentSkip to conversation

Add test cases for command acpid.

PATCH New Wang Mingyu 1 participant 2 messages Aug 10, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add test cases for command acpid.

---
 engine/tests/Functional.acpid/acpid_test.sh        |  4 ++
 engine/tests/Functional.acpid/datas/test_action.sh |  6 ++
 engine/tests/Functional.acpid/datas/testfunc.sh    | 13 ++++
 engine/tests/Functional.acpid/datas/testhkey       |  2 +
 engine/tests/Functional.acpid/fuego_test.sh        | 20 +++++++
 engine/tests/Functional.acpid/parser.py            | 22 +++++++
 engine/tests/Functional.acpid/spec.json            |  7 +++
 engine/tests/Functional.acpid/tests/acpid_help.sh  | 13 ++++
 .../tests/Functional.acpid/tests/acpid_logfile.sh  | 47 +++++++++++++++
 engine/tests/Functional.acpid/tests/acpid_ps.sh    | 41 +++++++++++++
 .../tests/Functional.acpid/tests/acpid_reload.sh   | 70 ++++++++++++++++++++++
 .../Functional.acpid/tests/acpid_socketfile.sh     | 47 +++++++++++++++
 12 files changed, 292 insertions(+)
 create mode 100644 engine/tests/Functional.acpid/acpid_test.sh
 create mode 100644 engine/tests/Functional.acpid/datas/test_action.sh
 create mode 100644 engine/tests/Functional.acpid/datas/testfunc.sh
 create mode 100644 engine/tests/Functional.acpid/datas/testhkey
 create mode 100644 engine/tests/Functional.acpid/fuego_test.sh
 create mode 100644 engine/tests/Functional.acpid/parser.py
 create mode 100644 engine/tests/Functional.acpid/spec.json
 create mode 100644 engine/tests/Functional.acpid/tests/acpid_help.sh
 create mode 100644 engine/tests/Functional.acpid/tests/acpid_logfile.sh
 create mode 100644 engine/tests/Functional.acpid/tests/acpid_ps.sh
 create mode 100644 engine/tests/Functional.acpid/tests/acpid_reload.sh
 create mode 100644 engine/tests/Functional.acpid/tests/acpid_socketfile.sh
engine/tests/Functional.acpid/acpid_test.sh new file +4 -0
new file mode 100644
index 0000000..dd5ce37
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
engine/tests/Functional.acpid/datas/test_action.sh new file +6 -0
new file mode 100644
index 0000000..904dba8
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+sync
+sync
+sleep 2
+echo "acpi test"
engine/tests/Functional.acpid/datas/testfunc.sh new file +13 -0
new file mode 100644
index 0000000..b13041c
@@ -0,0 +1,13 @@
+# $1: Used to determine whether the command line execution result is correct or not
+function exec_service_on_target {
+local service_name="$1"
+local action="$2"
+if [ "$init_manager" = "sysvinit" ]
+then 
+    $service_name $action
+elif [ "$init_manager" = "systemd" ]
+then
+    systemctl $action $service_name
+fi
+return
+}
engine/tests/Functional.acpid/datas/testhkey new file +2 -0
new file mode 100644
index 0000000..6e234fc
@@ -0,0 +1,2 @@
+event=button/sleep *
+action=/etc/acpi/actions/test_action.sh
engine/tests/Functional.acpid/fuego_test.sh new file +20 -0
new file mode 100644
index 0000000..56b5d7f
@@ -0,0 +1,20 @@
+function test_pre_check {
+    is_on_target_path acpid PROGRAM_ACPID
+    assert_define PROGRAM_ACPID "Missing 'acpid' program on target board"
+}
+
+function test_deploy {
+    put $TEST_HOME/acpid_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/datas $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    export init_manager=systemd;\
+    sh -v acpid_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
engine/tests/Functional.acpid/parser.py new file +22 -0
new file mode 100644
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.acpid/spec.json new file +7 -0
new file mode 100644
index 0000000..1a7630e
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.acpid",
+    "specs": {
+        "default": {}
+    }
+}
+
engine/tests/Functional.acpid/tests/acpid_help.sh new file +13 -0
new file mode 100644
index 0000000..c0ad586
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+#  In target, run comannd acpi_listen.
+#  To make sure that there is string "Usage" in output.
+
+test="help"
+
+if acpi_listen -h | grep Usage
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi;
engine/tests/Functional.acpid/tests/acpid_logfile.sh new file +47 -0

47 lines not on this page · raw message

engine/tests/Functional.acpid/tests/acpid_ps.sh new file +41 -0

41 lines not on this page · raw message

engine/tests/Functional.acpid/tests/acpid_reload.sh new file +70 -0

70 lines not on this page · raw message

engine/tests/Functional.acpid/tests/acpid_socketfile.sh new file +47 -0

47 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 Add test cases for command brctl.

---
 engine/tests/Functional.brctl/brctl_test.sh        |  4 ++++
 engine/tests/Functional.brctl/fuego_test.sh        | 18 ++++++++++++++++++
 engine/tests/Functional.brctl/parser.py            | 22 ++++++++++++++++++++++
 engine/tests/Functional.brctl/spec.json            |  7 +++++++
 engine/tests/Functional.brctl/tests/brctl_addbr.sh | 15 +++++++++++++++
 engine/tests/Functional.brctl/tests/brctl_delbr.sh | 14 ++++++++++++++
 .../Functional.brctl/tests/brctl_setageing.sh      | 16 ++++++++++++++++
 .../tests/Functional.brctl/tests/brctl_sethello.sh | 16 ++++++++++++++++
 engine/tests/Functional.brctl/tests/brctl_show.sh  | 15 +++++++++++++++
 .../tests/Functional.brctl/tests/brctl_showstp.sh  | 15 +++++++++++++++
 10 files changed, 142 insertions(+)
 create mode 100644 engine/tests/Functional.brctl/brctl_test.sh
 create mode 100644 engine/tests/Functional.brctl/fuego_test.sh
 create mode 100644 engine/tests/Functional.brctl/parser.py
 create mode 100644 engine/tests/Functional.brctl/spec.json
 create mode 100644 engine/tests/Functional.brctl/tests/brctl_addbr.sh
 create mode 100644 engine/tests/Functional.brctl/tests/brctl_delbr.sh
 create mode 100644 engine/tests/Functional.brctl/tests/brctl_setageing.sh
 create mode 100644 engine/tests/Functional.brctl/tests/brctl_sethello.sh
 create mode 100644 engine/tests/Functional.brctl/tests/brctl_show.sh
 create mode 100644 engine/tests/Functional.brctl/tests/brctl_showstp.sh
engine/tests/Functional.brctl/brctl_test.sh new file +4 -0
new file mode 100644
index 0000000..dd5ce37
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
engine/tests/Functional.brctl/fuego_test.sh new file +18 -0
new file mode 100644
index 0000000..fb52758
@@ -0,0 +1,18 @@
+function test_pre_check {
+    is_on_target_path brctl PROGRAM_BRCTL
+    assert_define PROGRAM_BRCTL "Missing 'brctl' program on target board"
+}
+
+function test_deploy {
+    put $TEST_HOME/brctl_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    sh -v brctl_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
engine/tests/Functional.brctl/parser.py new file +22 -0
new file mode 100644
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.brctl/spec.json new file +7 -0
new file mode 100644
index 0000000..f0dcc8e
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.brctl",
+    "specs": {
+        "default": {}
+    }
+}
+
engine/tests/Functional.brctl/tests/brctl_addbr.sh new file +15 -0
new file mode 100644
index 0000000..78678c3
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+#  In the target to execute command brct; and confirm the result.
+#  option : addbr
+
+test="brctl->addbr"
+
+brctl addbr br0
+if ifconfig br0
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+brctl delbr br0
engine/tests/Functional.brctl/tests/brctl_delbr.sh new file +14 -0
new file mode 100644
index 0000000..bafe33f
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+#  In the target to execute command brct; and confirm the result.
+#  option : delbr
+
+test="brctl->delbr"
+
+brctl addbr br0
+if brctl delbr br0
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
engine/tests/Functional.brctl/tests/brctl_setageing.sh new file +16 -0
new file mode 100644
index 0000000..20d1e68
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+#  In the target to execute command brct; and confirm the result.
+#  option : setageing
+
+test="brctl->setageing"
+
+brctl addbr br0
+brctl setageing br0 200.00
+if brctl showstp br0 | grep "ageing time.*200.00"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+brctl delbr br0
engine/tests/Functional.brctl/tests/brctl_sethello.sh new file +16 -0
new file mode 100644
index 0000000..4e351b7
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+#  In the target to execute command brct; and confirm the result.
+#  option : sethello
+
+test="brctl->sethello"
+
+brctl addbr br0
+brctl sethello br0 5.00
+if brctl showstp br0 | grep "hello time.*5.00"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+brctl delbr br0
engine/tests/Functional.brctl/tests/brctl_show.sh new file +15 -0
new file mode 100644
index 0000000..68d9c02
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+#  In the target to execute command brct; and confirm the result.
+#  option : show
+
+test="brctl->show"
+
+brctl addbr br0
+if brctl show | grep br0
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+brctl delbr br0
engine/tests/Functional.brctl/tests/brctl_showstp.sh new file +15 -0
new file mode 100644
index 0000000..9ce687b
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+#  In the target to execute command brct; and confirm the result.
+#  option : showstp
+
+test="brctl->showstp"
+
+brctl addbr br0
+if brctl showstp br0 | grep "bridge id"
+then
+    echo " -> $test: TEST-PASS"
+else
+    echo " -> $test: TEST-FAIL"
+fi
+brctl delbr br0
Signature · 1 line
1.8.3.1