[oe-commits] [openembedded-core] 17/25: ifupdown: add ptest

git at git.openembedded.org git at git.openembedded.org
Tue Feb 4 15:57:16 UTC 2020


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master
in repository openembedded-core.

commit 2333ef5bb40132f05f69a5f6abaa3d086ecf9f6c
Author: Kai Kang <kai.kang at windriver.com>
AuthorDate: Mon Feb 3 17:33:11 2020 +0800

    ifupdown: add ptest
    
    Add ptest for ifupdown with its own test cases.
    
    [Yocto #13736]
    
    Signed-off-by: Kai Kang <kai.kang at windriver.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/recipes-core/ifupdown/files/run-ptest         |  4 ++
 .../ifupdown/files/tweak-ptest-script.patch        | 49 ++++++++++++++++++++++
 meta/recipes-core/ifupdown/ifupdown_0.8.35.bb      | 10 ++++-
 3 files changed, 62 insertions(+), 1 deletion(-)

diff --git a/meta/recipes-core/ifupdown/files/run-ptest b/meta/recipes-core/ifupdown/files/run-ptest
new file mode 100644
index 0000000..8694042
--- /dev/null
+++ b/meta/recipes-core/ifupdown/files/run-ptest
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+CURDIR=$(dirname `readlink -f $0`)
+cd $CURDIR/tests && ./testbuild-linux
diff --git a/meta/recipes-core/ifupdown/files/tweak-ptest-script.patch b/meta/recipes-core/ifupdown/files/tweak-ptest-script.patch
new file mode 100644
index 0000000..d7600cf
--- /dev/null
+++ b/meta/recipes-core/ifupdown/files/tweak-ptest-script.patch
@@ -0,0 +1,49 @@
+Tweak tests of ifupdown to make it work with oe-core ptest framework.
+
+Upstream-Status: Inappropriate [oe-core specific]
+
+Signed-off-by: Kai Kang <kai.kang at windriver.com>
+
+diff --git a/tests/testbuild-linux b/tests/testbuild-linux
+index 1181ea0..d5c1814 100755
+--- a/tests/testbuild-linux
++++ b/tests/testbuild-linux
+@@ -1,6 +1,7 @@
+ #!/bin/sh -e
+ 
+-dir=tests/linux
++curdir=$(dirname `readlink -f $0`)
++dir=$curdir/linux
+ 
+ result=true
+ for test in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18; do
+@@ -12,7 +13,7 @@ for test in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18; do
+         echo "Testcase $test: $args"
+ 
+ 	exitcode=0
+-        ./ifup -v --no-act-commands --force -i $dir/testcase.$test --state-dir=$dir/state.$test $args \
++        ifup -v --no-act-commands --force -i $dir/testcase.$test --state-dir=$dir/state.$test $args \
+                 >$dir/up-res-out.$test 2>$dir/up-res-err.$test || exitcode=$?
+ 
+         (echo "exit code: $exitcode";
+@@ -20,7 +21,7 @@ for test in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18; do
+          echo "====stderr===="; cat $dir/up-res-err.$test) > $dir/up-res.$test
+ 
+ 	exitcode=0
+-        ./ifdown -v --no-act-commands --force -i $dir/testcase.$test --state-dir=$dir/state.$test $args \
++        ifdown -v --no-act-commands --force -i $dir/testcase.$test --state-dir=$dir/state.$test $args \
+                >$dir/down-res-out.$test 2>$dir/down-res-err.$test || exitcode=$?
+ 
+         (echo "exit code: $exitcode";
+@@ -28,9 +29,9 @@ for test in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18; do
+          echo "====stderr===="; cat $dir/down-res-err.$test) > $dir/down-res.$test
+ 
+         if diff -ub $dir/up.$test $dir/up-res.$test && diff -ub $dir/down.$test $dir/down-res.$test; then
+-                echo "(okay)"
++                echo "PASS: $test"
+         else
+-                echo "(failed)"
++                echo "FAIL: $test"
+                 result=false
+         fi
+         echo "=========="
diff --git a/meta/recipes-core/ifupdown/ifupdown_0.8.35.bb b/meta/recipes-core/ifupdown/ifupdown_0.8.35.bb
index 0de97fe..53cb971 100644
--- a/meta/recipes-core/ifupdown/ifupdown_0.8.35.bb
+++ b/meta/recipes-core/ifupdown/ifupdown_0.8.35.bb
@@ -11,13 +11,15 @@ SRC_URI = "git://salsa.debian.org/debian/ifupdown.git;protocol=https \
            file://99_network \
            file://0001-Define-FNM_EXTMATCH-for-musl.patch \
            file://0001-Makefile-do-not-use-dpkg-for-determining-OS-type.patch \
+           file://run-ptest \
+           ${@bb.utils.contains('DISTRO_FEATURES', 'ptest', 'file://tweak-ptest-script.patch', '', d)} \
            "
 SRCREV = "4af76318cfc57f8e4a44d357104188666213bd4b"
 
 S = "${WORKDIR}/git"
 
 
-inherit update-alternatives
+inherit ptest update-alternatives
 
 do_compile () {
 	chmod a+rx *.pl *.sh
@@ -40,6 +42,12 @@ do_install () {
 	cd ${D}${mandir}/man8 && ln -s ifup.8 ifdown.8
 }
 
+do_install_ptest () {
+    install -d ${D}${PTEST_PATH}/tests
+    cp -r ${S}/tests/testbuild-linux ${D}${PTEST_PATH}/tests/
+    cp -r ${S}/tests/linux ${D}${PTEST_PATH}/tests/
+}
+
 ALTERNATIVE_PRIORITY = "100"
 ALTERNATIVE_${PN} = "ifup ifdown"
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list