xref: /freebsd/sys/contrib/openzfs/tests/zfs-tests/tests/functional/io/mmap.ksh (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1#! /bin/ksh -p
2# SPDX-License-Identifier: CDDL-1.0
3#
4# CDDL HEADER START
5#
6# The contents of this file are subject to the terms of the
7# Common Development and Distribution License (the "License").
8# You may not use this file except in compliance with the License.
9#
10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11# or https://opensource.org/licenses/CDDL-1.0.
12# See the License for the specific language governing permissions
13# and limitations under the License.
14#
15# When distributing Covered Code, include this CDDL HEADER in each
16# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17# If applicable, add the following below this CDDL HEADER, with the
18# fields enclosed by brackets "[]" replaced with your own identifying
19# information: Portions Copyright [yyyy] [name of copyright owner]
20#
21# CDDL HEADER END
22#
23
24#
25# Copyright (c) 2018 by Lawrence Livermore National Security, LLC.
26#
27
28. $STF_SUITE/include/libtest.shlib
29. $STF_SUITE/tests/functional/io/io.cfg
30
31#
32# DESCRIPTION:
33#	Verify memory mapped IO with mmap(2) and memcpy(3)
34#
35# STRATEGY:
36#	1. Use fio(1) in verify mode to perform write, read,
37#	   random read, and random write workloads.
38#	2. Repeat the test with additional fio(1) options.
39#
40
41if ! compare_version_gte "$(fio --version)" "fio-2.3"; then
42	log_unsupported "Requires fio-2.3 or newer"
43fi
44
45verify_runnable "global"
46
47function cleanup
48{
49	log_must rm -f "$mntpnt/rw*"
50}
51
52log_assert "Verify memory mapped IO with mmap(2) and memcpy(3)"
53
54log_onexit cleanup
55
56ioengine="--ioengine=mmap"
57mntpnt=$(get_prop mountpoint $TESTPOOL/$TESTFS)
58dir="--directory=$mntpnt"
59
60set -A fio_arg -- "--sync=0" "--sync=1" "--direct=0" "--direct=1"
61
62for arg in "${fio_arg[@]}"; do
63	log_must fio $dir $ioengine $arg $FIO_WRITE_ARGS
64	log_must fio $dir $ioengine $arg $FIO_READ_ARGS
65	log_must fio $dir $ioengine $arg $FIO_RANDWRITE_ARGS
66	log_must fio $dir $ioengine $arg $FIO_RANDREAD_ARGS
67	log_must rm -f "$mntpnt/rw*"
68done
69
70log_pass "Verified memory mapped IO with mmap(2) and memcpy(3)"
71