From f05ca36e8c6920c435d5426b67ce5d13f9bf772b Mon Sep 17 00:00:00 2001 From: Yu Jian Date: Fri, 13 Apr 2012 14:33:48 +0800 Subject: [PATCH] LU-425 tests: fix the issue of using "grep -w" 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 Change-Id: I53d306d38b05408c351db10dc545120f2f9dabce Reviewed-on: http://review.whamcloud.com/2529 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Minh Diep Reviewed-by: Wei Liu Reviewed-by: Oleg Drokin --- lustre/tests/acceptance-small.sh | 4 ++-- lustre/tests/auster | 4 ++-- lustre/tests/replay-dual.sh | 2 +- lustre/tests/test-framework.sh | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lustre/tests/acceptance-small.sh b/lustre/tests/acceptance-small.sh index abc9e84..e69ede2 100755 --- a/lustre/tests/acceptance-small.sh +++ b/lustre/tests/acceptance-small.sh @@ -66,7 +66,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 @@ -78,7 +78,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 diff --git a/lustre/tests/auster b/lustre/tests/auster index 6b5988e..7b69bb0 100755 --- a/lustre/tests/auster +++ b/lustre/tests/auster @@ -134,7 +134,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 @@ -146,7 +146,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 diff --git a/lustre/tests/replay-dual.sh b/lustre/tests/replay-dual.sh index 1d3f1c3..08a9662 100755 --- a/lustre/tests/replay-dual.sh +++ b/lustre/tests/replay-dual.sh @@ -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 diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index c21e281..a7fdf95 100644 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -869,7 +869,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; @@ -939,7 +939,7 @@ fi; exit \\\$rc" || return ${PIPESTATUS[0]} echo "Started clients $clients: " - do_nodes $clients "mount | grep -w $mnt" + do_nodes $clients "mount | grep $mnt' '" set_default_debug_nodes $clients -- 1.8.3.1