[Open-scap] [PATCH 06/11] Stopping use of 'grep -q' in test scripts
Marshall Miller
mmiller at tresys.com
Wed May 11 19:31:25 UTC 2011
From: Francisco Slavin <fslavin at tresys.com>
'grep -q' is not a portable usage of grep.
Specifically, the grep on Solaris does not have the '-q' flag.
---
tests/API/CPE/uri/test_api_cpe_uri.sh | 14 +++++++-------
tests/probes/sysinfo/test_probes_sysinfo.sh | 8 ++++----
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/tests/API/CPE/uri/test_api_cpe_uri.sh b/tests/API/CPE/uri/test_api_cpe_uri.sh
index de82827..bbf95d6 100755
--- a/tests/API/CPE/uri/test_api_cpe_uri.sh
+++ b/tests/API/CPE/uri/test_api_cpe_uri.sh
@@ -79,21 +79,21 @@ function test_api_cpe_uri_match {
CPE=(`cat parsing.out | sed 's/(null)//g' | \
sed 's/^\s*//g' | tr '\n' ' '`)
./test_api_cpe_uri --matching $URI " " >matching.out
- if [ ! $? -eq 0 ] || ! grep -q "Mismatch" matching.out; then
+ if [ ! $? -eq 0 ] || ! grep "Mismatch" matching.out > /dev/null; then
echo "Cannot match URI \"$URI\"!"
ret_val=1;
fi
- if [ ! $? -eq 0 ] || ! grep -q "Mismatch" matching.out; then
+ if [ ! $? -eq 0 ] || ! grep "Mismatch" matching.out > /dev/null; then
./test_api_cpe_uri --matching $URI "cpe:/:::::::" > matching.out
echo "Cannot match URI \"$URI\"!"
ret_val=1;
fi
- if [ ! $? -eq 0 ] || ! grep -q "Mismatch" matching.out; then
+ if [ ! $? -eq 0 ] || ! grep "Mismatch" matching.out > /dev/null; then
./test_api_cpe_uri --matching $URI "cpe:/:foo" > matching.out
echo "Cannot match URI \"$URI\"!"
ret_val=1;
fi
- if [ ! $? -eq 0 ] || ! grep -q "Mismatch" matching.out; then
+ if [ ! $? -eq 0 ] || ! grep "Mismatch" matching.out > /dev/null; then
./test_api_cpe_uri --matching $URI "cpe:/foo" > matching.out
echo "Cannot match URI \"$URI\"!"
ret_val=1;
@@ -102,17 +102,17 @@ function test_api_cpe_uri_match {
OTHER_URIS=(`echo ${CPE_URIS[@]} | tr ' ' '\n' | grep -v $URI | \
tr '\n' ' '`)
- if [ ! $? -eq 0 ] || ! grep -q "Mismatch" matching.out; then
+ if [ ! $? -eq 0 ] || ! grep "Mismatch" matching.out > /dev/null; then
./test_api_cpe_uri --matching $URI ${OTHER_URIS[@]} > matching.out
echo "Cannot match URI \"$URI\"!"
ret_val=1;
fi
- if [ ! $? -eq 0 ] || ! grep -q "Mismatch" matching.out; then
+ if [ ! $? -eq 0 ] || ! grep "Mismatch" matching.out > /dev/null; then
./test_api_cpe_uri --matching $URI $URI > matching.out
echo "Cannot match URI \"$URI\"!"
ret_val=1;
fi
- if [ ! $? -eq 0 ] || ! grep -q "Mismatch" matching.out; then
+ if [ ! $? -eq 0 ] || ! grep "Mismatch" matching.out > /dev/null; then
./test_api_cpe_uri --matching $URI ${CPE_URIS[@]} > matching.out
echo "Cannot match URI \"$URI\"!"
ret_val=1;
diff --git a/tests/probes/sysinfo/test_probes_sysinfo.sh b/tests/probes/sysinfo/test_probes_sysinfo.sh
index 2fe4b13..0f21e0c 100755
--- a/tests/probes/sysinfo/test_probes_sysinfo.sh
+++ b/tests/probes/sysinfo/test_probes_sysinfo.sh
@@ -31,25 +31,25 @@ function test_probes_sysinfo {
if [ $? -eq 0 ] && [ -f $RESFILE ]; then
OS_NAME="`uname -s`"
- if ! grep -q "os_name: $OS_NAME" "$LOGFILE"; then
+ if ! grep "os_name: $OS_NAME" "$LOGFILE" > /dev/null; then
echo "os_name should be `uname -s`"
ret_val=$[$ret_val + 1]
fi
OS_VERSION="`uname -v`"
- if ! grep -q "os_version: ${OS_VERSION}" "$LOGFILE"; then
+ if ! grep "os_version: ${OS_VERSION}" "$LOGFILE" > /dev/null; then
echo "os_version should be ${OS_VERSION}"
ret_val=$[$ret_val + 1]
fi
OS_ARCHITECTURE="`uname -m`"
- if ! grep -q "os_architecture: ${OS_ARCHITECTURE}" "$LOGFILE"; then
+ if ! grep "os_architecture: ${OS_ARCHITECTURE}" "$LOGFILE" > /dev/null; then
echo "os_architecture should be ${OS_ARCHITECTURE}"
ret_val=$[$ret_val + 1]
fi
PRIMARY_HOST_NAME="`uname -n`"
- if ! grep -q "primary_host_name: ${PRIMARY_HOST_NAME}" "$LOGFILE"; then
+ if ! grep "primary_host_name: ${PRIMARY_HOST_NAME}" "$LOGFILE" > /dev/null; then
echo "primary_host_name should be ${PRIMARY_HOST_NAME}"
ret_val=$[$ret_val + 1]
fi
--
1.6.2.5
More information about the Open-scap-list
mailing list