1*e7b21111Santon /* $OpenBSD: wscons.c,v 1.1 2018/12/17 19:29:55 anton Exp $ */
2*e7b21111Santon
3*e7b21111Santon /*
4*e7b21111Santon * Copyright (c) 2018 Anton Lindqvist <anton@openbsd.org>
5*e7b21111Santon *
6*e7b21111Santon * Permission to use, copy, modify, and distribute this software for any
7*e7b21111Santon * purpose with or without fee is hereby granted, provided that the above
8*e7b21111Santon * copyright notice and this permission notice appear in all copies.
9*e7b21111Santon *
10*e7b21111Santon * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11*e7b21111Santon * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12*e7b21111Santon * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13*e7b21111Santon * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14*e7b21111Santon * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15*e7b21111Santon * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16*e7b21111Santon * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*e7b21111Santon */
18*e7b21111Santon
19*e7b21111Santon #include <sys/ioctl.h>
20*e7b21111Santon
21*e7b21111Santon #include <err.h>
22*e7b21111Santon #include <errno.h>
23*e7b21111Santon #include <stdlib.h>
24*e7b21111Santon
25*e7b21111Santon #include "util.h"
26*e7b21111Santon
27*e7b21111Santon static int test_ioctl_unknown(int);
28*e7b21111Santon
29*e7b21111Santon /*
30*e7b21111Santon * Test that inappropriate ioctl commands are rejected.
31*e7b21111Santon */
32*e7b21111Santon static int
test_ioctl_unknown(int fd)33*e7b21111Santon test_ioctl_unknown(int fd)
34*e7b21111Santon {
35*e7b21111Santon if (ioctl(fd, TIOCSCTTY) == -1) {
36*e7b21111Santon if (errno != ENOTTY)
37*e7b21111Santon err(1, "ioctl: TIOCSCTTY");
38*e7b21111Santon } else {
39*e7b21111Santon errx(1, "ioctl: TIOCSCTTY: not rejected");
40*e7b21111Santon }
41*e7b21111Santon return 0;
42*e7b21111Santon }
43*e7b21111Santon
44*e7b21111Santon int
main(int argc,char * argv[])45*e7b21111Santon main(int argc, char *argv[])
46*e7b21111Santon {
47*e7b21111Santon struct test tests[] = {
48*e7b21111Santon { "ioctl-unknown", test_ioctl_unknown },
49*e7b21111Santon { NULL, NULL },
50*e7b21111Santon };
51*e7b21111Santon
52*e7b21111Santon return dotest(argc, argv, tests);
53*e7b21111Santon }
54