9 #define T(f, x, m) do { \
12 error("%s failed (got %d, expected %d, errno \"%s\") (%s)\n", \
13 #f, r, x, errno ? strerror(errno) : "", m); \
17 #define S(s, x, m) do { \
18 if (strcmp(s, x) != 0) \
19 error("got [%s] want [%s] (%s)\n", s, x, m); \
29 T(pipe(p), 0, "open pipe");
30 T(!(f = fdopen(p[0], "rb")), 0, "fdopen pipe");
37 T(write(p[1], "hello, world\n", 13), 13, "write to pipe");
38 T(fscanf(f, "%s %[own]", a, b), 2, "");
39 S(a, "hello,", "wrong result for %s");
40 S(b, "wo", "wrong result for %[own]");
41 T(fgetc(f), 'r', "fgetc 'r'");
43 T(write(p[1], " 0x12 0x34", 10), 10, "");
44 T(fscanf(f, "ld %5i%2i", &x, &y), 1, "");
46 T(fgetc(f), '3', "fgetc '3'");