mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-29 00:11:34 +00:00
add proper test for thread names
This commit is contained in:
committed by
peperronii
parent
0b5d3b0dd8
commit
99442fa390
@@ -49,4 +49,40 @@ poly_data_test :: proc(_t: ^testing.T) {
|
||||
defer free(t4)
|
||||
|
||||
thread.join_multiple(t1, t2, t3, t4)
|
||||
}
|
||||
}
|
||||
|
||||
@(test)
|
||||
name_test :: proc(_t: ^testing.T) {
|
||||
@static name_test_t: ^testing.T
|
||||
@static main_wait := true
|
||||
@static child_wait := true
|
||||
name_test_t = _t
|
||||
|
||||
t := thread.create_and_start(name = "test_name", fn = proc() {
|
||||
main_wait = false
|
||||
|
||||
for (child_wait) {}
|
||||
|
||||
n, err := thread.get_name()
|
||||
defer if err != nil {
|
||||
delete(n)
|
||||
}
|
||||
testing.expect(name_test_t, err == nil, "thread name allocation failed")
|
||||
testing.expect(name_test_t, n == "test_name","thread name on self did not match")
|
||||
|
||||
})
|
||||
defer free(t)
|
||||
|
||||
for (main_wait) {}
|
||||
|
||||
n, err := thread.get_name(t)
|
||||
defer if err != nil {
|
||||
delete(n)
|
||||
}
|
||||
testing.expect(name_test_t, err == nil, "thread name allocation failed")
|
||||
testing.expect(name_test_t, n == "test_name","thread name on main did not match")
|
||||
|
||||
child_wait = false
|
||||
|
||||
thread.join(t)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user