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 . $STF_SUITE/include/libtest.shlib
29
30 # Perform a bunch of extended attribute test on some newly created filesystem.
31 # Create, mount and set the properties on a filesystem before clobbering it
32 # with a bunch of commands.
33 #
34 # @return: 0 if all the work completed ok
35
36 NUM_FILE=${NUM_FILE:-5}
37 NUM_ATTR=${NUM_ATTR:-20}
38 RES_DIR=${RES_DIR:-res}
39 INI_DIR=${INI_DIR:-init}
40 TST_DIR=${TST_DIR:-test}
41 TMP_DIR=${TMP_DIR:-tmp}
42
43 # Defined for saving files and attributes' cksum results.
44 set -A BEFORE_FCKSUM
45 set -A BEFORE_ACKSUM
46 set -A AFTER_FCKSUM
47 set -A AFTER_ACKSUM
48
49 # Get the specified item of the specified string
50 #
51 # $1: Item number, count from 0.
52 # $2-n: strings
53 function getitem {
54 typeset -i n=$1
55 shift
56
57 (( n += 1 ))
58 eval echo \${$n}
59 }
60
61 # This function calculate the specified directory files checksum and write
62 # to the specified array.
63 #
64 # $1 directory in which the files will be cksum.
65 # $2 file array name which was used to store file cksum information.
66 # $3 attribute array name which was used to store attribute information.
67 function cksum_file {
68 typeset dir=$1
69 typeset farr_name=$2
70 typeset aarr_name=$3
71
72 [[ ! -d $dir ]] && return
73 cd $dir
74 typeset files=$(ls file*)
75
76 typeset -i i=0
77 typeset -i n=0
78 while (( i < NUM_FILE )); do
79 typeset f=$(getitem $i $files)
80 eval $farr_name[$i]=\$\(cksum $f\)
81
82 typeset -i j=0
83 while (( j < NUM_ATTR )); do
84 eval $aarr_name[$n]=\$\(runat \$f cksum attribute.$j\)
85 (( j += 1 ))
86 (( n += 1 ))
87 done
88
89 (( i += 1 ))
90 done
91 }
92
93 # This function compare two cksum results array.
94 #
95 # $1 The array name which stored the cksum before operation.
96 # $2 The array name which stored the cksum after operation.
97 function compare_cksum {
98 typeset before=$1
99 typeset after=$2
100 eval typeset -i count=\${#$before[@]}
101
102 typeset -i i=0
103 while (( i < count )); do
104 eval typeset var1=\${$before[$i]}
105 eval typeset var2=\${$after[$i]}
106
107 if [[ $var1 != $var2 ]]; then
108 log_fail "($var1 != $var2)chksum failed."
109 fi
110
111 (( i += 1 ))
112 done
113 }
114
115 # This function calculates all the files cksum information in current directory
116 # and outputs them to the specified file.
117 #
118 # $1 output file
119 function record_cksum {
120 typeset outfile=$1
121
122 [[ ! -d ${outfile%/*} ]] && mdkir -p ${outfile%/*}
123
124 find . -depth -type f -exec cksum {} \; | sort > $outfile
125 find . -depth -type f -xattr -exec runat {} cksum attribute \; | \
126 sort >> $outfile
127 }
128
129 # The clean_up function is called periodically throughout
130 # the script to either get rid of files that have already
131 # been used by other scripts or to get rid of the test
132 # files after the script is finished.
133 #
134 # $1 base directory
135 function clean_up {
136 typeset basedir=$1
137 if [[ -d $basedir ]]; then
138 cd $basedir
139 rm -rf $basedir/*
140 fi
141 }
142
143 # The function create_files creates the directories and files that the script
144 # will operate on to test extended attribute functionality.
145 #
146 # $1 The basic directory in which to create directories and files.
147 function create_files {
148 typeset basedir=$1
149 typeset resdir=$basedir/$RES_DIR
150 typeset initdir=$basedir/$INI_DIR
151 typeset testdir=$basedir/$TST_DIR
152 typeset tmpdir=$basedir/$TMP_DIR
153
154 [[ ! -d $basedir ]] && mkdir -m 777 $basedir
155 [[ ! -d $resdir ]] && mkdir -m 777 $resdir
156 [[ ! -d $initdir ]] && mkdir -m 777 $initdir
157 [[ ! -d $testdir ]] && mkdir -m 777 $testdir
158 [[ ! -d $tmpdir ]] && mkdir -m 777 $tmpdir
159
160 # Create the original file and its attribute files.
161 [[ ! -a $resdir/file ]] && \
162 file_write -o create -f $resdir/file -b 1024 -d 0 -c 1
163 [[ ! -a $resdir/attribute ]] && \
164 cp $resdir/file $resdir/attribute
165
166 cd $initdir
167 typeset -i i=0
168 while (( i < NUM_FILE )); do
169 typeset dstfile=$initdir/file.$$.$i
170 cp $resdir/file $dstfile
171
172 typeset -i j=0
173 while (( j < NUM_ATTR )); do
174 runat $dstfile \
175 cp $resdir/attribute ./attribute.$j
176 (( j += 1 ))
177 done
178
179 (( i += 1 ))
180 done
181 }
182
183 # The test_compress function tests the functionality of the compress and
184 # uncompress utility. The function verifies that compress will keep file
185 # attribute intact after the file is compressed and uncompressed.
186 #
187 # $1 Base directory for compress testing.
188 function test_compress
189 {
190 log_assert "($$) Starting compress/uncompress test..."
191
192 typeset basedir=$1
193 typeset initdir=$basedir/$INI_DIR
194 typeset testdir=$basedir/$TST_DIR
195
196 create_files $basedir
197 cksum_file $initdir BEFORE_FCKSUM BEFORE_ACKSUM
198
199 compress $initdir/*
200 mv $initdir/* $testdir
201 uncompress $testdir/*
202
203 cksum_file $testdir AFTER_FCKSUM AFTER_ACKSUM
204
205 compare_cksum BEFORE_FCKSUM AFTER_FCKSUM
206 compare_cksum BEFORE_ACKSUM AFTER_ACKSUM
207
208 clean_up $basedir
209 log_note "($$) Finished compress/uncompress test."
210 }
211
212 # The test_cp function tests the functionality of the cp
213 # utility. The function tests the following:
214 #
215 # * verifies that cp will include file attribute when
216 # using the -@ flag
217 # * verifies that cp will not be able to include file
218 # attribute when attribute is unreadable (unless the
219 # user is root)
220 # * verifies that cp will not include file attribute
221 # when the -@ flag is not present
222 function test_cp
223 {
224 log_assert "($$) Starting cp test..."
225
226 typeset basedir=$1
227 typeset initdir=$basedir/$INI_DIR
228 typeset testdir=$basedir/$TST_DIR
229
230 log_note "Verify that 'cp -@' will include file attribute."
231 create_files $basedir
232 cksum_file $initdir BEFORE_FCKSUM BEFORE_ACKSUM
233
234 #
235 # Get initial directory files name and 'cp -@p' to the test directory.
236 #
237 typeset ini_files=$(ls $initdir/file*)
238 typeset -i i=0
239 while (( i < NUM_FILE )); do
240 typeset f=$(getitem $i $ini_files)
241 cp -@p $f $testdir
242 (( i += 1 ))
243 done
244
245 cksum_file $testdir AFTER_FCKSUM AFTER_ACKSUM
246 compare_cksum BEFORE_FCKSUM AFTER_FCKSUM
247 compare_cksum BEFORE_ACKSUM AFTER_ACKSUM
248
249 clean_up $basedir
250
251 log_note "Verifies that cp won't be able to include file" \
252 "attribute when attribute is unreadable (except root)"
253 create_files $basedir
254 ini_files=$(ls $initdir/file*)
255
256 i=0
257 while (( i < NUM_FILE )); do
258 typeset f=$(getitem $i $ini_files)
259 typeset -i j=0
260 while (( j < NUM_ATTR )); do
261 # chmod all the attribute files to '000'.
262 runat $f chmod 000 attribute.$j
263
264 (( j += 1 ))
265 done
266
267 # Apply 'cp -@p' to the file whose attribute files
268 # models are '000'.
269 cp -@p $f $testdir
270
271 typeset tst_files=$(ls $testdir/file*)
272 typeset tf=$(getitem $i $tst_files)
273 typeset ls_attr=$(ls -@ $tf | nawk '{print substr($1, 11, 1)}')
274 if [[ $ls_attr != "@" ]]; then
275 log_fail "Should be able to cp attribute when" \
276 "attribute files is unreadable as root."
277 fi
278
279 (( i += 1 ))
280 done
281
282 clean_up $basedir
283
284 log_note "Verifies that cp will not include file attribute" \
285 "when the -@ flag is not present."
286 create_files $basedir
287 ini_files=$(ls $initdir/file*)
288
289 i=0
290 while (( i < NUM_FILE )); do
291 typeset f=$(getitem $i $ini_files)
292 cp $f $testdir
293
294 tst_files=$(ls $testdir/file*)
295 typeset tf=$(getitem $i $tst_files)
296 typeset ls_attr=$(ls -@ $tf | nawk '{print substr($1, 11, 1)}')
297 if [[ $ls_attr == "@" ]]; then
298 log_fail "cp of attribute successful without" \
299 "-@ or -p option"
300 fi
301
302 (( i += 1 ))
303 done
304
305 clean_up $basedir
306 log_note "($$) Finished cp test."
307 }
308
309 # The test_find function tests the functionality of the find
310 # utility. The function tests the following:
311 #
312 # * verifies ability to find files with attribute with -xattr
313 # flag and using "-exec runat ls"
314 # * verifies -xattr doesn't include files without attribute
315 # and using "-exec runat ls"
316 # * verifies that using the command "find . -xattr" will only
317 # return those files known to have attribute
318 function test_find
319 {
320
321 log_assert "($$)Starting find test ..."
322 typeset basedir=$1
323 typeset initdir=$basedir/$INI_DIR
324
325 log_note "Verifies ability to find files with attribute with" \
326 "-xattr flag and using '-exec runat ls'"
327 typeset oldpwd=$PWD
328 create_files $basedir
329 typeset ini_files=$(ls $initdir/file*)
330 typeset ff fa
331
332 cd $initdir
333 typeset -i i=0
334 while (( i < NUM_FILE )); do
335 typeset f=$(getitem $i $ini_files)
336 ff=$(find $initdir -type f -name ${f##*/} -xattr -print)
337 if [[ $ff != $f ]]; then
338 log_fail "failed to find file containing attribute"
339 fi
340
341 cd $initdir
342 typeset j=0
343 while (( j < NUM_ATTR )); do
344 typeset af=attribute.$j
345 fa=$(find . -type f -name ${f##*/} -xattr \
346 -exec runat {} ls $af \;)
347 if [[ $fa != $af ]]; then
348 log_fail "find file attribute fail"
349 fi
350 (( j += 1 ))
351 done
352 (( i += 1 ))
353 done
354
355 log_note "verifies -xattr doesn't include files without" \
356 "attribute and using '-exec runat ls'"
357 i=0
358 while (( i < NUM_FILE )); do
359 f=$(getitem $i $ini_files)
360 runat $f rm attribute*
361 (( i += 1 ))
362 done
363
364 i=0
365 while (( i < NUM_FILE )); do
366 typeset f=$(getitem $i $ini_files)
367 ff=$(find $initdir -type f -name ${f##*/} -xattr -print)
368 if [[ $ff == $f ]]; then
369 log_fail "find not containing attribute should fail"
370 fi
371 typeset j=0
372 while (( j < NUM_ATTR )); do
373 fa=$(find . -type f -name ${f##*/} -xattr \
374 -exec runat {} ls attribute.$j \;)
375 if [[ $fa == attribute.$j ]]; then
376 log_note "find file attribute should fail"
377 fi
378 (( j += 1 ))
379 done
380 (( i += 1 ))
381 done
382
383 clean_up $basedir
384 cd $oldpwd
385 log_note "($$) Finished find test."
386 }
387
388 # The test_ls function tests the functionality of the ls
389 # utility. The function tests the following:
390 #
391 # * verifies that ls displays @ in the file permissions
392 # using ls -@ for files with attribute
393 # * verifies that ls doesn't display @ in the file
394 # permissions using ls -@ for files without attribute
395 function test_ls
396 {
397 log_assert "($$)Starting ls test ..."
398 typeset basedir=$1
399 typeset initdir=$basedir/$INI_DIR
400
401 log_note "Verifies that ls displays @ in the file permissions" \
402 "using ls -@ for files with attribute."
403 create_files $basedir
404
405 typeset ini_files=$(ls $initdir/file*)
406 typeset ls_attr
407 typeset -i i=0
408 while (( i < NUM_FILE )); do
409 typeset f=$(getitem $i $ini_files)
410 ls_attr=$(ls -@ $f | nawk '{print substr($1, 11, 1)}')
411 if [[ $ls_attr != "@" ]]; then
412 log_fail "ls with attribute failed"
413 fi
414 (( i += 1 ))
415 done
416
417 log_note "Verifies that ls doesn't display @ in the file" \
418 "permissions using ls -@ for files without attribute."
419 i=0
420 while (( i < NUM_FILE )); do
421 typeset f=$(getitem $i $ini_files)
422 runat $f rm attribute*
423 ls_attr=$(ls -l $f | nawk '{print substr($1, 11, 1)}')
424 if [[ $ls_attr == "@" ]]; then
425 log_fail "ls with attribute shouldn't succeed."
426 fi
427 (( i += 1 ))
428 done
429
430 clean_up $basedir
431 log_note "($$) Finished ls test."
432 }
433
434 # The mv_test function tests the functionality of the mv
435 # utility. The function tests the following:
436 #
437 # * verifies that mv will include file attribute
438 function test_mv
439 {
440 log_assert "($$)Starting mv test ... "
441
442 typeset basedir=$1
443 typeset initdir=$basedir/$INI_DIR
444 typeset testdir=$basedir/$TST_DIR
445
446 create_files $basedir
447 typeset ini_files=$(ls $initdir/file*)
448
449 cksum_file $initdir BEFORE_FCKSUM BEFORE_ACKSUM
450
451 typeset -i i=0
452 while (( i < NUM_FILE )); do
453 typeset f=$(getitem $i $ini_files)
454 mv $f $testdir
455 (( i += 1 ))
456 done
457
458 cksum_file $testdir AFTER_FCKSUM AFTER_ACKSUM
459
460 compare_cksum BEFORE_FCKSUM AFTER_FCKSUM
461 compare_cksum BEFORE_ACKSUM AFTER_ACKSUM
462
463 clean_up $basedir
464 log_note "($$) Finished mv test."
465 }
466
467 # The pack_test function tests the functionality of the pack
468 # and unpack utility. The function tests the following:
469 #
470 # * verifies that pack will keep file attribute intact after
471 # the file is packed and unpacked
472 function test_pack
473 {
474 log_assert "($$)Starting pack/unpack test ... "
475
476 typeset basedir=$1
477 typeset initdir=$basedir/$INI_DIR
478 typeset testdir=$basedir/$TST_DIR
479
480 create_files $basedir
481
482 cksum_file $initdir BEFORE_FCKSUM BEFORE_ACKSUM
483 pack -f $initdir/file* > /dev/null 2>&1
484 mv $initdir/* $testdir
485 unpack $testdir/file* > /dev/null 2>&1
486 cksum_file $testdir AFTER_FCKSUM AFTER_ACKSUM
487
488 compare_cksum BEFORE_FCKSUM AFTER_FCKSUM
489 compare_cksum BEFORE_ACKSUM AFTER_ACKSUM
490
491 clean_up $basedir
492 log_note "($$) Finished pack/unpack test."
493 }
494
495 # The test_pax function tests the functionality of the pax
496 # utility. The function tests the following:
497 #
498 # * include attribute in pax archive and restore with pax
499 # * include attribute in tar archive and restore with pax
500 # * include attribute in cpio archive and restore with pax
501 # * include attribute in tar archive and restore with tar
502 # * include attribute in cpio archive and restore with cpio
503 function test_pax
504 {
505 log_assert "($$)Starting pax test ..."
506
507 typeset basedir=$1
508 typeset initdir=$basedir/$INI_DIR
509 typeset testdir=$basedir/$TST_DIR
510 typeset tmpdir=$basedir/$TMP_DIR
511 typeset oldpwd=$PWD
512
513 log_note "Include attribute in pax archive and restore with pax"
514 [[ ! -d $initdir ]] && mkdir -m 777 -p $initdir
515 mktree -b $initdir -l 6 -d 2 -f 2
516
517 # Enter into initial directory and record all directory information,
518 # then pax all the files to $tmpdir/files.pax.
519 [[ ! -d $tmpdir ]] && mkdir $tmpdir
520 typeset initout=$tmpdir/initout.$$
521 cd $initdir
522 record_cksum $initout
523 typeset paxout=$tmpdir/files.pax
524 pax -w -@ -f $paxout * > /dev/null 2>&1
525
526 # Enter into test directory and pax $tmpdir/files.pax to current
527 # directory. Record all directory information and compare with initial
528 # directory record.
529 [[ ! -d $testdir ]] && mkdir -m 777 $testdir
530 typeset testout=$tmpdir/testout.$$
531 cd $testdir
532 pax -r -@ -f $paxout > /dev/null 2>&1
533 record_cksum $testout
534 diff $initout $testout
535
536 clean_up $basedir
537
538 log_note "Include attribute in tar archive and restore with pax"
539 [[ ! -d $initdir ]] && mkdir -m 777 $initdir
540 mktree -b $initdir -l 5 -d 2 -f 2
541 [[ ! -d $tmpdir ]] && mkdir -m 777 $tmpdir
542 cd $initdir
543 record_cksum $initout
544 paxout=$tmpdir/files.$$.tar
545 pax -w -x ustar -@ -f $paxout * > /dev/null 2>&1
546
547 [[ ! -d $testdir ]] && mkdir -m 777 $testdir
548 cd $testdir
549 tar xpf@ $paxout
550 record_cksum $testout
551
552 diff $initout $testout
553
554 clean_up $basedir
555
556 log_note "Include attribute in cpio archive and restore with pax"
557 [[ ! -d $initdir ]] && mkdir -m 777 $initdir
558 mktree -b $inidir -l 5 -d 2 -f 2
559
560 cd $initdir
561 record_cksum $initout
562 paxout=$tmpdir/files.cpio
563 pax -w -x cpio -@ -f $paxout * > /dev/null 2>&1
564
565 [[ ! -d $testdir ]] && mkdir -m 777 $testdir
566 cd $testdir
567 cpio -ivd@ < $paxout > /dev/null 2>&1
568 record_cksum $testout
569
570 diff $initout $testout
571
572 clean_up $basedir
573
574 log_note "Include attribute in tar archive and restore with tar"
575 create_files $basedir
576 cksum_file $initdir BEFORE_FCKSUM BEFORE_ACKSUM
577 cd $initdir
578 paxout=$tmpdir/files.pax
579 pax -w -@ -f $paxout file* > /dev/null 2>&1
580 cd $testdir
581 pax -r -@ -f $paxout > /dev/null 2>&1
582 cksum_file $testdir AFTER_FCKSUM AFTER_ACKSUM
583
584 compare_cksum BEFORE_FCKSUM AFTER_FCKSUM
585 compare_cksum BEFORE_ACKSUM AFTER_ACKSUM
586 clean_up $basedir
587
588 log_note "Include attribute in cpio archive and restore with cpio"
589 create_files $basedir
590 cd $initdir
591 paxout=$tmpdir/files.cpio
592 cksum_file $initdir BEFORE_FCKSUM BEFORE_ACKSUM
593 pax -w -x cpio -@ -f $paxout file* > /dev/null 2>&1
594
595 cd $testdir
596 pax -r -x cpio -@ -f $paxout > /dev/null 2>&1
597 cksum_file $testdir AFTER_FCKSUM AFTER_ACKSUM
598
599 compare_cksum BEFORE_FCKSUM AFTER_FCKSUM
600 compare_cksum BEFORE_ACKSUM AFTER_ACKSUM
601
602 rm -rf file*
603 cpio -iv@ < $paxout > /dev/null 2>&1
604 cksum_file $testdir AFTER_FCKSUM AFTER_ACKSUM
605
606 compare_cksum BEFORE_FCKSUM AFTER_FCKSUM
607 compare_cksum BEFORE_ACKSUM AFTER_ACKSUM
608
609 clean_up $basedir
610
611 create_files $basedir
612 cksum_file $initdir BEFORE_FCKSUM BEFORE_ACKSUM
613 paxout=$tmpdir/files.$$.tar
614 cd $initdir
615 pax -w -x ustar -@ -f $paxout file* > /dev/null 2>&1
616 cd $testdir
617 pax -r -x ustar -@ -f $paxout > /dev/null 2>&1
618 cksum_file $testdir AFTER_FCKSUM AFTER_ACKSUM
619
620 compare_cksum BEFORE_FCKSUM AFTER_FCKSUM
621 compare_cksum BEFORE_ACKSUM AFTER_ACKSUM
622
623 rm -rf file*
624 tar xf@ $tmpdir/files.$$.tar > /dev/null 2>&1
625 cksum_file $testdir AFTER_FCKSUM AFTER_ACKSUM
626
627 compare_cksum BEFORE_FCKSUM AFTER_FCKSUM
628 compare_cksum BEFORE_ACKSUM AFTER_ACKSUM
629
630 clean_up $basedir
631 cd $oldpwd
632 log_note "($$) Finished pax test."
633 }
634
635 # The test_rm function tests the functionality of the rm
636 # utility. The function tests the following:
637 #
638 # * removal of file and associated attribute
639 function test_rm
640 {
641 log_assert "($$)Starting rm test ..."
642
643 typeset basedir=$1
644 typeset initdir=$basedir/$INI_DIR
645 typeset testdir=$basedir/$TST_DIR
646
647 create_files $basedir
648 typeset ini_files=$(ls $initdir/file*)
649
650 typeset -i i=0
651 while (( i < NUM_FILE )); do
652 typeset f=$(getitem $i $ini_files)
653 rm $f
654 ls $f
655
656 (( i += 1 ))
657 done
658
659 clean_up $basedir
660 log_note "($$) Finished rm test."
661 }
662
663 # The test_tar function tests the functionality of the tar
664 # utility. The function tests the following:
665 #
666 # * verifies that tar will include file attribute when
667 # @ flag is present
668 # * verifies that tar will not include files attribute
669 # when @ flag is not present
670 function test_tar
671 {
672 log_assert "($$)Starting tar test ..."
673
674 typeset basedir=$1
675 typeset initdir=$basedir/$INI_DIR
676 typeset testdir=$basedir/$TST_DIR
677 typeset tmpdir=$basedir/$TMP_DIR
678 typeset oldpwd=$PWD
679
680 [[ ! -d $initdir ]] && mkdir -m 777 $initdir
681 [[ ! -d $tmpdir ]] && mkdir -m 777 $tmpdir
682 [[ ! -d $testdir ]] && mkdir -m 777 $testdir
683 mktree -b $initdir -l 5 -d 2 -f 2
684
685 log_note "Verifies that tar will include file attribute" \
686 "when @ flag is present."
687 typeset initout=$tmpdir/initout.$$
688 typeset tarout=$tmpdir/files.$$.tar
689 cd $initdir
690 record_cksum $initout
691 tar cpf@ $tarout *
692
693 typeset testout=$tmpdir/testout.$$
694 cd $testdir
695 tar xpf@ $tarout
696 record_cksum $testout
697
698 diff $initout $testout
699 clean_up $basedir
700
701 log_note "Verifies that tar will not include files attribute" \
702 "when @ flag is not present."
703 create_files $basedir
704 cd $initdir
705 cksum_file $initdir BEFORE_FCKSUM BEFORE_ACKSUM
706 tarout=$tmpdir/files.$$.tar
707 tar cpf@ $tarout * > /dev/null 2>&1
708 cksum_tara=$(cksum $tarout)
709 cp $tarout $testdir
710
711 cd $testdir
712 tar xpf@ $tarout > /dev/null 2>&1
713 cksum_file $testdir AFTER_FCKSUM AFTER_ACKSUM
714
715 compare_cksum BEFORE_FCKSUM AFTER_FCKSUM
716 compare_cksum BEFORE_ACKSUM AFTER_ACKSUM
717
718 ck_tvf=$(tar tvf $tarout | grep attribute | wc -l)
719 if (( $ck_tvf != NUM_ATTR * NUM_FILE + NUM_FILE )); then
720 log_note "table of contents displayed attribute fail"
721 fi
722
723 clean_up $basedir
724
725 create_files $basedir
726
727 cd $initdir
728 tar cpf $tarout file* > /dev/null 2>&1
729 cksum_tarb=$(cksum $tarout)
730 cp $tarout $testdir
731
732 cd $testdir
733 tar xpf $tarout > /dev/null 2>&1
734 typeset test_files=$(ls $testdir/file*)
735 typeset -i i=0
736 while (( i < NUM_FILE )); do
737 typeset f=$(getitem $i $test_files)
738 ls_attr=$(ls -@ $f | nawk '{print substr($1, 11, 1)}')
739 if [[ $ls_attr == "@" ]]; then
740 log_fail "extraction of attribute successful w/ -@ flag"
741 fi
742
743 (( i += 1 ))
744 done
745
746 if [[ $cksum_tara == $cksum_tarb ]]; then
747 log_fail "inclusion of attribute in tar file without -@ failed"
748 fi
749
750 clean_up $basedir
751 cd $oldpwd
752 log_note "($$) Finished tar test."
753 }
754
755 function test_all #<directory>
756 {
757 typeset dir=$1
758
759 test_compress $dir
760 test_cp $dir
761 test_find $dir
762 test_ls $dir
763 test_mv $dir
764 test_pack $dir
765 test_pax $dir
766 test_rm $dir
767 test_tar $dir
768
769 exit 0
770 }
771
772 function trap_handle
773 {
774 typeset pid
775
776 for pid in $@; do
777 kill -9 $pid
778 done
779 kill -9 $$
780 }
781
782 typeset dataset=$1
783 typeset ddirb=${TEST_BASE_DIR%%/}/dir.$$
784 typeset -i runat=0
785
786 (( count = TOTAL_COUNT * NUM_CREATORS ))
787
788 while (( runat < count )); do
789 typeset -i run_count=0
790 typeset tfs=$dataset/fs.$$.$runat
791 typeset tdir=$ddirb/$runat
792
793 mkdir -p $tdir
794 zfs create $tfs
795 zfs set mountpoint=$tdir $tfs
796 if ! dataset_set_defaultproperties $tfs; then
797 log_fail "dataset_set_defaultproperties failed"
798 fi
799
800 typeset runpids=""
801 while (( run_count < NUM_CREATORS )); do
802 log_note "Starting No.$run_count running..."
803
804 [[ ! -d $tdir/$run_count ]] && mkdir -m 777 $tdir/$run_count
805
806 test_all $tdir/$run_count > /dev/null 2>&1 &
807 runpids="$! $runpids"
808
809 (( run_count += 1 ))
810 done
811
812 trap 'trap_handle $runpids' USR1
813
814 for pid in $runpids; do
815 wait $pid
816 typeset status=$?
817 if [ $status -ne 0 ]; then
818 log_note "($pid)Extend attribute test failed. ($status)"
819 fi
820 done
821 runpids=""
822
823 if datasetexists $tfs; then
824 zfs destroy -Rf $tfs
825 fi
826 if [[ -d $tdir ]]; then
827 rm -rf $tdir
828 fi
829
830 (( runat += 1 ))
831 done