]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[v9_11] Stabilize logfileconfig system test
authorMichał Kępień <michal@isc.org>
Thu, 16 Nov 2017 07:06:57 +0000 (08:06 +0100)
committerMichał Kępień <michal@isc.org>
Thu, 16 Nov 2017 07:09:43 +0000 (08:09 +0100)
4818. [test] The logfileconfig system test could intermittently
report false negatives on some platforms. [RT #46615]

(cherry picked from commit 7a0188774f1acd5d9f2abaf978ba56a582ebcb8c)

CHANGES
bin/named/include/named/seccomp.h
bin/tests/system/logfileconfig/tests.sh

diff --git a/CHANGES b/CHANGES
index e8c243980960fe90fcce008b881daf0025416745..de82e1271af3bbd5d93244c59b53ff0fae4ea1f3 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+4818.  [test]          The logfileconfig system test could intermittently
+                       report false negatives on some platforms. [RT #46615]
+
 4817.  [cleanup]       Use DNS_NAME_INITABSOLUTE and DNS_NAME_INITNONABSOLUTE.
                        [RT #45433]
 
index 2e7f6b41a179ca4ad37070861c75d671184ea58b..a0490d2e951ea169b4c6c4df6a6a616f6b98665e 100644 (file)
@@ -26,6 +26,8 @@
 int scmp_syscalls[] = {
        SCMP_SYS(access),
        SCMP_SYS(open),
+       SCMP_SYS(openat),
+       SCMP_SYS(lseek),
        SCMP_SYS(clock_gettime),
        SCMP_SYS(time),
        SCMP_SYS(read),
@@ -54,6 +56,7 @@ int scmp_syscalls[] = {
 #ifdef HAVE_GETRANDOM
        SCMP_SYS(getrandom),
 #endif
+       SCMP_SYS(rename),
        SCMP_SYS(unlink),
        SCMP_SYS(socket),
        SCMP_SYS(sendto),
@@ -72,7 +75,6 @@ int scmp_syscalls[] = {
        SCMP_SYS(getsockopt),
        SCMP_SYS(getsockname),
        SCMP_SYS(lstat),
-       SCMP_SYS(lseek),
        SCMP_SYS(getgid),
        SCMP_SYS(getegid),
        SCMP_SYS(getuid),
@@ -83,9 +85,7 @@ int scmp_syscalls[] = {
        SCMP_SYS(setuid),
        SCMP_SYS(prctl),
        SCMP_SYS(epoll_wait),
-       SCMP_SYS(openat),
        SCMP_SYS(getdents),
-       SCMP_SYS(rename),
        SCMP_SYS(utimes),
        SCMP_SYS(dup),
 #endif
@@ -93,6 +93,8 @@ int scmp_syscalls[] = {
 const char *scmp_syscall_names[] = {
        "access",
        "open",
+       "openat",
+       "lseek",
        "clock_gettime",
        "time",
        "read",
@@ -121,6 +123,7 @@ const char *scmp_syscall_names[] = {
 #ifdef HAVE_GETRANDOM
        "getrandom",
 #endif
+       "rename",
        "unlink",
        "socket",
        "sendto",
@@ -139,7 +142,6 @@ const char *scmp_syscall_names[] = {
        "getsockopt",
        "getsockname",
        "lstat",
-       "lseek",
        "getgid",
        "getegid",
        "getuid",
@@ -150,9 +152,7 @@ const char *scmp_syscall_names[] = {
        "setuid",
        "prctl",
        "epoll_wait",
-       "openat",
        "getdents",
-       "rename",
        "utimes",
        "dup",
 #endif
index eef5db0622a82000272a524d87f375495877df7e..846be9838be427ac9c21ff1c7e645db3876133f9 100644 (file)
@@ -30,6 +30,19 @@ PIDFILE="${THISDIR}/${CONFDIR}/named.pid"
 myRNDC="$RNDC -c ${THISDIR}/${CONFDIR}/rndc.conf"
 myNAMED="$NAMED -c ${THISDIR}/${CONFDIR}/named.conf -m record,size,mctx -T clienttest -T nosyslog -d 99 -X named.lock -U 4"
 
+# Test given condition.  If true, test again after a second.  Used for testing
+# filesystem-dependent conditions in order to prevent false negatives caused by
+# directory contents not being synchronized immediately after rename() returns.
+test_with_retry() {
+       if test "$@"; then
+               sleep 1
+               if test "$@"; then
+                       return 0
+               fi
+       fi
+       return 1
+}
+
 waitforpidfile() {
        for _w in 1 2 3 4 5 6 7 8 9 10
        do
@@ -43,9 +56,10 @@ n=0
 
 cd $CONFDIR
 
-n=`expr $n + 1`
-echo "I:testing log file validity (named -g + only plain files allowed) ($n)"
+echo "I:testing log file validity (named -g + only plain files allowed)"
 
+n=`expr $n + 1`
+echo "I: testing plain file (named -g) ($n)"
 # First run with a known good config.
 echo > $PLAINFILE
 cp $PLAINCONF named.conf
@@ -53,9 +67,9 @@ $myRNDC reconfig > rndc.out.test$n 2>&1
 grep "reloading configuration failed" named.run > /dev/null 2>&1
 if [ $? -ne 0 ]
 then
-       echo "I: testing plain file succeeded"
+       echo "I:  testing plain file succeeded"
 else
-       echo "I: testing plain file failed (unexpected)"
+       echo "I:  testing plain file failed (unexpected)"
        echo "I:exit status: 1"
        exit 1 
 fi
@@ -74,14 +88,14 @@ then
        grep "checking logging configuration failed: invalid file" named.run > /dev/null 2>&1
        if [ $? -ne 0 ]
        then
-               echo "I: testing directory as file succeeded (UNEXPECTED)"
+               echo "I:  testing directory as file succeeded (UNEXPECTED)"
                echo "I:exit status: 1"
                exit 1
        else
-               echo "I: testing directory as log file failed (expected)"
+               echo "I:  testing directory as log file failed (expected)"
        fi
 else
-       echo "I: skipping directory test (unable to create directory)"
+       echo "I:  skipping directory test (unable to create directory)"
 fi
 
 # Now try pipe file, expect failure
@@ -98,14 +112,14 @@ then
        grep "checking logging configuration failed: invalid file" named.run  > /dev/null 2>&1
        if [ $? -ne 0 ]
        then
-               echo "I: testing pipe file as log file succeeded (UNEXPECTED)"
+               echo "I:  testing pipe file as log file succeeded (UNEXPECTED)"
                echo "I:exit status: 1"
                exit 1
        else
-               echo "I: testing pipe file as log file failed (expected)"
+               echo "I:  testing pipe file as log file failed (expected)"
        fi
 else
-       echo "I: skipping pipe test (unable to create pipe)"
+       echo "I:  skipping pipe test (unable to create pipe)"
 fi
 
 # Now try symlink file to plain file, expect success 
@@ -124,14 +138,14 @@ then
        grep "reloading configuration failed" named.run > /dev/null 2>&1
        if [ $? -ne 0 ]
        then
-               echo "I: testing symlink to plain file succeeded"
+               echo "I:  testing symlink to plain file succeeded"
        else
-               echo "I: testing symlink to plain file failed (unexpected)"
+               echo "I:  testing symlink to plain file failed (unexpected)"
                echo "I:exit status: 1"
                exit 1
        fi
 else
-       echo "I: skipping symlink test (unable to create symlink)"
+       echo "I:  skipping symlink test (unable to create symlink)"
 fi
 # Stop the server and run through a series of tests with various config
 # files while controlling the stop/start of the server.
@@ -150,9 +164,10 @@ fi
 
 status=0
 
-n=`expr $n + 1`
-echo "I:testing log file validity (only plain files allowed) ($n)"
+echo "I:testing log file validity (only plain files allowed)"
 
+n=`expr $n + 1`
+echo "I: testing plain file (named -g) ($n)"
 # First run with a known good config.
 echo > $PLAINFILE
 cp $PLAINCONF named.conf
@@ -160,9 +175,9 @@ $myRNDC reconfig > rndc.out.test$n 2>&1
 grep "reloading configuration failed" named.run > /dev/null 2>&1
 if [ $? -ne 0 ]
 then
-       echo "I: testing plain file succeeded"
+       echo "I:  testing plain file succeeded"
 else
-       echo "I: testing plain file failed (unexpected)"
+       echo "I:  testing plain file failed (unexpected)"
        echo "I:exit status: 1"
        exit 1 
 fi
@@ -181,14 +196,14 @@ then
        grep "configuring logging: invalid file" named.run > /dev/null 2>&1
        if [ $? -ne 0 ]
        then
-               echo "I: testing directory as file succeeded (UNEXPECTED)"
+               echo "I:  testing directory as file succeeded (UNEXPECTED)"
                echo "I:exit status: 1"
                exit 1
        else
-               echo "I: testing directory as log file failed (expected)"
+               echo "I:  testing directory as log file failed (expected)"
        fi
 else
-       echo "I: skipping directory test (unable to create directory)"
+       echo "I:  skipping directory test (unable to create directory)"
 fi
 
 # Now try pipe file, expect failure
@@ -205,14 +220,14 @@ then
        grep "configuring logging: invalid file" named.run  > /dev/null 2>&1
        if [ $? -ne 0 ]
        then
-               echo "I: testing pipe file as log file succeeded (UNEXPECTED)"
+               echo "I:  testing pipe file as log file succeeded (UNEXPECTED)"
                echo "I:exit status: 1"
                exit 1
        else
-               echo "I: testing pipe file as log file failed (expected)"
+               echo "I:  testing pipe file as log file failed (expected)"
        fi
 else
-       echo "I: skipping pipe test (unable to create pipe)"
+       echo "I:  skipping pipe test (unable to create pipe)"
 fi
 
 # Now try symlink file to plain file, expect success 
@@ -232,14 +247,14 @@ then
        grep "reloading configuration failed" named.run > /dev/null 2>&1
        if [ $? -ne 0 ]
        then
-               echo "I: testing symlink to plain file succeeded"
+               echo "I:  testing symlink to plain file succeeded"
        else
-               echo "I: testing symlink to plain file failed (unexpected)"
+               echo "I:  testing symlink to plain file failed (unexpected)"
                echo "I:exit status: 1"
                exit 1
        fi
 else
-       echo "I: skipping symlink test (unable to create symlink)"
+       echo "I:  skipping symlink test (unable to create symlink)"
 fi
 
 status=0
@@ -253,7 +268,7 @@ if ! test -f $PIDFILE; then
        cp $PLAINCONF named.conf
        $myNAMED -L $DLFILE > /dev/null 2>&1
        if [ $? -ne 0 ]; then
-               echo "I:failed to start $myNAMED"
+               echo "I: failed to start $myNAMED"
                echo "I:exit status: $status"
                exit $status
        fi
@@ -269,7 +284,7 @@ if ! test -f $PIDFILE; then
                exit 1
        fi
 else
-       echo "I:failed to cleanly stop $myNAMED"
+       echo "I: failed to cleanly stop $myNAMED"
        echo "I:exit status: 1"
        exit 1
 fi
@@ -277,7 +292,7 @@ fi
 echo "I:testing logging functionality"
 
 n=`expr $n + 1`
-echo "I: testing explict versions ($n)"
+echo "I: testing explicit versions ($n)"
 cp $VERSCONF named.conf
 # a seconds since epoch version number
 touch $VERSFILE.1480039317
@@ -288,27 +303,27 @@ t2=`$PERL -e 'print time()."\n";'`
 t=`expr ${t2:-0} - ${t1:-0}`
 if test ${t:-1000} -gt 5
 then
-        echo "I: testing explict versions failed cleanup of old entries took too long ($t secs)"
+        echo "I:  testing explicit versions failed: cleanup of old entries took too long ($t secs)"
        status=`expr $status + 1`
 fi 
 if ! grep "status: NOERROR" dig.out.test$n > /dev/null
 then
-       echo "I: testing explict versions failed DiG lookup failed"
+       echo "I:  testing explicit versions failed: DiG lookup failed"
        status=`expr $status + 1`
 fi
-if test -f $VERSFILE.1480039317
+if test_with_retry -f $VERSFILE.1480039317
 then
-       echo "I: testing explict versions failed $VERSFILE.1480039317 not removed"
+       echo "I:  testing explicit versions failed: $VERSFILE.1480039317 not removed"
        status=`expr $status + 1`
 fi
-if test -f $VERSFILE.5
+if test_with_retry -f $VERSFILE.5
 then
-       echo "I: testing explict versions failed $VERSFILE.5 exists"
+       echo "I:  testing explicit versions failed: $VERSFILE.5 exists"
        status=`expr $status + 1`
 fi
-if test ! -f $VERSFILE.4
+if test_with_retry ! -f $VERSFILE.4
 then
-       echo "I: testing explict versions failed $VERSFILE.4 does not exist"
+       echo "I:  testing explicit versions failed: $VERSFILE.4 does not exist"
        status=`expr $status + 1`
 fi
 
@@ -324,22 +339,22 @@ t2=`$PERL -e 'print time()."\n";'`
 t=`expr ${t2:-0} - ${t1:-0}`
 if test ${t:-1000} -gt 5
 then
-        echo "I: testing unlimited versions failed took too long ($t secs)"
+        echo "I:  testing unlimited versions failed: took too long ($t secs)"
        status=`expr $status + 1`
 fi 
 if ! grep "status: NOERROR" dig.out.test$n > /dev/null
 then
-       echo "I: testing unlimited versions failed DiG lookup failed"
+       echo "I:  testing unlimited versions failed: DiG lookup failed"
        status=`expr $status + 1`
 fi
-if test ! -f $UNLIMITEDFILE.1480039317
+if test_with_retry ! -f $UNLIMITEDFILE.1480039317
 then
-       echo "I: testing unlimited versions failed $UNLIMITEDFILE.1480039317 removed"
+       echo "I:  testing unlimited versions failed: $UNLIMITEDFILE.1480039317 removed"
        status=`expr $status + 1`
 fi
-if test ! -f $UNLIMITEDFILE.4
+if test_with_retry ! -f $UNLIMITEDFILE.4
 then
-       echo "I: testing unlimited versions failed $UNLIMITEDFILE.4 does not"
+       echo "I:  testing unlimited versions failed: $UNLIMITEDFILE.4 does not exist"
        status=`expr $status + 1`
 fi