aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMingli Yu <Mingli.Yu@windriver.com>2018-01-04 10:04:58 +0800
committerJoe MacDonald <joe_macdonald@mentor.com>2018-01-08 12:06:37 -0500
commit40dcf5203b1ed04e0516d475bf582cb32217a8c6 (patch)
treee3417184327fd2535cce825daa3afabbb255df17
parent8031dd5affa4d4c34a61efae938c435275800ea6 (diff)
downloadmeta-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>
-rw-r--r--meta-networking/recipes-protocols/openl2tp/openl2tp/openl2tpd-enable-tests.patch24
-rw-r--r--meta-networking/recipes-protocols/openl2tp/openl2tp/run-ptest97
-rw-r--r--meta-networking/recipes-protocols/openl2tp/openl2tp_1.8.bb12
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 @@
+commit 3e96a6c41bdd26417265a45ed685138d8eed564e
+Author: Aws Ismail <aws.ismail@windriver.com>
+Date: Fri Sep 14 02:32:53 2012 -0400
+
+ openl2tp: Enable tests
+
+ Build the test direcctory as part
+ of the overall build
+
+ Signed-off-by: Aws Ismail <aws.ismail@windriver.com>
+
+diff --git a/Makefile b/Makefile
+index 412cf4d..adf4f44 100644
+--- a/Makefile
++++ b/Makefile
+@@ -16,7 +16,7 @@ L2TP_FEATURE_LOCAL_CONF_FILE= y
+
+ # Define to include test code. This must be defined to run the
+ # regression tests
+-# L2TP_TEST= y
++L2TP_TEST=y
+
+ # Define to compile in debug code. Also makes default trace flags
+ # 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 @@
+#!/bin/sh
+
+TMP_DIR=`mktemp -d /tmp/std.26.tmp.XXXXXX`
+
+# restore the file if exist
+restore_file()
+{
+ filelist="test_procs.tcl tunnel.test session.test"
+ for file in ${filelist}
+ do
+ if [ -f ${TMP_DIR}/${file} ]; then
+ mv ${TMP_DIR}/${file} ${OPENL2TP_DIR}
+ fi
+ done
+}
+
+exit_cus()
+{
+ restore_file
+ echo $1
+ exit $2
+}
+
+if [ -d /usr/lib64/openl2tp/ptest ]; then
+ OPENL2TP_DIR="/usr/lib64/openl2tp"
+elif [ -d /usr/lib/openl2tp/ptest ]; then
+ OPENL2TP_DIR="/usr/lib/openl2tp"
+else
+ exit_cus "The openl2tp ptest directory not installed, skip the test" 1
+fi
+
+#read -p "Please input the network interface you use to test(such as eth0, em1 etc):" ETH_TEST
+echo "Please input the network interface you use to test(such as eth0, em1 etc):"
+read ETH_TEST > /dev/null
+
+if [ x"$ETH_TEST" = x ]; then
+ exit_cus "The network interface cannot be null" 1
+fi
+ifconfig | grep $ETH_TEST > /dev/null || exit_cus "The network interface you provide is invalid" 1
+
+# check openl2tp related kernel config
+zcat /proc/config.gz | grep CONFIG_L2TP=y > /dev/null || exit_cus "Failed to check CONFIG_L2TP=y, skip the tests." 1
+zcat /proc/config.gz | grep CONFIG_PPPOL2TP=m > /dev/null || exit_cus "Failed to check CONFIG_PPPOL2TP=m, skip the tests." 1
+
+SYSV_INIT="/etc/init.d/rpcbind"
+if [ -e ${SYSV_INIT} ]; then
+ ${SYSV_INIT} status > /dev/null || ${SYSV_INIT} start > /dev/null
+else
+ systemctl status rpcbind > /dev/null || systemctl start rpcbind > /dev/null
+fi
+
+which systemctl > /dev/null && systemctl status rpcbind > /dev/null || service rpcbind status > /dev/null
+[ $? -ne 0 ] && exit_cus "Failed to start rpcbind service, skip the tests." 1
+
+# backup the below files
+cp ${OPENL2TP_DIR}/ptest/test_procs.tcl $TMP_DIR
+cp ${OPENL2TP_DIR}/ptest/tunnel.test $TMP_DIR
+cp ${OPENL2TP_DIR}/ptest/session.test $TMP_DIR
+
+# customise the config
+if [ x"$ETH_TEST" = x ]; then
+ exit_cus "Please set ETH_TEST which used to test first, skip the tests." 1
+fi
+
+sed -i 's/eth2/'\"$ETH_TEST\"'/g' ${OPENL2TP_DIR}/ptest/test_procs.tcl
+test_ip="`ifconfig $ETH_TEST | grep 'inet ' | sed 's/^.*inet addr://g' | \
+ sed 's/ *Mask.*$//g'|sed 's/ *Bcast.*$//g'`"
+sed -i 's/192.168.0.1/'"$test_ip"'/g' ${OPENL2TP_DIR}/ptest/tunnel.test
+
+# load module l2tp_ppp
+modprobe l2tp_ppp > /dev/null
+lsmod | grep l2tp_ppp > /dev/null || exit_cus "FAIL: Load module l2tp_ppp" 2
+
+# start openl2tpd
+ps aux | grep openl2tpd | grep -v grep > /dev/null && killall openl2tpd > /dev/null
+ppp_path=`rpm -ql openl2tp | grep ppp_null.so`
+echo "test it here"
+/usr/sbin/openl2tpd -d all -D -f -p ${ppp_path} & > /dev/null
+
+# prepare the test env
+rm -rf $OPENL2TP_DIR/results
+mkdir -p $OPENL2TP_DIR/results || exit_cus "FAIL: mkdir $OPENL2TP_DIR/results" 2
+cp /usr/bin/l2tpconfig ${OPENL2TP_DIR} || exit_cus "FAIL: copy /usr/bin/l2tpconfig to ${OPENL2TP_DIR}" 2
+
+# start the test
+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"
+
+# check the result
+PASSNUM=`grep PASS $OPENL2TP_DIR/results/test-l2tpd.result | wc -l`
+FAILNUM=`grep FAIL $OPENL2TP_DIR/results/test-l2tpd.result | wc -l`
+if [ $PASSNUM -ne 0 ] && [ $FAILNUM -eq 0 ]; then
+ echo "PASS: openl2tp"
+else
+ echo "FAIL: openl2tp"
+fi
+
+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 \
file://openl2tpd-initscript-fix-sysconfig.patch \
file://openl2tpd-initscript-fix-warning.patch \
file://openl2tpd.service \
+ file://openl2tpd-enable-tests.patch \
+ file://run-ptest \
"
SRC_URI_append_libc-musl = "\
@@ -41,7 +43,7 @@ SRC_URI_append_libc-musl = "\
SRC_URI[md5sum] = "e3d08dedfb9e6a9a1e24f6766f6dadd0"
SRC_URI[sha256sum] = "1c97704d4b963a87fbc0e741668d4530933991515ae9ab0dffd11b5444f4860f"
-inherit autotools-brokensep pkgconfig systemd
+inherit autotools-brokensep pkgconfig systemd ptest
SYSTEMD_SERVICE_${PN} = "openl2tpd.service"
SYSTEMD_AUTO_ENABLE = "disable"
@@ -85,4 +87,12 @@ do_install_append () {
fi
}
+do_install_ptest () {
+ for i in all.tcl configfile.test peer_profile.test ppp_profile.test \
+ session_profile.test session.test system.test test_procs.tcl \
+ thirdparty_lns.test tunnel_profile.test tunnel.test; do
+ install -m 0755 ${S}/test/$i ${D}${PTEST_PATH}
+ done
+}
+
RDEPENDS_${PN} = "ppp ppp-l2tp bash"