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 2012 Spectra Logic Corporation.  All rights reserved.
25# Use is subject to license terms.
26#
27
28. $STF_SUITE/include/libtest.kshlib
29. $STF_SUITE/tests/zil/zil.kshlib
30
31###############################################################################
32#
33# __stc_assertion_start
34#
35# ID: zil_002_pos
36#
37# DESCRIPTION:
38#
39# XXX XXX XXX
40#
41# STRATEGY:
42# 1) XXX
43# 2) XXX
44#
45# TESTABILITY: explicit
46#
47# TEST_AUTOMATION_LEVEL: automated
48#
49# CODING_STATUS: COMPLETED (YYYY-MM-DD) XXX
50#
51# __stc_assertion_end
52#
53###############################################################################
54
55verify_runnable "both"
56
57td5=$TESTDIR/5
58tf1=$td5/1
59tf2=$td5/2
60tf3=$td5/3
61file_size=`expr $POOLSIZE / 4`
62write_count=`expr $file_size / $BLOCK_SIZE`
63
64function check_file
65{
66	typeset fname="$1"
67	typeset -i expected_size="$2"
68
69	log_must test -f $fname
70	log_must test $expected_size == $(size_of_file $fname)
71}
72
73function cleanup
74{
75	ls -lr $TESTDIR
76	log_must $RM -rf $TESTDIR/*
77}
78
79log_onexit cleanup
80
81log_assert "Verify that creating and deleting content works"
82
83# Run the pre-export tests.
84zil_setup
85log_must $MKDIR $td5
86log_must $FILE_WRITE -o create -f $tf1 -b $BLOCK_SIZE -c $write_count -d 0
87check_file $tf1 $file_size
88log_must $CP $tf1 $tf2
89log_must $CP $tf2 $tf3
90check_file $tf2 $file_size
91log_must $CMP $tf1 $tf2
92log_must $RM -f $tf3
93
94# Now run the post-export tests.
95zil_reimport_pool $TESTPOOL
96check_file $tf1 $file_size
97check_file $tf2 $file_size
98log_must $CMP $tf1 $tf2
99log_mustnot test -f $tf3
100log_must test -f $tf1
101cur_file_size=$(size_of_file $tf1)
102log_must test $file_size -eq $cur_file_size
103
104log_pass "Success creating and deleting content"
105