blob: 3840f696b3e97eaf5c70bf6fe012082ebdffdcce [file] [log] [blame]
Dmitry V. Levin38a34c92015-12-17 17:56:48 +00001/*
2 * Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
Dmitry V. Levin0c8853c2016-01-02 13:28:43 +000028#include "tests.h"
Dmitry V. Levindf7aa2b2015-01-19 17:02:16 +000029#include <fcntl.h>
Dmitry V. Levinfb2a5432015-09-22 21:22:37 +000030#include <stdio.h>
Dmitry V. Levindf7aa2b2015-01-19 17:02:16 +000031#include <stdint.h>
32#include <unistd.h>
33#include <termios.h>
34#include <sys/ioctl.h>
35
36#ifdef HAVE_LINUX_MMTIMER_H
37# include <linux/mmtimer.h>
38#endif
39#ifdef HAVE_LINUX_HIDDEV_H
40# include <linux/hiddev.h>
41#endif
42#ifdef HAVE_LINUX_INPUT_H
43# include <linux/input.h>
44#endif
45
Dmitry V. Levin8c20d892015-05-21 16:19:40 +000046#include <linux/videodev2.h>
47
Dmitry V. Levindf7aa2b2015-01-19 17:02:16 +000048#if defined MMTIMER_GETRES \
Dmitry V. Levin8c20d892015-05-21 16:19:40 +000049 && defined VIDIOC_ENUMINPUT \
Dmitry V. Levindf7aa2b2015-01-19 17:02:16 +000050 && defined HIDIOCGVERSION \
51 && defined HIDIOCGPHYS \
52 && defined EVIOCGBIT \
53 && defined EV_KEY
54
55int
56main(void )
57{
Dmitry V. Levinfb2a5432015-09-22 21:22:37 +000058 uint64_t data = 0;
Dmitry V. Levindf7aa2b2015-01-19 17:02:16 +000059
Dmitry V. Levin0f8af612015-11-16 01:53:43 +000060#ifndef POWERPC
61 struct termios tty;
Dmitry V. Levinfb2a5432015-09-22 21:22:37 +000062 (void) ioctl(-1, TCGETS, &tty);
63 printf("ioctl(-1, TCGETS, %p)"
64 " = -1 EBADF (Bad file descriptor)\n", &tty);
Dmitry V. Levin0f8af612015-11-16 01:53:43 +000065#endif
Dmitry V. Levindf7aa2b2015-01-19 17:02:16 +000066
Dmitry V. Levinfb2a5432015-09-22 21:22:37 +000067 (void) ioctl(-1, MMTIMER_GETRES, &data);
68 printf("ioctl(-1, MMTIMER_GETRES, %p)"
69 " = -1 EBADF (Bad file descriptor)\n", &data);
70
71 (void) ioctl(-1, VIDIOC_ENUMINPUT, 0);
72 printf("ioctl(-1, VIDIOC_ENUMINPUT, 0)"
73 " = -1 EBADF (Bad file descriptor)\n");
74
75 (void) ioctl(-1, HIDIOCGVERSION, &data);
76 printf("ioctl(-1, HIDIOCGRDESCSIZE or HIDIOCGVERSION, %p)"
77 " = -1 EBADF (Bad file descriptor)\n", &data);
78
79 (void) ioctl(-1, HIDIOCGPHYS(8), &data);
80 printf("ioctl(-1, HIDIOCGPHYS(8), %p)"
81 " = -1 EBADF (Bad file descriptor)\n", &data);
82
83 (void) ioctl(-1, EVIOCGBIT(EV_KEY, 8), &data);
84 printf("ioctl(-1, EVIOCGBIT(EV_KEY, 8), %p)"
85 " = -1 EBADF (Bad file descriptor)\n", &data);
86
Gabriel Laskar9c4fc342015-09-23 10:11:55 +020087 (void) ioctl(-1, _IOR('M', 13, int), &data);
88 printf("ioctl(-1, MIXER_READ(13) or OTPSELECT, [MTD_OTP_OFF])"
89 " = -1 EBADF (Bad file descriptor)\n");
90
Dmitry V. Levinfb2a5432015-09-22 21:22:37 +000091 (void) ioctl(-1, _IOR(0xde, 0xad, data), &data);
92 printf("ioctl(-1, _IOC(_IOC_READ, 0xde, 0xad, 0x08), %p)"
93 " = -1 EBADF (Bad file descriptor)\n", &data);
94
95 puts("+++ exited with 0 +++");
Dmitry V. Levindf7aa2b2015-01-19 17:02:16 +000096 return 0;
97}
98
99#else
100
101int
102main(void )
103{
104 return 77;
105}
106
107#endif