[mlir-reduce] Create proper tmp test files (NFC)
authorChristian Ulmann <christian.ulmann@nextsilicon.com>
Wed, 1 Mar 2023 12:05:43 +0000 (13:05 +0100)
committerChristian Ulmann <christian.ulmann@nextsilicon.com>
Wed, 1 Mar 2023 12:22:19 +0000 (13:22 +0100)
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

mlir/test/mlir-reduce/failure-test.sh

index f5ddfb8fe9de44cea1d655302cb4435f3795bc22..db6a4720d2d56d6ef316690e92163ca56f730eb2 100755 (executable)
@@ -1,8 +1,14 @@
 #!/bin/sh
+
+# 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 > /tmp/stdout.$$ 2>/tmp/stderr.$$
+mlir-opt $1 -test-mlir-reducer > $stdout_file 2> $stderr_file
 
-if [ $? -ne 0 ] && grep 'failure' /tmp/stderr.$$; then
+if [ $? -ne 0 ] && grep 'failure' $stderr_file; then
   exit 1
   #Interesting behavior
 else