1 | // RUN: %clangxx -g %s -o %t && %run %t | FileCheck %s |
2 | // CHECK: 1 |
3 | // CHECK-NEXT: 2 |
4 | |
5 | #include <assert.h> |
6 | #include <stdio.h> |
7 | |
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(command: "sort" , modes: "w" ); |
12 | assert(fp); |
13 | |
14 | // verify that fileno() returns a meaningful descriptor (needed |
15 | // for the implementation of TSan) |
16 | assert(fileno(fp) != -1); |
17 | |
18 | assert(fputs("2\n" , fp) >= 0); |
19 | assert(fputs("1\n" , fp) >= 0); |
20 | assert(pclose(fp) == 0); |
21 | |
22 | return 0; |
23 | } |
24 | |