Home | History | Annotate | Download | only in tests
      1 /*
      2  * Copyright (c) 2015 Dmitry V. Levin <ldv (at) 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 
     28 #ifdef HAVE_CONFIG_H
     29 # include "config.h"
     30 #endif
     31 
     32 #include <fcntl.h>
     33 #include <stdio.h>
     34 #include <stdint.h>
     35 #include <unistd.h>
     36 #include <termios.h>
     37 #include <sys/ioctl.h>
     38 
     39 #ifdef HAVE_LINUX_MMTIMER_H
     40 # include <linux/mmtimer.h>
     41 #endif
     42 #ifdef HAVE_LINUX_HIDDEV_H
     43 # include <linux/hiddev.h>
     44 #endif
     45 #ifdef HAVE_LINUX_INPUT_H
     46 # include <linux/input.h>
     47 #endif
     48 
     49 #include <linux/videodev2.h>
     50 
     51 #if defined MMTIMER_GETRES \
     52  && defined VIDIOC_ENUMINPUT \
     53  && defined HIDIOCGVERSION \
     54  && defined HIDIOCGPHYS \
     55  && defined EVIOCGBIT \
     56  && defined EV_KEY
     57 
     58 int
     59 main(void )
     60 {
     61 	uint64_t data = 0;
     62 
     63 #ifndef POWERPC
     64 	struct termios tty;
     65 	(void) ioctl(-1, TCGETS, &tty);
     66 	printf("ioctl(-1, TCGETS, %p)"
     67 	       " = -1 EBADF (Bad file descriptor)\n", &tty);
     68 #endif
     69 
     70 	(void) ioctl(-1, MMTIMER_GETRES, &data);
     71 	printf("ioctl(-1, MMTIMER_GETRES, %p)"
     72 	       " = -1 EBADF (Bad file descriptor)\n", &data);
     73 
     74 	(void) ioctl(-1, VIDIOC_ENUMINPUT, 0);
     75 	printf("ioctl(-1, VIDIOC_ENUMINPUT, 0)"
     76 	       " = -1 EBADF (Bad file descriptor)\n");
     77 
     78 	(void) ioctl(-1, HIDIOCGVERSION, &data);
     79 	printf("ioctl(-1, HIDIOCGRDESCSIZE or HIDIOCGVERSION, %p)"
     80 	       " = -1 EBADF (Bad file descriptor)\n", &data);
     81 
     82 	(void) ioctl(-1, HIDIOCGPHYS(8), &data);
     83 	printf("ioctl(-1, HIDIOCGPHYS(8), %p)"
     84 	       " = -1 EBADF (Bad file descriptor)\n", &data);
     85 
     86 	(void) ioctl(-1, EVIOCGBIT(EV_KEY, 8), &data);
     87 	printf("ioctl(-1, EVIOCGBIT(EV_KEY, 8), %p)"
     88 	       " = -1 EBADF (Bad file descriptor)\n", &data);
     89 
     90 	(void) ioctl(-1, _IOR('M', 13, int), &data);
     91 	printf("ioctl(-1, MIXER_READ(13) or OTPSELECT, [MTD_OTP_OFF])"
     92 	       " = -1 EBADF (Bad file descriptor)\n");
     93 
     94 	(void) ioctl(-1, _IOR(0xde, 0xad, data), &data);
     95 	printf("ioctl(-1, _IOC(_IOC_READ, 0xde, 0xad, 0x08), %p)"
     96 	       " = -1 EBADF (Bad file descriptor)\n", &data);
     97 
     98 	puts("+++ exited with 0 +++");
     99 	return 0;
    100 }
    101 
    102 #else
    103 
    104 int
    105 main(void )
    106 {
    107 	return 77;
    108 }
    109 
    110 #endif
    111