diff options
Diffstat (limited to 'test/Scripts')
-rw-r--r-- | test/Scripts/README.txt | 2 | ||||
-rwxr-xr-x | test/Scripts/count | 17 | ||||
-rwxr-xr-x | test/Scripts/ignore | 10 | ||||
-rwxr-xr-x | test/Scripts/not | 12 | ||||
-rwxr-xr-x | test/Scripts/notcast | 16 | ||||
-rwxr-xr-x | test/Scripts/prcontext.tcl | 36 |
6 files changed, 93 insertions, 0 deletions
diff --git a/test/Scripts/README.txt b/test/Scripts/README.txt new file mode 100644 index 0000000000000..b0b11050375f2 --- /dev/null +++ b/test/Scripts/README.txt @@ -0,0 +1,2 @@ +This directory contains scripts which are used by the TestRunner style +tests, which allows them to be simpler and more direct. diff --git a/test/Scripts/count b/test/Scripts/count new file mode 100755 index 0000000000000..1c3d7e0953b2c --- /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 diff --git a/test/Scripts/ignore b/test/Scripts/ignore new file mode 100755 index 0000000000000..865ae4df1bd4d --- /dev/null +++ b/test/Scripts/ignore @@ -0,0 +1,10 @@ +#!/bin/sh +# +# Program: ignore +# +# Synopsis: Ignore the result code of the command and always return 0 +# +# Syntax: ignore command <arguments> + +"$@" || exit 0 && exit 0 +exit 0 diff --git a/test/Scripts/not b/test/Scripts/not new file mode 100755 index 0000000000000..e3b1efe35c8d1 --- /dev/null +++ b/test/Scripts/not @@ -0,0 +1,12 @@ +#!/bin/sh +# +# Program: not +# +# Synopsis: Inverse the output of the program specified on the command line +# +# Syntax: not command <arguments> + +if "$@" +then exit 1 +else exit 0 +fi diff --git a/test/Scripts/notcast b/test/Scripts/notcast new file mode 100755 index 0000000000000..6d56580c8fc9f --- /dev/null +++ b/test/Scripts/notcast @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Program: notcast +# +# Synopsis: Returns 0 if the input does not contain a cast operator +# +# Syntax: notcast tailexpr +# +# postpat - optionally allows a regular expression to go at the end +# prepat - optionally allow a regular expression to go at the start +# + +if grep "$2"'\(\([sz]ext\)\|\(trunc\)\|\(fpto[us]i\)\|\([us]itofp\)\|\(bitcast\)\|\(fpext\)\|\(fptrunc\)\|\(ptrtoint\)\|\(inttoptr\)\|\(cast\)\)'"$1" +then exit 1 +else exit 0 +fi diff --git a/test/Scripts/prcontext.tcl b/test/Scripts/prcontext.tcl new file mode 100755 index 0000000000000..5ab0854b0b3f3 --- /dev/null +++ b/test/Scripts/prcontext.tcl @@ -0,0 +1,36 @@ +#!/usr/bin/tclsh +# +# Usage: +# prcontext <pattern> <# lines of context> +# (for platforms that don't have grep -C) + + +# +# Get the arguments +# +set pattern [lindex $argv 0] +set num [lindex $argv 1] + + +# +# Get all of the lines in the file. +# +set lines [split [read stdin] \n] + +set index 0 +foreach line $lines { + if { [regexp $pattern $line match matchline] } { + if { [ expr [expr $index - $num] < 0 ] } { + set bottom 0 + } else { + set bottom [expr $index - $num] + } + set endLineNum [ expr [expr $index + $num] + 1] + while {$bottom < $endLineNum} { + set output [lindex $lines $bottom] + puts $output + set bottom [expr $bottom + 1] + } + } + set index [expr $index + 1] +}
\ No newline at end of file |