[LTP] [PATCH 1/2] tst_test.sh: Cleanup getopts usage

Petr Vorel pvorel@suse.cz
Sat Apr 2 00:30:32 CEST 2022


Hi,

Also dhcp tests should be changed due tst_selinux_enforced being available after
dhcp_lib.sh load.

Yes, defining global variables can be tricky now, we must be careful if they
don't depend on anything (here only library defines setup function, that's why
it's outside of the function).

In case anybody wants to test this latest version is branch
tst_test.sh/cleanup-getopts.fixes in my fork:
https://github.com/pevik/ltp/commits/tst_test.sh/cleanup-getopts.fixes

Kind regards,
Petr

diff --git testcases/network/dhcp/dnsmasq_tests.sh testcases/network/dhcp/dnsmasq_tests.sh
index 8dd43124ed..0183c1da25 100755
--- testcases/network/dhcp/dnsmasq_tests.sh
+++ testcases/network/dhcp/dnsmasq_tests.sh
@@ -5,17 +5,6 @@
 #
 # Author: Alexey Kodanev alexey.kodanev@oracle.com
 
-dhcp_name="dnsmasq"
-log="/var/log/dnsmasq.tst.log"
-
-lease_dir="/var/lib/misc"
-
-lease_file="$lease_dir/dnsmasq.tst.leases"
-
-common_opt="--no-hosts --no-resolv --dhcp-authoritative \
-	--log-facility=$log --interface=$iface0 \
-	--dhcp-leasefile=$lease_file --port=0 --conf-file= "
-
 start_dhcp()
 {
 	dnsmasq $common_opt \
@@ -45,6 +34,17 @@ print_dhcp_version()
 }
 
 . dhcp_lib.sh
+
+lease_dir="/var/lib/misc"
 tst_selinux_enforced && lease_dir="/var/lib/dnsmasq"
 
+dhcp_name="dnsmasq"
+log="/var/log/dnsmasq.tst.log"
+
+lease_file="$lease_dir/dnsmasq.tst.leases"
+
+common_opt="--no-hosts --no-resolv --dhcp-authoritative \
+	--log-facility=$log --interface=$iface0 \
+	--dhcp-leasefile=$lease_file --port=0 --conf-file= "
+
 tst_run


More information about the ltp mailing list