Skip to content

Commit 4ab22d7

Browse files
committed
[NFC][sanitizer] Extract test from main function
And extract cleanup into RUN: command
1 parent e5d174c commit 4ab22d7

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1-
// RUN: %clangxx -O1 %s -o %t && %run %t %t.tmp
1+
// RUN: rm -rf %t.tmp
2+
// RUN: mkdir -p %t.tmp
3+
// RUN: %clangxx -O1 %s -o %t && %run %t %t.tmp/1
24

35
#include <assert.h>
46
#include <fcntl.h>
5-
#include <unistd.h>
67
#include <sys/stat.h>
8+
#include <unistd.h>
79

8-
int main(int argc, char *argv[]) {
9-
assert(argv[1]);
10-
unlink(argv[1]);
11-
int fd = open(argv[1], O_RDWR | O_CREAT, 0600);
10+
void test(const char *path, int flags) {
11+
assert(path);
12+
int fd = open(path, flags, 0600);
1213
assert(fd != -1);
1314
struct stat info;
1415
int result = fstat(fd, &info);
1516
assert((info.st_mode & ~S_IFMT) == 0600);
1617
assert(result == 0);
1718
close(fd);
1819
}
20+
21+
int main(int argc, char *argv[]) {
22+
assert(argc == 2);
23+
test(argv[1], O_RDWR | O_CREAT);
24+
}

0 commit comments

Comments
 (0)