1 /* $NetBSD: t_p2kifs.c,v 1.6 2017/01/13 21:30:43 christos Exp $ */
4 * Copyright (c) 2010 The NetBSD Foundation, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include <sys/types.h>
31 #include <sys/mount.h>
32 #include <sys/sysctl.h>
34 #include <rump/rump.h>
35 #include <rump/rumpvnode_if.h>
36 #include <rump/rump_syscalls.h>
47 ATF_TC_HEAD(makecn, tc)
50 atf_tc_set_md_var(tc, "descr", "Tests makecn/LOOKUP/freecn");
53 #define TESTFILE "testi"
55 ATF_TC_BODY(makecn, tc)
57 struct componentname *cn;
58 char pathstr[MAXPATHLEN] = TESTFILE;
60 extern struct vnode *rumpns_rootvnode;
65 * Strategy is to create a componentname, edit the passed
66 * string, and then do a lookup with the componentname.
68 RL(rump_sys_mkdir("/" TESTFILE, 0777));
70 /* need stable lwp for componentname */
71 RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG));
73 /* try it once with the right path */
74 cn = rump_pub_makecn(RUMP_NAMEI_LOOKUP, 0, pathstr, strlen(pathstr),
75 rump_pub_cred_create(0, 0, 0, NULL), rump_pub_lwproc_curlwp());
76 RZ(RUMP_VOP_LOOKUP(rumpns_rootvnode, &vp, cn));
77 rump_pub_freecn(cn, RUMPCN_FREECRED);
79 /* and then with modification-in-the-middle */
80 cn = rump_pub_makecn(RUMP_NAMEI_LOOKUP, 0, pathstr, strlen(pathstr),
81 rump_pub_cred_create(0, 0, 0, NULL), rump_pub_lwproc_curlwp());
82 strcpy(pathstr, "/muuta");
83 RZ(RUMP_VOP_LOOKUP(rumpns_rootvnode, &vp, cn));
84 rump_pub_freecn(cn, RUMPCN_FREECRED);
90 ATF_TP_ADD_TC(tp, makecn);
92 return atf_no_error();