]> git.ipfire.org Git - thirdparty/glibc.git/blame - io/tst-ttyname_r.c
build-many-glibcs.py: Add openrisc hard float glibc variant
[thirdparty/glibc.git] / io / tst-ttyname_r.c
CommitLineData
f0d5e1f6
UD
1#include <errno.h>
2#include <error.h>
3#include <fcntl.h>
4#include <stdio.h>
5#include <unistd.h>
6
7static void do_prepare (void);
8#define PREPARE(argc, argv) do_prepare ()
9static int do_test (void);
10#define TEST_FUNCTION do_test ()
11#include <test-skeleton.c>
12
13static int temp_fd;
14
15static void
16do_prepare (void)
17{
18 char *temp_file;
19 temp_fd = create_temp_file ("tst-ttyname_r.", &temp_file);
20 if (temp_fd == -1)
21 error (1, errno, "cannot create temporary file");
22}
23
24static int
25do_test (void)
26{
27 int ret = 0;
28 char buf[sysconf (_SC_TTY_NAME_MAX) + 1];
29 int res = ttyname_r (-1, buf, sizeof (buf));
30 if (res != EBADF)
31 {
32 printf ("1st ttyname_r returned with res %d\n", res);
33 ret++;
34 }
35 res = ttyname_r (temp_fd, buf, sizeof (buf));
36 if (res != ENOTTY)
37 {
38 printf ("2nd ttyname_r returned with res %d\n", res);
39 ret++;
40 }
41 return ret;
42}