24 lines · cpp
1// RUN: %clangxx -g %s -o %t && %run %t | FileCheck %s2// CHECK: 13// CHECK-NEXT: 24 5#include <assert.h>6#include <stdio.h>7 8int main(void) {9 // use a tool that produces different output than input to verify10 // that everything worked correctly11 FILE *fp = popen("sort", "w");12 assert(fp);13 14 // verify that fileno() returns a meaningful descriptor (needed15 // 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