Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/regress/sys/uvm/mmap ../regress/sys/uvm/mmap/mmap.c is now p...
details: https://anonhg.NetBSD.org/src/rev/da737d5d8bcc
branches: trunk
changeset: 767276:da737d5d8bcc
user: jruoho <jruoho%NetBSD.org@localhost>
date: Thu Jul 14 08:12:20 2011 +0000
description:
../regress/sys/uvm/mmap/mmap.c is now part of tests(7).
diffstat:
regress/sys/uvm/mmap/Makefile | 18 -
regress/sys/uvm/mmap/mmap.c | 451 ------------------------------------------
2 files changed, 0 insertions(+), 469 deletions(-)
diffs (truncated from 477 to 300 lines):
diff -r 749aef57c058 -r da737d5d8bcc regress/sys/uvm/mmap/Makefile
--- a/regress/sys/uvm/mmap/Makefile Thu Jul 14 08:09:48 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-# $NetBSD: Makefile,v 1.5 2006/10/14 20:57:10 bjh21 Exp $
-
-NOMAN= # defined
-
-PROG= mmap
-CLEANFILES+= mapped_file
-
-# This is hopefully just some file not mmap'd very often.
-SOME_FILE= /usr/share/misc/zipcodes
-
-regress: ${PROG}
- @if ./mmap ${SOME_FILE}; then \
- echo "PASSED"; \
- else \
- echo "FAILED"; \
- fi
-
-.include <bsd.prog.mk>
diff -r 749aef57c058 -r da737d5d8bcc regress/sys/uvm/mmap/mmap.c
--- a/regress/sys/uvm/mmap/mmap.c Thu Jul 14 08:09:48 2011 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,451 +0,0 @@
-/* $NetBSD: mmap.c,v 1.19 2011/05/24 16:11:08 joerg Exp $ */
-
-/*-
- * Copyright (c) 1999 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
- * NASA Ames Research Center.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Test various memory mapping facilities.
- */
-
-#include <sys/param.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-
-#include <err.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h> /* for memset declaration (?) */
-
-int main(int, char *[]);
-void usage(void);
-
-int check_residency(void *, int);
-
-int pgsize;
-int verbose;
-
-#define MAPPED_FILE "mapped_file"
-#define TEST_PATTERN 0xa5
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- struct stat st;
- void *addr, *addr2, *addr3;
- int i, ch, ecode, fd, npgs, shmid;
- const char *filename;
- u_int8_t *cp;
-
- while ((ch = getopt(argc, argv, "v")) != -1) {
- switch (ch) {
- case 'v':
- verbose = 1;
- break;
-
- default:
- usage();
- }
- }
- argv += optind;
- argc -= optind;
-
- if (argc != 1)
- usage();
-
- filename = argv[0];
-
- ecode = 0;
-
- pgsize = sysconf(_SC_PAGESIZE);
-
- /*
- * TEST MLOCKING A FILE.
- */
-
- printf(">>> MAPPING FILE <<<\n");
-
- fd = open(filename, O_RDONLY, 0666);
- if (fd == -1)
- err(1, "open %s", filename);
-
- if (fstat(fd, &st) == -1)
- err(1, "fstat %s", filename);
-
- addr = mmap(NULL, (size_t) st.st_size, PROT_READ, MAP_FILE|MAP_SHARED,
- fd, (off_t) 0);
- if (addr == MAP_FAILED)
- err(1, "mmap %s", filename);
-
- (void) close(fd);
-
- npgs = (st.st_size / pgsize);
- if (st.st_size % pgsize != 0)
- npgs++;
-
- printf(" CHECKING RESIDENCY\n");
-
- (void) check_residency(addr, npgs);
-
- printf(" LOCKING RANGE\n");
-
- if (mlock(addr, npgs * pgsize) == -1)
- err(1, "mlock %s", filename);
-
- printf(" CHECKING RESIDENCY\n");
-
- if (check_residency(addr, npgs) != npgs) {
- printf(" RESIDENCY CHECK FAILED!\n");
- ecode = 1;
- }
-
- printf(" UNLOCKING RANGE\n");
-
- if (munlock(addr, pgsize) == -1)
- err(1, "munlock %s", filename);
-
- (void) munmap(addr, st.st_size);
-
- /*
- * TEST THE MAP_WIRED FLAG TO MMAP.
- */
-
- npgs = 128;
-
- printf(">>> MAPPING %d PAGE ANONYMOUS REGION WITH MAP_WIRED <<<\n",
- npgs);
-
- addr = mmap(NULL, npgs * pgsize, PROT_READ|PROT_WRITE,
- MAP_ANON|MAP_PRIVATE|MAP_WIRED, -1, (off_t) 0);
- if (addr == MAP_FAILED)
- err(1, "mmap anon MAP_WIRED");
-
- printf(" CHECKING RESIDENCY\n");
-
- if (check_residency(addr, npgs) != npgs) {
- printf(" RESIDENCY CHECK FAILED!\n");
- ecode = 1;
- }
-
- (void) munmap(addr, npgs * pgsize);
-
- /*
- * TEST MLOCKALL'ING AN ANONYMOUS MEMORY RANGE.
- */
-
- npgs = 128;
-
- printf(">>> MAPPING %d PAGE ANONYMOUS REGION <<<\n", npgs);
-
- addr = mmap(NULL, npgs * pgsize, PROT_READ|PROT_WRITE,
- MAP_ANON|MAP_PRIVATE, -1, (off_t) 0);
- if (addr == MAP_FAILED)
- err(1, "mmap anon #1");
-
- printf(" CHECKING RESIDENCY\n");
-
- if (check_residency(addr, npgs) != 0) {
- printf(" RESIDENCY CHECK FAILED!\n");
- ecode = 1;
- }
-
- printf(" LOCKING ALL - CURRENT and FUTURE\n");
-
- if (mlockall(MCL_CURRENT|MCL_FUTURE) == -1)
- err(1, "mlockall current/future");
-
- printf(" CHECKING RESIDENCY\n");
-
- if (check_residency(addr, npgs) != npgs) {
- printf(" RESIDENCY CHECK FAILED!\n");
- ecode = 1;
- }
-
- printf(">>> MAPPING ANOTHER %d PAGE ANONYMOUS REGION <<<\n", npgs);
-
- addr2 = mmap(NULL, npgs * pgsize, PROT_READ, MAP_ANON, -1, (off_t) 0);
- if (addr2 == MAP_FAILED)
- err(1, "mmap anon #2");
-
- printf(" CHECKING RESIDENCY\n");
-
- if (check_residency(addr2, npgs) != npgs) {
- printf(" RESIDENCY CHECK FAILED!\n");
- ecode = 1;
- }
-
- printf(">>> MAPPING THIRD %d PAGE ANONYMOUS REGION, PROT_NONE <<<\n",
- npgs);
-
- addr3 = mmap(NULL, npgs * pgsize, PROT_NONE, MAP_ANON, -1, (off_t) 0);
- if (addr3 == MAP_FAILED)
- err(1, "mmap anon #3");
-
- printf(" CHECKING RESIDENCY\n");
-
- if (check_residency(addr3, npgs) != 0) {
- printf(" RESIDENCY CHECK FAILED!\n");
- ecode = 1;
- }
-
- printf(" PROT_READ'ING MAPPING\n");
-
- if (mprotect(addr3, npgs * pgsize, PROT_READ) == -1)
- err(1, "mprotect");
-
- printf(" CHECKING RESIDENCY\n");
-
- if (check_residency(addr3, npgs) != npgs) {
- printf(" RESIDENCY CHECK FAILED!\n");
- ecode = 1;
- }
-
- printf(" UNLOCKING ALL\n");
-
- printf(" CHECKING RESIDENCY\n");
-
- if (check_residency(addr, npgs) != npgs ||
- check_residency(addr2, npgs) != npgs) {
- printf(" RESIDENCY CHECK FAILED!\n");
- ecode = 1;
- }
-
- (void) munlockall();
-
- printf(">>> MADV_FREE'ING SECOND ANONYMOUS REGION <<<\n");
-
- if (madvise(addr2, npgs * pgsize, MADV_FREE) == -1)
- err(1, "madvise");
-
- printf(" CHECKING RESIDENCY\n");
-
- if (check_residency(addr2, npgs) != 0) {
- printf(" RESIDENCY CHECK FAILED!\n");
- ecode = 1;
- }
-
- printf(">>> MADV_FREE'ING FIRST ANONYMOUS REGION <<<\n");
-
- if (madvise(addr, npgs * pgsize, MADV_FREE) == -1)
- err(1, "madvise");
-
- printf(" CHECKING RESIDENCY\n");
-
- if (check_residency(addr, npgs) != 0) {
- printf(" RESIDENCY CHECK FAILED!\n");
- ecode = 1;
- }
-
- printf(">>> ZEROING FIRST ANONYMOUS REGION <<<\n");
-
- memset(addr, 0, npgs * pgsize);
Home |
Main Index |
Thread Index |
Old Index