1*960493d8Skre /* $NetBSD: t_vm.c,v 1.7 2023/04/11 18:23:42 kre Exp $ */
29b9ff1afSpooka
39b9ff1afSpooka /*-
49b9ff1afSpooka * Copyright (c) 2010 The NetBSD Foundation, Inc.
59b9ff1afSpooka * All rights reserved.
69b9ff1afSpooka *
79b9ff1afSpooka * Redistribution and use in source and binary forms, with or without
89b9ff1afSpooka * modification, are permitted provided that the following conditions
99b9ff1afSpooka * are met:
109b9ff1afSpooka * 1. Redistributions of source code must retain the above copyright
119b9ff1afSpooka * notice, this list of conditions and the following disclaimer.
129b9ff1afSpooka * 2. Redistributions in binary form must reproduce the above copyright
139b9ff1afSpooka * notice, this list of conditions and the following disclaimer in the
149b9ff1afSpooka * documentation and/or other materials provided with the distribution.
159b9ff1afSpooka *
169b9ff1afSpooka * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
179b9ff1afSpooka * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
189b9ff1afSpooka * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
199b9ff1afSpooka * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
209b9ff1afSpooka * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
219b9ff1afSpooka * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
229b9ff1afSpooka * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
239b9ff1afSpooka * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
249b9ff1afSpooka * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
259b9ff1afSpooka * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
269b9ff1afSpooka * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
279b9ff1afSpooka * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
289b9ff1afSpooka */
299b9ff1afSpooka
309b9ff1afSpooka #include <sys/types.h>
319b9ff1afSpooka #include <sys/mount.h>
329b9ff1afSpooka #include <sys/sysctl.h>
339b9ff1afSpooka
349b9ff1afSpooka #include <rump/rump.h>
359b9ff1afSpooka
369b9ff1afSpooka #include <atf-c.h>
37e094e235Spooka #include <stdio.h>
38e094e235Spooka #include <stdlib.h>
399b9ff1afSpooka
40c54cb811Schristos #include "h_macros.h"
419b9ff1afSpooka #include "../kernspace/kernspace.h"
429b9ff1afSpooka
439b9ff1afSpooka ATF_TC(busypage);
ATF_TC_HEAD(busypage,tc)449b9ff1afSpooka ATF_TC_HEAD(busypage, tc)
459b9ff1afSpooka {
469b9ff1afSpooka
479b9ff1afSpooka atf_tc_set_md_var(tc, "descr", "Checks VM pagewaits work");
489b9ff1afSpooka }
499b9ff1afSpooka
ATF_TC_BODY(busypage,tc)509b9ff1afSpooka ATF_TC_BODY(busypage, tc)
519b9ff1afSpooka {
529b9ff1afSpooka
536ab81237Schs #if 0
54a7b9f930Schs atf_tc_expect_fail("test bug: unbusies an uninitialized page");
556ab81237Schs #endif
56*960493d8Skre atf_tc_skip("this test is buggy and hits an assertion, but atf doesn't provide any way to expect that a test program crashes, thus all we can do is skip");
579b9ff1afSpooka rump_init();
589b9ff1afSpooka
599b9ff1afSpooka rump_schedule();
609b9ff1afSpooka rumptest_busypage();
619b9ff1afSpooka rump_unschedule();
629b9ff1afSpooka }
639b9ff1afSpooka
64e094e235Spooka ATF_TC(uvmwait);
ATF_TC_HEAD(uvmwait,tc)65e094e235Spooka ATF_TC_HEAD(uvmwait, tc)
66e094e235Spooka {
67e094e235Spooka
68e094e235Spooka atf_tc_set_md_var(tc, "descr", "Tests that uvm_wait works");
690207daf6Shannken atf_tc_set_md_var(tc, "timeout", "30");
70e094e235Spooka }
71e094e235Spooka
72e094e235Spooka #define UVMWAIT_LIMIT 1024*1024
ATF_TC_BODY(uvmwait,tc)73e094e235Spooka ATF_TC_BODY(uvmwait, tc)
74e094e235Spooka {
75e094e235Spooka char buf[64];
76e094e235Spooka
77e094e235Spooka /* limit rump kernel memory */
78e094e235Spooka snprintf(buf, sizeof(buf), "%d", UVMWAIT_LIMIT);
79e094e235Spooka setenv("RUMP_MEMLIMIT", buf, 1);
80e094e235Spooka
81e094e235Spooka rump_init();
82e094e235Spooka
83e094e235Spooka rump_schedule();
84e094e235Spooka rumptest_alloc(UVMWAIT_LIMIT);
85e094e235Spooka rump_unschedule();
86e094e235Spooka }
87e094e235Spooka
ATF_TP_ADD_TCS(tp)889b9ff1afSpooka ATF_TP_ADD_TCS(tp)
899b9ff1afSpooka {
90e094e235Spooka
919b9ff1afSpooka ATF_TP_ADD_TC(tp, busypage);
92e094e235Spooka ATF_TP_ADD_TC(tp, uvmwait);
939b9ff1afSpooka
949b9ff1afSpooka return atf_no_error();
959b9ff1afSpooka }
96