unstack, sort: cleanup and improvement
[minix.git] / commands / tar / test / test-flags.sh
blobbfbf542163caa6e31fbb8e839b8643e695059fd1
1 #!/bin/sh
2 # Copyright (c) 2007 Tim Kientzle
3 # All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 # 1. Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
14 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 # IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 # $FreeBSD: src/usr.bin/tar/test/test-flags.sh,v 1.1 2007/03/11 10:36:42 kientzle Exp $
27 # Exercise copying of file flags
28 echo "File Flag handling"
29 # Basic test configuration
30 . `dirname $0`/config.sh
32 # Create some files with various flags set
33 mkdir original
34 FLAGS='uchg opaque nodump uappnd'
35 for f in $FLAGS; do
36 touch original/test.$f
37 chflags $f original/test.$f
38 done
39 #ls -ol ${TESTDIR}/original
41 # Copy the dir with -p
42 echo " -p preserves flags"
43 mkdir copy
44 (cd original && ${BSDTAR} -cf - .) | (cd copy; ${BSDTAR} -xpf -)
45 # Verify that the flags are set
46 for f in $FLAGS; do
47 [ "$f" = `ls -ol copy/test.$f | awk '{print $5}'` ] \
48 || echo XXX FAIL: $f not preserved with -p XXX
49 done
50 #ls -ol ${TESTDIR}/copy
52 # Copy the dir without -p
53 echo " flags omitted without -p"
54 mkdir copy2
55 (cd original && ${BSDTAR} -cf - .) | (cd copy2; ${BSDTAR} -xf -)
56 # Verify that the flags are not set
57 for f in $FLAGS; do
58 [ "$f" = `ls -ol copy2/test.$f | awk '{print $5}'` ] \
59 && echo XXX FAIL: $f copied without -p XXX
60 done
61 #ls -ol ${TESTDIR}/copy2
63 # Strip off the flags so we can clean this directory on the next test
64 for f in $FLAGS; do
65 if [ $f = 'nodump' ]; then
66 chflags dump original/test.$f
67 chflags dump copy/test.$f
68 else
69 chflags no$f original/test.$f
70 chflags no$f copy/test.$f
72 done
73 cd ..