Ticket #19058: foo.c

File foo.c, 840 bytes (added by bhaible, 2 months ago)

test case foo.c

Line 
1#include <errno.h>
2#include <fcntl.h>
3#include <unistd.h>
4#include <stdio.h>
5#include <string.h>
6#include <assert.h>
7
8int
9main ()
10{
11 int fail = 0;
12
13 {
14 errno = 0;
15 int ret = renameat (-1, "foo", AT_FDCWD, "bar");
16
17 if (ret >= 0)
18 printf ("ret = %d\n", ret);
19 else if (errno == EBADF)
20 printf ("ret = %d, errno == EBADF\n", ret);
21 else
22 printf ("ret = %d, errno == %s\n", ret, strerror (errno));
23
24 fail |= !(ret < 0 && errno == EBADF);
25 }
26
27 {
28 errno = 0;
29 int ret = renameat (AT_FDCWD, "foo", -1, "bar");
30
31 if (ret >= 0)
32 printf ("ret = %d\n", ret);
33 else if (errno == EBADF)
34 printf ("ret = %d, errno == EBADF\n", ret);
35 else
36 printf ("ret = %d, errno == %s\n", ret, strerror (errno));
37
38 fail |= !(ret < 0 && errno == EBADF);
39 }
40
41 assert (!fail);
42 printf ("OK\n");
43}