[Box Backup-commit] COMMIT r1578 - box/chris/merge/test/bbackupd
boxbackup-dev@fluffy.co.uk
boxbackup-dev@fluffy.co.uk
Sun, 22 Apr 2007 21:52:16 +0100
Author: chris
Date: 2007-04-22 21:52:15 +0100 (Sun, 22 Apr 2007)
New Revision: 1578
Modified:
box/chris/merge/test/bbackupd/testbbackupd.cpp
Log:
Use Cygwin chmod command-line tool to make the read-only file writable
on Win32, instead of our own chmod() (which does nothing). (refs #3)
Modified: box/chris/merge/test/bbackupd/testbbackupd.cpp
===================================================================
--- box/chris/merge/test/bbackupd/testbbackupd.cpp 2007-04-22 20:48:18 UTC (rev 1577)
+++ box/chris/merge/test/bbackupd/testbbackupd.cpp 2007-04-22 20:52:15 UTC (rev 1578)
@@ -1809,11 +1809,31 @@
// Then modify an existing file
{
- chmod("testfiles/TestDir1/sub23/rand.h", 0777); // in the archive, it's read only
- FILE *f = fopen("testfiles/TestDir1/sub23/rand.h", "w+");
+ // in the archive, it's read only
+ #ifdef WIN32
+ TEST_THAT(::system("chmod 0777 testfiles"
+ "/TestDir1/sub23/rand.h") == 0);
+ #else
+ TEST_THAT(chmod("testfiles/TestDir1/sub23"
+ "/rand.h", 0777) == 0);
+ #endif
+
+ FILE *f = fopen("testfiles/TestDir1/sub23/rand.h",
+ "w+");
+
+ if (f == 0)
+ {
+ perror("Failed to open");
+ }
+
TEST_THAT(f != 0);
- fprintf(f, "MODIFIED!\n");
- fclose(f);
+
+ if (f != 0)
+ {
+ fprintf(f, "MODIFIED!\n");
+ fclose(f);
+ }
+
// and then move the time backwards!
struct timeval times[2];
BoxTimeToTimeval(SecondsToBoxTime((time_t)(365*24*60*60)), times[1]);