Skip to content

Commit

Permalink
test/bbackupd: fix test_interrupted_restore_can_be_recovered for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
qris committed Jun 20, 2019
1 parent a9be6f8 commit 8aef1bc
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions test/bbackupd/testbbackupd.cpp
Expand Up @@ -694,13 +694,14 @@ void do_interrupted_restore(const TLSContext &context, int64_t restoredirid,
// For once, Windows makes things easier. We can start a process without blocking (waiting
// for it to finish) using CreateProcess, wrapped by LaunchServer:

std::string cmd = BBACKUPQUERY;
cmd += " -c " + bbackupd_conf_file + " restore "
"testfiles/restore-interrupt " /* remote */
"testfiles/restore-interrupt " /* local */
std::ostringstream cmd;
cmd << BBACKUPQUERY << " " <<
"-c " << bbackupd_conf_file << " \"restore "
"-i " << restoredirid << " " /* remote dir ID */
"testfiles/restore-interrupt\" " /* local */
"quit";

int pid = LaunchServer(cmd, NULL /* pid_file */);
int pid = LaunchServer(cmd.str(), NULL /* pid_file */);
#else // !WIN32
int pid = 0;
switch((pid = fork()))
Expand All @@ -720,14 +721,16 @@ void do_interrupted_restore(const TLSContext &context, int64_t restoredirid,
GetConfiguredBackupClient(*apConfig, true); // read_only

// Test the restoration
TEST_THAT(BackupClientRestore(*apClient, restoredirid,
"testfiles/restore-interrupt", /* remote */
"testfiles/restore-interrupt", /* local */
true /* print progress dots */,
false /* restore deleted */,
false /* undelete after */,
false /* resume */,
false /* keep going */) == Restore_Complete);
TEST_THAT(BackupClientRestore(*apClient,
restoredirid, // ID of remote directory to restore
"Test1", // remote (source) name, for display (logging) only
"testfiles/restore-interrupt", // local (destination) name
true, // print progress dots
false, // restore deleted
false, // undelete after
false, // resume
false // keep going
) == Restore_Complete);

// Log out
apClient->QueryFinished();
Expand Down Expand Up @@ -2149,7 +2152,6 @@ bool test_bbackupd_responds_to_connection_failure_out_of_process(
TEST_THAT(!TestFileExists("testfiles/notifyran.backup-error.2"));
TEST_THAT(!TestFileExists("testfiles/notifyran.store-full.1"));
}
#endif // !WIN32

// It's very important to wait() for the server when using fork, otherwise the zombie never
// dies and the test fails:
Expand All @@ -2161,6 +2163,7 @@ bool test_bbackupd_responds_to_connection_failure_out_of_process(
{
StopServer(true); // wait_for_process
}
#endif // !WIN32

TEARDOWN_TEST_SPECIALISED_NO_CHECK(spec);
}
Expand Down Expand Up @@ -4164,7 +4167,7 @@ bool test_bbackupd_config_script()
TEST_RETURN(system(cmd.c_str()), 0)

cmd = "sed -i.orig -e 's/\\(ListenAddresses = inet:localhost\\)/\\1:22011/' "
"-e 's@PidFile = /var/run/bbstored.pid@PidFile = testfiles/bbstored.pid@' "
"-e 's@PidFile = .*/run/bbstored.pid@PidFile = testfiles/bbstored.pid@' "
"testfiles/tmp/bbstored.conf";
TEST_RETURN(system(cmd.c_str()), 0)

Expand Down

0 comments on commit 8aef1bc

Please sign in to comment.