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
diff --git a/tests/manual-lzo.sh b/tests/manual-lzo.sh
index c4e9b2e..b21ced2 100755
--- a/tests/manual-lzo.sh
+++ b/tests/manual-lzo.sh
@@ -56,7 +56,7 @@ case "$(uname -m)" in
56 echo "running on i386"56 echo "running on i386"
57 all_snaps=("${i386_snaps[@]}" "${all_arch_snaps[@]}")57 all_snaps=("${i386_snaps[@]}" "${all_arch_snaps[@]}")
58 ;;58 ;;
59 powerpc64le)59 ppc64le)
60 echo "running on ppc64el"60 echo "running on ppc64el"
61 all_snaps=("${ppc64el_snaps[@]}" "${all_arch_snaps[@]}")61 all_snaps=("${ppc64el_snaps[@]}" "${all_arch_snaps[@]}")
62 ;;62 ;;
@@ -198,6 +198,46 @@ pushd "$SCRIPT_DIR"
198# this every time automatically with curl198# this every time automatically with curl
199curl -L -o review-tools.tgz https://github.com/anonymouse64/review-tools/archive/lzo-test-2.tar.gz199curl -L -o review-tools.tgz https://github.com/anonymouse64/review-tools/archive/lzo-test-2.tar.gz
200200
201# NOTE: we can only do step 3 of this test, the deterministic resquash, on
202# systems that have squashfs-tools with the -fstime option, as otherwise
203# the resquashes will have different fstimes and thus never match. Thus,
204# before running this check, we ensure that the mksquashfs we have
205# available supports -fstime, and if it doesn't we skip it
206HAVE_FSTIME=yes
207
208# make simple squashfs
209rm -rf test-squashfs
210mkdir test-squashfs
211date "+%Y-%m-%dT%H:%M:%S%:z" > test-squashfs/filedate
212# don't need sudo cause no special device nodes or set{u,g}id bit files
213mksquashfs test-squashfs test-squashfs-1.snap -no-progress -noappend -comp xz -all-root -no-xattrs -no-fragments
214
215if TEST_FSTIME=$(unsquashfs -fstime test-squashfs-1.snap); then
216 # verify that the fstime options actually works as advertised on this system
217 mksquashfs test-squashfs test-squashfs-2.snap -fstime "$TEST_FSTIME" -no-progress -noappend -comp xz -all-root -no-xattrs -no-fragments
218 sleep 1
219 mksquashfs test-squashfs test-squashfs-3.snap -fstime "$TEST_FSTIME" -no-progress -noappend -comp xz -all-root -no-xattrs -no-fragments
220
221 # all 3 snaps should have the same hash
222 # verify that the fstime option actually works by resquashing twice with the
223 # option
224 prev_sum=""
225 for j in 1 2 3; do
226 sum=$(sha256sum "test-squashfs-$j.snap" | cut -f1 -d' ')
227 # if we have the previous one (not on the first iteration), check it matches
228 # the current one
229 if [ -n "$prev_sum" ] && [ "$sum" != "$prev_sum" ]; then
230 # fstime is broken, didn't produce the same hash of snap files
231 HAVE_FSTIME=no
232 break
233 fi
234 prev_sum=$sum
235 done
236else
237 # probably unsquashfs doesn't support fstime
238 HAVE_FSTIME=no
239fi
240
201241
202sudo echo "useless sudo to keep authenticated against sudo during loops..." > /dev/null242sudo echo "useless sudo to keep authenticated against sudo during loops..." > /dev/null
203243
@@ -246,53 +286,66 @@ for sn in "${all_snaps[@]}" ; do
246 $MAYBE_SUDO rm -rf "${sn}-src" # in case of interrupted runs286 $MAYBE_SUDO rm -rf "${sn}-src" # in case of interrupted runs
247 $MAYBE_SUDO unsquashfs -d "${sn}-src" "${sn}_xz.snap"287 $MAYBE_SUDO unsquashfs -d "${sn}-src" "${sn}_xz.snap"
248288
249 # also save the fstime of the snap for re-pack determinism check
250 fstime=$(unsquashfs -fstime "${sn}_xz.snap")
251289
252 # step 3. repack with lzo options set 10 times checking that the compressed290 # step 3. repack with lzo options set 10 times checking that the compressed
253 # snap has the same hash each time291 # snap has the same hash each time (only if we have fstime)
254 for i in $(seq 1 10); do292 if [ "$HAVE_FSTIME" = "yes" ]; then
255 hashfile="${sn}.lzo.sha256"293 # get the fstime to use for the deterministm check
294 fstime=$(unsquashfs -fstime "${sn}_xz.snap")
295
296 for i in $(seq 1 10); do
297 hashfile="${sn}.lzo.sha256"
298
299 # pack the snap - these options match "snap pack"
300 if [ -n "$MAYBE_SUDO" ]; then
301 # if we are calling sudo, don't use -all-root
302 sudo mksquashfs "${sn}-src" "${sn}_lzo-$i.snap" -fstime "$fstime" -no-progress -noappend -comp lzo -no-xattrs -no-fragments
303 else
304 # use -all-root when we are not using sudo
305 mksquashfs "${sn}-src" "${sn}_lzo-$i.snap" -fstime "$fstime" -no-progress -noappend -comp lzo -all-root -no-xattrs -no-fragments
306 fi
307
308 # calculate the sha256sum for the re-packed snap
309 sum=$(sha256sum "${sn}_lzo-$i.snap" | cut -f1 -d' ')
310
311 # in the first go-around, save the hash
312 if [ "$i" = "1" ]; then
313 echo "$sum" > "$hashfile"
314 else
315 # in all other iterations make sure the calculated hash matches the
316 # saved one from the first iteration
317 if [ "$sum" != "$(cat "$hashfile")" ]; then
318 echo ">>> TEST FAIL <<< snap $sn lzo compressed on iteration $i had sha256sum of $sum, expected $(cat "$hashfile") from iteration 1"
319 exit 1
320 fi
321
322 # we're done with this passing lzo, so discard it to not waste
323 # space during the runs
324 rm -f "${sn}_lzo-$i.snap"
325
326 # sleep a small amount of time to ensure that the time is different
327 # when we re-pack again in the next iteration
328 sleep 0.5
329 fi
330
331 sudo echo "useless sudo to keep authenticated against sudo during loops..." > /dev/null
332 done
256333
257 # pack the snap - these options match "snap pack"334 # cleanup the re-packed snaps, saving the first one for later usage
335 $MAYBE_SUDO mv "${sn}_lzo-1.snap" "${sn}_lzo.snap"
336 $MAYBE_SUDO rm -f "${sn}_lzo-"*.snap
337 $MAYBE_SUDO rm -rf "${sn}-src"
338 else
339 # we don't have -fstime, but we still need to produce a lzo snap to test
340 # in the store check
258 if [ -n "$MAYBE_SUDO" ]; then341 if [ -n "$MAYBE_SUDO" ]; then
259 # if we are calling sudo, don't use -all-root342 # if we are calling sudo, don't use -all-root
260 sudo mksquashfs "${sn}-src" "${sn}_lzo-$i.snap" -fstime "$fstime" -no-progress -noappend -comp lzo -no-xattrs -no-fragments343 sudo mksquashfs "${sn}-src" "${sn}_lzo.snap" -no-progress -noappend -comp lzo -no-xattrs -no-fragments
261 else344 else
262 # use -all-root when we are not using sudo345 # use -all-root when we are not using sudo
263 mksquashfs "${sn}-src" "${sn}_lzo-$i.snap" -fstime "$fstime" -no-progress -noappend -comp lzo -all-root -no-xattrs -no-fragments346 mksquashfs "${sn}-src" "${sn}_lzo.snap" -no-progress -noappend -comp lzo -all-root -no-xattrs -no-fragments
264 fi347 fi
265348 fi
266 # calculate the sha256sum for the re-packed snap
267 sum=$(sha256sum "${sn}_lzo-$i.snap" | cut -f1 -d' ')
268
269 # in the first go-around, save the hash
270 if [ "$i" = "1" ]; then
271 echo "$sum" > "$hashfile"
272 else
273 # in all other iterations make sure the calculated hash matches the
274 # saved one from the first iteration
275 if [ "$sum" != "$(cat "$hashfile")" ]; then
276 echo ">>> TEST FAIL <<< snap $sn lzo compressed on iteration $i had sha256sum of $sum, expected $(cat "$hashfile") from iteration 1"
277 exit 1
278 fi
279
280 # we're done with this passing lzo, so discard it to not waste
281 # space during the runs
282 rm -f "${sn}_lzo-$i.snap"
283
284 # sleep a small amount of time to ensure that the time is different
285 # when we re-pack again in the next iteration
286 sleep 0.5
287 fi
288
289 sudo echo "useless sudo to keep authenticated against sudo during loops..." > /dev/null
290 done
291
292 # cleanup the re-packed snaps, saving the first one for later usage
293 $MAYBE_SUDO mv "${sn}_lzo-1.snap" "${sn}_lzo.snap"
294 $MAYBE_SUDO rm -f "${sn}_lzo-"*.snap
295 $MAYBE_SUDO rm -rf "${sn}-src"
296349
297 # step 4. run the review-tools inside the various ubuntu lxc containers to350 # step 4. run the review-tools inside the various ubuntu lxc containers to
298 # check that the snap is unsquashed and resquashed to the same blob351 # check that the snap is unsquashed and resquashed to the same blob

Subscribers

People subscribed via source and target branches

to all changes: