1#!/usr/local/bin/ksh93 -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. $STF_SUITE/include/libtest.kshlib 27 28################################################################################ 29# 30# __stc_assertion_start 31# 32# ID: compress_001_pos 33# 34# DESCRIPTION: 35# Create two files of exactly the same size. One with compression 36# and one without. Ensure the compressed file is smaller. 37# 38# STRATEGY: 39# Use "zfs set" to turn on compression and create files before 40# and after the set call. The compressed file should be smaller. 41# 42# TESTABILITY: explicit 43# 44# TEST_AUTOMATION_LEVEL: automated 45# 46# CODING_STATUS: COMPLETED (2005-07-04) 47# 48# __stc_assertion_end 49# 50################################################################################ 51 52verify_runnable "both" 53 54typeset OP=create 55 56log_assert "Ensure that compressed files are smaller." 57 58log_note "Ensure compression is off" 59log_must $ZFS set compression=off $TESTPOOL/$TESTFS 60 61log_note "Writing file without compression..." 62log_must $FILE_WRITE -o $OP -f $TESTDIR/$TESTFILE0 -b $BLOCKSZ \ 63 -c $NUM_WRITES -d $DATA 64 65log_note "Add compression property to the dataset and write another file" 66log_must $ZFS set compression=on $TESTPOOL/$TESTFS 67 68log_must $FILE_WRITE -o $OP -f $TESTDIR/$TESTFILE1 -b $BLOCKSZ \ 69 -c $NUM_WRITES -d $DATA 70 71log_must $SYNC $TESTDIR 72 73FILE0_BLKS=`$DU -k $TESTDIR/$TESTFILE0 | $AWK '{ print $1}'` 74FILE1_BLKS=`$DU -k $TESTDIR/$TESTFILE1 | $AWK '{ print $1}'` 75 76if [[ $FILE0_BLKS -le $FILE1_BLKS ]]; then 77 log_fail "$TESTFILE0 is smaller than $TESTFILE1" \ 78 "($FILE0_BLKS <= $FILE1_BLKS)" 79fi 80 81log_pass "$TESTFILE0 is bigger than $TESTFILE1 ($FILE0_BLKS > $FILE1_BLKS)" 82