Merge lp:~sil2100/unity/tests_glib_timeout_modifications into lp:unity
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | Marco Trevisan (Treviño) on 2012-11-28 | ||||
| Approved revision: | 2926 | ||||
| Merged at revision: | 2936 | ||||
| Proposed branch: | lp:~sil2100/unity/tests_glib_timeout_modifications | ||||
| Merge into: | lp:unity | ||||
| Diff against target: |
71 lines (+12/-21) 1 file modified
tests/test_glib_source.cpp (+12/-21) |
||||
| To merge this branch: | bzr merge lp:~sil2100/unity/tests_glib_timeout_modifications | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Marco Trevisan (Treviño) | 2012-11-23 | Approve on 2012-11-28 | |
| PS Jenkins bot | continuous-integration | Pending | |
|
Review via email:
|
|||
Commit Message
Change some test_glib_source unit tests. Those tests are measuring times of execution of timeouts, which is not really suitable for unit testing. Those tests are also failing sometimes on ARM machines, as the timeouts are longer than expected. We're dropping time measurement from these tests, only testing if the timeouts actually happen, because that seems enough.
Description of the Change
Change for comment.
- Problem:
3 tests from the test_glib_
- Fix:
Remove time measurement in the glib::Timeout failing test functions. Instead, all that we need is actually just making sure that the one-shot and multiple-shots just work (i.e. the callbacks are executed). We don't really care if the timeouts happen a bit later, since we can't do anything about that really if the hardware has issues.
- Tests:
N/A
| Francis Ginther (fginther) wrote : | # |
- 2925. By Łukasz Zemczak on 2012-11-26
-
Actually, greater than is better.
| Łukasz Zemczak (sil2100) wrote : | # |
The test, as it is right now, works in the following way. We wait until the callback_call_count is 6 OR when the timeout happens (I think the default is 10 seconds? Or something like that). That is why there is that callback_call_count check at the end actually. Since if the timeout happens, we check how many times the callback_call_count happened. Actually, EXPECT_GE() is better there!
I would prefer not to measure time in a test like this. Since when this test fails, the number of callback calls is sometimes 3-4, so we would have to be REALLY tolerant. This would make such testing a bit pointless... That's why I wanted to actually just make sure that it can timeout more than once (6 times).
Anyway, I still wonder about this test though, since you're right, maybe we could make it more useful somehow. Also, there are many other tests MultipleShotsRun in this source file which in fact also measure time. So maybe I would have to change those as well.
| Marco Trevisan (Treviño) (3v1n0) wrote : | # |
Of course we lose some checks, but we can survive without them... However probably you can use:
Utils::
53 - timeout.
Replace it with
timeout.
And check for removed_called value at the end...
- 2926. By Łukasz Zemczak on 2012-11-28
-
As suggested by Trevinho, we can also check if removed was called in all of those tests. Also, let's just wait up to 1 second during the WaitUntil call.
| Łukasz Zemczak (sil2100) wrote : | # |
I changed it as suggested. Do you think this would be a sufficient workaround for now?


The MultipleShotsRun test doesn't look very useful now as it waits until the callback count is 6, then checks that it is 6. Also, what happens if the callback count never increments? The other test changes look appropriate.
Perhaps it should test that callback count is within a given range, but I'm unsure of the appropriate tolerance. Just a suggestion: meout, MultipleShotsRun) call_count = 0; ckContinue) ; :WaitForTimeout MSec(650) ; TRUE(timeout. IsRunning( )); TRUE(callback_ called) ; GE(callback_ call_count, 5); LT(callback_ call_count, 7);
TEST(TestGLibTi
{
callback_called = false;
callback_
{
Timeout timeout(100, &OnSourceCallba
Utils:
EXPECT_
}
EXPECT_
EXPECT_
EXPECT_
}