Author: asomers
Date: Wed Feb 15 00:16:52 2017
New Revision: 313754
URL: https://svnweb.freebsd.org/changeset/base/313754

Log:
  MFC r311893, r313008, r313081
  
  I had to modify the tests slightly for the MFC to stable/10, because
  stable/10 lacks r294037, which enabled /sbin/md5 to work on md(4)
  devices.
  
  r311893:
  ATFify the geom gate tests.
  
  This ensures their cleanup routines will be run even if they should timeout.
  
  tests/sys/geom/class/gate/ggate_test.sh
  tests/sys/geom/class/gate/Makefile
        Add an ATF test with three testcases, one for each TAP test. Use
        ATF-style cleanup functions, and convert sleeps to polling loops.
  
  ObsoleteFiles.inc
  tests/sys/geom/class/gate/conf.sh
  tests/sys/geom/class/gate/1_test.sh
  tests/sys/geom/class/gate/2_test.sh
  tests/sys/geom/class/gate/3_test.sh
        Delete TAP test files
  
  Reviewed by:  ngie
  MFC after:    4 weeks
  Sponsored by: Spectra Logic Corp
  Differential Revision:        https://reviews.freebsd.org/D8891
  
  r313008:
  Wait for /dev/ggate* to appear after calling `ggatel create` in 
:ggatel_{file,md}
  
  The test assumed that `ggatel create` created a device on completion, but 
that's
  incorrect. This squashes the race by waiting for the device to appear, as
  `ggatel create` daemonizes before issuing an ioctl to geom_gate(4) if not 
called
  with `-v`.
  
  Discussed with:       asomers
  MFC after:    1 week
  PR:           204616
  Sponsored by: Dell EMC Isilon
  
  r313081:
  Replace for/retry loops with "wait_for_ggate_device" calls and check
  results of commands
  
  As noted in r313008, the underlying issue was that geom_gate device
  creation wasn't created at ggatel command completion, but some short
  time after. ggatec(8) employs similar logic when creating geom_gate(4)
  devices.
  
  Switch from retry loops (after the ggatec/dd write calls) to
  wait_for_ggate_device function calls after calling ggatec(8) instead
  to detect the presence of the /dev/ggate* device, as this function is
  sufficient for determining whether or not the character device is ready
  for testing
  
  While here, use atf_check consistently with all dd calls to ensure that
  data output is as expected.
  
  MFC after:    1 week
  Reviewed by:  asomers
  Differential Revision:        D9409
  Sponsored by: Dell EMC Isilon

Added:
  stable/10/tests/sys/geom/class/gate/ggate_test.sh
     - copied, changed from r311893, 
head/tests/sys/geom/class/gate/ggate_test.sh
Deleted:
  stable/10/tests/sys/geom/class/gate/1_test.sh
  stable/10/tests/sys/geom/class/gate/2_test.sh
  stable/10/tests/sys/geom/class/gate/3_test.sh
  stable/10/tests/sys/geom/class/gate/conf.sh
Modified:
  stable/10/ObsoleteFiles.inc
  stable/10/tests/sys/geom/class/gate/Makefile
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/ObsoleteFiles.inc
==============================================================================
--- stable/10/ObsoleteFiles.inc Wed Feb 15 00:15:24 2017        (r313753)
+++ stable/10/ObsoleteFiles.inc Wed Feb 15 00:16:52 2017        (r313754)
@@ -38,6 +38,11 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20170214: Four files from ggate tests consolidated into one
+OLD_FILES+=usr/tests/sys/geom/class/gate/1_test
+OLD_FILES+=usr/tests/sys/geom/class/gate/2_test
+OLD_FILES+=usr/tests/sys/geom/class/gate/3_test
+OLD_FILES+=usr/tests/sys/geom/class/gate/conf.sh
 # 20170211: libarchive ACL pax test renamed to test_acl_pax_posix1e.tar.uu
 OLD_FILES+=usr/tests/lib/libarchive/test_acl_pax.tar.uu
 # 20161229: Three files from gnop tests consolidated into one

Modified: stable/10/tests/sys/geom/class/gate/Makefile
==============================================================================
--- stable/10/tests/sys/geom/class/gate/Makefile        Wed Feb 15 00:15:24 
2017        (r313753)
+++ stable/10/tests/sys/geom/class/gate/Makefile        Wed Feb 15 00:16:52 
2017        (r313754)
@@ -2,16 +2,6 @@
 
 TESTSDIR=      ${TESTSBASE}/sys/geom/class/${.CURDIR:T}
 
-TAP_TESTS_SH+= 1_test
-TAP_TESTS_SH+= 2_test
-TAP_TESTS_SH+= 3_test
-
-FILES+=                conf.sh
-FILESNAME_conf.sh=     conf.sh
-FILESDIR=      ${TESTSDIR}
-
-.for t in ${TAP_TESTS_SH}
-TEST_METADATA.$t+=     required_user="root"
-.endfor
+ATF_TESTS_SH+= ggate_test
 
 .include <bsd.test.mk>

Copied and modified: stable/10/tests/sys/geom/class/gate/ggate_test.sh (from 
r311893, head/tests/sys/geom/class/gate/ggate_test.sh)
==============================================================================
--- head/tests/sys/geom/class/gate/ggate_test.sh        Tue Jan 10 20:35:09 
2017        (r311893, copy source)
+++ stable/10/tests/sys/geom/class/gate/ggate_test.sh   Wed Feb 15 00:16:52 
2017        (r313754)
@@ -4,7 +4,6 @@ PIDFILE=ggated.pid
 PLAINFILES=plainfiles
 PORT=33080
 CONF=gg.exports
-RETRIES=16
 
 atf_test_case ggated cleanup
 ggated_head()
@@ -21,31 +20,23 @@ ggated_body()
        work=$(alloc_md)
        src=$(alloc_md)
 
-       dd if=/dev/random of=/dev/$work bs=1m count=1 conv=notrunc
-       dd if=/dev/random of=/dev/$src bs=1m count=1 conv=notrunc
+       atf_check -e ignore -o ignore \
+           dd if=/dev/random of=/dev/$work bs=1m count=1 conv=notrunc
+       atf_check -e ignore -o ignore \
+           dd if=/dev/random of=/dev/$src bs=1m count=1 conv=notrunc
 
        echo $CONF >> $PLAINFILES
        echo "127.0.0.1 RW /dev/$work" > $CONF
 
        atf_check ggated -p $PORT -F $PIDFILE $CONF
-       for try in `jot $RETRIES`; do
-               ggatec create -p $PORT -u $us 127.0.0.1 /dev/$work && break
-               # wait for ggated to be ready
-               sleep 0.25
-       done
-       if [ "$try" -eq "$RETRIES" ]; then
-               atf_fail "ggatec create failed"
-       fi
+       atf_check ggatec create -p $PORT -u $us 127.0.0.1 /dev/$work
 
-       for try in `jot $RETRIES`; do
-               dd if=/dev/${src} of=/dev/ggate${us} bs=1m count=1 conv=notrunc\
-                       && break
-               # Wait for /dev/ggate${us} to be ready
-               sleep 0.25
-       done
-       if [ "$try" -eq "$RETRIES" ]; then
-               atf_fail "dd failed; /dev/ggate${us} isn't working"
-       fi
+       ggate_dev=/dev/ggate${us}
+
+       wait_for_ggate_device ${ggate_dev}
+
+       atf_check -e ignore -o ignore \
+           dd if=/dev/${src} of=${ggate_dev} bs=1m count=1 conv=notrunc
 
        checksum /dev/$src /dev/$work
 }
@@ -74,7 +65,12 @@ ggatel_file_body()
 
        atf_check ggatel create -u $us work
 
-       dd if=src of=/dev/ggate${us} bs=1m count=1 conv=notrunc
+       ggate_dev=/dev/ggate${us}
+
+       wait_for_ggate_device ${ggate_dev}
+
+       atf_check -e ignore -o ignore \
+           dd if=src of=${ggate_dev} bs=1m count=1 conv=notrunc
 
        checksum src work
 }
@@ -99,12 +95,19 @@ ggatel_md_body()
        work=$(alloc_md)
        src=$(alloc_md)
 
-       dd if=/dev/random of=$work bs=1m count=1 conv=notrunc
-       dd if=/dev/random of=$src bs=1m count=1 conv=notrunc
+       atf_check -e ignore -o ignore \
+           dd if=/dev/random of=$work bs=1m count=1 conv=notrunc
+       atf_check -e ignore -o ignore \
+           dd if=/dev/random of=$src bs=1m count=1 conv=notrunc
 
        atf_check ggatel create -u $us /dev/$work
 
-       dd if=/dev/$src of=/dev/ggate${us} bs=1m count=1 conv=notrunc
+       ggate_dev=/dev/ggate${us}
+
+       wait_for_ggate_device ${ggate_dev}
+
+       atf_check -e ignore -o ignore \
+           dd if=/dev/$src of=${ggate_dev} bs=1m count=1 conv=notrunc
 
        checksum /dev/$src /dev/$work
 }
@@ -149,14 +152,14 @@ checksum()
        src=$1
        work=$2
 
-       src_checksum=$(md5 -q $src)
-       work_checksum=$(md5 -q $work)
+       src_checksum=$(dd if=${src} bs=1m | md5 -q)
+       work_checksum=$(dd if=${work} bs=1m | md5 -q)
 
        if [ "$work_checksum" != "$src_checksum" ]; then
                atf_fail "work md5 checksum didn't match"
        fi
 
-       ggate_checksum=$(md5 -q /dev/ggate${us})
+       ggate_checksum=$(dd if=/dev/ggate${us} bs=1m | md5 -q)
        if [ "$ggate_checksum" != "$src_checksum" ]; then
                atf_fail "ggate md5 checksum didn't match"
        fi
@@ -191,3 +194,14 @@ common_cleanup()
        fi
        true
 }
+
+# Bug 204616: ggatel(8) creates /dev/ggate* asynchronously if `ggatel create`
+#             isn't called with `-v`.
+wait_for_ggate_device()
+{
+       ggate_device=$1
+
+       while [ ! -c $ggate_device ]; do
+               sleep 0.5
+       done
+}
_______________________________________________
svn-src-stable-10@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-stable-10
To unsubscribe, send any mail to "svn-src-stable-10-unsubscr...@freebsd.org"

Reply via email to