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#
21
22. $STF_SUITE/include/libtest.shlib
23
24verify_runnable "global"
25
26if is_freebsd; then
27	log_unsupported "FreeBSD has no hole punching mechanism for the time being."
28	diskinfo -v $DISKS | grep -qE 'No.*# TRIM/UNMAP support' &&
29	    log_unsupported "DISKS do not support discard (TRIM/UNMAP)"
30else
31	DISK1=${DISKS%% *}
32
33	typeset -i max_discard=0
34	if is_disk_device $DEV_RDSKDIR/$DISK1; then
35		max_discard=$(lsblk -Dbn $DEV_RDSKDIR/$DISK1 | awk '{ print $4; exit }')
36	fi
37
38	if test $max_discard -eq 0; then
39		log_unsupported "DISKS do not support discard (TRIM/UNMAP)"
40	fi
41fi
42
43log_pass
44