diff --git a/mlir/test/mlir-reduce/failure-test.sh b/mlir/test/mlir-reduce/failure-test.sh index f5ddfb8fe9de..db6a4720d2d5 100755 --- a/mlir/test/mlir-reduce/failure-test.sh +++ b/mlir/test/mlir-reduce/failure-test.sh @@ -1,8 +1,14 @@ #!/bin/sh -# Tests for the keyword "failure" in the stderr of the optimization pass -mlir-opt $1 -test-mlir-reducer > /tmp/stdout.$$ 2>/tmp/stderr.$$ -if [ $? -ne 0 ] && grep 'failure' /tmp/stderr.$$; then +# Create temporary files that are automatically deleted after the script's +# execution. +stdout_file=$(mktemp /tmp/stdout.XXXXXX) +stderr_file=$(mktemp /tmp/stderr.XXXXXX) + +# Tests for the keyword "failure" in the stderr of the optimization pass +mlir-opt $1 -test-mlir-reducer > $stdout_file 2> $stderr_file + +if [ $? -ne 0 ] && grep 'failure' $stderr_file; then exit 1 #Interesting behavior else