mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-30 19:30:06 +00:00
Port tests\core\thread
This commit is contained in:
+1
-2
@@ -1,7 +1,6 @@
|
||||
ODIN=../../odin
|
||||
PYTHON=$(shell which python3)
|
||||
COMMON=-no-bounds-check -vet -strict-style
|
||||
COLLECTION=-collection:tests=..
|
||||
|
||||
all: all_bsd \
|
||||
net_test
|
||||
@@ -103,7 +102,7 @@ strings_test:
|
||||
$(ODIN) test strings $(COMMON) -out:test_core_strings
|
||||
|
||||
thread_test:
|
||||
$(ODIN) run thread $(COMMON) -out:test_core_thread
|
||||
$(ODIN) test thread $(COMMON) -out:test_core_thread
|
||||
|
||||
time_test:
|
||||
$(ODIN) test time $(COMMON) -out:test_core_time
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
@echo off
|
||||
set COMMON=-no-bounds-check -vet -strict-style
|
||||
set COLLECTION=-collection:tests=..
|
||||
set PATH_TO_ODIN==..\..\odin
|
||||
python3 download_assets.py
|
||||
echo ---
|
||||
@@ -112,7 +111,7 @@ echo ---
|
||||
echo ---
|
||||
echo Running core:thread tests
|
||||
echo ---
|
||||
%PATH_TO_ODIN% run thread %COMMON% %COLLECTION% -out:test_core_thread.exe || exit /b
|
||||
%PATH_TO_ODIN% test thread %COMMON% -out:test_core_thread.exe || exit /b
|
||||
|
||||
echo ---
|
||||
echo Running core:time tests
|
||||
|
||||
Binary file not shown.
@@ -2,39 +2,7 @@ package test_core_thread
|
||||
|
||||
import "core:testing"
|
||||
import "core:thread"
|
||||
import "core:fmt"
|
||||
import "core:os"
|
||||
|
||||
TEST_count := 0
|
||||
TEST_fail := 0
|
||||
|
||||
t := &testing.T{}
|
||||
|
||||
when ODIN_TEST {
|
||||
expect :: testing.expect
|
||||
log :: testing.log
|
||||
} else {
|
||||
expect :: proc(t: ^testing.T, condition: bool, message: string, loc := #caller_location) {
|
||||
TEST_count += 1
|
||||
if !condition {
|
||||
TEST_fail += 1
|
||||
fmt.printf("[%v] %v\n", loc, message)
|
||||
return
|
||||
}
|
||||
}
|
||||
log :: proc(t: ^testing.T, v: any, loc := #caller_location) {
|
||||
fmt.printf("[%v] ", loc)
|
||||
fmt.printf("log: %v\n", v)
|
||||
}
|
||||
}
|
||||
|
||||
main :: proc() {
|
||||
poly_data_test(t)
|
||||
|
||||
if TEST_fail > 0 {
|
||||
os.exit(1)
|
||||
}
|
||||
}
|
||||
import "base:intrinsics"
|
||||
|
||||
@(test)
|
||||
poly_data_test :: proc(_t: ^testing.T) {
|
||||
@@ -46,7 +14,7 @@ poly_data_test :: proc(_t: ^testing.T) {
|
||||
b: [MAX]byte = 8
|
||||
t1 := thread.create_and_start_with_poly_data(b, proc(b: [MAX]byte) {
|
||||
b_expect: [MAX]byte = 8
|
||||
expect(poly_data_test_t, b == b_expect, "thread poly data not correct")
|
||||
testing.expect(poly_data_test_t, b == b_expect, "thread poly data not correct")
|
||||
})
|
||||
defer free(t1)
|
||||
|
||||
@@ -55,8 +23,8 @@ poly_data_test :: proc(_t: ^testing.T) {
|
||||
t2 := thread.create_and_start_with_poly_data2(b1, b2, proc(b: [3]uintptr, b2: [MAX / 2]byte) {
|
||||
b_expect: [3]uintptr = 1
|
||||
b2_expect: [MAX / 2]byte = 3
|
||||
expect(poly_data_test_t, b == b_expect, "thread poly data not correct")
|
||||
expect(poly_data_test_t, b2 == b2_expect, "thread poly data not correct")
|
||||
testing.expect(poly_data_test_t, b == b_expect, "thread poly data not correct")
|
||||
testing.expect(poly_data_test_t, b2 == b2_expect, "thread poly data not correct")
|
||||
})
|
||||
defer free(t2)
|
||||
|
||||
@@ -64,21 +32,21 @@ poly_data_test :: proc(_t: ^testing.T) {
|
||||
b_expect: [3]uintptr = 1
|
||||
b2_expect: [MAX / 2]byte = 3
|
||||
|
||||
expect(poly_data_test_t, b == b_expect, "thread poly data not correct")
|
||||
expect(poly_data_test_t, b2 == b2_expect, "thread poly data not correct")
|
||||
expect(poly_data_test_t, b3 == 333, "thread poly data not correct")
|
||||
testing.expect(poly_data_test_t, b == b_expect, "thread poly data not correct")
|
||||
testing.expect(poly_data_test_t, b2 == b2_expect, "thread poly data not correct")
|
||||
testing.expect(poly_data_test_t, b3 == 333, "thread poly data not correct")
|
||||
})
|
||||
defer free(t3)
|
||||
|
||||
t4 := thread.create_and_start_with_poly_data4(uintptr(111), b1, uintptr(333), u8(5), proc(n: uintptr, b: [3]uintptr, n2: uintptr, n4: u8) {
|
||||
b_expect: [3]uintptr = 1
|
||||
|
||||
expect(poly_data_test_t, n == 111, "thread poly data not correct")
|
||||
expect(poly_data_test_t, b == b_expect, "thread poly data not correct")
|
||||
expect(poly_data_test_t, n2 == 333, "thread poly data not correct")
|
||||
expect(poly_data_test_t, n4 == 5, "thread poly data not correct")
|
||||
testing.expect(poly_data_test_t, n == 111, "thread poly data not correct")
|
||||
testing.expect(poly_data_test_t, b == b_expect, "thread poly data not correct")
|
||||
testing.expect(poly_data_test_t, n2 == 333, "thread poly data not correct")
|
||||
testing.expect(poly_data_test_t, n4 == 5, "thread poly data not correct")
|
||||
})
|
||||
defer free(t4)
|
||||
|
||||
thread.join_multiple(t1, t2, t3, t4)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user