Skip to contentSkip to conversation

common: Fixes for testing NFS over IPv6

PATCH Superseded Anna Schumaker 2 participants 3 messages Oct 29, 2014 – Oct 30, 2014

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common: Fixes for testing NFS over IPv6

When testing NFS over IPv6, the user will set a $TEST_DEV of the form [fe80::42]:/export. The use of square brackets surrounding the IPv6 address is an accepted convention, but grep and awk think that our IPv6 address is actually a regex and tries to evaluate it instead. The result is that xfstests reports our filesystem "is busy or already mounted".

This patch fixes the IPv6 problem by telling awk and grep to treat $TEST_DEV as a fixed string rather than a regex.

---
 common/rc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
common/rc +4 -4
index 747cf72..5f24eb0 100644
@@ -810,13 +810,13 @@ _df_device()
     fi
 
     $DF_PROG 2>/dev/null | $AWK_PROG -v what=$1 '
-        match($1,what) && NF==1 {
+        ($1==what) && (NF==1) {
             v=$1
             getline
             print v, $0
             exit
         }
-        match($1,what) {
+        ($1==what) {
             print
             exit
         }
@@ -1132,10 +1132,10 @@ _require_test()
     esac
 
     # mounted?
-    if _mount | grep -q $TEST_DEV
+    if _mount | grep -F -q $TEST_DEV
     then
         # if it's mounted, make sure its on $TEST_DIR
-        if ! _mount | grep $TEST_DEV | grep -q $TEST_DIR
+        if ! _mount | grep -F $TEST_DEV | grep -q $TEST_DIR
         then
             echo "\$TEST_DEV is mounted but not on \$TEST_DIR - aborting"
             exit 1
Signature · 1 line
2.1.2
#1 lore raw
Quoted 11 lines · Anna Schumaker

When testing NFS over IPv6, the user will set a $TEST_DEV of the form [fe80::42]:/export. The use of square brackets surrounding the IPv6 address is an accepted convention, but grep and awk think that our IPv6 address is actually a regex and tries to evaluate it instead. The result is that xfstests reports our filesystem "is busy or already mounted".

This patch fixes the IPv6 problem by telling awk and grep to treat $TEST_DEV as a fixed string rather than a regex.

Seems sensible, but it needs comments so that when someone copies the code they know why it's using these sorts of matches.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
#2 lore raw
Quoted 8 lines · Dave Chinner
Quoted 7 lines · Anna Schumaker

When testing NFS over IPv6, the user will set a $TEST_DEV of the form [fe80::42]:/export. The use of square brackets surrounding the IPv6 address is an accepted convention, but grep and awk think that our IPv6 address is actually a regex and tries to evaluate it instead. The result is that xfstests reports our filesystem "is busy or already mounted".

Quoted 7 lines
Quoted 4 lines

This patch fixes the IPv6 problem by telling awk and grep to treat $TEST_DEV as a fixed string rather than a regex.

Seems sensible, but it needs comments so that when someone copies the code they know why it's using these sorts of matches.

Sure. I'll add that in, thanks!

Quoted 5 lines

Cheers,

Dave.