[compiler-rt] 4ab22d7 - [NFC][sanitizer] Extract test from `main` function

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 22 12:36:25 PDT 2024


Author: Vitaly Buka
Date: 2024-09-22T12:35:56-07:00
New Revision: 4ab22d7b3cc92d08c6371df367ae21716d1b6942

URL: https://github.com/llvm/llvm-project/commit/4ab22d7b3cc92d08c6371df367ae21716d1b6942
DIFF: https://github.com/llvm/llvm-project/commit/4ab22d7b3cc92d08c6371df367ae21716d1b6942.diff

LOG: [NFC][sanitizer] Extract test from `main` function

And extract cleanup into RUN: command

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 88f9eb17c3439d..fd4c4ae0d123ae 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix/variadic-open.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/variadic-open.cpp
@@ -1,14 +1,15 @@
-// RUN: %clangxx -O1 %s -o %t && %run %t %t.tmp
+// RUN: rm -rf %t.tmp
+// RUN: mkdir -p %t.tmp
+// RUN: %clangxx -O1 %s -o %t && %run %t %t.tmp/1
 
 #include <assert.h>
 #include <fcntl.h>
-#include <unistd.h>
 #include <sys/stat.h>
+#include <unistd.h>
 
-int main(int argc, char *argv[]) {
-  assert(argv[1]);
-  unlink(argv[1]);
-  int fd = open(argv[1], O_RDWR | O_CREAT, 0600);
+void test(const char *path, int flags) {
+  assert(path);
+  int fd = open(path, flags, 0600);
   assert(fd != -1);
   struct stat info;
   int result = fstat(fd, &info);
@@ -16,3 +17,8 @@ int main(int argc, char *argv[]) {
   assert(result == 0);
   close(fd);
 }
+
+int main(int argc, char *argv[]) {
+  assert(argc == 2);
+  test(argv[1], O_RDWR | O_CREAT);
+}


        


More information about the llvm-commits mailing list