* [LTP] [PATCH 1/3] network/dhcpd: improve testcase, use dummy module
@ 2014-12-03 13:55 Alexey Kodanev
2014-12-03 13:55 ` [LTP] [PATCH 2/3] network/dhcpd: rename to dhcp Alexey Kodanev
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alexey Kodanev @ 2014-12-03 13:55 UTC (permalink / raw)
To: ltp-list; +Cc: vasily.isaenko
Run dhcp client and check that the interface configured as expected.
Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
testcases/network/dhcpd/dhcpd_tests.sh | 148 +++++++++++++++++++++-----------
1 files changed, 98 insertions(+), 50 deletions(-)
diff --git a/testcases/network/dhcpd/dhcpd_tests.sh b/testcases/network/dhcpd/dhcpd_tests.sh
index ad95875..c4c2c21 100755
--- a/testcases/network/dhcpd/dhcpd_tests.sh
+++ b/testcases/network/dhcpd/dhcpd_tests.sh
@@ -17,6 +17,7 @@
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Author: Manoj Iyer, manjo@mail.utexas.edu
+# Author: Alexey Kodanev alexey.kodanev@oracle.com
TST_CLEANUP=cleanup
TST_TOTAL=1
@@ -28,42 +29,62 @@ stop_dhcp()
{
if [ "$(pgrep -x dhcpd)" ]; then
tst_resm TINFO "stopping DHCP server"
- pkill -x dhcpd || tst_brkm "failed to stop DHCP server"
+ pkill -x dhcpd
+ sleep 1
fi
}
-# alias ethX to ethX:1 with IP 10.1.1.12
-init()
+setup_conf()
{
- tst_require_root
- tst_tmpdir
- tst_check_cmds cat dhcpd awk ip pgrep pkill diff
-
- stop_dhcp
-
cat > tst_dhcpd.conf <<-EOF
+ ddns-update-style none;
+ update-static-leases off;
subnet 10.1.1.0 netmask 255.255.255.0 {
- # default gateway
- range 10.1.1.12 10.1.1.12;
- default-lease-time 600;
- max-lease-time 1200;
- option routers 10.1.1.1;
- option subnet-mask
- 255.255.255.0;
- option
- domain-name-servers
- 10.1.1.1;
- option
- domain-name
- "dhcptest.net";
+ range 10.1.1.100 10.1.1.100;
+ default-lease-time 60;
+ max-lease-time 60;
}
- ddns-update-style interim;
EOF
+}
- if [ $? -ne 0 ]; then
- tst_brkm TBROK "unable to create temp file: tst_dhcpd.conf"
+setup_conf6()
+{
+ cat > tst_dhcpd.conf <<-EOF
+ ddns-update-style none;
+ update-static-leases off;
+ subnet6 fd00:1:1:2::/64 {
+ range6 fd00:1:1:2::100 fd00:1:1:2::100;
+ default-lease-time 60;
+ max-lease-time 60;
+ }
+ EOF
+}
+
+init()
+{
+ tst_require_root
+ tst_check_cmds cat dhcpd awk ip pgrep pkill dhclient
+
+ dummy_loaded=
+ lsmod | grep -q '^dummy '
+ if [ $? -eq 0 ]; then
+ dummy_loaded=1
+ else
+ modprobe dummy || tst_brkm TCONF "failed to find dummy module"
fi
+ tst_resm TINFO "create dummy interface"
+ ip li add $iface type dummy || \
+ tst_brkm TBROK "failed to add dummy $iface"
+
+ ip li set up $iface || tst_brkm TBROK "failed to bring $iface up"
+
+ tst_tmpdir
+
+ stop_dhcp
+
+ setup_conf$TST_IPV6
+
if [ -f /etc/dhcpd.conf ]; then
DHCPD_CONF="/etc/dhcpd.conf"
elif [ -f /etc/dhcp/dhcpd.conf ]; then
@@ -78,58 +99,85 @@ init()
mv tst_dhcpd.conf $DHCPD_CONF
[ $? -ne 0 ] && tst_brkm TBROK "failed to create dhcpd.conf"
- tst_resm TINFO "add $iface:1 10.1.1.12/24 to create private network"
- ip addr add 10.1.1.12/24 dev $iface label $iface:1
- if [ $? -ne 0 ]; then
- tst_brkm TBROK "failed to add alias"
+ dhclient_lease="/var/lib/dhclient/dhclient${TST_IPV6}.leases"
+ if [ -f $dhclient_lease ]; then
+ tst_resm TINFO "backup dhclient${TST_IPV6}.leases"
+ mv $dhclient_lease .
fi
+
+ tst_resm TINFO "add $ip_addr to $iface to create private network"
+ ip addr add $ip_addr dev $iface || \
+ tst_brkm TBROK "failed to add ip address"
}
cleanup()
{
stop_dhcp
+
+ pkill -f "dhclient -$ipv $iface"
+
[ -f dhcpd.conf ] && mv dhcpd.conf $DHCPD_CONF
- ip addr show $iface | grep "$iface:1" > /dev/null &&
- ip addr del 10.1.1.12/24 dev $iface label $iface:1
+ # restore dhclient leases
+ rm -f $dhclient_lease
+ [ -f "dhclient${TST_IPV6}.leases" ] && \
+ mv dhclient${TST_IPV6}.leases $dhclient_lease
+
+ if [ "$dummy_loaded" ]; then
+ ip li del $iface
+ else
+ rmmod dummy
+ fi
tst_rmdir
}
test01()
{
- tst_resm TINFO "start/stop DHCP server"
+ tst_resm TINFO "starting DHCPv${ipv} server on $iface"
+ dhcpd -$ipv $iface > tst_dhcpd.err 2>&1
+ if [ $? -ne 0 ]; then
+ cat tst_dhcpd.err
+ tst_brkm TBROK "Failed to start dhcpd"
+ fi
- cat > tst_dhcpd.exp <<-EOF
- Sending on Socket/fallback/fallback-net
- EOF
- [ $? -ne 0 ] && tst_brkm TBROK "unable to create expected results"
+ sleep 1
- tst_resm TINFO "starting DHCP server"
- dhcpd > tst_dhcpd.err 2>&1
- if [ $? -ne 0 ]; then
+ if [ "$(pgrep 'dhcpd -$ipv $iface')" ]; then
cat tst_dhcpd.err
tst_brkm TBROK "Failed to start dhcpd"
fi
- cat tst_dhcpd.err | tail -n 1 > tst_dhcpd.out
- [ $? -ne 0 ] && tst_brkm TBROK "unable to create output file"
+ tst_resm TINFO "starting dhclient -${ipv} $iface"
+ dhclient -$ipv $iface || \
+ tst_brkm TBROK "dhclient failed"
- diff -iwB tst_dhcpd.out tst_dhcpd.exp
- if [ $? -ne 0 ]; then
- tst_resm TFAIL "failed to start dhcpd"
- return
+ # check that we get configured ip address
+ ip addr show $iface | grep $ip_addr_check > /dev/null
+ if [ $? -eq 0 ]; then
+ tst_resm TPASS "'$ip_addr_check' configured by DHCPv$ipv"
+ else
+ tst_resm TFAIL "'$ip_addr_check' not configured by DHCPv$ipv"
fi
stop_dhcp
-
- tst_resm TPASS "dhcpd started and stopped successfully"
}
-iface=$(tst_iface)
+tst_read_opts $*
-init
+iface="ltp_dummy"
+ipv=${TST_IPV6:-"4"}
-test01
+if [ $TST_IPV6 ]; then
+ ip_addr="fd00:1:1:2::12/64"
+ ip_addr_check="fd00:1:1:2::100/64"
+else
+ ip_addr="10.1.1.12/24"
+ ip_addr_check="10.1.1.100/24"
+fi
+
+trap "tst_brkm TBROK 'test interrupted'" INT
+init
+test01
tst_exit
--
1.7.1
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH 2/3] network/dhcpd: rename to dhcp
2014-12-03 13:55 [LTP] [PATCH 1/3] network/dhcpd: improve testcase, use dummy module Alexey Kodanev
@ 2014-12-03 13:55 ` Alexey Kodanev
2014-12-03 13:55 ` [LTP] [PATCH 3/3] network/dhcp: add dnsmasq to dhcp test Alexey Kodanev
2015-02-18 10:34 ` [LTP] [PATCH 1/3] network/dhcpd: improve testcase, use dummy module Alexey Kodanev
2 siblings, 0 replies; 4+ messages in thread
From: Alexey Kodanev @ 2014-12-03 13:55 UTC (permalink / raw)
To: ltp-list; +Cc: vasily.isaenko
Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
testcases/network/dhcp/Makefile | 31 ++++++
testcases/network/dhcp/dhcpd_tests.sh | 183 ++++++++++++++++++++++++++++++++
testcases/network/dhcpd/Makefile | 31 ------
testcases/network/dhcpd/dhcpd_tests.sh | 183 --------------------------------
4 files changed, 214 insertions(+), 214 deletions(-)
create mode 100644 testcases/network/dhcp/Makefile
create mode 100755 testcases/network/dhcp/dhcpd_tests.sh
delete mode 100644 testcases/network/dhcpd/Makefile
delete mode 100755 testcases/network/dhcpd/dhcpd_tests.sh
diff --git a/testcases/network/dhcp/Makefile b/testcases/network/dhcp/Makefile
new file mode 100644
index 0000000..a963a45
--- /dev/null
+++ b/testcases/network/dhcp/Makefile
@@ -0,0 +1,31 @@
+#
+# network/dhcpd testcases Makefile.
+#
+# Copyright (C) 2009, Cisco Systems Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Garrett Cooper, July 2009
+#
+
+top_srcdir ?= ../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS := dhcpd_tests.sh
+
+MAKE_TARGETS :=
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/dhcp/dhcpd_tests.sh b/testcases/network/dhcp/dhcpd_tests.sh
new file mode 100755
index 0000000..c4c2c21
--- /dev/null
+++ b/testcases/network/dhcp/dhcpd_tests.sh
@@ -0,0 +1,183 @@
+#!/bin/sh
+# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) International Business Machines Corp., 2001
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Author: Manoj Iyer, manjo@mail.utexas.edu
+# Author: Alexey Kodanev alexey.kodanev@oracle.com
+
+TST_CLEANUP=cleanup
+TST_TOTAL=1
+TCID="dhcpd"
+
+. test_net.sh
+
+stop_dhcp()
+{
+ if [ "$(pgrep -x dhcpd)" ]; then
+ tst_resm TINFO "stopping DHCP server"
+ pkill -x dhcpd
+ sleep 1
+ fi
+}
+
+setup_conf()
+{
+ cat > tst_dhcpd.conf <<-EOF
+ ddns-update-style none;
+ update-static-leases off;
+ subnet 10.1.1.0 netmask 255.255.255.0 {
+ range 10.1.1.100 10.1.1.100;
+ default-lease-time 60;
+ max-lease-time 60;
+ }
+ EOF
+}
+
+setup_conf6()
+{
+ cat > tst_dhcpd.conf <<-EOF
+ ddns-update-style none;
+ update-static-leases off;
+ subnet6 fd00:1:1:2::/64 {
+ range6 fd00:1:1:2::100 fd00:1:1:2::100;
+ default-lease-time 60;
+ max-lease-time 60;
+ }
+ EOF
+}
+
+init()
+{
+ tst_require_root
+ tst_check_cmds cat dhcpd awk ip pgrep pkill dhclient
+
+ dummy_loaded=
+ lsmod | grep -q '^dummy '
+ if [ $? -eq 0 ]; then
+ dummy_loaded=1
+ else
+ modprobe dummy || tst_brkm TCONF "failed to find dummy module"
+ fi
+
+ tst_resm TINFO "create dummy interface"
+ ip li add $iface type dummy || \
+ tst_brkm TBROK "failed to add dummy $iface"
+
+ ip li set up $iface || tst_brkm TBROK "failed to bring $iface up"
+
+ tst_tmpdir
+
+ stop_dhcp
+
+ setup_conf$TST_IPV6
+
+ if [ -f /etc/dhcpd.conf ]; then
+ DHCPD_CONF="/etc/dhcpd.conf"
+ elif [ -f /etc/dhcp/dhcpd.conf ]; then
+ DHCPD_CONF="/etc/dhcp/dhcpd.conf"
+ else
+ tst_brkm TBROK "failed to find dhcpd.conf"
+ fi
+
+ mv $DHCPD_CONF dhcpd.conf
+ [ $? -ne 0 ] && tst_brkm TBROK "failed to backup dhcpd.conf"
+
+ mv tst_dhcpd.conf $DHCPD_CONF
+ [ $? -ne 0 ] && tst_brkm TBROK "failed to create dhcpd.conf"
+
+ dhclient_lease="/var/lib/dhclient/dhclient${TST_IPV6}.leases"
+ if [ -f $dhclient_lease ]; then
+ tst_resm TINFO "backup dhclient${TST_IPV6}.leases"
+ mv $dhclient_lease .
+ fi
+
+ tst_resm TINFO "add $ip_addr to $iface to create private network"
+ ip addr add $ip_addr dev $iface || \
+ tst_brkm TBROK "failed to add ip address"
+}
+
+cleanup()
+{
+ stop_dhcp
+
+ pkill -f "dhclient -$ipv $iface"
+
+ [ -f dhcpd.conf ] && mv dhcpd.conf $DHCPD_CONF
+
+ # restore dhclient leases
+ rm -f $dhclient_lease
+ [ -f "dhclient${TST_IPV6}.leases" ] && \
+ mv dhclient${TST_IPV6}.leases $dhclient_lease
+
+ if [ "$dummy_loaded" ]; then
+ ip li del $iface
+ else
+ rmmod dummy
+ fi
+
+ tst_rmdir
+}
+
+test01()
+{
+ tst_resm TINFO "starting DHCPv${ipv} server on $iface"
+ dhcpd -$ipv $iface > tst_dhcpd.err 2>&1
+ if [ $? -ne 0 ]; then
+ cat tst_dhcpd.err
+ tst_brkm TBROK "Failed to start dhcpd"
+ fi
+
+ sleep 1
+
+ if [ "$(pgrep 'dhcpd -$ipv $iface')" ]; then
+ cat tst_dhcpd.err
+ tst_brkm TBROK "Failed to start dhcpd"
+ fi
+
+ tst_resm TINFO "starting dhclient -${ipv} $iface"
+ dhclient -$ipv $iface || \
+ tst_brkm TBROK "dhclient failed"
+
+ # check that we get configured ip address
+ ip addr show $iface | grep $ip_addr_check > /dev/null
+ if [ $? -eq 0 ]; then
+ tst_resm TPASS "'$ip_addr_check' configured by DHCPv$ipv"
+ else
+ tst_resm TFAIL "'$ip_addr_check' not configured by DHCPv$ipv"
+ fi
+
+ stop_dhcp
+}
+
+tst_read_opts $*
+
+iface="ltp_dummy"
+ipv=${TST_IPV6:-"4"}
+
+if [ $TST_IPV6 ]; then
+ ip_addr="fd00:1:1:2::12/64"
+ ip_addr_check="fd00:1:1:2::100/64"
+else
+ ip_addr="10.1.1.12/24"
+ ip_addr_check="10.1.1.100/24"
+fi
+
+trap "tst_brkm TBROK 'test interrupted'" INT
+
+init
+test01
+tst_exit
diff --git a/testcases/network/dhcpd/Makefile b/testcases/network/dhcpd/Makefile
deleted file mode 100644
index a963a45..0000000
--- a/testcases/network/dhcpd/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# network/dhcpd testcases Makefile.
-#
-# Copyright (C) 2009, Cisco Systems Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Garrett Cooper, July 2009
-#
-
-top_srcdir ?= ../../..
-
-include $(top_srcdir)/include/mk/env_pre.mk
-
-INSTALL_TARGETS := dhcpd_tests.sh
-
-MAKE_TARGETS :=
-
-include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/dhcpd/dhcpd_tests.sh b/testcases/network/dhcpd/dhcpd_tests.sh
deleted file mode 100755
index c4c2c21..0000000
--- a/testcases/network/dhcpd/dhcpd_tests.sh
+++ /dev/null
@@ -1,183 +0,0 @@
-#!/bin/sh
-# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
-# Copyright (c) International Business Machines Corp., 2001
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; either version 2 of
-# the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it would be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#
-# Author: Manoj Iyer, manjo@mail.utexas.edu
-# Author: Alexey Kodanev alexey.kodanev@oracle.com
-
-TST_CLEANUP=cleanup
-TST_TOTAL=1
-TCID="dhcpd"
-
-. test_net.sh
-
-stop_dhcp()
-{
- if [ "$(pgrep -x dhcpd)" ]; then
- tst_resm TINFO "stopping DHCP server"
- pkill -x dhcpd
- sleep 1
- fi
-}
-
-setup_conf()
-{
- cat > tst_dhcpd.conf <<-EOF
- ddns-update-style none;
- update-static-leases off;
- subnet 10.1.1.0 netmask 255.255.255.0 {
- range 10.1.1.100 10.1.1.100;
- default-lease-time 60;
- max-lease-time 60;
- }
- EOF
-}
-
-setup_conf6()
-{
- cat > tst_dhcpd.conf <<-EOF
- ddns-update-style none;
- update-static-leases off;
- subnet6 fd00:1:1:2::/64 {
- range6 fd00:1:1:2::100 fd00:1:1:2::100;
- default-lease-time 60;
- max-lease-time 60;
- }
- EOF
-}
-
-init()
-{
- tst_require_root
- tst_check_cmds cat dhcpd awk ip pgrep pkill dhclient
-
- dummy_loaded=
- lsmod | grep -q '^dummy '
- if [ $? -eq 0 ]; then
- dummy_loaded=1
- else
- modprobe dummy || tst_brkm TCONF "failed to find dummy module"
- fi
-
- tst_resm TINFO "create dummy interface"
- ip li add $iface type dummy || \
- tst_brkm TBROK "failed to add dummy $iface"
-
- ip li set up $iface || tst_brkm TBROK "failed to bring $iface up"
-
- tst_tmpdir
-
- stop_dhcp
-
- setup_conf$TST_IPV6
-
- if [ -f /etc/dhcpd.conf ]; then
- DHCPD_CONF="/etc/dhcpd.conf"
- elif [ -f /etc/dhcp/dhcpd.conf ]; then
- DHCPD_CONF="/etc/dhcp/dhcpd.conf"
- else
- tst_brkm TBROK "failed to find dhcpd.conf"
- fi
-
- mv $DHCPD_CONF dhcpd.conf
- [ $? -ne 0 ] && tst_brkm TBROK "failed to backup dhcpd.conf"
-
- mv tst_dhcpd.conf $DHCPD_CONF
- [ $? -ne 0 ] && tst_brkm TBROK "failed to create dhcpd.conf"
-
- dhclient_lease="/var/lib/dhclient/dhclient${TST_IPV6}.leases"
- if [ -f $dhclient_lease ]; then
- tst_resm TINFO "backup dhclient${TST_IPV6}.leases"
- mv $dhclient_lease .
- fi
-
- tst_resm TINFO "add $ip_addr to $iface to create private network"
- ip addr add $ip_addr dev $iface || \
- tst_brkm TBROK "failed to add ip address"
-}
-
-cleanup()
-{
- stop_dhcp
-
- pkill -f "dhclient -$ipv $iface"
-
- [ -f dhcpd.conf ] && mv dhcpd.conf $DHCPD_CONF
-
- # restore dhclient leases
- rm -f $dhclient_lease
- [ -f "dhclient${TST_IPV6}.leases" ] && \
- mv dhclient${TST_IPV6}.leases $dhclient_lease
-
- if [ "$dummy_loaded" ]; then
- ip li del $iface
- else
- rmmod dummy
- fi
-
- tst_rmdir
-}
-
-test01()
-{
- tst_resm TINFO "starting DHCPv${ipv} server on $iface"
- dhcpd -$ipv $iface > tst_dhcpd.err 2>&1
- if [ $? -ne 0 ]; then
- cat tst_dhcpd.err
- tst_brkm TBROK "Failed to start dhcpd"
- fi
-
- sleep 1
-
- if [ "$(pgrep 'dhcpd -$ipv $iface')" ]; then
- cat tst_dhcpd.err
- tst_brkm TBROK "Failed to start dhcpd"
- fi
-
- tst_resm TINFO "starting dhclient -${ipv} $iface"
- dhclient -$ipv $iface || \
- tst_brkm TBROK "dhclient failed"
-
- # check that we get configured ip address
- ip addr show $iface | grep $ip_addr_check > /dev/null
- if [ $? -eq 0 ]; then
- tst_resm TPASS "'$ip_addr_check' configured by DHCPv$ipv"
- else
- tst_resm TFAIL "'$ip_addr_check' not configured by DHCPv$ipv"
- fi
-
- stop_dhcp
-}
-
-tst_read_opts $*
-
-iface="ltp_dummy"
-ipv=${TST_IPV6:-"4"}
-
-if [ $TST_IPV6 ]; then
- ip_addr="fd00:1:1:2::12/64"
- ip_addr_check="fd00:1:1:2::100/64"
-else
- ip_addr="10.1.1.12/24"
- ip_addr_check="10.1.1.100/24"
-fi
-
-trap "tst_brkm TBROK 'test interrupted'" INT
-
-init
-test01
-tst_exit
--
1.7.1
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH 3/3] network/dhcp: add dnsmasq to dhcp test
2014-12-03 13:55 [LTP] [PATCH 1/3] network/dhcpd: improve testcase, use dummy module Alexey Kodanev
2014-12-03 13:55 ` [LTP] [PATCH 2/3] network/dhcpd: rename to dhcp Alexey Kodanev
@ 2014-12-03 13:55 ` Alexey Kodanev
2015-02-18 10:34 ` [LTP] [PATCH 1/3] network/dhcpd: improve testcase, use dummy module Alexey Kodanev
2 siblings, 0 replies; 4+ messages in thread
From: Alexey Kodanev @ 2014-12-03 13:55 UTC (permalink / raw)
To: ltp-list; +Cc: vasily.isaenko
* use Virtual Ethernet Tunnel pair instead of dummy interface
* move common code to dhcp_lib.sh
Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
testcases/network/dhcp/Makefile | 2 +-
testcases/network/dhcp/dhcp_lib.sh | 126 +++++++++++++++++++++++++
testcases/network/dhcp/dhcpd_tests.sh | 152 +++++++------------------------
testcases/network/dhcp/dnsmasq_tests.sh | 63 +++++++++++++
4 files changed, 224 insertions(+), 119 deletions(-)
create mode 100755 testcases/network/dhcp/dhcp_lib.sh
create mode 100755 testcases/network/dhcp/dnsmasq_tests.sh
diff --git a/testcases/network/dhcp/Makefile b/testcases/network/dhcp/Makefile
index a963a45..b419137 100644
--- a/testcases/network/dhcp/Makefile
+++ b/testcases/network/dhcp/Makefile
@@ -24,7 +24,7 @@ top_srcdir ?= ../../..
include $(top_srcdir)/include/mk/env_pre.mk
-INSTALL_TARGETS := dhcpd_tests.sh
+INSTALL_TARGETS := dhcp_lib.sh dhcpd_tests.sh dnsmasq_tests.sh
MAKE_TARGETS :=
diff --git a/testcases/network/dhcp/dhcp_lib.sh b/testcases/network/dhcp/dhcp_lib.sh
new file mode 100755
index 0000000..b8b3b9f
--- /dev/null
+++ b/testcases/network/dhcp/dhcp_lib.sh
@@ -0,0 +1,126 @@
+#!/bin/sh
+# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Author: Alexey Kodanev alexey.kodanev@oracle.com
+
+stop_dhcp()
+{
+ [ "$(pgrep -x $dhcp_name)" ] || return
+
+ tst_resm TINFO "stopping $dhcp_name"
+ pkill -x $dhcp_name || tst_brkm "failed to stop $dhcp_name"
+ pkill -x $dhcp_name
+ sleep 1
+}
+
+init()
+{
+ tst_require_root
+ tst_check_cmds cat $dhcp_name awk ip pgrep pkill dhclient
+
+ veth_loaded=
+ lsmod | grep -q '^veth ' && veth_loaded=1
+
+ tst_resm TINFO "create veth interfaces"
+ ip li add $iface0 type veth peer name $iface1 || \
+ tst_brkm TBROK "failed to add veth $iface0"
+
+ veth_added=1
+ ip li set up $iface0 || tst_brkm TBROK "failed to bring $iface0 up"
+ ip li set up $iface1 || tst_brkm TBROK "failed to bring $iface1 up"
+
+ tst_tmpdir
+
+ stop_dhcp
+
+ dhclient_lease="/var/lib/dhclient/dhclient${TST_IPV6}.leases"
+ if [ -f $dhclient_lease ]; then
+ tst_resm TINFO "backup dhclient${TST_IPV6}.leases"
+ mv $dhclient_lease .
+ fi
+
+ tst_resm TINFO "add $ip_addr to $iface0"
+ ip addr add $ip_addr dev $iface0 || \
+ tst_brkm TBROK "failed to add ip address"
+}
+
+cleanup()
+{
+ stop_dhcp
+
+ pkill -f "dhclient -$ipv $iface1"
+
+ cleanup_dhcp
+
+ # restore dhclient leases
+ rm -f $dhclient_lease
+ [ -f "dhclient${TST_IPV6}.leases" ] && \
+ mv dhclient${TST_IPV6}.leases $dhclient_lease
+
+ [ $veth_added ] && ip li del $iface0
+
+ if [ -z $veth_loaded ]; then
+ lsmod | grep -q '^veth ' && rmmod veth
+ fi
+
+ tst_rmdir
+}
+
+test01()
+{
+ tst_resm TINFO "starting DHCPv${ipv} server on $iface0"
+
+ start_dhcp$TST_IPV6
+
+ sleep 1
+
+ if [ "$(pgrep '$dhcp_name')" ]; then
+ print_dhcp_log
+ tst_brkm TBROK "Failed to start $dhcp_name"
+ fi
+
+ tst_resm TINFO "starting dhclient -${ipv} $iface1"
+ dhclient -$ipv $iface1 || \
+ tst_brkm TBROK "dhclient failed"
+
+ # check that we get configured ip address
+ ip addr show $iface1 | grep $ip_addr_check > /dev/null
+ if [ $? -eq 0 ]; then
+ tst_resm TPASS "'$ip_addr_check' configured by DHCPv$ipv"
+ else
+ tst_resm TFAIL "'$ip_addr_check' not configured by DHCPv$ipv"
+ print_dhcp_log
+ fi
+
+ stop_dhcp
+}
+
+tst_read_opts $*
+
+iface0="ltp_veth0"
+iface1="ltp_veth1"
+ipv=${TST_IPV6:-"4"}
+
+if [ $TST_IPV6 ]; then
+ ip_addr="fd00:1:1:2::12/64"
+ ip_addr_check="fd00:1:1:2::100/64"
+else
+ ip_addr="10.1.1.12/24"
+ ip_addr_check="10.1.1.100/24"
+fi
+
+trap "tst_brkm TBROK 'test interrupted'" INT
diff --git a/testcases/network/dhcp/dhcpd_tests.sh b/testcases/network/dhcp/dhcpd_tests.sh
index c4c2c21..785dc1e 100755
--- a/testcases/network/dhcp/dhcpd_tests.sh
+++ b/testcases/network/dhcp/dhcpd_tests.sh
@@ -22,19 +22,39 @@
TST_CLEANUP=cleanup
TST_TOTAL=1
TCID="dhcpd"
+dhcp_name="dhcpd"
. test_net.sh
+. dhcp_lib.sh
-stop_dhcp()
+setup_dhcpd_conf()
{
- if [ "$(pgrep -x dhcpd)" ]; then
- tst_resm TINFO "stopping DHCP server"
- pkill -x dhcpd
- sleep 1
+ if [ -f /etc/dhcpd.conf ]; then
+ DHCPD_CONF="/etc/dhcpd.conf"
+ elif [ -f /etc/dhcp/dhcpd.conf ]; then
+ DHCPD_CONF="/etc/dhcp/dhcpd.conf"
+ else
+ tst_brkm TBROK "failed to find dhcpd.conf"
fi
+
+ mv $DHCPD_CONF dhcpd.conf
+ [ $? -ne 0 ] && tst_brkm TBROK "failed to backup dhcpd.conf"
+
+ mv tst_dhcpd.conf $DHCPD_CONF
+ [ $? -ne 0 ] && tst_brkm TBROK "failed to create dhcpd.conf"
}
-setup_conf()
+start_dhcpd()
+{
+ dhcpd -$ipv $iface0 > tst_dhcpd.err 2>&1
+ if [ $? -ne 0 ]; then
+ cat tst_dhcpd.err
+ tst_brkm TBROK "Failed to start dhcpd"
+ fi
+
+}
+
+start_dhcp()
{
cat > tst_dhcpd.conf <<-EOF
ddns-update-style none;
@@ -45,9 +65,11 @@ setup_conf()
max-lease-time 60;
}
EOF
+ setup_dhcpd_conf
+ start_dhcpd
}
-setup_conf6()
+start_dhcp6()
{
cat > tst_dhcpd.conf <<-EOF
ddns-update-style none;
@@ -58,126 +80,20 @@ setup_conf6()
max-lease-time 60;
}
EOF
+ setup_dhcpd_conf
+ start_dhcpd
}
-init()
+cleanup_dhcp()
{
- tst_require_root
- tst_check_cmds cat dhcpd awk ip pgrep pkill dhclient
-
- dummy_loaded=
- lsmod | grep -q '^dummy '
- if [ $? -eq 0 ]; then
- dummy_loaded=1
- else
- modprobe dummy || tst_brkm TCONF "failed to find dummy module"
- fi
-
- tst_resm TINFO "create dummy interface"
- ip li add $iface type dummy || \
- tst_brkm TBROK "failed to add dummy $iface"
-
- ip li set up $iface || tst_brkm TBROK "failed to bring $iface up"
-
- tst_tmpdir
-
- stop_dhcp
-
- setup_conf$TST_IPV6
-
- if [ -f /etc/dhcpd.conf ]; then
- DHCPD_CONF="/etc/dhcpd.conf"
- elif [ -f /etc/dhcp/dhcpd.conf ]; then
- DHCPD_CONF="/etc/dhcp/dhcpd.conf"
- else
- tst_brkm TBROK "failed to find dhcpd.conf"
- fi
-
- mv $DHCPD_CONF dhcpd.conf
- [ $? -ne 0 ] && tst_brkm TBROK "failed to backup dhcpd.conf"
-
- mv tst_dhcpd.conf $DHCPD_CONF
- [ $? -ne 0 ] && tst_brkm TBROK "failed to create dhcpd.conf"
-
- dhclient_lease="/var/lib/dhclient/dhclient${TST_IPV6}.leases"
- if [ -f $dhclient_lease ]; then
- tst_resm TINFO "backup dhclient${TST_IPV6}.leases"
- mv $dhclient_lease .
- fi
-
- tst_resm TINFO "add $ip_addr to $iface to create private network"
- ip addr add $ip_addr dev $iface || \
- tst_brkm TBROK "failed to add ip address"
-}
-
-cleanup()
-{
- stop_dhcp
-
- pkill -f "dhclient -$ipv $iface"
-
[ -f dhcpd.conf ] && mv dhcpd.conf $DHCPD_CONF
-
- # restore dhclient leases
- rm -f $dhclient_lease
- [ -f "dhclient${TST_IPV6}.leases" ] && \
- mv dhclient${TST_IPV6}.leases $dhclient_lease
-
- if [ "$dummy_loaded" ]; then
- ip li del $iface
- else
- rmmod dummy
- fi
-
- tst_rmdir
}
-test01()
+print_dhcp_log()
{
- tst_resm TINFO "starting DHCPv${ipv} server on $iface"
- dhcpd -$ipv $iface > tst_dhcpd.err 2>&1
- if [ $? -ne 0 ]; then
- cat tst_dhcpd.err
- tst_brkm TBROK "Failed to start dhcpd"
- fi
-
- sleep 1
-
- if [ "$(pgrep 'dhcpd -$ipv $iface')" ]; then
- cat tst_dhcpd.err
- tst_brkm TBROK "Failed to start dhcpd"
- fi
-
- tst_resm TINFO "starting dhclient -${ipv} $iface"
- dhclient -$ipv $iface || \
- tst_brkm TBROK "dhclient failed"
-
- # check that we get configured ip address
- ip addr show $iface | grep $ip_addr_check > /dev/null
- if [ $? -eq 0 ]; then
- tst_resm TPASS "'$ip_addr_check' configured by DHCPv$ipv"
- else
- tst_resm TFAIL "'$ip_addr_check' not configured by DHCPv$ipv"
- fi
-
- stop_dhcp
+ cat tst_dhcpd.err
}
-tst_read_opts $*
-
-iface="ltp_dummy"
-ipv=${TST_IPV6:-"4"}
-
-if [ $TST_IPV6 ]; then
- ip_addr="fd00:1:1:2::12/64"
- ip_addr_check="fd00:1:1:2::100/64"
-else
- ip_addr="10.1.1.12/24"
- ip_addr_check="10.1.1.100/24"
-fi
-
-trap "tst_brkm TBROK 'test interrupted'" INT
-
init
test01
tst_exit
diff --git a/testcases/network/dhcp/dnsmasq_tests.sh b/testcases/network/dhcp/dnsmasq_tests.sh
new file mode 100755
index 0000000..d2f7430
--- /dev/null
+++ b/testcases/network/dhcp/dnsmasq_tests.sh
@@ -0,0 +1,63 @@
+#!/bin/sh
+# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Author: Alexey Kodanev alexey.kodanev@oracle.com
+
+TST_CLEANUP=cleanup
+TST_TOTAL=1
+TCID="dnsmasq"
+dhcp_name="dnsmasq"
+
+. test_net.sh
+. dhcp_lib.sh
+
+start_dhcp()
+{
+ dnsmasq $common_opt \
+ --dhcp-range=10.1.1.100,10.1.1.100,255.255.255.0,2m \
+ --dhcp-option=option:router --dhcp-option=option:dns-server
+}
+
+start_dhcp6()
+{
+ # check that dnsmasq supports IPv6
+ dnsmasq --dhcp-range=fd00::1,fd00::1 --test > /dev/null 2>&1 || \
+ tst_brkm TCONF "dnsmasq doesn't support DHCPv6"
+
+ dnsmasq $common_opt \
+ --dhcp-range=fd00:1:1:2::100,fd00:1:1:2::100 --enable-ra \
+ --dhcp-option=option6:dns-server
+}
+
+cleanup_dhcp()
+{
+ rm -f tst_dnsmasq.log
+}
+
+print_dhcp_log()
+{
+ cat tst_dnsmasq.log
+}
+
+init
+
+common_opt="--no-hosts --no-resolv --dhcp-authoritative \
+ --log-facility=$(pwd)/tst_dnsmasq.log --interface=$iface0 \
+ --dhcp-leasefile=$(pwd)/tst_dnsmasq.lease --conf-file= "
+
+test01
+tst_exit
--
1.7.1
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH 1/3] network/dhcpd: improve testcase, use dummy module
2014-12-03 13:55 [LTP] [PATCH 1/3] network/dhcpd: improve testcase, use dummy module Alexey Kodanev
2014-12-03 13:55 ` [LTP] [PATCH 2/3] network/dhcpd: rename to dhcp Alexey Kodanev
2014-12-03 13:55 ` [LTP] [PATCH 3/3] network/dhcp: add dnsmasq to dhcp test Alexey Kodanev
@ 2015-02-18 10:34 ` Alexey Kodanev
2 siblings, 0 replies; 4+ messages in thread
From: Alexey Kodanev @ 2015-02-18 10:34 UTC (permalink / raw)
To: ltp-list; +Cc: vasily.isaenko
Hi!
On 12/03/2014 04:55 PM, Alexey Kodanev wrote:
> Run dhcp client and check that the interface configured as expected.
>
> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
> ---
> testcases/network/dhcpd/dhcpd_tests.sh | 148 +++++++++++++++++++++-----------
> 1 files changed, 98 insertions(+), 50 deletions(-)
network/dhcp patch-set pushed. dhcpd test, and new dnsmasq test both run
on isolated Virtual Ethernet Tunnel pair to ensure they won't interfere
with existed network setup.
Thanks,
Alexey
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-02-18 10:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-03 13:55 [LTP] [PATCH 1/3] network/dhcpd: improve testcase, use dummy module Alexey Kodanev
2014-12-03 13:55 ` [LTP] [PATCH 2/3] network/dhcpd: rename to dhcp Alexey Kodanev
2014-12-03 13:55 ` [LTP] [PATCH 3/3] network/dhcp: add dnsmasq to dhcp test Alexey Kodanev
2015-02-18 10:34 ` [LTP] [PATCH 1/3] network/dhcpd: improve testcase, use dummy module Alexey Kodanev
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.