1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
#include "stdafx.h"
#include "Test/Lib/TestMgr.h"
#include "Core/Timing.h"
#include "OS/Thread.h"
static Engine *engineObj = null;
static void *stackBase = null;
static Url *createRoot(Engine &e, void *param) {
(void)param;
Url *root = executableUrl(e)->parent();
return root->pushDir(new (e) Str(S("root")));
}
Engine &gEngine() {
if (!engineObj) {
PLN(L"==> Starting compiler...");
Moment start;
engineObj = new Engine(&createRoot, null, Engine::reuseMain, stackBase);
PLN(L"==> Compiler boot: " << (Moment() - start));
}
return *engineObj;
}
static Gc *usedGc = null;
Gc &gc() {
if (engineObj) {
if (usedGc) {
delete usedGc;
usedGc = null;
}
return engineObj->gc;
}
if (!usedGc) {
// Don't take up too much VM since we have to share VM with the Engine later on.
usedGc = new Gc(2*1024*1024, 1000);
usedGc->attachThread();
}
return *usedGc;
}
int _tmain(int argc, const wchar_t *argv[]) {
initDebug();
stackBase = &argv;
// Allows using threads without an Engine.
os::Thread::setStackBase(stackBase);
Moment start, end;
TestResult r;
try {
start = Moment();
r = Tests::run(argc, argv);
end = Moment();
delete engineObj;
engineObj = null;
delete usedGc;
usedGc = null;
} catch (const storm::Exception *e) {
PLN(L"Unknown error: " << e);
} catch (const ::Exception &e) {
PLN(L"Unknown error: " << e.what());
}
PLN(L"Total time: " << (end - start));
return r.ok() ? 0 : 1;
}
|