1#!/bin/ksh -p 2# 3# This file and its contents are supplied under the terms of the 4# Common Development and Distribution License ("CDDL"), version 1.0. 5# You may only use this file in accordance with the terms of version 6# 1.0 of the CDDL. 7# 8# A full copy of the text of the CDDL should have accompanied this 9# source. A copy of the CDDL is also available via the Internet at 10# http://www.illumos.org/license/CDDL. 11# 12 13# 14# Copyright 2017, loli10K <ezomori.nozomu@gmail.com>. All rights reserved. 15# 16 17. $STF_SUITE/include/libtest.shlib 18. $STF_SUITE/tests/functional/cli_root/zpool_events/zpool_events.kshlib 19 20# 21# DESCRIPTION: 22# 'zpool events -f' should successfully follow new events. 23# 24# STRATEGY: 25# 1. Clear all ZFS events 26# 2. Run 'zpool events -f' in background, saving its output to a temporary file 27# 3. Generate some ZFS events 28# 4. Verify 'zpool events -f' successfully recorded these new events 29# 30 31verify_runnable "both" 32 33function cleanup 34{ 35 [[ -n $pid ]] && kill $pid 2>/dev/null 36 rm -f $EVENTS_FILE 37} 38 39log_assert "'zpool events -f' should follow new events." 40log_onexit cleanup 41 42EVENTS_FILE="$TESTDIR/zpool_events.$$" 43 44# 1. Clear all ZFS events 45log_must zpool events -c 46 47# 2. Run 'zpool events -f' in background, saving its output to a temporary file 48log_must eval "zpool events -H -f > $EVENTS_FILE &" 49pid=$! 50 51# 3. Generate some ZFS events 52for i in {1..$EVENTS_NUM}; do 53 log_must zpool clear $TESTPOOL 54done 55# wait a bit to allow the kernel module to process new events 56zpool_events_settle 57 58# 4. Verify 'zpool events -f' successfully recorded these new events 59EVENTS_LOG=$(wc -l < $EVENTS_FILE) 60if [[ $EVENTS_LOG -ne $EVENTS_NUM ]]; then 61 log_fail "Unexpected number of events: $EVENTS_LOG != $EVENTS_NUM" 62fi 63 64log_pass "'zpool events -f' successfully follows new events." 65