blob: 68ac8cad96e0d91b21887a7593f020c3093d3c05 [file] [log] [blame]
Dmitry V. Levin38a34c92015-12-17 17:56:48 +00001/*
Dmitry V. Levincf401112016-01-06 11:40:00 +00002 * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
Dmitry V. Levin38a34c92015-12-17 17:56:48 +00003 * 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)"
Dmitry V. Levincf401112016-01-06 11:40:00 +000064 " = -1 EBADF (%m)\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)"
Dmitry V. Levincf401112016-01-06 11:40:00 +000069 " = -1 EBADF (%m)\n", &data);
Dmitry V. Levinfb2a5432015-09-22 21:22:37 +000070
71 (void) ioctl(-1, VIDIOC_ENUMINPUT, 0);
72 printf("ioctl(-1, VIDIOC_ENUMINPUT, 0)"
Dmitry V. Levincf401112016-01-06 11:40:00 +000073 " = -1 EBADF (%m)\n");
Dmitry V. Levinfb2a5432015-09-22 21:22:37 +000074
75 (void) ioctl(-1, HIDIOCGVERSION, &data);
76 printf("ioctl(-1, HIDIOCGRDESCSIZE or HIDIOCGVERSION, %p)"
Dmitry V. Levincf401112016-01-06 11:40:00 +000077 " = -1 EBADF (%m)\n", &data);
Dmitry V. Levinfb2a5432015-09-22 21:22:37 +000078
79 (void) ioctl(-1, HIDIOCGPHYS(8), &data);
80 printf("ioctl(-1, HIDIOCGPHYS(8), %p)"
Dmitry V. Levincf401112016-01-06 11:40:00 +000081 " = -1 EBADF (%m)\n", &data);
Dmitry V. Levinfb2a5432015-09-22 21:22:37 +000082
83 (void) ioctl(-1, EVIOCGBIT(EV_KEY, 8), &data);
84 printf("ioctl(-1, EVIOCGBIT(EV_KEY, 8), %p)"
Dmitry V. Levincf401112016-01-06 11:40:00 +000085 " = -1 EBADF (%m)\n", &data);
Dmitry V. Levinfb2a5432015-09-22 21:22:37 +000086
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])"
Dmitry V. Levincf401112016-01-06 11:40:00 +000089 " = -1 EBADF (%m)\n");
Gabriel Laskar9c4fc342015-09-23 10:11:55 +020090
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)"
Dmitry V. Levincf401112016-01-06 11:40:00 +000093 " = -1 EBADF (%m)\n", &data);
Dmitry V. Levinfb2a5432015-09-22 21:22:37 +000094
95 puts("+++ exited with 0 +++");
Dmitry V. Levindf7aa2b2015-01-19 17:02:16 +000096 return 0;
97}
98
99#else
100
Dmitry V. Levincf401112016-01-06 11:40:00 +0000101SKIP_MAIN_UNDEFINED("MMTIMER_GETRES && VIDIOC_ENUMINPUT"
102 " && HIDIOCGVERSION && HIDIOCGPHYS"
103 " && EVIOCGBIT && EV_KEY")
Dmitry V. Levindf7aa2b2015-01-19 17:02:16 +0000104
105#endif