diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2018-01-09 19:12:21 +0100 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2018-01-10 11:29:13 +0100 |
commit | 2652f2bc393934bda267697243654d1ea20b18f6 (patch) | |
tree | 7779fe675f1869e0225a51b2ec702d9ac2ba42c9 /tests | |
parent | 93d9b114b7021f58c6ef166b0128b86aaa9cc542 (diff) |
tests: Timeval: adapt to have reproducible output and enable autotest
Change-Id: I1a79892ba3c934879a171789e0edb357277acae4
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CommonLibs/TimevalTest.cpp | 21 | ||||
-rw-r--r-- | tests/CommonLibs/TimevalTest.ok | 23 | ||||
-rw-r--r-- | tests/testsuite.at | 10 |
3 files changed, 23 insertions, 31 deletions
diff --git a/tests/CommonLibs/TimevalTest.cpp b/tests/CommonLibs/TimevalTest.cpp index b4746f2..f579878 100644 --- a/tests/CommonLibs/TimevalTest.cpp +++ b/tests/CommonLibs/TimevalTest.cpp @@ -28,18 +28,31 @@ #include "Timeval.h" #include <iostream> +#include <assert.h> using namespace std; int main(int argc, char *argv[]) { - Timeval then(10000); - cout << then.elapsed() << endl; + assert(then.elapsed() == -10000); + cerr << then << " elapsed: " << then.elapsed() << endl; + double then_seconds = then.seconds(); + double last_now = Timeval().seconds(); + long last_remaining = 10000; + int loops = 0; while (!then.passed()) { - cout << "now: " << Timeval() << " then: " << then << " remaining: " << then.remaining() << endl; + double tnow = Timeval().seconds(); + cerr << "now: " << tnow << " then: " << then << " remaining: " << then.remaining() << endl; + assert(last_now <= tnow && last_remaining >= then.remaining()); + assert(then_seconds == then.seconds()); usleep(500000); + loops++; } - cout << "now: " << Timeval() << " then: " << then << " remaining: " << then.remaining() << endl; + cerr << "now: " << Timeval() << " then: " << then << " remaining: " << then.remaining() << endl; + assert(then.remaining() <= 0); + assert(loops >= 18); + + printf("Done\n"); } diff --git a/tests/CommonLibs/TimevalTest.ok b/tests/CommonLibs/TimevalTest.ok index c97031d..a965a70 100644 --- a/tests/CommonLibs/TimevalTest.ok +++ b/tests/CommonLibs/TimevalTest.ok @@ -1,22 +1 @@ --10000 -now: 1515515602.357742 then: 1515515612.357710 remaining: 10000 -now: 1515515602.857837 then: 1515515612.357710 remaining: 9500 -now: 1515515603.357975 then: 1515515612.357710 remaining: 9000 -now: 1515515603.858163 then: 1515515612.357710 remaining: 8500 -now: 1515515604.358353 then: 1515515612.357710 remaining: 8000 -now: 1515515604.858465 then: 1515515612.357710 remaining: 7500 -now: 1515515605.358622 then: 1515515612.357710 remaining: 7000 -now: 1515515605.858745 then: 1515515612.357710 remaining: 6499 -now: 1515515606.358852 then: 1515515612.357710 remaining: 5999 -now: 1515515606.859055 then: 1515515612.357710 remaining: 5499 -now: 1515515607.359170 then: 1515515612.357710 remaining: 4999 -now: 1515515607.859349 then: 1515515612.357710 remaining: 4499 -now: 1515515608.359455 then: 1515515612.357710 remaining: 3999 -now: 1515515608.859549 then: 1515515612.357710 remaining: 3499 -now: 1515515609.359748 then: 1515515612.357710 remaining: 2998 -now: 1515515609.859865 then: 1515515612.357710 remaining: 2498 -now: 1515515610.360064 then: 1515515612.357710 remaining: 1998 -now: 1515515610.860223 then: 1515515612.357710 remaining: 1498 -now: 1515515611.360386 then: 1515515612.357710 remaining: 998 -now: 1515515611.860592 then: 1515515612.357710 remaining: 498 -now: 1515515612.360712 then: 1515515612.357710 remaining: -3 +Done diff --git a/tests/testsuite.at b/tests/testsuite.at index 5d519d2..8e9a541 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -32,11 +32,11 @@ AT_CLEANUP #AT_CHECK([$abs_top_builddir/tests/CommonLibs/SocketsTest], [], [expout], []) #AT_CLEANUP -#AT_SETUP([TimevalTest]) -#AT_KEYWORDS([TimevalTest]) -#cat $abs_srcdir/CommonLibs/TimevalTest.ok > expout -#AT_CHECK([$abs_top_builddir/tests/CommonLibs/TimevalTest], [], [expout], []) -#AT_CLEANUP +AT_SETUP([TimevalTest]) +AT_KEYWORDS([TimevalTest]) +cat $abs_srcdir/CommonLibs/TimevalTest.ok > expout +AT_CHECK([$abs_top_builddir/tests/CommonLibs/TimevalTest], [], [expout], [ignore]) +AT_CLEANUP AT_SETUP([VectorTest]) AT_KEYWORDS([VectorTest]) |