mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-04 04:02:33 +00:00
os2 tests
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
//+private
|
||||
package os2
|
||||
|
||||
import "core:sys/unix"
|
||||
|
||||
EPERM :: 1
|
||||
ENOENT :: 2
|
||||
ESRCH :: 3
|
||||
@@ -126,6 +128,15 @@ ENOTRECOVERABLE:: 131 /* State not recoverable */
|
||||
ERFKILL :: 132 /* Operation not possible due to RF-kill */
|
||||
EHWPOISON :: 133 /* Memory page has hardware error */
|
||||
|
||||
_get_platform_error :: proc(res: int) -> Error {
|
||||
errno := unix.get_errno(res)
|
||||
return Platform_Error{i32(errno)}
|
||||
}
|
||||
|
||||
_ok_or_error :: proc(res: int) -> Error {
|
||||
return res >= 0 ? nil : _get_platform_error(res)
|
||||
}
|
||||
|
||||
_error_string :: proc(errno: i32) -> string {
|
||||
if errno == 0 {
|
||||
return ""
|
||||
|
||||
@@ -61,10 +61,6 @@ create :: proc(name: string, perm: File_Mode = 0) -> (Handle, Error) {
|
||||
return open(name, {.Read, .Write, .Create}, perm)
|
||||
}
|
||||
|
||||
opendir :: proc(name: string) -> (Handle, Error) {
|
||||
return _opendir(name)
|
||||
}
|
||||
|
||||
open :: proc(name: string, flags := File_Flags{.Read}, perm: File_Mode = 0) -> (Handle, Error) {
|
||||
flags := flags
|
||||
if .Write not_in flags {
|
||||
|
||||
@@ -7,22 +7,8 @@ import "core:strings"
|
||||
import "core:sys/unix"
|
||||
|
||||
|
||||
_get_platform_error :: proc(res: int) -> Error {
|
||||
errno := unix.get_errno(res)
|
||||
return Platform_Error{i32(errno)}
|
||||
}
|
||||
|
||||
_ok_or_error :: proc(res: int) -> Error {
|
||||
return res >= 0 ? nil : _get_platform_error(res)
|
||||
}
|
||||
|
||||
_std_handle :: proc(kind: Std_Handle_Kind) -> Handle {
|
||||
switch kind {
|
||||
case .stdin: return Handle(0)
|
||||
case .stdout: return Handle(1)
|
||||
case .stderr: return Handle(2)
|
||||
}
|
||||
unreachable()
|
||||
return Handle(kind)
|
||||
}
|
||||
|
||||
__O_RDONLY :: 0o0
|
||||
@@ -38,19 +24,6 @@ __O_DIRECTORY :: 0o200000
|
||||
__O_SYNC :: 0o4010000
|
||||
__O_CLOEXEC :: 0o2000000
|
||||
|
||||
_opendir :: proc(name: string) -> (Handle, Error) {
|
||||
cstr := strings.clone_to_cstring(name, context.temp_allocator)
|
||||
|
||||
flags := __O_RDONLY|__O_NONBLOCK|__O_DIRECTORY|__O_LARGEFILE|__O_CLOEXEC
|
||||
|
||||
handle_i := unix.sys_open(cstr, flags)
|
||||
if handle_i < 0 {
|
||||
return INVALID_HANDLE, _get_platform_error(handle_i)
|
||||
}
|
||||
|
||||
return Handle(handle_i), nil
|
||||
}
|
||||
|
||||
_open :: proc(name: string, flags: File_Flags, perm: File_Mode) -> (Handle, Error) {
|
||||
cstr := strings.clone_to_cstring(name, context.temp_allocator)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
ODIN=../../odin
|
||||
PYTHON=$(shell which python3)
|
||||
|
||||
all: download_test_assets image_test compress_test strings_test hash_test crypto_test noise_test
|
||||
all: download_test_assets image_test compress_test strings_test hash_test crypto_test noise_test os2_test
|
||||
|
||||
download_test_assets:
|
||||
$(PYTHON) download_assets.py
|
||||
@@ -22,4 +22,7 @@ crypto_test:
|
||||
$(ODIN) run crypto -out=crypto_hash -o:speed -no-bounds-check
|
||||
|
||||
noise_test:
|
||||
$(ODIN) run math/noise -out=test_noise
|
||||
$(ODIN) run math/noise -out=test_noise
|
||||
|
||||
os2_test:
|
||||
$(ODIN) run os2/test_os2.odin -out=test_os2
|
||||
|
||||
Reference in New Issue
Block a user