xref: /titanic_41/usr/src/test/zfs-tests/tests/functional/no_space/enospc_001_pos.ksh (revision 32a712da90cea6ff9a05f51e7844944ccfa28d5e)
1#!/bin/ksh -p
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27#
28# Copyright (c) 2013, 2014 by Delphix. All rights reserved.
29#
30
31. $STF_SUITE/include/libtest.shlib
32. $STF_SUITE/tests/functional/no_space/enospc.cfg
33
34#
35# DESCRIPTION:
36# ENOSPC is returned on an attempt to write a second file
37# to a file system after a first file was written that terminated
38# with ENOSPC on a cleanly initialized file system.
39#
40# STRATEGY:
41# 1. Write a file until the file system is full.
42# 2. Ensure that ENOSPC is returned.
43# 3. Write a second file while the file system remains full.
44# 4. Verify the return code is ENOSPC.
45#
46
47verify_runnable "both"
48
49function cleanup
50{
51	rm -f $TESTDIR/$TESTFILE0
52	rm -f $TESTDIR/$TESTFILE1
53}
54
55log_onexit cleanup
56
57log_assert "ENOSPC is returned when file system is full."
58log_must $ZFS set compression=off $TESTPOOL/$TESTFS
59
60log_note "Writing file: $TESTFILE0 until ENOSPC."
61$FILE_WRITE -o create -f $TESTDIR/$TESTFILE0 -b $BLOCKSZ \
62    -c $NUM_WRITES -d $DATA
63ret=$?
64
65(( $ret != $ENOSPC )) && \
66    log_fail "$TESTFILE0 returned: $ret rather than ENOSPC."
67
68log_note "Write another file: $TESTFILE1 but expect ENOSPC."
69$FILE_WRITE -o create -f $TESTDIR/$TESTFILE1 -b $BLOCKSZ \
70    -c $NUM_WRITES -d $DATA
71ret=$?
72
73(( $ret != $ENOSPC )) && \
74    log_fail "$TESTFILE1 returned: $ret rather than ENOSPC."
75
76log_pass "ENOSPC returned as expected."
77