Merge ~anonymouse67/review-tools:feature/lzo-test-updates into review-tools:master

Proposed by Ian Johnson
Status: Merged
Merged at revision: b55e0edf62e82cd7c647ef7722dc02079054178b
Proposed branch: ~anonymouse67/review-tools:feature/lzo-test-updates
Merge into: review-tools:master
Diff against target: 166 lines (+93/-40)
1 file modified
tests/manual-lzo.sh (+93/-40)
Reviewer Review Type Date Requested Status
Jamie Strandboge (community) Approve
Review via email: mp+386409@code.launchpad.net

Description of the change

* Fix ppc64el kernel uname arch
* Skip the deterministic check on systems with squashfs-tools that doesn't support -fstime

The fstime changes were tested on a Debian 9 system with squashfs 4.3, which does not support -fstime.

To post a comment you must log in.
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Thanks for the patch! I was expecting the changes to be a bit simpler.... I asked for more info inline.

review: Needs Information
Revision history for this message
Ian Johnson (anonymouse67) :
Revision history for this message
Jamie Strandboge (jdstrand) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/tests/manual-lzo.sh b/tests/manual-lzo.sh
2index c4e9b2e..b21ced2 100755
3--- a/tests/manual-lzo.sh
4+++ b/tests/manual-lzo.sh
5@@ -56,7 +56,7 @@ case "$(uname -m)" in
6 echo "running on i386"
7 all_snaps=("${i386_snaps[@]}" "${all_arch_snaps[@]}")
8 ;;
9- powerpc64le)
10+ ppc64le)
11 echo "running on ppc64el"
12 all_snaps=("${ppc64el_snaps[@]}" "${all_arch_snaps[@]}")
13 ;;
14@@ -198,6 +198,46 @@ pushd "$SCRIPT_DIR"
15 # this every time automatically with curl
16 curl -L -o review-tools.tgz https://github.com/anonymouse64/review-tools/archive/lzo-test-2.tar.gz
17
18+# NOTE: we can only do step 3 of this test, the deterministic resquash, on
19+# systems that have squashfs-tools with the -fstime option, as otherwise
20+# the resquashes will have different fstimes and thus never match. Thus,
21+# before running this check, we ensure that the mksquashfs we have
22+# available supports -fstime, and if it doesn't we skip it
23+HAVE_FSTIME=yes
24+
25+# make simple squashfs
26+rm -rf test-squashfs
27+mkdir test-squashfs
28+date "+%Y-%m-%dT%H:%M:%S%:z" > test-squashfs/filedate
29+# don't need sudo cause no special device nodes or set{u,g}id bit files
30+mksquashfs test-squashfs test-squashfs-1.snap -no-progress -noappend -comp xz -all-root -no-xattrs -no-fragments
31+
32+if TEST_FSTIME=$(unsquashfs -fstime test-squashfs-1.snap); then
33+ # verify that the fstime options actually works as advertised on this system
34+ mksquashfs test-squashfs test-squashfs-2.snap -fstime "$TEST_FSTIME" -no-progress -noappend -comp xz -all-root -no-xattrs -no-fragments
35+ sleep 1
36+ mksquashfs test-squashfs test-squashfs-3.snap -fstime "$TEST_FSTIME" -no-progress -noappend -comp xz -all-root -no-xattrs -no-fragments
37+
38+ # all 3 snaps should have the same hash
39+ # verify that the fstime option actually works by resquashing twice with the
40+ # option
41+ prev_sum=""
42+ for j in 1 2 3; do
43+ sum=$(sha256sum "test-squashfs-$j.snap" | cut -f1 -d' ')
44+ # if we have the previous one (not on the first iteration), check it matches
45+ # the current one
46+ if [ -n "$prev_sum" ] && [ "$sum" != "$prev_sum" ]; then
47+ # fstime is broken, didn't produce the same hash of snap files
48+ HAVE_FSTIME=no
49+ break
50+ fi
51+ prev_sum=$sum
52+ done
53+else
54+ # probably unsquashfs doesn't support fstime
55+ HAVE_FSTIME=no
56+fi
57+
58
59 sudo echo "useless sudo to keep authenticated against sudo during loops..." > /dev/null
60
61@@ -246,53 +286,66 @@ for sn in "${all_snaps[@]}" ; do
62 $MAYBE_SUDO rm -rf "${sn}-src" # in case of interrupted runs
63 $MAYBE_SUDO unsquashfs -d "${sn}-src" "${sn}_xz.snap"
64
65- # also save the fstime of the snap for re-pack determinism check
66- fstime=$(unsquashfs -fstime "${sn}_xz.snap")
67
68 # step 3. repack with lzo options set 10 times checking that the compressed
69- # snap has the same hash each time
70- for i in $(seq 1 10); do
71- hashfile="${sn}.lzo.sha256"
72+ # snap has the same hash each time (only if we have fstime)
73+ if [ "$HAVE_FSTIME" = "yes" ]; then
74+ # get the fstime to use for the deterministm check
75+ fstime=$(unsquashfs -fstime "${sn}_xz.snap")
76+
77+ for i in $(seq 1 10); do
78+ hashfile="${sn}.lzo.sha256"
79+
80+ # pack the snap - these options match "snap pack"
81+ if [ -n "$MAYBE_SUDO" ]; then
82+ # if we are calling sudo, don't use -all-root
83+ sudo mksquashfs "${sn}-src" "${sn}_lzo-$i.snap" -fstime "$fstime" -no-progress -noappend -comp lzo -no-xattrs -no-fragments
84+ else
85+ # use -all-root when we are not using sudo
86+ mksquashfs "${sn}-src" "${sn}_lzo-$i.snap" -fstime "$fstime" -no-progress -noappend -comp lzo -all-root -no-xattrs -no-fragments
87+ fi
88+
89+ # calculate the sha256sum for the re-packed snap
90+ sum=$(sha256sum "${sn}_lzo-$i.snap" | cut -f1 -d' ')
91+
92+ # in the first go-around, save the hash
93+ if [ "$i" = "1" ]; then
94+ echo "$sum" > "$hashfile"
95+ else
96+ # in all other iterations make sure the calculated hash matches the
97+ # saved one from the first iteration
98+ if [ "$sum" != "$(cat "$hashfile")" ]; then
99+ echo ">>> TEST FAIL <<< snap $sn lzo compressed on iteration $i had sha256sum of $sum, expected $(cat "$hashfile") from iteration 1"
100+ exit 1
101+ fi
102+
103+ # we're done with this passing lzo, so discard it to not waste
104+ # space during the runs
105+ rm -f "${sn}_lzo-$i.snap"
106+
107+ # sleep a small amount of time to ensure that the time is different
108+ # when we re-pack again in the next iteration
109+ sleep 0.5
110+ fi
111+
112+ sudo echo "useless sudo to keep authenticated against sudo during loops..." > /dev/null
113+ done
114
115- # pack the snap - these options match "snap pack"
116+ # cleanup the re-packed snaps, saving the first one for later usage
117+ $MAYBE_SUDO mv "${sn}_lzo-1.snap" "${sn}_lzo.snap"
118+ $MAYBE_SUDO rm -f "${sn}_lzo-"*.snap
119+ $MAYBE_SUDO rm -rf "${sn}-src"
120+ else
121+ # we don't have -fstime, but we still need to produce a lzo snap to test
122+ # in the store check
123 if [ -n "$MAYBE_SUDO" ]; then
124 # if we are calling sudo, don't use -all-root
125- sudo mksquashfs "${sn}-src" "${sn}_lzo-$i.snap" -fstime "$fstime" -no-progress -noappend -comp lzo -no-xattrs -no-fragments
126+ sudo mksquashfs "${sn}-src" "${sn}_lzo.snap" -no-progress -noappend -comp lzo -no-xattrs -no-fragments
127 else
128 # use -all-root when we are not using sudo
129- mksquashfs "${sn}-src" "${sn}_lzo-$i.snap" -fstime "$fstime" -no-progress -noappend -comp lzo -all-root -no-xattrs -no-fragments
130+ mksquashfs "${sn}-src" "${sn}_lzo.snap" -no-progress -noappend -comp lzo -all-root -no-xattrs -no-fragments
131 fi
132-
133- # calculate the sha256sum for the re-packed snap
134- sum=$(sha256sum "${sn}_lzo-$i.snap" | cut -f1 -d' ')
135-
136- # in the first go-around, save the hash
137- if [ "$i" = "1" ]; then
138- echo "$sum" > "$hashfile"
139- else
140- # in all other iterations make sure the calculated hash matches the
141- # saved one from the first iteration
142- if [ "$sum" != "$(cat "$hashfile")" ]; then
143- echo ">>> TEST FAIL <<< snap $sn lzo compressed on iteration $i had sha256sum of $sum, expected $(cat "$hashfile") from iteration 1"
144- exit 1
145- fi
146-
147- # we're done with this passing lzo, so discard it to not waste
148- # space during the runs
149- rm -f "${sn}_lzo-$i.snap"
150-
151- # sleep a small amount of time to ensure that the time is different
152- # when we re-pack again in the next iteration
153- sleep 0.5
154- fi
155-
156- sudo echo "useless sudo to keep authenticated against sudo during loops..." > /dev/null
157- done
158-
159- # cleanup the re-packed snaps, saving the first one for later usage
160- $MAYBE_SUDO mv "${sn}_lzo-1.snap" "${sn}_lzo.snap"
161- $MAYBE_SUDO rm -f "${sn}_lzo-"*.snap
162- $MAYBE_SUDO rm -rf "${sn}-src"
163+ fi
164
165 # step 4. run the review-tools inside the various ubuntu lxc containers to
166 # check that the snap is unsquashed and resquashed to the same blob

Subscribers

People subscribed via source and target branches

to all changes: