Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / Posix / popen.cpp
blob6bf6255a697a18918ad547cbab1adda73acf2445
1 // RUN: %clangxx -g %s -o %t && %run %t | FileCheck %s
2 // CHECK: 1
3 // CHECK-NEXT: 2
5 #include <assert.h>
6 #include <stdio.h>
8 int main(void) {
9 // use a tool that produces different output than input to verify
10 // that everything worked correctly
11 FILE *fp = popen("sort", "w");
12 assert(fp);
14 // verify that fileno() returns a meaningful descriptor (needed
15 // for the implementation of TSan)
16 assert(fileno(fp) != -1);
18 assert(fputs("2\n", fp) >= 0);
19 assert(fputs("1\n", fp) >= 0);
20 assert(pclose(fp) == 0);
22 return 0;