svn commit: r267997 - user/marcel/mkimg

Marcel Moolenaar marcel at FreeBSD.org
Sat Jun 28 04:27:01 UTC 2014


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)


More information about the svn-src-user mailing list