Dmitry V. Levin | 38a34c9 | 2015-12-17 17:56:48 +0000 | [diff] [blame] | 1 | /* |
Dmitry V. Levin | cf40111 | 2016-01-06 11:40:00 +0000 | [diff] [blame] | 2 | * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org> |
Dmitry V. Levin | 38a34c9 | 2015-12-17 17:56:48 +0000 | [diff] [blame] | 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. Levin | 0c8853c | 2016-01-02 13:28:43 +0000 | [diff] [blame] | 28 | #include "tests.h" |
Dmitry V. Levin | df7aa2b | 2015-01-19 17:02:16 +0000 | [diff] [blame] | 29 | #include <fcntl.h> |
Dmitry V. Levin | fb2a543 | 2015-09-22 21:22:37 +0000 | [diff] [blame] | 30 | #include <stdio.h> |
Dmitry V. Levin | df7aa2b | 2015-01-19 17:02:16 +0000 | [diff] [blame] | 31 | #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. Levin | 8c20d89 | 2015-05-21 16:19:40 +0000 | [diff] [blame] | 46 | #include <linux/videodev2.h> |
| 47 | |
Dmitry V. Levin | df7aa2b | 2015-01-19 17:02:16 +0000 | [diff] [blame] | 48 | #if defined MMTIMER_GETRES \ |
Dmitry V. Levin | 8c20d89 | 2015-05-21 16:19:40 +0000 | [diff] [blame] | 49 | && defined VIDIOC_ENUMINPUT \ |
Dmitry V. Levin | df7aa2b | 2015-01-19 17:02:16 +0000 | [diff] [blame] | 50 | && defined HIDIOCGVERSION \ |
| 51 | && defined HIDIOCGPHYS \ |
| 52 | && defined EVIOCGBIT \ |
| 53 | && defined EV_KEY |
| 54 | |
| 55 | int |
| 56 | main(void ) |
| 57 | { |
Dmitry V. Levin | fb2a543 | 2015-09-22 21:22:37 +0000 | [diff] [blame] | 58 | uint64_t data = 0; |
Dmitry V. Levin | df7aa2b | 2015-01-19 17:02:16 +0000 | [diff] [blame] | 59 | |
Dmitry V. Levin | 0f8af61 | 2015-11-16 01:53:43 +0000 | [diff] [blame] | 60 | #ifndef POWERPC |
| 61 | struct termios tty; |
Dmitry V. Levin | fb2a543 | 2015-09-22 21:22:37 +0000 | [diff] [blame] | 62 | (void) ioctl(-1, TCGETS, &tty); |
| 63 | printf("ioctl(-1, TCGETS, %p)" |
Dmitry V. Levin | cf40111 | 2016-01-06 11:40:00 +0000 | [diff] [blame] | 64 | " = -1 EBADF (%m)\n", &tty); |
Dmitry V. Levin | 0f8af61 | 2015-11-16 01:53:43 +0000 | [diff] [blame] | 65 | #endif |
Dmitry V. Levin | df7aa2b | 2015-01-19 17:02:16 +0000 | [diff] [blame] | 66 | |
Dmitry V. Levin | fb2a543 | 2015-09-22 21:22:37 +0000 | [diff] [blame] | 67 | (void) ioctl(-1, MMTIMER_GETRES, &data); |
| 68 | printf("ioctl(-1, MMTIMER_GETRES, %p)" |
Dmitry V. Levin | cf40111 | 2016-01-06 11:40:00 +0000 | [diff] [blame] | 69 | " = -1 EBADF (%m)\n", &data); |
Dmitry V. Levin | fb2a543 | 2015-09-22 21:22:37 +0000 | [diff] [blame] | 70 | |
| 71 | (void) ioctl(-1, VIDIOC_ENUMINPUT, 0); |
Dmitry V. Levin | 0a47ff7 | 2016-05-01 17:25:24 +0000 | [diff] [blame] | 72 | printf("ioctl(-1, VIDIOC_ENUMINPUT, NULL)" |
Dmitry V. Levin | cf40111 | 2016-01-06 11:40:00 +0000 | [diff] [blame] | 73 | " = -1 EBADF (%m)\n"); |
Dmitry V. Levin | fb2a543 | 2015-09-22 21:22:37 +0000 | [diff] [blame] | 74 | |
| 75 | (void) ioctl(-1, HIDIOCGVERSION, &data); |
| 76 | printf("ioctl(-1, HIDIOCGRDESCSIZE or HIDIOCGVERSION, %p)" |
Dmitry V. Levin | cf40111 | 2016-01-06 11:40:00 +0000 | [diff] [blame] | 77 | " = -1 EBADF (%m)\n", &data); |
Dmitry V. Levin | fb2a543 | 2015-09-22 21:22:37 +0000 | [diff] [blame] | 78 | |
| 79 | (void) ioctl(-1, HIDIOCGPHYS(8), &data); |
| 80 | printf("ioctl(-1, HIDIOCGPHYS(8), %p)" |
Dmitry V. Levin | cf40111 | 2016-01-06 11:40:00 +0000 | [diff] [blame] | 81 | " = -1 EBADF (%m)\n", &data); |
Dmitry V. Levin | fb2a543 | 2015-09-22 21:22:37 +0000 | [diff] [blame] | 82 | |
| 83 | (void) ioctl(-1, EVIOCGBIT(EV_KEY, 8), &data); |
| 84 | printf("ioctl(-1, EVIOCGBIT(EV_KEY, 8), %p)" |
Dmitry V. Levin | cf40111 | 2016-01-06 11:40:00 +0000 | [diff] [blame] | 85 | " = -1 EBADF (%m)\n", &data); |
Dmitry V. Levin | fb2a543 | 2015-09-22 21:22:37 +0000 | [diff] [blame] | 86 | |
Gabriel Laskar | 9c4fc34 | 2015-09-23 10:11:55 +0200 | [diff] [blame] | 87 | (void) ioctl(-1, _IOR('M', 13, int), &data); |
| 88 | printf("ioctl(-1, MIXER_READ(13) or OTPSELECT, [MTD_OTP_OFF])" |
Dmitry V. Levin | cf40111 | 2016-01-06 11:40:00 +0000 | [diff] [blame] | 89 | " = -1 EBADF (%m)\n"); |
Gabriel Laskar | 9c4fc34 | 2015-09-23 10:11:55 +0200 | [diff] [blame] | 90 | |
Dmitry V. Levin | fb2a543 | 2015-09-22 21:22:37 +0000 | [diff] [blame] | 91 | (void) ioctl(-1, _IOR(0xde, 0xad, data), &data); |
| 92 | printf("ioctl(-1, _IOC(_IOC_READ, 0xde, 0xad, 0x08), %p)" |
Dmitry V. Levin | cf40111 | 2016-01-06 11:40:00 +0000 | [diff] [blame] | 93 | " = -1 EBADF (%m)\n", &data); |
Dmitry V. Levin | fb2a543 | 2015-09-22 21:22:37 +0000 | [diff] [blame] | 94 | |
| 95 | puts("+++ exited with 0 +++"); |
Dmitry V. Levin | df7aa2b | 2015-01-19 17:02:16 +0000 | [diff] [blame] | 96 | return 0; |
| 97 | } |
| 98 | |
| 99 | #else |
| 100 | |
Dmitry V. Levin | cf40111 | 2016-01-06 11:40:00 +0000 | [diff] [blame] | 101 | SKIP_MAIN_UNDEFINED("MMTIMER_GETRES && VIDIOC_ENUMINPUT" |
| 102 | " && HIDIOCGVERSION && HIDIOCGPHYS" |
| 103 | " && EVIOCGBIT && EV_KEY") |
Dmitry V. Levin | df7aa2b | 2015-01-19 17:02:16 +0000 | [diff] [blame] | 104 | |
| 105 | #endif |