Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Sep 2014 16:37:38 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r271979 - head/usr.bin/mkimg/tests
Message-ID:  <201409221637.s8MGbcWT086919@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marcel
Date: Mon Sep 22 16:37:37 2014
New Revision: 271979
URL: http://svnweb.freebsd.org/changeset/base/271979

Log:
  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.

Modified:
  head/usr.bin/mkimg/tests/mkimg.sh

Modified: head/usr.bin/mkimg/tests/mkimg.sh
==============================================================================
--- head/usr.bin/mkimg/tests/mkimg.sh	Mon Sep 22 16:35:48 2014	(r271978)
+++ head/usr.bin/mkimg/tests/mkimg.sh	Mon Sep 22 16:37:37 2014	(r271979)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201409221637.s8MGbcWT086919>