[Fuego] [PATCH] rpm: add test cases for rpm command.

Tim Bird tbird20d at gmail.com
Tue Aug 21 04:07:45 UTC 2018


On Mon, Aug 20, 2018 at 8:42 PM, Tim Bird <tbird20d at gmail.com> wrote:
> Zheng,
>
> I applied this patch.  It looks OK from a visual inspection of the
> code.  I don't have
> a test system that uses RPM, so I couldn't test it very well here.

OK - I spun up a system that has rpm, and this is what I got:

the testlog,txt:
#!/bin/sh
for i in tests/*.sh; do
    sh $i
done
Usage: rpm [OPTION...]
 -> rpm01: TEST-PASS
rpm: RPM should not be used directly install RPM packages, use Alien instead!
rpm: However assuming you know what you are doing...
warning: test-manual-1.2.3.noarch.rpm: Header V4 DSA/SHA1 Signature,
key ID c08249da: NOKEY
Preparing...                          ########################################
Updating / installing...
test-manual-1.2.3-20130226            warning: user test does not
exist - using root
warning: group test does not exist - using root
########################################
error: unpacking of archive failed on file /home/test: cpio: mkdir
error: test-manual-1.2.3-20130226.noarch: install failed
 -> rpm02: TEST-FAIL
package test-manual-1.2.3.noarch is not installed
 -> rpm03: TEST-PASS

I suspect it is because I need to be root to perform the operations, but
my fuego test user was not root.

Can you please add NEED_ROOT=1 to fuego_test.sh, if this is the case?

Thanks,
 -- Tim

> On Fri, Aug 10, 2018 at 3:23 AM, Zheng Ruoqin
> <zhengrq.fnst at cn.fujitsu.com> wrote:
>> Signed-off-by: Zheng Ruoqin <zhengrq.fnst at cn.fujitsu.com>
>> ---
>>  engine/tests/Functional.rpm/fuego_test.sh          |  19 ++++++++++++++++++
>>  engine/tests/Functional.rpm/parser.py              |  22 +++++++++++++++++++++
>>  engine/tests/Functional.rpm/rpm_test.sh            |   4 ++++
>>  engine/tests/Functional.rpm/spec.json              |   6 ++++++
>>  .../Functional.rpm/test-manual-1.2.3.noarch.rpm    | Bin 0 -> 3293 bytes
>>  engine/tests/Functional.rpm/tests/rpm_01.sh        |  13 ++++++++++++
>>  engine/tests/Functional.rpm/tests/rpm_02.sh        |  21 ++++++++++++++++++++
>>  engine/tests/Functional.rpm/tests/rpm_03.sh        |  14 +++++++++++++
>>  8 files changed, 99 insertions(+)
>>  create mode 100755 engine/tests/Functional.rpm/fuego_test.sh
>>  create mode 100755 engine/tests/Functional.rpm/parser.py
>>  create mode 100644 engine/tests/Functional.rpm/rpm_test.sh
>>  create mode 100644 engine/tests/Functional.rpm/spec.json
>>  create mode 100644 engine/tests/Functional.rpm/test-manual-1.2.3.noarch.rpm
>>  create mode 100644 engine/tests/Functional.rpm/tests/rpm_01.sh
>>  create mode 100644 engine/tests/Functional.rpm/tests/rpm_02.sh
>>  create mode 100644 engine/tests/Functional.rpm/tests/rpm_03.sh
>>
>> diff --git a/engine/tests/Functional.rpm/fuego_test.sh b/engine/tests/Functional.rpm/fuego_test.sh
>> new file mode 100755
>> index 0000000..d1fd260
>> --- /dev/null
>> +++ b/engine/tests/Functional.rpm/fuego_test.sh
>> @@ -0,0 +1,19 @@
>> +function test_pre_check {
>> +    is_on_target_path rpm PROGRAM_RPM
>> +    assert_define PROGRAM_RPM
>> +}
>> +
>> +function test_deploy {
>> +    put $TEST_HOME/rpm_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
>> +    put $TEST_HOME/test-manual-1.2.3.noarch.rpm $BOARD_TESTDIR/fuego.$TESTDIR/
>> +    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
>> +}
>> +
>> +function test_run {
>> +    report "cd $BOARD_TESTDIR/fuego.$TESTDIR; \
>> +        sh -v rpm_test.sh"
>> +}
>> +
>> +function test_processing {
>> +    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
>> +}
>> diff --git a/engine/tests/Functional.rpm/parser.py b/engine/tests/Functional.rpm/parser.py
>> new file mode 100755
>> index 0000000..d85abd7
>> --- /dev/null
>> +++ b/engine/tests/Functional.rpm/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.rpm/rpm_test.sh b/engine/tests/Functional.rpm/rpm_test.sh
>> new file mode 100644
>> index 0000000..dd5ce37
>> --- /dev/null
>> +++ b/engine/tests/Functional.rpm/rpm_test.sh
>> @@ -0,0 +1,4 @@
>> +#!/bin/sh
>> +for i in tests/*.sh; do
>> +    sh $i
>> +done
>> diff --git a/engine/tests/Functional.rpm/spec.json b/engine/tests/Functional.rpm/spec.json
>> new file mode 100644
>> index 0000000..3f04dc9
>> --- /dev/null
>> +++ b/engine/tests/Functional.rpm/spec.json
>> @@ -0,0 +1,6 @@
>> +{
>> +    "testName": "Functional.rpm",
>> +    "specs": {
>> +        "default": {}
>> +    }
>> +}
>> diff --git a/engine/tests/Functional.rpm/test-manual-1.2.3.noarch.rpm b/engine/tests/Functional.rpm/test-manual-1.2.3.noarch.rpm
>> new file mode 100644
>> index 0000000000000000000000000000000000000000..d2e681cda59011f78fe3d8015c0693e185bbe7bf
>> GIT binary patch
>> literal 3293
>> zcmeH}U5p!7702(|UPw%%ZrhEhpnzKfP35fZ8ISF8Af)#A+g^{?Ua#$KK^c3-AG at B9
>> z^^Ct3Rb<0bC{>ey3Q7UBso)_Jpi&^B-%ZsPcnq`;sA(S%MGB~CsZ=3^0?RqxyHSD!
>> zPl%^p>-c|vbI!eU?$O*kbLod~U$B$^S)2a%nU4SX;uO91K|<^|L;rJN&?l$BW(b-3
>> z5M>Zj2Hpeuf$ctlvG$A5cYqxQLw*Ys$8Uncc>6n`=zkDw>hRXq7AX495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>
>> diff --git a/engine/tests/Functional.rpm/tests/rpm_01.sh b/engine/tests/Functional.rpm/tests/rpm_01.sh
>> new file mode 100644
>> index 0000000..6ab9e3d
>> --- /dev/null
>> +++ b/engine/tests/Functional.rpm/tests/rpm_01.sh
>> @@ -0,0 +1,13 @@
>> +#!/bin/sh
>> +
>> +#  The testscript checks the following options of the command file
>> +#  1) Option help
>> +
>> +test="rpm01"
>> +
>> +if rpm --help | grep .*Usage.*
>> +then
>> +    echo " -> $test: TEST-PASS"
>> +else
>> +    echo " -> $test: TEST-FAIL"
>> +fi;
>> diff --git a/engine/tests/Functional.rpm/tests/rpm_02.sh b/engine/tests/Functional.rpm/tests/rpm_02.sh
>> new file mode 100644
>> index 0000000..41ad005
>> --- /dev/null
>> +++ b/engine/tests/Functional.rpm/tests/rpm_02.sh
>> @@ -0,0 +1,21 @@
>> +#!/bin/sh
>> +
>> +#  The testscript checks the following options of the command file
>> +#  1) Option ql
>> +
>> +test="rpm02"
>> +test_manual="test-manual-1.2.3.noarch"
>> +
>> +if rpm -qa | grep $test_manual
>> +then
>> +    rpm -e $test_manual
>> +fi
>> +
>> +rpm -ivh ${test_manual}.rpm --nodeps
>> +
>> +if rpm -ql $test_manual | grep '.*/home/test/rpm-test/text1.txt.*'
>> +then
>> +    echo " -> $test: TEST-PASS"
>> +else
>> +    echo " -> $test: TEST-FAIL"
>> +fi;
>> diff --git a/engine/tests/Functional.rpm/tests/rpm_03.sh b/engine/tests/Functional.rpm/tests/rpm_03.sh
>> new file mode 100644
>> index 0000000..9306de7
>> --- /dev/null
>> +++ b/engine/tests/Functional.rpm/tests/rpm_03.sh
>> @@ -0,0 +1,14 @@
>> +#!/bin/sh
>> +
>> +#  The testscript checks the following options of the command file
>> +#  1) Option qi
>> +
>> +test="rpm03"
>> +test_manual="test-manual-1.2.3.noarch"
>> +
>> +if rpm -qi $test_manual | grep ".*1.2.3.*"
>> +then
>> +    echo " -> $test: TEST-PASS"
>> +else
>> +    echo " -> $test: TEST-FAIL"
>> +fi;
>> --
>> 1.8.3.1
>>
>>
>>
>> _______________________________________________
>> Fuego mailing list
>> Fuego at lists.linuxfoundation.org
>> https://lists.linuxfoundation.org/mailman/listinfo/fuego
>
>
>
> --
>  -- Tim Bird
> Senior Staff Software Engineer, Sony Corporation
> Architecture Group Chair, Core Embedded Linux Project, Linux Foundation



-- 
 -- Tim Bird
Senior Staff Software Engineer, Sony Corporation
Architecture Group Chair, Core Embedded Linux Project, Linux Foundation


More information about the Fuego mailing list