[compiler-rt] 397b96a - [NFC][sanitizer] Make test Android friendly

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 22 16:16:35 PDT 2024


Author: Vitaly Buka
Date: 2024-09-22T16:16:24-07:00
New Revision: 397b96aa87d1546e2b2fd34a7622fe6f4194776e

URL: https://github.com/llvm/llvm-project/commit/397b96aa87d1546e2b2fd34a7622fe6f4194776e
DIFF: https://github.com/llvm/llvm-project/commit/397b96aa87d1546e2b2fd34a7622fe6f4194776e.diff

LOG: [NFC][sanitizer] Make test Android friendly

Added: 
    

Modified: 
    compiler-rt/test/sanitizer_common/TestCases/Posix/variadic-open.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/variadic-open.cpp b/compiler-rt/test/sanitizer_common/TestCases/Posix/variadic-open.cpp
index e32294770b882b..8ac5596791a9e0 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix/variadic-open.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/variadic-open.cpp
@@ -1,8 +1,12 @@
-// RUN: %clangxx -O1 %s -o %t && %run %t %t.tmp %T
+// RUN: %clangxx -O1 %s -o %t
+// RUN: %run %t 1
+// RUN: %run %t 2
 
 #include <assert.h>
 #include <fcntl.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <sys/stat.h>
 #include <unistd.h>
 
@@ -19,13 +23,21 @@ void test(const char *path, int flags) {
 }
 
 int main(int argc, char *argv[]) {
-  assert(argc == 3);
-  assert(argv[1]);
-  unlink(argv[1]);
-  test(argv[1], O_RDWR | O_CREAT);
+  assert(argc == 2);
+  char buff[10000];
+  sprintf(buff, "%s.tmp", argv[0]);
+
+  if (atoi(argv[1]) == 1) {
+    unlink(buff);
+    test(buff, O_RDWR | O_CREAT);
+  }
 
 #ifdef O_TMPFILE
-assert(argv[2]);
-  test(argv[2], O_RDWR | O_TMPFILE);
+  if (atoi(argv[1]) == 2) {
+    char *last = strrchr(buff, '/');
+    assert(last);
+    *last = 0;
+    test(buff, O_RDWR | O_TMPFILE);
+  }
 #endif
 }


        


More information about the llvm-commits mailing list