From: Cyril H. <su...@li...> - 2013-10-31 08:51:16
|
The branch, master, has been updated via 278743a7938096197436148f265d7a9c2a98697d (commit) via 2edca2f697cbd337d9e73338202171b39e821331 (commit) via 1237969a0e91a18e566124300f242e3fdd525782 (commit) via 792fcce8ae68436c8963c6a51f1f98c66c575494 (commit) from 2d127a3fcdbe19b892e3a3ee348c95f4a4fde374 (commit) - Log ----------------------------------------------------------------- commit 278743a7938096197436148f265d7a9c2a98697d Author: Wanlong Gao <gao...@cn...> Date: Thu Oct 31 16:37:47 2013 +0800 chroot03: code clean up Clean up the code. Signed-off-by: Wanlong Gao <gao...@cn...> commit 2edca2f697cbd337d9e73338202171b39e821331 Author: Xiaoguang Wang <wan...@cn...> Date: Thu Oct 31 10:15:05 2013 +0800 chroot/chroot03.c: add ELOOP error value test for chroot(2) Signed-off-by: Xiaoguang Wang <wan...@cn...> Reviewed-by: Wanlong Gao <gao...@cn...> commit 1237969a0e91a18e566124300f242e3fdd525782 Author: Simon Xu <xu....@or...> Date: Thu Oct 31 13:44:12 2013 +0800 dhcpd_tests.sh: fix dhcpd.conf file paths dhcpd_tests.sh only checks for /etc/dhcpd.conf, while in some distros the path is /etc/dhcp/dhcpd.conf. Signed-off-by: Simon Xu <xu....@or...> Reviewed-by: Wanlong Gao <gao...@cn...> commit 792fcce8ae68436c8963c6a51f1f98c66c575494 Author: Simon Xu <xu....@or...> Date: Thu Oct 31 14:13:38 2013 +0800 iptables_tests.sh: nat table can have 4 chains It is considered by iptables_tests.sh a failure When nat table chain count is not 3, while recent kernels can have 4 built-in chains in nat table, namely PREROUTING, OUTPUT, POSTROUTING and INPUT. Signed-off-by: Simon Xu <xu....@or...> Reviewed-by: Wanlong Gao <gao...@cn...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/syscalls/chroot/chroot03.c | 93 ++++++++----------------- testcases/network/dhcpd/dhcpd_tests.sh | 23 ++++-- testcases/network/iptables/iptables_tests.sh | 2 +- 3 files changed, 46 insertions(+), 72 deletions(-) diff --git a/testcases/kernel/syscalls/chroot/chroot03.c b/testcases/kernel/syscalls/chroot/chroot03.c index c34d8ea..3d295f7 100644 --- a/testcases/kernel/syscalls/chroot/chroot03.c +++ b/testcases/kernel/syscalls/chroot/chroot03.c @@ -1,5 +1,4 @@ /* - * * Copyright (c) International Business Machines Corp., 2001 * * This program is free software; you can redistribute it and/or modify @@ -18,16 +17,8 @@ */ /* - * NAME - * chroot03.c - * - * DESCRIPTION * Testcase to test whether chroot(2) sets errno correctly. * - * CALLS - * chroot(2) - * - * ALGORITHM * 1. Test for ENAMETOOLONG: * Create a bad directory name with length more than * VFS_MAXNAMELEN (Linux kernel variable), and pass it as the @@ -43,20 +34,11 @@ * The pathname parameter to chroot() points to an invalid address, * chroot(2) fails with EPERM. * - * USAGE: <for command-line> - * chroot03 [-c n] [-e] [-i n] [-I x] [-P x] [-t] - * where, -c n : Run n copies concurrently. - * -e : Turn on errno logging. - * -i n : Execute test n times. - * -I x : Execute test for x seconds. - * -P x : Pause for x seconds between iterations. - * -t : Turn on syscall timing. + * 5. Test for ELOOP: + * Too many symbolic links were encountered When resolving the + * pathname parameter. * - * HISTORY * 07/2001 Ported by Wayne Boyer - * - * RESTRICTIONS - * None */ #include <stdio.h> @@ -66,16 +48,17 @@ #include "test.h" #include "usctest.h" #include <fcntl.h> +#include "safe_macros.h" char *TCID = "chroot03"; -int fd = 0; -char fname[255]; -char good_dir[100] = "/tmp/testdir"; -char bad_dir[] = - "abcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyz"; +static int fd; +static char fname[255]; +static char good_dir[100] = "/tmp/testdir"; +static char bad_dir[] = "abcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyzabcdefghijklmnopqrstmnopqrstuvwxyz"; +static char symbolic_dir[] = "sym_dir1"; -int exp_enos[] = { ENAMETOOLONG, ENOENT, ENOTDIR, EFAULT, 0 }; +static int exp_enos[] = { ENAMETOOLONG, ENOENT, ENOTDIR, EFAULT, ELOOP, 0 }; struct test_case_t { char *dir; @@ -105,16 +88,17 @@ struct test_case_t { * and expect EFAULT as errno */ { - (char *)-1, EFAULT} + (char *)-1, EFAULT}, #endif + {symbolic_dir, ELOOP} }; int TST_TOTAL = (sizeof(TC) / sizeof(*TC)); -char *bad_addr = 0; +static char *bad_addr; -void setup(void); -void cleanup(void); +static void setup(void); +static void cleanup(void); int main(int ac, char **av) { @@ -122,22 +106,18 @@ int main(int ac, char **av) int i; char *msg; - if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) { + msg = parse_opts(ac, av, NULL, NULL); + if (msg != NULL) tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); - } setup(); - /* set up the expected errnos */ TEST_EXP_ENOS(exp_enos); for (lc = 0; TEST_LOOPING(lc); lc++) { - /* reset tst_count in case we are looping */ tst_count = 0; - /* loop through the test cases */ for (i = 0; i < TST_TOTAL; i++) { - TEST(chroot(TC[i].dir)); if (TEST_RETURN != -1) { @@ -155,22 +135,15 @@ int main(int ac, char **av) } } } - cleanup(); + cleanup(); tst_exit(); } -/* - * setup() - performs all ONE TIME setup for this test. - */ -void setup() +static void setup(void) { - tst_sig(NOFORK, DEF_HANDLER, cleanup); - TEST_PAUSE; - - /* make a temporary directory and cd to it */ tst_tmpdir(); /* @@ -178,9 +151,9 @@ void setup() * ENOTDIR if the argument is not a directory. */ (void)sprintf(fname, "tfile_%d", getpid()); - if ((fd = creat(fname, 0777)) == -1) { + fd = creat(fname, 0777); + if (fd == -1) tst_brkm(TBROK, cleanup, "Failed to creat a temp file"); - } /* * set up good_dir to test whether chroot() is setting ENOENT if the @@ -191,28 +164,22 @@ void setup() #if !defined(UCLINUX) bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE_EXCEPT_UCLINUX | MAP_ANONYMOUS, 0, 0); - if (bad_addr == MAP_FAILED) { + if (bad_addr == MAP_FAILED) tst_brkm(TBROK, cleanup, "mmap failed"); - } + TC[3].dir = bad_addr; #endif + /* + * create two symbolic directory who point to each other to + * test ELOOP. + */ + SAFE_SYMLINK(cleanup, "sym_dir1/", "sym_dir2"); + SAFE_SYMLINK(cleanup, "sym_dir2/", "sym_dir1"); } -/* - * cleanup() - performs all ONE TIME cleanup for this test at - * completion or premature exit. - */ -void cleanup() +static void cleanup(void) { - /* - * print timing stats if that option was specified. - * print errno log if that option was specified. - */ close(fd); - TEST_CLEANUP; - - /* delete the test directory created in setup() */ tst_rmdir(); - } diff --git a/testcases/network/dhcpd/dhcpd_tests.sh b/testcases/network/dhcpd/dhcpd_tests.sh index 64c64e8..c00e549 100755 --- a/testcases/network/dhcpd/dhcpd_tests.sh +++ b/testcases/network/dhcpd/dhcpd_tests.sh @@ -42,7 +42,7 @@ # Function: init # # Description: - Check if command dhcpd is available. -# - Check if /etc/dhcpd.conf is available. +# - Check if dhcpd.conf file is available. # - Create temporary config file, for dhcpd. # - alias ethX to ethX:1 with IP 10.1.1.12 # @@ -141,11 +141,18 @@ init() return $RC fi - if [ -f /etc/dhcpd.conf ] + 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 + DHCPD_CONF="" + fi + if [ -n $DHCPD_CONF ] then RC1=0 - mv /etc/dhcpd.conf $LTPTMP/dhcpd.conf > $LTPTMP/tst_dhcpd.err 2>&1 || RC=$? - mv $LTPTMP/tst_dhcpd.conf /etc/dhcpd.conf > $LTPTMP/tst_dhcpd.err 2>&1 \ + mv $DHCPD_CONF $LTPTMP/dhcpd.conf > $LTPTMP/tst_dhcpd.err 2>&1 || RC=$? + mv $LTPTMP/tst_dhcpd.conf $DHCPD_CONF > $LTPTMP/tst_dhcpd.err 2>&1 \ || RC1=$? if [ $RC -ne 0 -o $RC1 -ne 0 ] then @@ -155,7 +162,7 @@ init() fi else tst_brkm TBROK NULL \ - "INIT: No /etc/dhcpd.conf file found." + "INIT: No dhcpd.conf file found." return $(($RC+1)) fi @@ -204,7 +211,7 @@ cleanup() if [ -f $LTPTMP/dhcpd.conf ] then - mv $LTPTMP/dhcpd.conf /etc/dhcpd.conf > $LTPTMP/tst_dhcpd.err 2>&1 + mv $LTPTMP/dhcpd.conf $DHCPD_CONF > $LTPTMP/tst_dhcpd.err 2>&1 fi /sbin/ifconfig | grep "${ETH_INTERFACE}:1" > $LTPTMP/tst_dhcpd.err 2>&1 || RC=$? @@ -225,7 +232,7 @@ cleanup() # # Description - Test basic functionality of dhcpd. # - Test #1: dhcpd will serve IP addresses based on rules in -# /etc/dhcpd.conf file. +# dhcpd.conf file. # - create dhcpd.conf file, server to listen to ethX/.../10.1.1.0 # - start dhcpd server # - create expected output @@ -241,7 +248,7 @@ test01() TST_COUNT=1 # Test number. tst_resm TINFO \ - "Test #1: dhcpd will serve IPaddr, rules in /etc/dhcpd.conf file." + "Test #1: dhcpd will serve IPaddr, rules in dhcpd.conf file." hwaddr=`ifconfig ${ETH_INTERFACE} | grep HWaddr | awk '{print $5}'` || RC=$? if [ $RC -ne 0 ] diff --git a/testcases/network/iptables/iptables_tests.sh b/testcases/network/iptables/iptables_tests.sh index 028d54e..77ee29b 100755 --- a/testcases/network/iptables/iptables_tests.sh +++ b/testcases/network/iptables/iptables_tests.sh @@ -165,7 +165,7 @@ test01() return $RC else chaincnt=$(grep -c Chain $LTPTMP/tst_iptables.out) - if [ $chaincnt -ne 3 ]; then + if [ $chaincnt -ne 3 ] && [ $chaincnt -ne 4 ]; then tst_res TFAIL $LTPTMP/tst_iptables.out \ "$TCID: $cmd failed to list rules. Reason:" return $chaincnt hooks/post-receive -- ltp |