aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2007-08-10 15:07:05 +0000
committerDan Gohman <gohman@apple.com>2007-08-10 15:07:05 +0000
commit57a6f30125ad4f83de0147379835e4386872f479 (patch)
treea2d140b043b9fc77ac5360490ead4bc54616242e /test
parent25ac7e8364f475597e2a6f3628fce839583e1f45 (diff)
downloadexternal_llvm-57a6f30125ad4f83de0147379835e4386872f479.zip
external_llvm-57a6f30125ad4f83de0147379835e4386872f479.tar.gz
external_llvm-57a6f30125ad4f83de0147379835e4386872f479.tar.bz2
Add a test script for counting lines. This can be used instead of the
"| grep foo | wc -l | grep 2" idiom used by many tests, so that, for example, tests don't mistakenly accept a count of 12 when 2 is expected. Also, the new form is more consice: "| grep foo | count 2". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40988 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rwxr-xr-xtest/Scripts/count17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/Scripts/count b/test/Scripts/count
new file mode 100755
index 0000000..cc03552
--- /dev/null
+++ b/test/Scripts/count
@@ -0,0 +1,17 @@
+#!/bin/sh
+#
+# Program: count
+#
+# Synopsis: Count the number of lines of input on stdin and test that it
+# matches the specified number.
+#
+# Syntax: count <number>
+
+set -e
+set -u
+input_lines=$(wc -l)
+if [ "$input_lines" -ne "$1" ]; then
+ echo "count: expected $1 lines and got ${input_lines}."
+ exit 1
+fi
+exit 0