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