[Mlir-commits] [mlir] 5957e90 - [mlir-reduce] Create proper tmp test files (NFC)

Christian Ulmann llvmlistbot at llvm.org
Wed Mar 1 04:22:46 PST 2023


Author: Christian Ulmann
Date: 2023-03-01T13:22:19+01:00
New Revision: 5957e90c4ed332046d7461366fd579c268553939

URL: https://github.com/llvm/llvm-project/commit/5957e90c4ed332046d7461366fd579c268553939
DIFF: https://github.com/llvm/llvm-project/commit/5957e90c4ed332046d7461366fd579c268553939.diff

LOG: [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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/mlir/test/mlir-reduce/failure-test.sh b/mlir/test/mlir-reduce/failure-test.sh
index f5ddfb8fe9de4..db6a4720d2d56 100755
--- a/mlir/test/mlir-reduce/failure-test.sh
+++ b/mlir/test/mlir-reduce/failure-test.sh
@@ -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 


        


More information about the Mlir-commits mailing list