1#!/bin/sh
2
3. functions
4
5cleanup() {
6	rm -rf h a a.xar
7}
8
9echo "Checking empty ea preservation on single empty file"
10cleanup
11mkdir h
12cd h
13touch a
14setfattr -n user.foo a
15if [ $? -ne 0 ]; then
16	echo "Error can't make user attribute on file"
17	cleanup
18	exit
19fi
20
21create_archive ../a.xar .
22cd ..
23extract_archive a.xar
24
25if [ ! -f a ]; then
26	echo "File didn't extract"
27	cleanup
28	exit 1
29fi
30
31count=`getfattr -d a | grep -c user.foo`
32if [ "$count" != "1" ]; then
33	echo "Didn't find the attribute after extraction"
34	cleanup
35	exit 1
36fi
37cleanup
38
39echo "Checking populated ea preservation on single empty file"
40cleanup
41mkdir h
42cd h
43touch a
44setfattr -n user.foo -v bar a
45if [ $? -ne 0 ]; then
46	echo "Error can't make user attribute on file"
47	cleanup
48	exit
49fi
50
51create_archive ../a.xar .
52cd ..
53extract_archive a.xar
54
55if [ ! -f a ]; then
56	echo "File didn't extract"
57	cleanup
58	exit 1
59fi
60
61count=`getfattr -d a | grep user.foo`
62if [ "$count" != "user.foo=\"bar\"" ]; then
63	echo "Didn't find the attribute after extraction"
64	#cleanup
65	exit 1
66fi
67
68cleanup
69
70echo "Checking populated ea preservation on single file with data"
71cleanup
72mkdir h
73cd h
74touch a
75echo "foo" > a
76setfattr -n user.foo -v bar a
77if [ $? -ne 0 ]; then
78	echo "Error can't make user attribute on file"
79	cleanup
80	exit
81fi
82
83create_archive ../a.xar .
84cd ..
85extract_archive a.xar
86
87if [ ! -f a ]; then
88	echo "File didn't extract"
89	cleanup
90	exit 1
91fi
92
93count=`getfattr -d a | grep user.foo`
94if [ "$count" != "user.foo=\"bar\"" ]; then
95	echo "Didn't find the attribute after extraction"
96	cleanup
97	exit 1
98fi
99
100contents=`cat a`
101if [ "$contents" != "foo" ]; then
102	echo "Contents of the file aren't the same after extraction"
103	cleanup
104	exit 1
105fi
106
107cleanup
108
109