xref: /freebsd/contrib/netbsd-tests/fs/ptyfs/t_ptyfs.c (revision af23369a6deaaeb612ab266eb88b8bb8d560c322)
1 /*	$NetBSD: t_ptyfs.c,v 1.2 2017/01/13 21:30:40 christos Exp $	*/
2 
3 #include <sys/types.h>
4 #include <sys/mount.h>
5 
6 #include <atf-c.h>
7 #include <err.h>
8 #include <errno.h>
9 #include <fcntl.h>
10 #include <stdio.h>
11 #include <unistd.h>
12 #include <string.h>
13 #include <stdlib.h>
14 
15 #include <rump/rump.h>
16 #include <rump/rump_syscalls.h>
17 
18 #include <fs/ptyfs/ptyfs.h>
19 
20 #include "h_macros.h"
21 
22 static void
23 mountptyfs(const char *mp, int flags)
24 {
25 	struct ptyfs_args args;
26 
27 	if (rump_sys_mkdir("/mp", 0777) == -1) {
28 		if (errno != EEXIST)
29 			atf_tc_fail_errno("mp1");
30 	}
31 	memset(&args, 0, sizeof(args));
32 	args.version = PTYFS_ARGSVERSION;
33 	args.mode = 0777;
34 	if (rump_sys_mount(MOUNT_PTYFS, mp, flags, &args, sizeof(args)) == -1)
35 		atf_tc_fail_errno("could not mount ptyfs");
36 }
37 
38 ATF_TC(basic);
39 ATF_TC_HEAD(basic, tc)
40 {
41 	atf_tc_set_md_var(tc, "descr", "mount ptyfs");
42 }
43 
44 ATF_TC_BODY(basic, tc)
45 {
46 
47 	rump_init();
48 
49 	mountptyfs("/mp", 0);
50 	if (rump_sys_unmount("/mp", 0) == -1)
51 		atf_tc_fail_errno("unmount failed");
52 
53 	/* done */
54 }
55 
56 ATF_TP_ADD_TCS(tp)
57 {
58 
59 	ATF_TP_ADD_TC(tp, basic);
60 
61 	return atf_no_error();
62 }
63