1*2e2699c4SPeter Holm#!/bin/sh 2*2e2699c4SPeter Holm 3*2e2699c4SPeter Holm# 4*2e2699c4SPeter Holm# Copyright (c) 2024 Peter Holm <pho@FreeBSD.org> 5*2e2699c4SPeter Holm# 6*2e2699c4SPeter Holm# SPDX-License-Identifier: BSD-2-Clause 7*2e2699c4SPeter Holm# 8*2e2699c4SPeter Holm 9*2e2699c4SPeter Holm# A SEEK_HOLE / SEEK_DATA test scenario, variation of tmpfs24.sh 10*2e2699c4SPeter Holm 11*2e2699c4SPeter Holm# A regression test for "40c1672e886b - main - swap_pager: fix 12*2e2699c4SPeter Holm# seek_data with invalid first page" 13*2e2699c4SPeter Holm 14*2e2699c4SPeter Holm[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 15*2e2699c4SPeter Holm 16*2e2699c4SPeter Holm. ../default.cfg 17*2e2699c4SPeter Holm 18*2e2699c4SPeter Holmprog=$(basename "$0" .sh) 19*2e2699c4SPeter Holmexp=/tmp/$prog.exp 20*2e2699c4SPeter Holmhere=`pwd` 21*2e2699c4SPeter Holmlog=/tmp/$prog.log 22*2e2699c4SPeter Holm 23*2e2699c4SPeter Holmcc -o /tmp/lsholes -Wall -Wextra -O2 $here/../tools/lsholes.c | exit 1 24*2e2699c4SPeter Holmcat > $exp <<EXP 25*2e2699c4SPeter HolmMin hole size is 4096, file size is 524288000. 26*2e2699c4SPeter Holmdata #1 @ 0, size=4096) 27*2e2699c4SPeter Holmhole #2 @ 4096, size=4096 28*2e2699c4SPeter Holmdata #3 @ 8192, size=4096) 29*2e2699c4SPeter Holmhole #4 @ 12288, size=4096 30*2e2699c4SPeter Holmdata #5 @ 16384, size=4096) 31*2e2699c4SPeter Holmhole #6 @ 20480, size=524267520 32*2e2699c4SPeter HolmEXP 33*2e2699c4SPeter Holm 34*2e2699c4SPeter Holmset -eu 35*2e2699c4SPeter Holmmount -t tmpfs dummy $mntpoint 36*2e2699c4SPeter Holmset +e 37*2e2699c4SPeter Holm 38*2e2699c4SPeter Holmfile=$mntpoint/file 39*2e2699c4SPeter Holmcopy=$mntpoint/copy 40*2e2699c4SPeter Holmtruncate -s 500m $file 41*2e2699c4SPeter Holmbs=`getconf MIN_HOLE_SIZE $file` 42*2e2699c4SPeter Holmprintf "\001" | dd of=$file seek=$((0*bs)) bs=1 count=1 conv=notrunc status=none 43*2e2699c4SPeter Holmprintf "\002" | dd of=$file seek=$((2*bs)) bs=1 count=1 conv=notrunc status=none 44*2e2699c4SPeter Holmprintf "\003" | dd of=$file seek=$((4*bs)) bs=1 count=1 conv=notrunc status=none 45*2e2699c4SPeter Holms1=0 46*2e2699c4SPeter Holms2=0 47*2e2699c4SPeter Holms3=0 48*2e2699c4SPeter Holm/tmp/lsholes $file > $log 2>&1 || s1=1 49*2e2699c4SPeter Holm 50*2e2699c4SPeter Holmcmp -s $exp $log || { s2=2; sdiff $exp $log; } 51*2e2699c4SPeter Holm 52*2e2699c4SPeter Holm$here/../testcases/swap/swap -t 2m -i 20 -h > /dev/null & 53*2e2699c4SPeter Holmsleep 10 54*2e2699c4SPeter Holmcp $file $copy 55*2e2699c4SPeter Holmwhile pkill swap; do :; done 56*2e2699c4SPeter Holmwait 57*2e2699c4SPeter Holmcmp $file $copy || { echo "copy error"; s3=4; } 58*2e2699c4SPeter Holm 59*2e2699c4SPeter Holmumount $mntpoint 60*2e2699c4SPeter Holmrm -f /tmp/lsholes $exp $log 61*2e2699c4SPeter Holmexit $((s1 + s2 + s3)) 62