1#!/bin/sh
2
3. functions
4
5cleanup() {
6	rm -rf h h1 h.xar h.toc h.out
7}
8
9echo "Checking normal heap archiving"
10cleanup
11mkdir -p h h1
12cp /bin/ls h
13cp h/ls h/foo
14
15cd h
16create_archive ../h.xar .
17cd ..
18${XAR} --dump-toc=h.toc -f h.xar
19cd h1
20extract_archive ../h.xar
21cd ..
22xsltproc heap1.xsl h.toc > h.out
23if [ $? -ne 0 ]; then
24	echo "Error processing toc"
25	cleanup
26	exit 1
27fi
28
29offset1=`head -1 h.out | awk '{print $2}'`
30offset2=`tail -1 h.out | awk '{print $2}'`
31if [ $offset1 -ge $offset2 ]; then
32	echo "Offset of first file is greater than or equal to offset of the first file"
33	cleanup
34	exit 1
35fi
36cleanup
37
38
39echo "Checking --coalesce-heap heap archiving"
40mkdir -p h h1
41cp /bin/ls h
42cp h/ls h/foo
43
44cd h
45${XAR} --coalesce-heap -cf ../h.xar .
46if [ $? -ne 0 ]; then
47	echo "Error creating archive"
48	cleanup
49	exit 1
50fi
51cd ..
52${XAR} --dump-toc=h.toc -f h.xar
53cd h1
54extract_archive ../h.xar
55cd ..
56xsltproc heap1.xsl h.toc > h.out
57if [ $? -ne 0 ]; then
58	echo "Error processing toc"
59	cleanup
60	exit 1
61fi
62
63offset1=`head -1 h.out | awk '{print $2}'`
64offset2=`tail -1 h.out | awk '{print $2}'`
65if [ $offset1 -ne $offset2 ]; then
66	echo "Offset of the files differ"
67	cleanup
68	exit 1
69fi
70cleanup
71
72
73echo "Checking --link-same heap archiving"
74mkdir -p h h1
75cp /bin/ls h
76cp h/ls h/foo
77
78cd h
79${XAR} --link-same -cf ../h.xar .
80if [ $? -ne 0 ]; then
81	echo "Error creating archive"
82	cleanup
83	exit 1
84fi
85cd ..
86${XAR} --dump-toc=h.toc -f h.xar
87cd h1
88extract_archive ../h.xar
89cd ..
90inode1=`ls -i h1/ls | awk '{print $1}'`
91inode2=`ls -i h1/foo | awk '{print $1}'`
92if [ $inode1 -ne $inode2 ]; then
93	echo "Inodes of extracted files don't match"
94	cleanup
95	exit 1
96fi
97cleanup
98