Return-Path: From: Wang Mingyu Date: Mon, 25 Mar 2019 02:19:22 -0700 Message-ID: <1553505567-3221-4-git-send-email-wangmy@cn.fujitsu.com> In-Reply-To: <1553505567-3221-1-git-send-email-wangmy@cn.fujitsu.com> References: <1553505567-3221-1-git-send-email-wangmy@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Fuego] [PATCH v2] m4: Add test cases for command m4. List-Id: Mailing list for the Fuego test framework List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: fuego@lists.linuxfoundation.org This test set is used to process macros by m4. Signed-off-by: Wang Mingyu --- tests/Functional.m4/fuego_test.sh | 17 +++++++++++++++++ tests/Functional.m4/m4_test.sh | 4 ++++ tests/Functional.m4/parser.py | 20 ++++++++++++++++++++ tests/Functional.m4/spec.json | 6 ++++++ tests/Functional.m4/tests/m4_01.sh | 13 +++++++++++++ tests/Functional.m4/tests/m4_02.sh | 19 +++++++++++++++++++ 6 files changed, 79 insertions(+) create mode 100644 tests/Functional.m4/fuego_test.sh create mode 100755 tests/Functional.m4/m4_test.sh create mode 100644 tests/Functional.m4/parser.py create mode 100644 tests/Functional.m4/spec.json create mode 100644 tests/Functional.m4/tests/m4_01.sh create mode 100644 tests/Functional.m4/tests/m4_02.sh diff --git a/tests/Functional.m4/fuego_test.sh b/tests/Functional.m4/fuego_test.sh new file mode 100644 index 0000000..9e9a556 --- /dev/null +++ b/tests/Functional.m4/fuego_test.sh @@ -0,0 +1,17 @@ +function test_pre_check { + assert_has_program m4 +} + +function test_deploy { + put $TEST_HOME/m4_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/ + put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/ +} + +function test_run { + report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\ + ./m4_test.sh" +} + +function test_processing { + log_compare "$TESTDIR" "0" "TEST-FAIL" "n" +} diff --git a/tests/Functional.m4/m4_test.sh b/tests/Functional.m4/m4_test.sh new file mode 100755 index 0000000..dd5ce37 --- /dev/null +++ b/tests/Functional.m4/m4_test.sh @@ -0,0 +1,4 @@ +#!/bin/sh +for i in tests/*.sh; do + sh $i +done diff --git a/tests/Functional.m4/parser.py b/tests/Functional.m4/parser.py new file mode 100644 index 0000000..f25a608 --- /dev/null +++ b/tests/Functional.m4/parser.py @@ -0,0 +1,20 @@ +#!/usr/bin/python +# See common.py for description of command-line arguments + +import os, sys, collections +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/tests/Functional.m4/spec.json b/tests/Functional.m4/spec.json new file mode 100644 index 0000000..4a3b807 --- /dev/null +++ b/tests/Functional.m4/spec.json @@ -0,0 +1,6 @@ +{ + "testName": "Functional.m4", + "specs": { + "default": {} + } +} diff --git a/tests/Functional.m4/tests/m4_01.sh b/tests/Functional.m4/tests/m4_01.sh new file mode 100644 index 0000000..4a553d1 --- /dev/null +++ b/tests/Functional.m4/tests/m4_01.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# In target, run command m4. +# option: --help + +test="m4_01" + +if m4 --help | grep Usage +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; diff --git a/tests/Functional.m4/tests/m4_02.sh b/tests/Functional.m4/tests/m4_02.sh new file mode 100644 index 0000000..4bdaf7a --- /dev/null +++ b/tests/Functional.m4/tests/m4_02.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# In target, run command m4. +# option: none + +test="m4_02" + +mkdir m4 +echo "define(\`STR', \`hello world')" > m4/m4.test +echo "syscmd(\`echo' STR)" >> m4/m4.test + +if m4 m4/m4.test | grep "hello world" +then + echo " -> $test: TEST-PASS" +else + echo " -> $test: TEST-FAIL" +fi; + +rm -fr m4 -- 1.8.3.1