diff options
| author | Mingli Yu <Mingli.Yu@windriver.com> | 2018-01-04 10:04:58 +0800 |
|---|---|---|
| committer | Joe MacDonald <joe_macdonald@mentor.com> | 2018-01-08 12:06:37 -0500 |
| commit | 40dcf5203b1ed04e0516d475bf582cb32217a8c6 (patch) | |
| tree | e3417184327fd2535cce825daa3afabbb255df17 | |
| parent | 8031dd5affa4d4c34a61efae938c435275800ea6 (diff) | |
| download | meta-openembedded-40dcf5203b1ed04e0516d475bf582cb32217a8c6.tar.gz | |
openl2tp: add ptest support
* Add run-ptest
* Add patch to enable the regressin test
Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
3 files changed, 132 insertions, 1 deletions
diff --git a/meta-networking/recipes-protocols/openl2tp/openl2tp/openl2tpd-enable-tests.patch b/meta-networking/recipes-protocols/openl2tp/openl2tp/openl2tpd-enable-tests.patch new file mode 100644 index 0000000000..0bece2f4d7 --- /dev/null +++ b/meta-networking/recipes-protocols/openl2tp/openl2tp/openl2tpd-enable-tests.patch | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | commit 3e96a6c41bdd26417265a45ed685138d8eed564e | ||
| 2 | Author: Aws Ismail <aws.ismail@windriver.com> | ||
| 3 | Date: Fri Sep 14 02:32:53 2012 -0400 | ||
| 4 | |||
| 5 | openl2tp: Enable tests | ||
| 6 | |||
| 7 | Build the test direcctory as part | ||
| 8 | of the overall build | ||
| 9 | |||
| 10 | Signed-off-by: Aws Ismail <aws.ismail@windriver.com> | ||
| 11 | |||
| 12 | diff --git a/Makefile b/Makefile | ||
| 13 | index 412cf4d..adf4f44 100644 | ||
| 14 | --- a/Makefile | ||
| 15 | +++ b/Makefile | ||
| 16 | @@ -16,7 +16,7 @@ L2TP_FEATURE_LOCAL_CONF_FILE= y | ||
| 17 | |||
| 18 | # Define to include test code. This must be defined to run the | ||
| 19 | # regression tests | ||
| 20 | -# L2TP_TEST= y | ||
| 21 | +L2TP_TEST=y | ||
| 22 | |||
| 23 | # Define to compile in debug code. Also makes default trace flags | ||
| 24 | # enable all messages | ||
diff --git a/meta-networking/recipes-protocols/openl2tp/openl2tp/run-ptest b/meta-networking/recipes-protocols/openl2tp/openl2tp/run-ptest new file mode 100644 index 0000000000..01c9c7b447 --- /dev/null +++ b/meta-networking/recipes-protocols/openl2tp/openl2tp/run-ptest | |||
| @@ -0,0 +1,97 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | TMP_DIR=`mktemp -d /tmp/std.26.tmp.XXXXXX` | ||
| 4 | |||
| 5 | # restore the file if exist | ||
| 6 | restore_file() | ||
| 7 | { | ||
| 8 | filelist="test_procs.tcl tunnel.test session.test" | ||
| 9 | for file in ${filelist} | ||
| 10 | do | ||
| 11 | if [ -f ${TMP_DIR}/${file} ]; then | ||
| 12 | mv ${TMP_DIR}/${file} ${OPENL2TP_DIR} | ||
| 13 | fi | ||
| 14 | done | ||
| 15 | } | ||
| 16 | |||
| 17 | exit_cus() | ||
| 18 | { | ||
| 19 | restore_file | ||
| 20 | echo $1 | ||
| 21 | exit $2 | ||
| 22 | } | ||
| 23 | |||
| 24 | if [ -d /usr/lib64/openl2tp/ptest ]; then | ||
| 25 | OPENL2TP_DIR="/usr/lib64/openl2tp" | ||
| 26 | elif [ -d /usr/lib/openl2tp/ptest ]; then | ||
| 27 | OPENL2TP_DIR="/usr/lib/openl2tp" | ||
| 28 | else | ||
| 29 | exit_cus "The openl2tp ptest directory not installed, skip the test" 1 | ||
| 30 | fi | ||
| 31 | |||
| 32 | #read -p "Please input the network interface you use to test(such as eth0, em1 etc):" ETH_TEST | ||
| 33 | echo "Please input the network interface you use to test(such as eth0, em1 etc):" | ||
| 34 | read ETH_TEST > /dev/null | ||
| 35 | |||
| 36 | if [ x"$ETH_TEST" = x ]; then | ||
| 37 | exit_cus "The network interface cannot be null" 1 | ||
| 38 | fi | ||
| 39 | ifconfig | grep $ETH_TEST > /dev/null || exit_cus "The network interface you provide is invalid" 1 | ||
| 40 | |||
| 41 | # check openl2tp related kernel config | ||
| 42 | zcat /proc/config.gz | grep CONFIG_L2TP=y > /dev/null || exit_cus "Failed to check CONFIG_L2TP=y, skip the tests." 1 | ||
| 43 | zcat /proc/config.gz | grep CONFIG_PPPOL2TP=m > /dev/null || exit_cus "Failed to check CONFIG_PPPOL2TP=m, skip the tests." 1 | ||
| 44 | |||
| 45 | SYSV_INIT="/etc/init.d/rpcbind" | ||
| 46 | if [ -e ${SYSV_INIT} ]; then | ||
| 47 | ${SYSV_INIT} status > /dev/null || ${SYSV_INIT} start > /dev/null | ||
| 48 | else | ||
| 49 | systemctl status rpcbind > /dev/null || systemctl start rpcbind > /dev/null | ||
| 50 | fi | ||
| 51 | |||
| 52 | which systemctl > /dev/null && systemctl status rpcbind > /dev/null || service rpcbind status > /dev/null | ||
| 53 | [ $? -ne 0 ] && exit_cus "Failed to start rpcbind service, skip the tests." 1 | ||
| 54 | |||
| 55 | # backup the below files | ||
| 56 | cp ${OPENL2TP_DIR}/ptest/test_procs.tcl $TMP_DIR | ||
| 57 | cp ${OPENL2TP_DIR}/ptest/tunnel.test $TMP_DIR | ||
| 58 | cp ${OPENL2TP_DIR}/ptest/session.test $TMP_DIR | ||
| 59 | |||
| 60 | # customise the config | ||
| 61 | if [ x"$ETH_TEST" = x ]; then | ||
| 62 | exit_cus "Please set ETH_TEST which used to test first, skip the tests." 1 | ||
| 63 | fi | ||
| 64 | |||
| 65 | sed -i 's/eth2/'\"$ETH_TEST\"'/g' ${OPENL2TP_DIR}/ptest/test_procs.tcl | ||
| 66 | test_ip="`ifconfig $ETH_TEST | grep 'inet ' | sed 's/^.*inet addr://g' | \ | ||
| 67 | sed 's/ *Mask.*$//g'|sed 's/ *Bcast.*$//g'`" | ||
| 68 | sed -i 's/192.168.0.1/'"$test_ip"'/g' ${OPENL2TP_DIR}/ptest/tunnel.test | ||
| 69 | |||
| 70 | # load module l2tp_ppp | ||
| 71 | modprobe l2tp_ppp > /dev/null | ||
| 72 | lsmod | grep l2tp_ppp > /dev/null || exit_cus "FAIL: Load module l2tp_ppp" 2 | ||
| 73 | |||
| 74 | # start openl2tpd | ||
| 75 | ps aux | grep openl2tpd | grep -v grep > /dev/null && killall openl2tpd > /dev/null | ||
| 76 | ppp_path=`rpm -ql openl2tp | grep ppp_null.so` | ||
| 77 | echo "test it here" | ||
| 78 | /usr/sbin/openl2tpd -d all -D -f -p ${ppp_path} & > /dev/null | ||
| 79 | |||
| 80 | # prepare the test env | ||
| 81 | rm -rf $OPENL2TP_DIR/results | ||
| 82 | mkdir -p $OPENL2TP_DIR/results || exit_cus "FAIL: mkdir $OPENL2TP_DIR/results" 2 | ||
| 83 | cp /usr/bin/l2tpconfig ${OPENL2TP_DIR} || exit_cus "FAIL: copy /usr/bin/l2tpconfig to ${OPENL2TP_DIR}" 2 | ||
| 84 | |||
| 85 | # start the test | ||
| 86 | cd ${OPENL2TP_DIR}/ptest && tclsh all.tcl -preservecore 3 -verbose bps -tmpdir $OPENL2TP_DIR/results -outfile test-l2tpd.result -constraints "l2tpdRunning peerProfile tunnelProfile sessionProfile pppProfile system" -match "peer_profile-1.1 tunnel_profile-1.1 session_profile-1.1 ppp_profile-1.1 system-1.1" | ||
| 87 | |||
| 88 | # check the result | ||
| 89 | PASSNUM=`grep PASS $OPENL2TP_DIR/results/test-l2tpd.result | wc -l` | ||
| 90 | FAILNUM=`grep FAIL $OPENL2TP_DIR/results/test-l2tpd.result | wc -l` | ||
| 91 | if [ $PASSNUM -ne 0 ] && [ $FAILNUM -eq 0 ]; then | ||
| 92 | echo "PASS: openl2tp" | ||
| 93 | else | ||
| 94 | echo "FAIL: openl2tp" | ||
| 95 | fi | ||
| 96 | |||
| 97 | restore_file | ||
diff --git a/meta-networking/recipes-protocols/openl2tp/openl2tp_1.8.bb b/meta-networking/recipes-protocols/openl2tp/openl2tp_1.8.bb index bbde8a337d..bf6850b17c 100644 --- a/meta-networking/recipes-protocols/openl2tp/openl2tp_1.8.bb +++ b/meta-networking/recipes-protocols/openl2tp/openl2tp_1.8.bb | |||
| @@ -31,6 +31,8 @@ SRC_URI = "ftp://ftp.openl2tp.org/releases/${BP}/${BP}.tar.gz \ | |||
| 31 | file://openl2tpd-initscript-fix-sysconfig.patch \ | 31 | file://openl2tpd-initscript-fix-sysconfig.patch \ |
| 32 | file://openl2tpd-initscript-fix-warning.patch \ | 32 | file://openl2tpd-initscript-fix-warning.patch \ |
| 33 | file://openl2tpd.service \ | 33 | file://openl2tpd.service \ |
| 34 | file://openl2tpd-enable-tests.patch \ | ||
| 35 | file://run-ptest \ | ||
| 34 | " | 36 | " |
| 35 | 37 | ||
| 36 | SRC_URI_append_libc-musl = "\ | 38 | SRC_URI_append_libc-musl = "\ |
| @@ -41,7 +43,7 @@ SRC_URI_append_libc-musl = "\ | |||
| 41 | SRC_URI[md5sum] = "e3d08dedfb9e6a9a1e24f6766f6dadd0" | 43 | SRC_URI[md5sum] = "e3d08dedfb9e6a9a1e24f6766f6dadd0" |
| 42 | SRC_URI[sha256sum] = "1c97704d4b963a87fbc0e741668d4530933991515ae9ab0dffd11b5444f4860f" | 44 | SRC_URI[sha256sum] = "1c97704d4b963a87fbc0e741668d4530933991515ae9ab0dffd11b5444f4860f" |
| 43 | 45 | ||
| 44 | inherit autotools-brokensep pkgconfig systemd | 46 | inherit autotools-brokensep pkgconfig systemd ptest |
| 45 | 47 | ||
| 46 | SYSTEMD_SERVICE_${PN} = "openl2tpd.service" | 48 | SYSTEMD_SERVICE_${PN} = "openl2tpd.service" |
| 47 | SYSTEMD_AUTO_ENABLE = "disable" | 49 | SYSTEMD_AUTO_ENABLE = "disable" |
| @@ -85,4 +87,12 @@ do_install_append () { | |||
| 85 | fi | 87 | fi |
| 86 | } | 88 | } |
| 87 | 89 | ||
| 90 | do_install_ptest () { | ||
| 91 | for i in all.tcl configfile.test peer_profile.test ppp_profile.test \ | ||
| 92 | session_profile.test session.test system.test test_procs.tcl \ | ||
| 93 | thirdparty_lns.test tunnel_profile.test tunnel.test; do | ||
| 94 | install -m 0755 ${S}/test/$i ${D}${PTEST_PATH} | ||
| 95 | done | ||
| 96 | } | ||
| 97 | |||
| 88 | RDEPENDS_${PN} = "ppp ppp-l2tp bash" | 98 | RDEPENDS_${PN} = "ppp ppp-l2tp bash" |
