]> granicus.if.org Git - strace/blob - tests/ioctl.c
tests/ioctl: workaround glibc ioctl wrapper on powerpc
[strace] / tests / ioctl.c
1 #ifdef HAVE_CONFIG_H
2 # include "config.h"
3 #endif
4
5 #include <fcntl.h>
6 #include <stdio.h>
7 #include <stdint.h>
8 #include <unistd.h>
9 #include <termios.h>
10 #include <sys/ioctl.h>
11
12 #ifdef HAVE_LINUX_MMTIMER_H
13 # include <linux/mmtimer.h>
14 #endif
15 #ifdef HAVE_LINUX_HIDDEV_H
16 # include <linux/hiddev.h>
17 #endif
18 #ifdef HAVE_LINUX_INPUT_H
19 # include <linux/input.h>
20 #endif
21
22 #include <linux/videodev2.h>
23
24 #if defined MMTIMER_GETRES \
25  && defined VIDIOC_ENUMINPUT \
26  && defined HIDIOCGVERSION \
27  && defined HIDIOCGPHYS \
28  && defined EVIOCGBIT \
29  && defined EV_KEY
30
31 int
32 main(void )
33 {
34         uint64_t data = 0;
35
36 #ifndef POWERPC
37         struct termios tty;
38         (void) ioctl(-1, TCGETS, &tty);
39         printf("ioctl(-1, TCGETS, %p)"
40                " = -1 EBADF (Bad file descriptor)\n", &tty);
41 #endif
42
43         (void) ioctl(-1, MMTIMER_GETRES, &data);
44         printf("ioctl(-1, MMTIMER_GETRES, %p)"
45                " = -1 EBADF (Bad file descriptor)\n", &data);
46
47         (void) ioctl(-1, VIDIOC_ENUMINPUT, 0);
48         printf("ioctl(-1, VIDIOC_ENUMINPUT, 0)"
49                " = -1 EBADF (Bad file descriptor)\n");
50
51         (void) ioctl(-1, HIDIOCGVERSION, &data);
52         printf("ioctl(-1, HIDIOCGRDESCSIZE or HIDIOCGVERSION, %p)"
53                " = -1 EBADF (Bad file descriptor)\n", &data);
54
55         (void) ioctl(-1, HIDIOCGPHYS(8), &data);
56         printf("ioctl(-1, HIDIOCGPHYS(8), %p)"
57                " = -1 EBADF (Bad file descriptor)\n", &data);
58
59         (void) ioctl(-1, EVIOCGBIT(EV_KEY, 8), &data);
60         printf("ioctl(-1, EVIOCGBIT(EV_KEY, 8), %p)"
61                " = -1 EBADF (Bad file descriptor)\n", &data);
62
63         (void) ioctl(-1, _IOR('M', 13, int), &data);
64         printf("ioctl(-1, MIXER_READ(13) or OTPSELECT, [MTD_OTP_OFF])"
65                " = -1 EBADF (Bad file descriptor)\n");
66
67         (void) ioctl(-1, _IOR(0xde, 0xad, data), &data);
68         printf("ioctl(-1, _IOC(_IOC_READ, 0xde, 0xad, 0x08), %p)"
69                " = -1 EBADF (Bad file descriptor)\n", &data);
70
71         puts("+++ exited with 0 +++");
72         return 0;
73 }
74
75 #else
76
77 int
78 main(void )
79 {
80         return 77;
81 }
82
83 #endif