unittest: Allow more time for apiexample_test when using a debug build

OCR of an image needs much more time than 55 s when running with
a debug build without optimisations on a slow host.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2019-01-14 15:39:18 +01:00
parent e67751633a
commit c4de29d16f

View File

@ -39,8 +39,17 @@ class QuickTest : public testing::Test {
protected:
virtual void SetUp() { start_time_ = time(nullptr); }
virtual void TearDown() {
#if defined(DEBUG)
// Debug builds can be very slow, so allow 4 min for OCR of a test image.
// apitest_example including disabled tests takes about 18 min on ARMv7.
const time_t MAX_SECONDS_FOR_TEST = 240;
#else
// Release builds typically need less than 10 s for OCR of a test image,
// apitest_example including disabled tests takes about 90 s on ARMv7.
const time_t MAX_SECONDS_FOR_TEST = 55;
#endif
const time_t end_time = time(nullptr);
EXPECT_TRUE(end_time - start_time_ <= 55)
EXPECT_TRUE(end_time - start_time_ <= MAX_SECONDS_FOR_TEST)
<< "The test took too long - "
<< ::testing::PrintToString(end_time - start_time_);
}