1eda14cbcSMatt Macy#!/bin/ksh -p
2eda14cbcSMatt Macy#
3eda14cbcSMatt Macy# CDDL HEADER START
4eda14cbcSMatt Macy#
5eda14cbcSMatt Macy# This file and its contents are supplied under the terms of the
6eda14cbcSMatt Macy# Common Development and Distribution License ("CDDL"), version 1.0.
7eda14cbcSMatt Macy# You may only use this file in accordance with the terms of version
8eda14cbcSMatt Macy# 1.0 of the CDDL.
9eda14cbcSMatt Macy#
10eda14cbcSMatt Macy# A full copy of the text of the CDDL should have accompanied this
11eda14cbcSMatt Macy# source.  A copy of the CDDL is also available via the Internet at
12eda14cbcSMatt Macy# http://www.illumos.org/license/CDDL.
13eda14cbcSMatt Macy#
14eda14cbcSMatt Macy# CDDL HEADER END
15eda14cbcSMatt Macy#
16eda14cbcSMatt Macy
17eda14cbcSMatt Macy#
18eda14cbcSMatt Macy# Copyright (c) 2019 by Tim Chase. All rights reserved.
19eda14cbcSMatt Macy# Copyright (c) 2019 Lawrence Livermore National Security, LLC.
20eda14cbcSMatt Macy#
21eda14cbcSMatt Macy
22eda14cbcSMatt Macy. $STF_SUITE/include/libtest.shlib
23caed7b1cSMartin Matuska. $STF_SUITE/tests/functional/cli_root/zpool_trim/zpool_trim.kshlib
24eda14cbcSMatt Macy
25eda14cbcSMatt Macy#
26eda14cbcSMatt Macy# DESCRIPTION:
27caed7b1cSMartin Matuska# Starting and stopping a trim works.
28eda14cbcSMatt Macy#
29eda14cbcSMatt Macy# STRATEGY:
30eda14cbcSMatt Macy# 1. Create a one-disk pool.
31caed7b1cSMartin Matuska# 2. Start trimming and verify that trimming is active.
32caed7b1cSMartin Matuska# 3. Cancel trimming and verify that trimming is not active.
33eda14cbcSMatt Macy#
34eda14cbcSMatt Macy
35eda14cbcSMatt MacyDISK1=${DISKS%% *}
36eda14cbcSMatt Macy
37eda14cbcSMatt Macylog_must zpool create -f $TESTPOOL $DISK1
38*c03c5b1cSMartin Matuskalog_must zpool trim -r 1 "$TESTPOOL"
39eda14cbcSMatt Macy
40caed7b1cSMartin Matuska[[ -z "$(trim_progress $TESTPOOL $DISK1)" ]] && \
41caed7b1cSMartin Matuska    log_fail "TRIM did not start"
42eda14cbcSMatt Macy
43caed7b1cSMartin Matuskalog_must zpool trim -c $TESTPOOL
44eda14cbcSMatt Macy
45caed7b1cSMartin Matuska[[ -z "$(trim_progress $TESTPOOL $DISK1)" ]] || \
46caed7b1cSMartin Matuska    log_fail "TRIM did not stop"
47eda14cbcSMatt Macy
48caed7b1cSMartin Matuskalog_pass "TRIM start + cancel works"
49