summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/fs/ptyfs/t_ptyfs.c
blob: 108c344c343c10860e2ecdbeaef9bc9798dbaa50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*	$NetBSD: t_ptyfs.c,v 1.2 2017/01/13 21:30:40 christos Exp $	*/

#include <sys/types.h>
#include <sys/mount.h>

#include <atf-c.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>

#include <rump/rump.h>
#include <rump/rump_syscalls.h>

#include <fs/ptyfs/ptyfs.h>

#include "h_macros.h"

static void
mountptyfs(const char *mp, int flags)
{
	struct ptyfs_args args;

	if (rump_sys_mkdir("/mp", 0777) == -1) {
		if (errno != EEXIST)
			atf_tc_fail_errno("mp1");
	}
	memset(&args, 0, sizeof(args));
	args.version = PTYFS_ARGSVERSION;
	args.mode = 0777;
	if (rump_sys_mount(MOUNT_PTYFS, mp, flags, &args, sizeof(args)) == -1)
		atf_tc_fail_errno("could not mount ptyfs");
}

ATF_TC(basic);
ATF_TC_HEAD(basic, tc)
{
	atf_tc_set_md_var(tc, "descr", "mount ptyfs");
}

ATF_TC_BODY(basic, tc)
{

	rump_init();

	mountptyfs("/mp", 0);
	if (rump_sys_unmount("/mp", 0) == -1)
		atf_tc_fail_errno("unmount failed");

	/* done */
}

ATF_TP_ADD_TCS(tp)
{

	ATF_TP_ADD_TC(tp, basic);

	return atf_no_error();
}
OpenPOWER on IntegriCloud