This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <config.h>
20
21 #include <unistd.h>
22
23 #include "signature.h"
24 SIGNATURE_CHECK (getlogin_r, int, (char *, size_t));
25
26 #include "test-getlogin.h"
27
28 int
29 main (void)
30 {
31
32
33 char buf[1024];
34 int err = getlogin_r (buf, sizeof buf);
35 #if defined __sun
36 if (err == EINVAL)
37 {
38
39 fprintf (stderr, "Skipping test: no entry in /var/adm/utmpx.\n");
40 exit (77);
41 }
42 #endif
43 test_getlogin_result (buf, err);
44
45
46 {
47 char smallbuf[1024];
48 size_t n = strlen (buf);
49 size_t i;
50
51 for (i = 0; i <= n; i++)
52 {
53 err = getlogin_r (smallbuf, i);
54 if (i == 0)
55 ASSERT (err == ERANGE || err == EINVAL);
56 else
57 ASSERT (err == ERANGE);
58 }
59 }
60
61
62 {
63 static char hugebuf[70000];
64
65 ASSERT (getlogin_r (hugebuf, sizeof (hugebuf)) == 0);
66 ASSERT (strcmp (hugebuf, buf) == 0);
67 }
68
69 return 0;
70 }