Commit f2253481 authored by Noah Orensa's avatar Noah Orensa
Browse files

add fail()

parent 99097a94
......@@ -389,6 +389,15 @@ public:
}
};
class TestFailureException : public SandboxException {
public:
inline TestFailureException(const char *msg)
: SandboxException(msg)
{
sandbox().enter();
}
};
} // end namespace dtest
#define assert(expr) \
......@@ -397,4 +406,10 @@ public:
throw dtest::AssertionException(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__); \
}
#define fail(msg) \
{ \
dtest::sandbox().exit(); \
throw dtest::TestFailureException(msg); \
}
#define err(msg) dtest::Context::instance()->logError(msg)
......@@ -16,16 +16,16 @@ dunit("distributed-unit-test", "pass")
dunit("distributed-unit-test", "fail")
.expect(Status::FAIL)
.driver([] {
assert(false)
fail("test_failed");
})
.worker([] {
assert(false)
fail("test_failed");
});
dunit("distributed-unit-test", "driver-fail")
.expect(Status::FAIL)
.driver([] {
assert(false)
fail("test_failed");
})
.worker([] {
assert(true)
......@@ -37,7 +37,7 @@ dunit("distributed-unit-test", "worker-fail")
assert(true)
})
.worker([] {
assert(false)
fail("test_failed");
});
dunit("distributed-unit-test", "mem-leak")
......@@ -253,7 +253,7 @@ dunit("distributed-unit-test", "udp-faulty")
}
}
close(fd);
assert(false); // shouldn't get here
fail("test_failed");; // shouldn't get here
})
.worker([] {
sockaddr addr;
......
......@@ -13,7 +13,7 @@ unit("unit-test", "pass")
unit("unit-test", "fail")
.expect(Status::FAIL)
.body([] {
assert(false);
fail("test failed");
});
unit("unit-test", "timeout")
......@@ -89,7 +89,7 @@ unit("unit-test", "fail-before-dynamic-free")
}
} b;
assert(false);
fail("test failed");
});
unit("unit-test", "uncaught-exception")
......@@ -108,7 +108,7 @@ unit("unit-test", "local-test-fail")
.inProcess()
.expect(Status::FAIL)
.body([] {
assert(false);
fail("test failed");
});
unit("unit-test", "openmp")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment