1 1.8 riastrad /* $NetBSD: t_vm.c,v 1.8 2025/04/02 11:28:00 riastradh Exp $ */ 2 1.1 pooka 3 1.1 pooka /*- 4 1.1 pooka * Copyright (c) 2010 The NetBSD Foundation, Inc. 5 1.1 pooka * All rights reserved. 6 1.1 pooka * 7 1.1 pooka * Redistribution and use in source and binary forms, with or without 8 1.1 pooka * modification, are permitted provided that the following conditions 9 1.1 pooka * are met: 10 1.1 pooka * 1. Redistributions of source code must retain the above copyright 11 1.1 pooka * notice, this list of conditions and the following disclaimer. 12 1.1 pooka * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 pooka * notice, this list of conditions and the following disclaimer in the 14 1.1 pooka * documentation and/or other materials provided with the distribution. 15 1.1 pooka * 16 1.1 pooka * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND 17 1.1 pooka * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 18 1.1 pooka * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 1.1 pooka * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 1.1 pooka * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 21 1.1 pooka * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 1.1 pooka * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 23 1.1 pooka * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 1.1 pooka * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25 1.1 pooka * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26 1.1 pooka * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27 1.1 pooka * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 1.1 pooka */ 29 1.1 pooka 30 1.1 pooka #include <sys/types.h> 31 1.1 pooka #include <sys/mount.h> 32 1.1 pooka #include <sys/sysctl.h> 33 1.1 pooka 34 1.1 pooka #include <rump/rump.h> 35 1.1 pooka 36 1.1 pooka #include <atf-c.h> 37 1.2 pooka #include <stdio.h> 38 1.2 pooka #include <stdlib.h> 39 1.1 pooka 40 1.4 christos #include "h_macros.h" 41 1.1 pooka #include "../kernspace/kernspace.h" 42 1.1 pooka 43 1.1 pooka ATF_TC(busypage); 44 1.1 pooka ATF_TC_HEAD(busypage, tc) 45 1.1 pooka { 46 1.1 pooka 47 1.1 pooka atf_tc_set_md_var(tc, "descr", "Checks VM pagewaits work"); 48 1.1 pooka } 49 1.1 pooka 50 1.1 pooka ATF_TC_BODY(busypage, tc) 51 1.1 pooka { 52 1.1 pooka 53 1.8 riastrad atf_tc_expect_signal(SIGABRT, 54 1.8 riastrad "PR kern/55945: test bug: unbusies an uninitialized page"); 55 1.8 riastrad 56 1.1 pooka rump_init(); 57 1.1 pooka 58 1.1 pooka rump_schedule(); 59 1.1 pooka rumptest_busypage(); 60 1.1 pooka rump_unschedule(); 61 1.1 pooka } 62 1.1 pooka 63 1.2 pooka ATF_TC(uvmwait); 64 1.2 pooka ATF_TC_HEAD(uvmwait, tc) 65 1.2 pooka { 66 1.2 pooka 67 1.2 pooka atf_tc_set_md_var(tc, "descr", "Tests that uvm_wait works"); 68 1.3 hannken atf_tc_set_md_var(tc, "timeout", "30"); 69 1.2 pooka } 70 1.2 pooka 71 1.2 pooka #define UVMWAIT_LIMIT 1024*1024 72 1.2 pooka ATF_TC_BODY(uvmwait, tc) 73 1.2 pooka { 74 1.2 pooka char buf[64]; 75 1.2 pooka 76 1.2 pooka /* limit rump kernel memory */ 77 1.2 pooka snprintf(buf, sizeof(buf), "%d", UVMWAIT_LIMIT); 78 1.2 pooka setenv("RUMP_MEMLIMIT", buf, 1); 79 1.2 pooka 80 1.2 pooka rump_init(); 81 1.2 pooka 82 1.2 pooka rump_schedule(); 83 1.2 pooka rumptest_alloc(UVMWAIT_LIMIT); 84 1.2 pooka rump_unschedule(); 85 1.2 pooka } 86 1.2 pooka 87 1.1 pooka ATF_TP_ADD_TCS(tp) 88 1.1 pooka { 89 1.2 pooka 90 1.1 pooka ATF_TP_ADD_TC(tp, busypage); 91 1.2 pooka ATF_TP_ADD_TC(tp, uvmwait); 92 1.1 pooka 93 1.1 pooka return atf_no_error(); 94 1.1 pooka } 95