[Ltrace-devel] [PATCH 4/11] test suite: grep syntax errors

Steve Fink sphink at gmail.com
Sat Aug 5 23:55:46 UTC 2006


-------------- next part --------------
From c5536084b4fb3590b2a2915b10e47a7e44ba7f43 Mon Sep 17 00:00:00 2001
From: Steve Fink sphink at gmail.com <sphink at gmail.com>
Date: Thu, 27 Jul 2006 08:29:58 -0700
Subject: [PATCH 4/11] Report syntax errors when running grep.

Quote the pattern so spaces and similar things can be used.
---
 ChangeLog                               |    5 +++++
 testsuite/lib/ltrace.exp                |    8 +++++---
 testsuite/ltrace.minor/count-record.exp |   26 +++++++++++++-------------
 3 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 48287ba..4575942 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2006-07-20    Steve Fink <sphink at gmail.com>
 
+	* testsuite/lib/ltrace.exp: better quoting and error detection for
+	  ltrace_verify_output's call to grep
+
+2006-07-20    Steve Fink <sphink at gmail.com>
+
 	* various: add 'ignore' parameter descriptor
 
 2006-07-20    Steve Fink <sphink at gmail.com>
diff --git a/testsuite/lib/ltrace.exp b/testsuite/lib/ltrace.exp
index a1d8dfe..b56d50d 100644
--- a/testsuite/lib/ltrace.exp
+++ b/testsuite/lib/ltrace.exp
@@ -260,10 +260,12 @@ #
 proc ltrace_verify_output { file_to_search pattern {instance_no 0}} {
 
 	# compute the number of PATTERN in FILE_TO_SEARCH by grep and wc.
-	catch "exec sh -c {grep $pattern $file_to_search | wc -l ;exit}" output
+	catch "exec sh -c {grep \"$pattern\" $file_to_search | wc -l ;exit}" output
 	verbose "output = $output"
-	
-	if { $instance_no == 0 } then {
+
+	if [ regexp "syntax error" $output ] then {
+		fail "Invalid regular expression $pattern"
+        } elseif { $instance_no == 0 } then {
 		if { $output == 0 } then {
 			fail "Fail to find $pattern in $file_to_search"
 		} else {
diff --git a/testsuite/ltrace.minor/count-record.exp b/testsuite/ltrace.minor/count-record.exp
index bd03d5b..7150568 100644
--- a/testsuite/ltrace.minor/count-record.exp
+++ b/testsuite/ltrace.minor/count-record.exp
@@ -48,30 +48,30 @@ #   3.81    0.000301         301        
 #   3.39    0.000268         268         1 fread
 #
 
-set pattern "\'1 rmdir\'"
+set pattern " 1 rmdir"
 ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
-set pattern "\'1 fopen\'"
+set pattern " 1 fopen"
 ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
-set pattern "\'2 remove\'"
+set pattern " 2 remove"
 ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
-set pattern "\'1 mkdir\'"
+set pattern " 1 mkdir"
 ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
-set pattern "\'1 fseek\'"
+set pattern " 1 fseek"
 ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
-set pattern "\'1 fwrite\'"
+set pattern " 1 fwrite"
 ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
-set pattern "\'1 fclose\'"
+set pattern " 1 fclose"
 ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
-set pattern "\'1 rename\'"
+set pattern " 1 rename"
 ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
-set pattern "\'1 symlink\'"
+set pattern " 1 symlink"
 ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
-set pattern "\'1 chdir\'"
+set pattern " 1 chdir"
 ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
-set pattern "\'1 access\'"
+set pattern " 1 access"
 ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
-set pattern "\'1 getcwd\'"
+set pattern " 1 getcwd"
 ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
-set pattern "\'1 fread\'"
+set pattern " 1 fread"
 ltrace_verify_output ${srcdir}/${subdir}/${testfile}.ltrace $pattern
 
-- 
1.4.1


More information about the Ltrace-devel mailing list