Changeset 219
- Timestamp:
- 12/12/2005 23:56:44 (6 years ago)
- Location:
- box/trunk
- Files:
-
- 10 edited
-
infrastructure/buildenv-testmain-template.cpp (modified) (3 diffs)
-
infrastructure/makebuildenv.pl (modified) (1 diff)
-
lib/common/DebugAssertFailed.cpp (modified) (1 diff)
-
lib/common/DebugPrintf.cpp (modified) (1 diff)
-
lib/common/FileStream.cpp (modified) (1 diff)
-
lib/common/Test.h (modified) (2 diffs)
-
modules.txt (modified) (1 diff)
-
runtest.pl (modified) (1 diff)
-
test/common/testcommon.cpp (modified) (11 diffs)
-
test/crypto/testcrypto.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/infrastructure/buildenv-testmain-template.cpp
r217 r219 21 21 #include <unistd.h> 22 22 #include <stdlib.h> 23 #include <syslog.h>24 23 #include <stdarg.h> 25 24 #include <fcntl.h> 26 25 #include <errno.h> 26 27 #ifdef WIN32 28 #include "emu.h" 29 #else 30 #include <syslog.h> 31 #endif 27 32 28 33 #include "MemLeakFindOn.h" … … 39 44 40 45 int filedes_open_at_beginning = -1; 46 47 #ifdef WIN32 48 49 // any way to check for open file descriptors on Win32? 50 inline int count_filedes() { return 0; } 51 inline bool checkfilesleftopen() { return false; } 52 53 #else // !WIN32 41 54 42 55 int count_filedes() … … 71 84 return filedes_open_at_beginning != count_filedes(); 72 85 } 86 87 #endif 73 88 74 89 int main(int argc, const char *argv[]) -
box/trunk/infrastructure/makebuildenv.pl
r217 r219 409 409 410 410 writetestfile("$mod/_t", 411 './test ${platform_exe_ext}$1 $2 $3 $4 $5', $mod);411 './test' . $platform_exe_ext . '$1 $2 $3 $4 $5', $mod); 412 412 writetestfile("$mod/_t-gdb", 413 'gdb ./test ${platform_exe_ext}', $mod);413 'gdb ./test ' . $platform_exe_ext, $mod); 414 414 415 415 } -
box/trunk/lib/common/DebugAssertFailed.cpp
r217 r219 13 13 14 14 #include <stdio.h> 15 #include <syslog.h> 15 16 #ifdef WIN32 17 #include "emu.h" 18 #else 19 #include <syslog.h> 20 #endif 16 21 17 22 #include "MemLeakFindOn.h" -
box/trunk/lib/common/DebugPrintf.cpp
r217 r219 14 14 #include <stdio.h> 15 15 #include <stdarg.h> 16 #include <syslog.h> 16 17 #ifdef WIN32 18 #include "emu.h" 19 #else 20 #include <syslog.h> 21 #endif 17 22 18 23 #include "MemLeakFindOn.h" -
box/trunk/lib/common/FileStream.cpp
r217 r219 198 198 if ( (res == 0) || (numBytesWritten != NBytes)) 199 199 { 200 DWORD err = GetLastError();200 // DWORD err = GetLastError(); 201 201 THROW_EXCEPTION(CommonException, OSFileWriteError) 202 202 } 203 204 205 203 #else 206 204 if(::write(mOSFileHandle, pBuffer, NBytes) != NBytes) -
box/trunk/lib/common/Test.h
r217 r219 109 109 } 110 110 111 #ifdef WIN32 112 113 #include "WinNamedPipeStream.h" 114 #include "IOStreamGetLine.h" 115 #include "BoxPortsAndFiles.h" 116 117 bool SendCommands(const std::string& rCmd) 118 { 119 WinNamedPipeStream connection; 120 121 try 122 { 123 connection.Connect(BOX_NAMED_PIPE_NAME); 124 } 125 catch(...) 126 { 127 printf("Failed to connect to daemon control socket.\n"); 128 return false; 129 } 130 131 // For receiving data 132 IOStreamGetLine getLine(connection); 133 134 // Wait for the configuration summary 135 std::string configSummary; 136 if(!getLine.GetLine(configSummary)) 137 { 138 printf("Failed to receive configuration summary from daemon\n"); 139 return false; 140 } 141 142 // Was the connection rejected by the server? 143 if(getLine.IsEOF()) 144 { 145 printf("Server rejected the connection.\n"); 146 return false; 147 } 148 149 // Decode it 150 int autoBackup, updateStoreInterval, minimumFileAge, maxUploadWait; 151 if(::sscanf(configSummary.c_str(), "bbackupd: %d %d %d %d", 152 &autoBackup, &updateStoreInterval, 153 &minimumFileAge, &maxUploadWait) != 4) 154 { 155 printf("Config summary didn't decode\n"); 156 return false; 157 } 158 159 std::string cmds; 160 bool expectResponse; 161 162 if (rCmd != "") 163 { 164 cmds = rCmd; 165 cmds += "\nquit\n"; 166 expectResponse = true; 167 } 168 else 169 { 170 cmds = "quit\n"; 171 expectResponse = false; 172 } 173 174 connection.Write(cmds.c_str(), cmds.size()); 175 176 // Read the response 177 std::string line; 178 bool statusOk = !expectResponse; 179 180 while (expectResponse && !getLine.IsEOF() && getLine.GetLine(line)) 181 { 182 // Is this an OK or error line? 183 if (line == "ok") 184 { 185 statusOk = true; 186 } 187 else if (line == "error") 188 { 189 printf("ERROR (%s)\n", rCmd.c_str()); 190 break; 191 } 192 else 193 { 194 printf("WARNING: Unexpected response to command '%s': " 195 "%s", rCmd.c_str(), line.c_str()); 196 } 197 } 198 199 return statusOk; 200 } 201 202 inline bool ServerIsAlive() 203 { 204 return SendCommands(""); 205 } 206 207 inline bool HUPServer(int pid) 208 { 209 return SendCommands("reload"); 210 } 211 212 inline bool KillServer(int pid) 213 { 214 TEST_THAT(SendCommands("terminate")); 215 ::sleep(1); 216 return !ServerIsAlive(); 217 } 218 219 #else // !WIN32 220 111 221 inline bool ServerIsAlive(int pid) 112 222 { … … 129 239 return !ServerIsAlive(pid); 130 240 } 241 242 #endif // WIN32 131 243 132 244 inline void TestRemoteProcessMemLeaks(const char *filename) -
box/trunk/modules.txt
r217 r219 19 19 lib/win32 lib/server 20 20 lib/compress 21 test/common 22 test/crypto lib/crypto 23 test/compress lib/compress 24 test/basicserver lib/server 21 test/common lib/win32 22 test/crypto lib/crypto lib/win32 23 test/compress lib/compress lib/win32 25 24 26 25 OMIT:mingw32 26 test/basicserver lib/server lib/win32 27 27 OMIT:CYGWIN 28 28 test/raidfile lib/raidfile -
box/trunk/runtest.pl
r217 r219 39 39 if(m/\AOMIT:(.+)/) 40 40 { 41 if($1 eq $build_os )41 if($1 eq $build_os or $1 eq $target_os) 42 42 { 43 43 while(<MODULES>) -
box/trunk/test/common/testcommon.cpp
r217 r219 182 182 // First, test the FdGetLine class -- rather important this works! 183 183 { 184 FileHandleGuard<O_RDONLY> file("testfiles/fdgetlinetest.txt"); 184 FileHandleGuard<O_RDONLY> file("testfiles" 185 DIRECTORY_SEPARATOR "fdgetlinetest.txt"); 185 186 FdGetLine getline(file); 186 187 … … 199 200 // and again without pre-processing 200 201 { 201 FileHandleGuard<O_RDONLY> file("testfiles/fdgetlinetest.txt"); 202 FILE *file2 = fopen("testfiles/fdgetlinetest.txt", "r"); 202 FileHandleGuard<O_RDONLY> file("testfiles" 203 DIRECTORY_SEPARATOR "fdgetlinetest.txt"); 204 FILE *file2 = fopen("testfiles" DIRECTORY_SEPARATOR 205 "fdgetlinetest.txt", "r"); 203 206 TEST_THAT_ABORTONFAIL(file2 != 0); 204 207 FdGetLine getline(file); … … 228 231 // Then the IOStream version of get line, seeing as we're here... 229 232 { 230 FileStream file("testfiles/fdgetlinetest.txt", O_RDONLY); 233 FileStream file("testfiles" DIRECTORY_SEPARATOR 234 "fdgetlinetest.txt", O_RDONLY); 231 235 IOStreamGetLine getline(file); 232 236 … … 248 252 // and again without pre-processing 249 253 { 250 FileStream file("testfiles/fdgetlinetest.txt", O_RDONLY); 254 FileStream file("testfiles" DIRECTORY_SEPARATOR 255 "fdgetlinetest.txt", O_RDONLY); 251 256 IOStreamGetLine getline(file); 252 257 253 FILE *file2 = fopen("testfiles/fdgetlinetest.txt", "r"); 258 FILE *file2 = fopen("testfiles" DIRECTORY_SEPARATOR 259 "fdgetlinetest.txt", "r"); 254 260 TEST_THAT_ABORTONFAIL(file2 != 0); 255 261 char ll[512]; … … 282 288 { 283 289 std::string errMsg; 284 TEST_CHECK_THROWS(std::auto_ptr<Configuration> pconfig(Configuration::LoadAndVerify("testfiles/DOESNTEXIST", &verify, errMsg)), CommonException, OSFileOpenError); 290 TEST_CHECK_THROWS(std::auto_ptr<Configuration> pconfig( 291 Configuration::LoadAndVerify( 292 "testfiles" DIRECTORY_SEPARATOR "DOESNTEXIST", 293 &verify, errMsg)), 294 CommonException, OSFileOpenError); 285 295 } 286 296 … … 288 298 { 289 299 std::string errMsg; 290 std::auto_ptr<Configuration> pconfig(Configuration::LoadAndVerify("testfiles/config1.txt", &verify, errMsg)); 300 std::auto_ptr<Configuration> pconfig( 301 Configuration::LoadAndVerify( 302 "testfiles" DIRECTORY_SEPARATOR "config1.txt", 303 &verify, errMsg)); 291 304 if(!errMsg.empty()) 292 305 { … … 333 346 static const char *file[] = 334 347 { 335 "testfiles/config2.txt", // Value missing from root 336 "testfiles/config3.txt", // Unexpected { 337 "testfiles/config4.txt", // Missing } 338 "testfiles/config5.txt", // { expected, but wasn't there 339 "testfiles/config6.txt", // Duplicate key 340 "testfiles/config7.txt", // Invalid key (no name) 341 "testfiles/config8.txt", // Not all sub blocks terminated 342 "testfiles/config9.txt", // Not valid integer 343 "testfiles/config9b.txt", // Not valid integer 344 "testfiles/config9c.txt", // Not valid integer 345 "testfiles/config9d.txt", // Not valid integer 346 "testfiles/config10.txt", // Missing key (in subblock) 347 "testfiles/config11.txt", // Unknown key 348 "testfiles/config12.txt", // Missing block 349 "testfiles/config13.txt", // Subconfig (wildcarded) should exist, but missing (ie nothing present) 350 "testfiles/config16.txt", // bad boolean value 348 "testfiles" DIRECTORY_SEPARATOR "config2.txt", 349 // Value missing from root 350 "testfiles" DIRECTORY_SEPARATOR "config3.txt", 351 // Unexpected { 352 "testfiles" DIRECTORY_SEPARATOR "config4.txt", 353 // Missing } 354 "testfiles" DIRECTORY_SEPARATOR "config5.txt", 355 // { expected, but wasn't there 356 "testfiles" DIRECTORY_SEPARATOR "config6.txt", 357 // Duplicate key 358 "testfiles" DIRECTORY_SEPARATOR "config7.txt", 359 // Invalid key (no name) 360 "testfiles" DIRECTORY_SEPARATOR "config8.txt", 361 // Not all sub blocks terminated 362 "testfiles" DIRECTORY_SEPARATOR "config9.txt", 363 // Not valid integer 364 "testfiles" DIRECTORY_SEPARATOR "config9b.txt", 365 // Not valid integer 366 "testfiles" DIRECTORY_SEPARATOR "config9c.txt", 367 // Not valid integer 368 "testfiles" DIRECTORY_SEPARATOR "config9d.txt", 369 // Not valid integer 370 "testfiles" DIRECTORY_SEPARATOR "config10.txt", 371 // Missing key (in subblock) 372 "testfiles" DIRECTORY_SEPARATOR "config11.txt", 373 // Unknown key 374 "testfiles" DIRECTORY_SEPARATOR "config12.txt", 375 // Missing block 376 "testfiles" DIRECTORY_SEPARATOR "config13.txt", 377 // Subconfig (wildcarded) should exist, but missing (ie nothing present) 378 "testfiles" DIRECTORY_SEPARATOR "config16.txt", 379 // bad boolean value 351 380 0 352 381 }; … … 365 394 { 366 395 std::string errMsg; 367 std::auto_ptr<Configuration> pconfig(Configuration::LoadAndVerify("testfiles/config14.txt", &verify, errMsg)); 396 std::auto_ptr<Configuration> pconfig( 397 Configuration::LoadAndVerify( 398 "testfiles" DIRECTORY_SEPARATOR "config14.txt", 399 &verify, errMsg)); 368 400 TEST_THAT(pconfig.get() != 0); 369 401 TEST_THAT(errMsg.empty()); … … 379 411 { 380 412 std::string errMsg; 381 std::auto_ptr<Configuration> pconfig(Configuration::LoadAndVerify("testfiles/config15.txt", &verify, errMsg)); 413 std::auto_ptr<Configuration> pconfig( 414 Configuration::LoadAndVerify( 415 "testfiles" DIRECTORY_SEPARATOR "config15.txt", 416 &verify, errMsg)); 382 417 TEST_THAT(pconfig.get() != 0); 383 418 TEST_THAT(errMsg.empty()); … … 392 427 NamedLock lock1; 393 428 // Try and get a lock on a name in a directory which doesn't exist 394 TEST_CHECK_THROWS(lock1.TryAndGetLock("testfiles/non-exist/lock"), CommonException, OSFileError); 429 TEST_CHECK_THROWS(lock1.TryAndGetLock( 430 "testfiles" 431 DIRECTORY_SEPARATOR "non-exist" 432 DIRECTORY_SEPARATOR "lock"), 433 CommonException, OSFileError); 434 395 435 // And a more resonable request 396 TEST_THAT(lock1.TryAndGetLock("testfiles/lock1") == true); 436 TEST_THAT(lock1.TryAndGetLock( 437 "testfiles" DIRECTORY_SEPARATOR "lock1") == true); 438 397 439 // Try to lock something using the same lock 398 TEST_CHECK_THROWS(lock1.TryAndGetLock("testfiles/non-exist/lock2"), CommonException, NamedLockAlreadyLockingSomething); 440 TEST_CHECK_THROWS( 441 lock1.TryAndGetLock( 442 "testfiles" 443 DIRECTORY_SEPARATOR "non-exist" 444 DIRECTORY_SEPARATOR "lock2"), 445 CommonException, NamedLockAlreadyLockingSomething); 399 446 #if defined(HAVE_FLOCK) || HAVE_DECL_O_EXLOCK 400 447 // And again on that name 401 448 NamedLock lock2; 402 TEST_THAT(lock2.TryAndGetLock("testfiles/lock1") == false); 449 TEST_THAT(lock2.TryAndGetLock( 450 "testfiles" DIRECTORY_SEPARATOR "lock1") == false); 403 451 #endif 404 452 } … … 406 454 // Check that it unlocked when it went out of scope 407 455 NamedLock lock3; 408 TEST_THAT(lock3.TryAndGetLock("testfiles/lock1") == true); 456 TEST_THAT(lock3.TryAndGetLock( 457 "testfiles" DIRECTORY_SEPARATOR "lock1") == true); 409 458 } 410 459 { 411 460 // And unlocking works 412 461 NamedLock lock4; 413 TEST_CHECK_THROWS(lock4.ReleaseLock(), CommonException, NamedLockNotHeld); 414 TEST_THAT(lock4.TryAndGetLock("testfiles/lock4") == true); 462 TEST_CHECK_THROWS(lock4.ReleaseLock(), CommonException, 463 NamedLockNotHeld); 464 TEST_THAT(lock4.TryAndGetLock( 465 "testfiles" DIRECTORY_SEPARATOR "lock4") == true); 415 466 lock4.ReleaseLock(); 416 467 NamedLock lock5; 417 TEST_THAT(lock5.TryAndGetLock("testfiles/lock4") == true); 468 TEST_THAT(lock5.TryAndGetLock( 469 "testfiles" DIRECTORY_SEPARATOR "lock4") == true); 418 470 // And can reuse it 419 TEST_THAT(lock4.TryAndGetLock("testfiles/lock5") == true); 471 TEST_THAT(lock4.TryAndGetLock( 472 "testfiles" DIRECTORY_SEPARATOR "lock5") == true); 420 473 } 421 474 -
box/trunk/test/crypto/testcrypto.cpp
r217 r219 44 44 } 45 45 46 #define ZERO_BUFFER(x) :: bzero(x, sizeof(x));46 #define ZERO_BUFFER(x) ::memset(x, 0, sizeof(x)); 47 47 48 48 template<typename CipherType, int BLOCKSIZE>
Note: See TracChangeset
for help on using the changeset viewer.
