[mlir-reduce] Create proper tmp test files (NFC)

This commit ensures that the sh script creates temporary files with
mktmp to ensure they do not collide with existing files. The previous
behaviour caused sporadic permission issues on a multi-user system.

Reviewed By: gysit

Differential Revision: https://reviews.llvm.org/D145054
This commit is contained in:
Christian Ulmann 2023-03-01 13:05:43 +01:00
parent 86b8abc2dd
commit 5957e90c4e

View File

@ -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