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