Ticket #18349: foo.c

File foo.c, 668 bytes (added by bhaible, 20 months ago)

test case

Line 
1#include <errno.h>
2#include <stdio.h>
3#include <stdlib.h>
4#include <string.h>
5#include <unistd.h>
6
7int
8main (void)
9{
10 char buf[1024];
11 int err = getlogin_r (buf, sizeof buf);
12 printf ("err = %d\n", err);
13
14 {
15 char smallbuf[1024];
16
17 err = getlogin_r (smallbuf, 0);
18 printf ("err = %d\n", err);
19 printf (" = %s\n", strerror (err));
20
21 err = getlogin_r (smallbuf, 1);
22 printf ("err = %d\n", err);
23 printf (" = %s\n", strerror (err));
24
25 err = getlogin_r (smallbuf, 2);
26 printf ("err = %d\n", err);
27 printf (" = %s\n", strerror (err));
28
29 fflush (stdout);
30
31 if (!(err == ERANGE || err == EINVAL)) abort ();
32 }
33
34 return 0;
35}