[Fuego] [PATCH 1/6] Add test script for commands of misc.

Wang Mingyu wangmy at cn.fujitsu.com
Tue Nov 6 13:56:42 UTC 2018


Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
---
 engine/tests/Functional.misc/data/tst-float.pl |  5 +++
 engine/tests/Functional.misc/fuego_test.sh     | 51 +++++++++++++++++++++
 engine/tests/Functional.misc/misc_test.sh      |  4 ++
 engine/tests/Functional.misc/parser.py         | 22 ++++++++++
 engine/tests/Functional.misc/spec.json         |  7 +++
 engine/tests/Functional.misc/test.yaml         | 61 ++++++++++++++++++++++++++
 6 files changed, 150 insertions(+)
 create mode 100755 engine/tests/Functional.misc/data/tst-float.pl
 create mode 100644 engine/tests/Functional.misc/fuego_test.sh
 create mode 100755 engine/tests/Functional.misc/misc_test.sh
 create mode 100644 engine/tests/Functional.misc/parser.py
 create mode 100644 engine/tests/Functional.misc/spec.json
 create mode 100644 engine/tests/Functional.misc/test.yaml

diff --git a/engine/tests/Functional.misc/data/tst-float.pl b/engine/tests/Functional.misc/data/tst-float.pl
new file mode 100755
index 0000000..89709d5
--- /dev/null
+++ b/engine/tests/Functional.misc/data/tst-float.pl
@@ -0,0 +1,5 @@
+#!/usr/bin/perl
+
+use Env;
+$float_val=1.0/2;
+print "test:$float_val\n";
diff --git a/engine/tests/Functional.misc/fuego_test.sh b/engine/tests/Functional.misc/fuego_test.sh
new file mode 100644
index 0000000..db29d5b
--- /dev/null
+++ b/engine/tests/Functional.misc/fuego_test.sh
@@ -0,0 +1,51 @@
+function test_pre_check {
+    assert_has_program nslookup
+    assert_has_program bzip2
+    assert_has_program saslauthd
+    assert_has_program dbus-cleanup-sockets
+    assert_has_program dumpe2fs
+    assert_has_program su
+    assert_has_program gawk
+    assert_has_program gdb
+    assert_has_program gettext
+    assert_has_program grep
+    assert_has_program ip
+    assert_has_program iptables
+    assert_has_program ping
+    assert_has_program mktemp
+    assert_has_program clear
+    assert_has_program snmpd
+    assert_has_program nfsstat
+    assert_has_program ssh-agent
+    assert_has_program sshd
+    assert_has_program openssl
+    assert_has_program perl
+    assert_has_program pm-powersave
+    assert_has_program uptime
+    assert_has_program rpm
+    assert_has_program useradd
+    assert_has_program strace
+    assert_has_program try-from
+    assert_has_program in.tftpd-hpa
+    assert_has_program vsftpd
+    assert_has_program xinetd
+}
+
+function test_deploy {
+    put $TEST_HOME/misc_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
+    put $FUEGO_CORE/engine/scripts/fuego_board_function_lib.sh $BOARD_TESTDIR/fuego.$TESTDIR
+    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
+    put -r $TEST_HOME/data $BOARD_TESTDIR/fuego.$TESTDIR/
+}
+
+function test_run {
+    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
+    export ramdiskdev=$DISK_DEV;\
+    export test_tcpip_host=$SRV_IP;\
+    export TERM=$CONTAINER_TERM;\
+    ./misc_test.sh"
+}
+
+function test_processing {
+    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
+}
diff --git a/engine/tests/Functional.misc/misc_test.sh b/engine/tests/Functional.misc/misc_test.sh
new file mode 100755
index 0000000..dd5ce37
--- /dev/null
+++ b/engine/tests/Functional.misc/misc_test.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+    sh $i
+done
diff --git a/engine/tests/Functional.misc/parser.py b/engine/tests/Functional.misc/parser.py
new file mode 100644
index 0000000..d85abd7
--- /dev/null
+++ b/engine/tests/Functional.misc/parser.py
@@ -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))
diff --git a/engine/tests/Functional.misc/spec.json b/engine/tests/Functional.misc/spec.json
new file mode 100644
index 0000000..f2cac47
--- /dev/null
+++ b/engine/tests/Functional.misc/spec.json
@@ -0,0 +1,7 @@
+{
+    "testName": "Functional.misc",
+    "specs": {
+        "default": {}
+    }
+}
+
diff --git a/engine/tests/Functional.misc/test.yaml b/engine/tests/Functional.misc/test.yaml
new file mode 100644
index 0000000..9c80aac
--- /dev/null
+++ b/engine/tests/Functional.misc/test.yaml
@@ -0,0 +1,61 @@
+fuego_package_version: 1
+name: Functional.misc
+description: |
+      This is a simple test to check the following commands:
+        nslookup/bzip2/saslauthd/dbus-cleanup-sockets/dumpe2fs/su/gawk/gdb/gettext/grep/
+        ip/iptables/ping/mktemp/clear/snmpd/nfsstat/ssh-agent/sshd/openssl/perl/pm-powersave/
+        uptime/rpm/useradd/strace/try-from/in.tftpd-hpa/vsftpd/xinetd
+license: Unknown
+author: Wang Mingyu <wangmy at cn.fujitsu.com>
+maintainer: Tim Bird <tim.bird at sony.com>
+version: 1.00
+fuego_release: 1
+type: Functional
+tags: ['misc']
+params:
+      DISK_DEV="the disk device in your target board" Defined in board file
+      SRV_IP="the IP address of host" Defined in board file
+      CONTAINER_TERM="the TERM environment variable of docker" Defined in board file
+data_files:
+ - misc_test.sh
+ - fuego_test.sh
+ - parser.py
+ - spec.json
+ - test.yaml
+ - data
+    tst-float.pl
+ - tests
+    bind-utils_nslookup.sh
+    bzip2.sh
+    cyrus-sasl_saslauthd.sh
+    dbus_dbus-cleanup-sockets.sh
+    e2fsprogs_dumpe2fs.sh
+    filesystem.sh
+    fjelinux_su.sh
+    gawk.sh
+    gdb.sh
+    gettext.sh
+    grep.sh
+    iproute_ip.sh
+    iptables.sh
+    iputils_ping.sh
+    mktemp.sh
+    ncurses_clear.sh
+    net-snmp_snmpd.sh
+    nfs-utils_nfsstat.sh
+    openssh-clients_ssh-agent.sh
+    openssh-server_sshd.sh
+    openssl.sh
+    perl.sh
+    perl_tst-float.sh
+    pm-utils_pm-powersave.sh
+    procps_uptime.sh
+    rpm.sh
+    setup.sh
+    shadow-utils_useradd.sh
+    strace.sh
+    tcp_wrappers_try-from.sh
+    telnetd.sh
+    tftp-server_in.tftpd-hpa.sh
+    vsftpd.sh
+    xinetd.sh
-- 
1.8.3.1





More information about the Fuego mailing list