Whamcloud - gitweb
LU-425 tests: fix the issue of using "grep -w"
authorYu Jian <yujian@whamcloud.com>
Thu, 12 Apr 2012 15:38:17 +0000 (23:38 +0800)
committerJohann Lombardi <johann@whamcloud.com>
Fri, 11 May 2012 07:20:01 +0000 (03:20 -0400)
This patch fixes the following issue while using "grep -w"
to do exact match:

$ echo /mnt/nbp0-2 | grep -w /mnt/nbp0
/mnt/nbp0-2

Per the description of "-w" option:
-w, --word-regexp
Select only those lines containing matches that form whole words.
The test is that the matching substring must either be at the
beginning of the line, or preceded by a non-word constituent
character. Similarly, it must be either at the end of the line
or followed by a non-word constituent character. Word-constituent
characters are letters, digits, and the underscore.

So, the hyphen "-" character is a non-word constituent character
and "grep -w" does not do exact match on strings which contain it.

Signed-off-by: Yu Jian <yujian@whamcloud.com>
Change-Id: I91962910033f561cc9c9a82bd88bbb6dff5594af
Reviewed-on: http://review.whamcloud.com/2528
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-by: Wei Liu <sarah@whamcloud.com>
Reviewed-by: Johann Lombardi <johann@whamcloud.com>
lustre/tests/acceptance-small.sh
lustre/tests/auster
lustre/tests/replay-dual.sh
lustre/tests/test-framework.sh

index 5f1f2e8..4f5a665 100755 (executable)
@@ -46,7 +46,7 @@ setup_if_needed() {
     nfs_client_mode && return
 
     local MOUNTED=$(mounted_lustre_filesystems)
-    if $(echo $MOUNTED | grep -w -q $MOUNT); then
+    if $(echo $MOUNTED' ' | grep -w -q $MOUNT' '); then
         check_config_clients $MOUNT
         init_facets_vars
         init_param_vars
@@ -58,7 +58,7 @@ setup_if_needed() {
     $SETUP
 
     MOUNTED=$(mounted_lustre_filesystems)
-    if ! $(echo $MOUNTED | grep -w -q $MOUNT); then
+    if ! $(echo $MOUNTED' ' | grep -w -q $MOUNT' '); then
         echo "Lustre is not mounted after setup! SETUP=$SETUP"
         exit 1
     fi
index d8ad562..a69362b 100755 (executable)
@@ -123,7 +123,7 @@ setup_if_needed() {
     auster_cleanup=false
 
     local MOUNTED=$(mounted_lustre_filesystems)
-    if $(echo $MOUNTED | grep -w -q $MOUNT); then
+    if $(echo $MOUNTED' ' | grep -w -q $MOUNT' '); then
         check_config_clients $MOUNT
        # init_facets_vars
        # init_param_vars
@@ -135,7 +135,7 @@ setup_if_needed() {
     setupall
 
     MOUNTED=$(mounted_lustre_filesystems)
-    if ! $(echo $MOUNTED | grep -w -q $MOUNT); then
+    if ! $(echo $MOUNTED' ' | grep -w -q $MOUNT' '); then
         echo "Lustre is not mounted after setup! "
         exit 1
     fi
index 871ecd5..2ca4a08 100755 (executable)
@@ -25,7 +25,7 @@ build_test_filter
 
 check_and_setup_lustre
 MOUNTED=$(mounted_lustre_filesystems)
-if ! $(echo $MOUNTED | grep -w -q $MOUNT2); then
+if ! $(echo $MOUNTED' ' | grep -w -q $MOUNT2' '); then
     zconf_mount $HOSTNAME $MOUNT2
     MOUNTED2=yes
 fi
index 9d1bcff..74629fd 100644 (file)
@@ -687,7 +687,7 @@ sanity_mount_check_nodes () {
     local rc=0
     for mnt in $mnts ; do
         do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
-mpts=\\\$(mount | grep -w -c $mnt);
+mpts=\\\$(mount | grep -c $mnt' ');
 if [ \\\$running -ne \\\$mpts ]; then
     echo \\\$(hostname) env are INSANE!;
     exit 1;
@@ -757,7 +757,7 @@ fi;
 exit $rc"
 
     echo "Started clients $clients: "
-    do_nodes $clients "mount | grep -w $mnt"
+    do_nodes $clients "mount | grep $mnt' '"
 
     set_default_debug_nodes $clients