* [Fuego] [PATCH v3] batch: add test case for batch.
@ 2018-11-16 16:33 Zheng Ruoqin
2018-11-20 0:51 ` Tim.Bird
0 siblings, 1 reply; 2+ messages in thread
From: Zheng Ruoqin @ 2018-11-16 16:33 UTC (permalink / raw)
To: fuego
batch command is used to queue, examine or delete jobs for later
execution
Signed-off-by: Zheng Ruoqin <zhengrq.fnst@cn.fujitsu.com>
---
engine/tests/Functional.batch/batch.sh | 4 ++++
engine/tests/Functional.batch/fuego_test.sh | 19 +++++++++++++++
engine/tests/Functional.batch/parser.py | 22 +++++++++++++++++
engine/tests/Functional.batch/spec.json | 6 +++++
engine/tests/Functional.batch/tests/batch.sh | 35 ++++++++++++++++++++++++++++
5 files changed, 86 insertions(+)
create mode 100644 engine/tests/Functional.batch/batch.sh
create mode 100644 engine/tests/Functional.batch/fuego_test.sh
create mode 100644 engine/tests/Functional.batch/parser.py
create mode 100644 engine/tests/Functional.batch/spec.json
create mode 100644 engine/tests/Functional.batch/tests/batch.sh
diff --git a/engine/tests/Functional.batch/batch.sh b/engine/tests/Functional.batch/batch.sh
new file mode 100644
index 0000000..dd5ce37
--- /dev/null
+++ b/engine/tests/Functional.batch/batch.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+for i in tests/*.sh; do
+ sh $i
+done
diff --git a/engine/tests/Functional.batch/fuego_test.sh b/engine/tests/Functional.batch/fuego_test.sh
new file mode 100644
index 0000000..7a5f1d1
--- /dev/null
+++ b/engine/tests/Functional.batch/fuego_test.sh
@@ -0,0 +1,19 @@
+NEED_ROOT=1
+
+function test_pre_check {
+ assert_has_program batch expect
+}
+
+function test_deploy {
+ put $TEST_HOME/batch.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 batch.sh"
+}
+
+function test_processing {
+ log_compare "$TESTDIR" "1" "TEST-PASS" "p"
+}
diff --git a/engine/tests/Functional.batch/parser.py b/engine/tests/Functional.batch/parser.py
new file mode 100644
index 0000000..d85abd7
--- /dev/null
+++ b/engine/tests/Functional.batch/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.batch/spec.json b/engine/tests/Functional.batch/spec.json
new file mode 100644
index 0000000..7c3e1f5
--- /dev/null
+++ b/engine/tests/Functional.batch/spec.json
@@ -0,0 +1,6 @@
+{
+ "testName": "Functional.batch",
+ "specs": {
+ "default": {}
+ }
+}
diff --git a/engine/tests/Functional.batch/tests/batch.sh b/engine/tests/Functional.batch/tests/batch.sh
new file mode 100644
index 0000000..7addb0d
--- /dev/null
+++ b/engine/tests/Functional.batch/tests/batch.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# In target, run comannd batch and execute "echo" in batch
+# Ensure that batch can work well.
+
+test="batch"
+
+if /tmp/batch_result
+then
+ rm /tmp/batch_result
+fi
+
+expect <<-EOF
+spawn batch
+expect {
+ -re ".*at.*" {
+ send_user " -> $test: batch executed.\n"
+ send "echo batch test done > /tmp/batch_result\n"
+ }
+ default { send_user " -> $test: TEST-FAIL\n" }
+ }
+send "\004\r"
+send_user " -> $test: batch executed succeeded.\n"
+expect eof
+EOF
+
+sleep 5
+
+if cat /tmp/batch_result | grep "batch test done"
+then
+ echo ' -> $test: TEST-PASS'
+else
+ echo ' -> $test: TEST-FAIL'
+fi
+
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Fuego] [PATCH v3] batch: add test case for batch.
2018-11-16 16:33 [Fuego] [PATCH v3] batch: add test case for batch Zheng Ruoqin
@ 2018-11-20 0:51 ` Tim.Bird
0 siblings, 0 replies; 2+ messages in thread
From: Tim.Bird @ 2018-11-20 0:51 UTC (permalink / raw)
To: zhengrq.fnst, fuego
Applied. Thanks.
-- Tim
> -----Original Message-----
> From: fuego-bounces@lists.linuxfoundation.org [mailto:fuego-
> bounces@lists.linuxfoundation.org] On Behalf Of Zheng Ruoqin
> Sent: Friday, November 16, 2018 8:34 AM
> To: fuego@lists.linuxfoundation.org
> Subject: [Fuego] [PATCH v3] batch: add test case for batch.
>
> batch command is used to queue, examine or delete jobs for later
> execution
>
> Signed-off-by: Zheng Ruoqin <zhengrq.fnst@cn.fujitsu.com>
> ---
> engine/tests/Functional.batch/batch.sh | 4 ++++
> engine/tests/Functional.batch/fuego_test.sh | 19 +++++++++++++++
> engine/tests/Functional.batch/parser.py | 22 +++++++++++++++++
> engine/tests/Functional.batch/spec.json | 6 +++++
> engine/tests/Functional.batch/tests/batch.sh | 35
> ++++++++++++++++++++++++++++
> 5 files changed, 86 insertions(+)
> create mode 100644 engine/tests/Functional.batch/batch.sh
> create mode 100644 engine/tests/Functional.batch/fuego_test.sh
> create mode 100644 engine/tests/Functional.batch/parser.py
> create mode 100644 engine/tests/Functional.batch/spec.json
> create mode 100644 engine/tests/Functional.batch/tests/batch.sh
>
> diff --git a/engine/tests/Functional.batch/batch.sh
> b/engine/tests/Functional.batch/batch.sh
> new file mode 100644
> index 0000000..dd5ce37
> --- /dev/null
> +++ b/engine/tests/Functional.batch/batch.sh
> @@ -0,0 +1,4 @@
> +#!/bin/sh
> +for i in tests/*.sh; do
> + sh $i
> +done
> diff --git a/engine/tests/Functional.batch/fuego_test.sh
> b/engine/tests/Functional.batch/fuego_test.sh
> new file mode 100644
> index 0000000..7a5f1d1
> --- /dev/null
> +++ b/engine/tests/Functional.batch/fuego_test.sh
> @@ -0,0 +1,19 @@
> +NEED_ROOT=1
> +
> +function test_pre_check {
> + assert_has_program batch expect
> +}
> +
> +function test_deploy {
> + put $TEST_HOME/batch.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 batch.sh"
> +}
> +
> +function test_processing {
> + log_compare "$TESTDIR" "1" "TEST-PASS" "p"
> +}
> diff --git a/engine/tests/Functional.batch/parser.py
> b/engine/tests/Functional.batch/parser.py
> new file mode 100644
> index 0000000..d85abd7
> --- /dev/null
> +++ b/engine/tests/Functional.batch/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.batch/spec.json
> b/engine/tests/Functional.batch/spec.json
> new file mode 100644
> index 0000000..7c3e1f5
> --- /dev/null
> +++ b/engine/tests/Functional.batch/spec.json
> @@ -0,0 +1,6 @@
> +{
> + "testName": "Functional.batch",
> + "specs": {
> + "default": {}
> + }
> +}
> diff --git a/engine/tests/Functional.batch/tests/batch.sh
> b/engine/tests/Functional.batch/tests/batch.sh
> new file mode 100644
> index 0000000..7addb0d
> --- /dev/null
> +++ b/engine/tests/Functional.batch/tests/batch.sh
> @@ -0,0 +1,35 @@
> +#!/bin/sh
> +
> +# In target, run comannd batch and execute "echo" in batch
> +# Ensure that batch can work well.
> +
> +test="batch"
> +
> +if /tmp/batch_result
> +then
> + rm /tmp/batch_result
> +fi
> +
> +expect <<-EOF
> +spawn batch
> +expect {
> + -re ".*at.*" {
> + send_user " -> $test: batch executed.\n"
> + send "echo batch test done > /tmp/batch_result\n"
> + }
> + default { send_user " -> $test: TEST-FAIL\n" }
> + }
> +send "\004\r"
> +send_user " -> $test: batch executed succeeded.\n"
> +expect eof
> +EOF
> +
> +sleep 5
> +
> +if cat /tmp/batch_result | grep "batch test done"
> +then
> + echo ' -> $test: TEST-PASS'
> +else
> + echo ' -> $test: TEST-FAIL'
> +fi
> +
> --
> 1.8.3.1
>
>
>
> _______________________________________________
> Fuego mailing list
> Fuego@lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/fuego
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-11-20 0:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-16 16:33 [Fuego] [PATCH v3] batch: add test case for batch Zheng Ruoqin
2018-11-20 0:51 ` Tim.Bird
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.