MCPcopy Create free account
hub / github.com/FoundationDB/fdb-document-layer / runUnitTests

Function runUnitTests

src/DocLayer.actor.cpp:405–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

403Reference<DocumentLayer> g_docLayer;
404
405ACTOR static void runUnitTests(StringRef testPattern) {
406 state int testRunLimit = -1; //< Parameter?
407 state std::vector<UnitTest*> tests;
408 state int testsAvailable = 0;
409 state int testsFailed = 0;
410 state int testsExecuted = 0;
411
412 for (auto t = g_unittests.tests; t != nullptr; t = t->next) {
413 printf("Test: '%s' pattern: '%s'\n", t->name, testPattern.toString().c_str());
414 if (StringRef(t->name).startsWith(testPattern)) {
415 ++testsAvailable;
416 tests.push_back(t);
417 }
418 }
419 g_random->randomShuffle(tests);
420 if (testRunLimit > 0 && tests.size() > testRunLimit)
421 tests.resize(testRunLimit);
422
423 state std::vector<UnitTest*>::iterator t;
424 for (t = tests.begin(); t != tests.end(); ++t) {
425 auto test = *t;
426 printf("Testing %s\n", test->name);
427
428 state Error result = success();
429 state double start_now = now();
430 state double start_timer = timer();
431
432 try {
433 wait(test->func());
434 } catch (Error& e) {
435 ++testsFailed;
436 result = e;
437 printf(" FAILED: %s\n", e.what());
438 }
439 ++testsExecuted;
440 double wallTime = timer() - start_timer;
441 double simTime = now() - start_now;
442
443 // self->totalWallTime += wallTime;
444 // self->totalSimTime += simTime;
445
446 auto unitTest = *t;
447 TraceEvent(result.code() != error_code_success ? SevError : SevInfo, "UnitTest")
448 .detail("Name", unitTest->name)
449 .detail("File", unitTest->file)
450 .detail("Line", unitTest->line)
451 .error(result, true)
452 .detail("WallTime", wallTime)
453 .detail("FlowTime", simTime);
454 }
455
456 printf("Tests available: %d\n", testsAvailable);
457 printf("Tests executed: %d\n", testsExecuted);
458 printf("Tests failed: %d\n", testsFailed);
459
460 _exit((testsFailed || !testsExecuted) ? 1 : 0);
461}
462

Callers 1

setupFunction · 0.85

Calls 5

startsWithMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
toStringMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected