xref: /freebsd/sys/contrib/openzfs/tests/zfs-tests/tests/functional/cli_root/zpool_trim/setup.ksh (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1#!/bin/ksh -p
2# SPDX-License-Identifier: CDDL-1.0
3#
4# CDDL HEADER START
5#
6# This file and its contents are supplied under the terms of the
7# Common Development and Distribution License ("CDDL"), version 1.0.
8# You may only use this file in accordance with the terms of version
9# 1.0 of the CDDL.
10#
11# A full copy of the text of the CDDL should have accompanied this
12# source.  A copy of the CDDL is also available via the Internet at
13# http://www.illumos.org/license/CDDL.
14#
15# CDDL HEADER END
16#
17
18#
19# Copyright (c) 2019 by Tim Chase. All rights reserved.
20# Copyright (c) 2019 Lawrence Livermore National Security, LLC.
21#
22
23. $STF_SUITE/include/libtest.shlib
24
25verify_runnable "global"
26
27if is_freebsd; then
28	log_unsupported "FreeBSD has no hole punching mechanism for the time being."
29	diskinfo -v $DISKS | grep -qE 'No.*# TRIM/UNMAP support' &&
30	    log_unsupported "DISKS do not support discard (TRIM/UNMAP)"
31else
32	DISK1=${DISKS%% *}
33
34	typeset -i max_discard=0
35	if is_disk_device $DEV_RDSKDIR/$DISK1; then
36		max_discard=$(lsblk -Dbn $DEV_RDSKDIR/$DISK1 | awk '{ print $4; exit }')
37	fi
38
39	if test $max_discard -eq 0; then
40		log_unsupported "DISKS do not support discard (TRIM/UNMAP)"
41	fi
42fi
43
44log_pass
45