11.4Sandvar/*	$NetBSD: t_modlinkset.c,v 1.4 2022/05/24 06:28:02 andvar Exp $	*/
21.1Spooka
31.1Spooka/*
41.1Spooka * Copyright (c) 2009 The NetBSD Foundation, Inc.
51.1Spooka * All rights reserved.
61.1Spooka *
71.1Spooka * Redistribution and use in source and binary forms, with or without
81.1Spooka * modification, are permitted provided that the following conditions
91.1Spooka * are met:
101.1Spooka * 1. Redistributions of source code must retain the above copyright
111.1Spooka *    notice, this list of conditions and the following disclaimer.
121.1Spooka * 2. Redistributions in binary form must reproduce the above copyright
131.1Spooka *    notice, this list of conditions and the following disclaimer in the
141.1Spooka *    documentation and/or other materials provided with the distribution.
151.1Spooka *
161.1Spooka * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
171.1Spooka * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
181.1Spooka * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
191.1Spooka * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
201.1Spooka * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
211.1Spooka * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221.1Spooka * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
231.1Spooka * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
241.1Spooka * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
251.1Spooka * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
261.1Spooka * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
271.1Spooka * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
281.1Spooka */
291.1Spooka
301.1Spooka#include <sys/types.h>
311.1Spooka#include <sys/mount.h>
321.1Spooka
331.1Spooka#include <rump/rump.h>
341.1Spooka#include <rump/ukfs.h>
351.1Spooka
361.1Spooka#include <atf-c.h>
371.1Spooka#include <dlfcn.h>
381.1Spooka#include <err.h>
391.1Spooka#include <errno.h>
401.1Spooka#include <string.h>
411.1Spooka
421.3Schristos#include "h_macros.h"
431.1Spooka
441.1SpookaATF_TC(modlinkset);
451.1SpookaATF_TC_HEAD(modlinkset, tc)
461.1Spooka{
471.1Spooka	atf_tc_set_md_var(tc, "descr", "Check that module linkset bootstrap "
481.1Spooka	    "works");
491.1Spooka}
501.1Spooka
511.1Spooka/*
521.4Sandvar * We link against cd9660 and msdosfs (both chosen because the names
531.1Spooka * are unlikely to ever be a substring of a another file system).
541.1Spooka * Without proper linkset handling at most one will be reported.
551.1Spooka */
561.1SpookaATF_TC_BODY(modlinkset, tc)
571.1Spooka{
581.1Spooka	char buf[1024];
591.1Spooka
601.1Spooka	rump_init();
611.1Spooka	if (ukfs_vfstypes(buf, sizeof(buf)) == -1)
621.1Spooka		atf_tc_fail_errno("ukfs_vfstypes");
631.1Spooka
641.1Spooka	ATF_CHECK((strstr(buf, "msdos") != NULL));
651.1Spooka	ATF_CHECK((strstr(buf, "cd9660") != NULL));
661.1Spooka}
671.1Spooka
681.1SpookaATF_TP_ADD_TCS(tp)
691.1Spooka{
701.1Spooka	ATF_TP_ADD_TC(tp, modlinkset);
711.2Spooka
721.2Spooka	return atf_no_error();
731.1Spooka}
74