Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Jun 2014 04:27:00 +0000 (UTC)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r267997 - user/marcel/mkimg
Message-ID:  <201406280427.s5S4R0bk013847@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marcel
Date: Sat Jun 28 04:27:00 2014
New Revision: 267997
URL: http://svnweb.freebsd.org/changeset/base/267997

Log:
  Support unit testing:
  o   use mkimg_uuid() instead of uuidgen().
  o   Check unit_testing in vhd_timestamp() to synthesize a time.

Modified:
  user/marcel/mkimg/vhd.c

Modified: user/marcel/mkimg/vhd.c
==============================================================================
--- user/marcel/mkimg/vhd.c	Sat Jun 28 04:19:43 2014	(r267996)
+++ user/marcel/mkimg/vhd.c	Sat Jun 28 04:27:00 2014	(r267997)
@@ -141,8 +141,12 @@ vhd_timestamp(void)
 {
 	time_t t;
 
-	t = time(NULL);
-	return (t - 0x386d4380);
+	if (!unit_testing) {
+		t = time(NULL);
+		return (t - 0x386d4380);
+	}
+
+	return (0x01234567);
 }
 
 static void
@@ -189,7 +193,7 @@ vhd_write(int fd)
 	be64enc(&footer.current_size, imgsz);
 	/* XXX Geometry */
 	be32enc(&footer.disk_type, VHD_DISK_TYPE_DYNAMIC);
-	uuidgen(&id, 1);
+	mkimg_uuid(&id);
 	vhd_uuid_enc(&footer.id, &id);
 	be32enc(&footer.checksum, vhd_checksum(&footer, sizeof(footer)));
 	if (sparse_write(fd, &footer, sizeof(footer)) < 0)



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