Commit Graph

11 Commits

Author SHA1 Message Date
Krzesimir Nowak
d687a45704 tests: Fix closure-refcount to preserve old semantics
The threads used to iterate at least 10000 times before setting the
"seen thread" flag to true. After porting they inadvertently did that
in the first iteration.
2019-02-28 07:05:29 +01:00
Philip Withnall
1ae54da69b tests: Continue closure-refcount test until all three threads are seen
Previously, the test assumed that thread1 and thread2 would be scheduled
enough to set seen_thread{1,2} by the fact that the test runs for a high
number of iterations. On some platforms/schedulers, that’s not true,
which causes the test to spuriously fail.

Fix that by forcing the test to continue iterating until both threads
are seen. If this takes too long, the Meson test runner timeout will be
hit and the test will be terminated.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-27 12:31:06 +00:00
Philip Withnall
86f4a02b65 tests: Fix thread safety in closure-refcount test
Previously, all three threads would access several global variables
without locking.

Fix that by using atomic accesses to data stored within the
test_closure_refcount() function, which also eliminates the global state
(which would confuse further tests if they were added to this file).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-27 12:31:06 +00:00
Philip Withnall
5a2a7f7db1 tests: Port closure-refcount from g_thread_create() to g_thread_new()
g_thread_create() has been deprecated for a long time.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-27 12:31:06 +00:00
Philip Withnall
85c02df04e tests: Use g_assert_*() in closure-refcount, rather than g_assert()
g_assert() can be compiled out if G_DISABLE_ASSERT is defined; and
g_assert_*() provide more specific error messages on failure.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-27 12:31:06 +00:00
Philip Withnall
d6e9111986 tests: Fix some code formatting in closure-refcount
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-27 12:31:06 +00:00
Philip Withnall
31664e62f9 tests: Remove unnecessary static attributes from variables
These functions are not run more than once, so the variables don’t need
to be static to save state between runs.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-27 12:31:06 +00:00
Philip Withnall
3aec6a3976 tests: Minor GObject cleanup in closure-refcount
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-27 12:31:06 +00:00
Philip Withnall
b4aadf6557 tests: Port closure-refcount to g_test_message() from g_print()
This allows more structured test output.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-27 11:59:24 +00:00
Philip Withnall
15958c3ba9 tests: Port closure-refcount to use g_test_run()
This allows more structured test running and output.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-27 11:59:23 +00:00
Philip Withnall
c96bfd57af build: Move tests/refcount/closures to gobject/tests/closure-refcount
One step towards removing the top-level tests/ directory.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1434
2019-02-27 11:48:29 +00:00