1// RUN: %clangxx_tsan -O1 %s -o %t && %run %t %t.tmp 2>&1 | FileCheck %s
2#include <stdio.h>
3#include <assert.h>
4#include <fcntl.h>
5#include <unistd.h>
6#include <sys/stat.h>
7
8int main(int argc, char *argv[]) {
9 fprintf(stderr, format: "Hello world.\n");
10 assert(argv[1]);
11 unlink(name: argv[1]);
12 int fd = open(file: argv[1], O_RDWR | O_CREAT, 0600);
13 assert(fd != -1);
14 struct stat info;
15 int result = fstat(fd: fd, buf: &info);
16 fprintf(stderr, format: "permissions = 0%o\n", info.st_mode & ~S_IFMT);
17 assert(result == 0);
18 close(fd: fd);
19 fprintf(stderr, format: "Done.\n");
20}
21
22// CHECK: Hello world.
23// CHECK: permissions = 0600
24// CHECK: Done.
25

source code of compiler-rt/test/tsan/Darwin/variadic-open.cpp