From owner-svn-src-head@FreeBSD.ORG Mon Sep 22 16:37:38 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7348D8F9; Mon, 22 Sep 2014 16:37:38 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 44D3C210; Mon, 22 Sep 2014 16:37:38 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s8MGbcN0086920; Mon, 22 Sep 2014 16:37:38 GMT (envelope-from marcel@FreeBSD.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s8MGbcWT086919; Mon, 22 Sep 2014 16:37:38 GMT (envelope-from marcel@FreeBSD.org) Message-Id: <201409221637.s8MGbcWT086919@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: marcel set sender to marcel@FreeBSD.org using -f From: Marcel Moolenaar Date: Mon, 22 Sep 2014 16:37:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r271979 - head/usr.bin/mkimg/tests X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Sep 2014 16:37:38 -0000 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