[Box Backup-dev] COMMIT r433 - box/chris/win32/vc2005-compile-fixes/test/win32

boxbackup-dev@fluffy.co.uk boxbackup-dev@fluffy.co.uk
Sun, 12 Feb 2006 00:43:28 +0000 (GMT)


Author: chris
Date: 2006-02-12 00:43:27 +0000 (Sun, 12 Feb 2006)
New Revision: 433

Modified:
   box/chris/win32/vc2005-compile-fixes/test/win32/Makefile
   box/chris/win32/vc2005-compile-fixes/test/win32/timezone.cpp
Log:
* win32/timezone.cpp
- Show times as ASCII test to make interpretation easier
- Abort with an error if the difference between system time and file
  creation time is too large

* win32/Makefile
- Added a "clean" target


Modified: box/chris/win32/vc2005-compile-fixes/test/win32/Makefile
===================================================================
--- box/chris/win32/vc2005-compile-fixes/test/win32/Makefile	2006-02-12 00:29:42 UTC (rev 432)
+++ box/chris/win32/vc2005-compile-fixes/test/win32/Makefile	2006-02-12 00:43:27 UTC (rev 433)
@@ -1,2 +1,5 @@
 timezone.exe: timezone.cpp Makefile
 	g++ -g -O0 -mno-cygwin -I../../lib/win32 -o timezone.exe timezone.cpp 
+
+clean:
+	rm timezone.exe

Modified: box/chris/win32/vc2005-compile-fixes/test/win32/timezone.cpp
===================================================================
--- box/chris/win32/vc2005-compile-fixes/test/win32/timezone.cpp	2006-02-12 00:29:42 UTC (rev 432)
+++ box/chris/win32/vc2005-compile-fixes/test/win32/timezone.cpp	2006-02-12 00:43:27 UTC (rev 433)
@@ -9,9 +9,12 @@
 
 int main(int argc, char** argv)
 {
-	int time_now = time(NULL);
-	printf("Time now is %d\n", time_now);
+	time_t time_now = time(NULL);
+	char* time_str = strdup(asctime(gmtime(&time_now)));
+	time_str[24] = 0;
 
+	printf("Time now is %d (%s)\n", time_now, time_str);
+
 	char testfile[80];
 	snprintf(testfile, sizeof(testfile), "test.%d", time_now);
 	printf("Test file is: %s\n", testfile);
@@ -56,10 +59,20 @@
 	}
 
 	time_t created_time = ConvertFileTimeToTime_t(&fi.ftCreationTime);
-	printf("File created time: %d\n", created_time);
+	time_str = strdup(asctime(gmtime(&created_time)));
+	time_str[24] = 0;
 
+	printf("File created time: %d (%s)\n", created_time, time_str);
+
 	printf("Difference is: %d\n", created_time - time_now);
 
+	if (abs(created_time - time_now) > 30)
+	{
+		fprintf(stderr, "Error: time difference too big: "
+			"bug in emu.h?\n");
+		exit(1);
+	}
+
 	/*
 	sleep(1);