diff options
Diffstat (limited to 'lib/common')
-rw-r--r-- | lib/common/BoxTime.h | 4 | ||||
-rw-r--r-- | lib/common/DebugMemLeakFinder.cpp | 3 | ||||
-rw-r--r-- | lib/common/FileStream.cpp | 2 | ||||
-rw-r--r-- | lib/common/IOStream.h | 5 | ||||
-rw-r--r-- | lib/common/ReadLoggingStream.h | 2 | ||||
-rw-r--r-- | lib/common/Test.cpp | 32 | ||||
-rw-r--r-- | lib/common/Test.h | 3 | ||||
-rw-r--r-- | lib/common/Timer.cpp | 2 |
8 files changed, 22 insertions, 31 deletions
diff --git a/lib/common/BoxTime.h b/lib/common/BoxTime.h index 3108d809..6afaada3 100644 --- a/lib/common/BoxTime.h +++ b/lib/common/BoxTime.h @@ -10,8 +10,8 @@ #ifndef BOXTIME__H #define BOXTIME__H -// Time is presented as an unsigned 64 bit integer, in microseconds -typedef int64_t box_time_t; +// Time is presented as a signed 64 bit integer, in microseconds +typedef int64_t box_time_t; #define NANO_SEC_IN_SEC (1000000000LL) #define NANO_SEC_IN_USEC (1000) diff --git a/lib/common/DebugMemLeakFinder.cpp b/lib/common/DebugMemLeakFinder.cpp index 70026969..30b2f41f 100644 --- a/lib/common/DebugMemLeakFinder.cpp +++ b/lib/common/DebugMemLeakFinder.cpp @@ -599,9 +599,6 @@ void memleakfinder_setup_exit_report(const char *filename, const char *markertex } } - - - void add_object_block(void *block, size_t size, const char *file, int line, bool array) { InternalAllocGuard guard; diff --git a/lib/common/FileStream.cpp b/lib/common/FileStream.cpp index 6d5810dc..99b66666 100644 --- a/lib/common/FileStream.cpp +++ b/lib/common/FileStream.cpp @@ -248,7 +248,7 @@ IOStream::pos_type FileStream::BytesLeftToRead() // -------------------------------------------------------------------------- void FileStream::Write(const void *pBuffer, int NBytes, int Timeout) { - if(mOSFileHandle == INVALID_FILE) + if(mOSFileHandle == INVALID_FILE) { THROW_EXCEPTION(CommonException, FileClosed) } diff --git a/lib/common/IOStream.h b/lib/common/IOStream.h index 80915d71..65b66d71 100644 --- a/lib/common/IOStream.h +++ b/lib/common/IOStream.h @@ -54,7 +54,7 @@ public: virtual pos_type GetPosition() const; virtual void Seek(pos_type Offset, int SeekType); virtual void Close(); - + // Has all data that can be read been read? virtual bool StreamDataLeft() = 0; // Has the stream been closed (writing not possible) @@ -69,7 +69,4 @@ public: virtual std::string ToString() const; }; - #endif // IOSTREAM__H - - diff --git a/lib/common/ReadLoggingStream.h b/lib/common/ReadLoggingStream.h index 4a01a45c..bee7e1d6 100644 --- a/lib/common/ReadLoggingStream.h +++ b/lib/common/ReadLoggingStream.h @@ -49,7 +49,7 @@ public: virtual bool StreamClosed(); private: - ReadLoggingStream(const ReadLoggingStream &rToCopy) + ReadLoggingStream(const ReadLoggingStream &rToCopy) : mrSource(rToCopy.mrSource), mrLogger(rToCopy.mrLogger) { /* do not call */ } }; diff --git a/lib/common/Test.cpp b/lib/common/Test.cpp index bfa7bcb0..67c27cf3 100644 --- a/lib/common/Test.cpp +++ b/lib/common/Test.cpp @@ -136,7 +136,7 @@ int ReadPidFile(const char *pidFile) if(!TestFileNotEmpty(pidFile)) { TEST_FAIL_WITH_MESSAGE("Server didn't save PID file " - "(perhaps one was already running?)"); + "(perhaps one was already running?)"); return -1; } @@ -145,7 +145,7 @@ int ReadPidFile(const char *pidFile) FILE *f = fopen(pidFile, "r"); if(f == NULL || fscanf(f, "%d", &pid) != 1) { - TEST_FAIL_WITH_MESSAGE("Couldn't read PID file"); + TEST_FAIL_WITH_MESSAGE("Couldn't read PID file"); return -1; } fclose(f); @@ -155,7 +155,7 @@ int ReadPidFile(const char *pidFile) int LaunchServer(const std::string& rCommandLine, const char *pidFile) { - ::fprintf(stdout, "Starting server: %s\n", rCommandLine.c_str()); + BOX_INFO("Starting server: " << rCommandLine); #ifdef WIN32 @@ -189,14 +189,10 @@ int LaunchServer(const std::string& rCommandLine, const char *pidFile) free(tempCmd); - if (result == 0) - { - DWORD err = GetLastError(); - printf("Launch failed: %s: error %d\n", rCommandLine.c_str(), - (int)err); - TEST_FAIL_WITH_MESSAGE("Couldn't start server"); + TEST_THAT_OR(result != 0, + BOX_LOG_WIN_ERROR("Launch failed: " << rCommandLine); return -1; - } + ); CloseHandle(procInfo.hProcess); CloseHandle(procInfo.hThread); @@ -205,11 +201,10 @@ int LaunchServer(const std::string& rCommandLine, const char *pidFile) #else // !WIN32 - if(RunCommand(rCommandLine) != 0) - { - TEST_FAIL_WITH_MESSAGE("Couldn't start server"); + TEST_THAT_OR(RunCommand(rCommandLine) == 0, + TEST_FAIL_WITH_MESSAGE("Failed to start server: " << rCommandLine); return -1; - } + ) return WaitForServerStartup(pidFile, 0); @@ -234,7 +229,7 @@ int WaitForServerStartup(const char *pidFile, int pidIfKnown) for (int i = 0; i < 15; i++) { - if (TestFileNotEmpty(pidFile)) + if (TestFileNotEmpty(pidFile)) { break; } @@ -252,13 +247,13 @@ int WaitForServerStartup(const char *pidFile, int pidIfKnown) if (pidIfKnown && !ServerIsAlive(pidIfKnown)) { - TEST_FAIL_WITH_MESSAGE("Server died!"); + TEST_FAIL_WITH_MESSAGE("Server died!"); return -1; } if (!TestFileNotEmpty(pidFile)) { - TEST_FAIL_WITH_MESSAGE("Server didn't save PID file"); + TEST_FAIL_WITH_MESSAGE("Server didn't save PID file"); return -1; } @@ -381,7 +376,7 @@ void terminate_bbackupd(int pid) // Wait a given number of seconds for something to complete void wait_for_operation(int seconds, const char* message) { - BOX_TRACE("Waiting " << seconds << " seconds for " << message); + BOX_INFO("Waiting " << seconds << " seconds for " << message); for(int l = 0; l < seconds; ++l) { @@ -395,4 +390,3 @@ void safe_sleep(int seconds) { ShortSleep(SecondsToBoxTime(seconds), true); } - diff --git a/lib/common/Test.h b/lib/common/Test.h index dbe1e979..146fafae 100644 --- a/lib/common/Test.h +++ b/lib/common/Test.h @@ -157,6 +157,9 @@ extern std::list<std::string> run_only_named_tests; printf("Test failed on <%s>\n", _line_str.c_str()); \ } +#define TEST_STARTSWITH(expected, actual) \ + TEST_EQUAL_LINE(expected, actual.substr(0, std::string(expected).size()), actual); + bool TestFileExists(const char *Filename); bool TestDirExists(const char *Filename); diff --git a/lib/common/Timer.cpp b/lib/common/Timer.cpp index ad6b5e8d..68042db2 100644 --- a/lib/common/Timer.cpp +++ b/lib/common/Timer.cpp @@ -155,7 +155,7 @@ void Timers::Remove(Timer& rTimer) } } } - + Reschedule(); } |