From deb4e9e0ed82c6efacaecc28d0d175c8df4bf479 Mon Sep 17 00:00:00 2001 From: marcel Date: Mon, 22 Sep 2014 16:37:37 +0000 Subject: [PATCH] Don't update the baseline file when the result of the test is identical to the baseline. Since we don't run gzip with the -n option, the output of gzip varies for identical result files if and when they are created at different time. Ouch... Rather than add -n and commit a 600K+ diff for the changes to all the .uu files, it's less of a churn to uudecode and gunzip the baseline file and compare that to the new result file to determine if the baseline file needs to be updated. This way, "atf-sh mkimg.sh rebase" can be run as many times as people like and a subsequent "svn status" will not show unnecessary diffs. --- usr.bin/mkimg/tests/mkimg.sh | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/usr.bin/mkimg/tests/mkimg.sh b/usr.bin/mkimg/tests/mkimg.sh index 00b5d928024a..f1fa93173897 100755 --- a/usr.bin/mkimg/tests/mkimg.sh +++ b/usr.bin/mkimg/tests/mkimg.sh @@ -68,6 +68,34 @@ makeimage() return 0 } +mkimg_rebase() +{ + local baseline image result tmpfile update + + image=$1 + result=$2 + + baseline=$image.gz.uu + update=yes + + if test -f $baseline; then + tmpfile=_tmp-baseline + uudecode -p $baseline | gunzip -c > $tmpfile + if cmp -s $tmpfile $result; then + update=no + fi + fi + + if test $update = yes; then + # Prevent keyword expansion when writing the keyword. + (echo -n '# $'; echo -n FreeBSD; echo '$') > $baseline + gzip -c $result | uuencode $image.gz >> $baseline + fi + + rm $image $result _tmp-* + return 0 +} + mkimg_test() { local blksz format geom scheme @@ -89,13 +117,10 @@ mkimg_test() image=`makeimage $format $scheme $blksz $geom img $partinfo` result=$image.out hexdump -C $image > $result - baseline=`atf_get_srcdir`/$image if test "x$mkimg_update_baseline" = "xyes"; then - # Prevent keyword expansion when writing the keyword. - (echo -n '# $'; echo -n FreeBSD; echo '$') > $image.gz.uu - gzip -c $result | uuencode $image.gz >> $image.gz.uu - rm $image $result _tmp-* + mkimg_rebase $image $result else + baseline=`atf_get_srcdir`/$image atf_check -s exit:0 cmp -s $baseline $result fi return 0