From a704000c347815a621b7b69cdc24446377e7c97c Mon Sep 17 00:00:00 2001 From: avanspector Date: Fri, 10 Jan 2025 06:42:19 +0100 Subject: [PATCH] Haiku: add posix tests --- tests/core/sys/posix/posix.odin | 46 ++++++++++++++++------- tests/core/sys/posix/structs.odin | 2 +- tests/core/sys/posix/structs/structs.c | 13 +++++++ tests/core/sys/posix/structs/structs.odin | 11 ++++-- 4 files changed, 54 insertions(+), 18 deletions(-) diff --git a/tests/core/sys/posix/posix.odin b/tests/core/sys/posix/posix.odin index 8daffc5b9..772190a3a 100644 --- a/tests/core/sys/posix/posix.odin +++ b/tests/core/sys/posix/posix.odin @@ -1,4 +1,4 @@ -#+build linux, darwin, freebsd, openbsd, netbsd +#+build linux, darwin, freebsd, openbsd, netbsd, haiku package tests_core_posix import "core:log" @@ -65,8 +65,17 @@ test_dirent :: proc(t: ^testing.T) { for entry in entries { defer posix.free(entry) - if entry.d_type != .REG { - continue + when ODIN_OS == .Haiku { + stat: posix.stat_t + posix.stat(cstring(raw_data(entry.d_name[:])), &stat) + + if !posix.S_ISREG(stat.st_mode) { + continue + } + } else { + if entry.d_type != .REG { + continue + } } name := string(cstring(raw_data(entry.d_name[:]))) @@ -86,8 +95,17 @@ test_dirent :: proc(t: ^testing.T) { break } - if entry.d_type != .REG { - continue + when ODIN_OS == .Haiku { + stat: posix.stat_t + posix.stat(cstring(raw_data(entry.d_name[:])), &stat) + + if !posix.S_ISREG(stat.st_mode) { + continue + } + } else { + if entry.d_type != .REG { + continue + } } name := string(cstring(raw_data(entry.d_name[:]))) @@ -140,15 +158,15 @@ test_langinfo :: proc(t: ^testing.T) { @(test) test_libgen :: proc(t: ^testing.T) { tests := [][3]cstring{ - { "usr", ".", "usr" }, - { "usr/", ".", "usr" }, - { "", ".", "." }, - { "/", "/", "/" }, - { "///", "/", "/" }, - { "/usr/", "/", "usr" }, - { "/usr/lib", "/usr", "lib" }, - { "//usr//lib//", "//usr", "lib" }, - { "/home//dwc//test", "/home//dwc", "test" }, + { "usr", ".", "usr" }, + { "usr/", ".", "usr" }, + { "", ".", "." }, + { "/", "/", "/" }, + { "///", "/", "/" }, + { "/usr/", "/", "usr" }, + { "/usr/lib", "/usr", "lib" }, + { "//usr//lib//", "//usr" + ("/" when ODIN_OS == .Haiku else ""), "lib" }, + { "/home//dwc//test", "/home//dwc" + ("/" when ODIN_OS == .Haiku else ""), "test" }, } for test in tests { diff --git a/tests/core/sys/posix/structs.odin b/tests/core/sys/posix/structs.odin index a0e8fea99..66b7cb0e1 100644 --- a/tests/core/sys/posix/structs.odin +++ b/tests/core/sys/posix/structs.odin @@ -1,4 +1,4 @@ -#+build linux, darwin, freebsd, openbsd, netbsd +#+build linux, darwin, freebsd, openbsd, netbsd, haiku package tests_core_posix import "core:log" diff --git a/tests/core/sys/posix/structs/structs.c b/tests/core/sys/posix/structs/structs.c index e78e872eb..396de579e 100644 --- a/tests/core/sys/posix/structs/structs.c +++ b/tests/core/sys/posix/structs/structs.c @@ -10,7 +10,11 @@ #include #include #include + +#ifndef __HAIKU__ #include +#endif + #include #include #include @@ -25,7 +29,11 @@ #include #include #include + +#ifndef __HAIKU__ #include +#endif + #include int main(int argc, char *argv[]) @@ -67,7 +75,10 @@ int main(int argc, char *argv[]) printf("passwd %zu %zu\n", sizeof(struct passwd), _Alignof(struct passwd)); +#ifndef __HAIKU__ printf("shmid_ds %zu %zu\n", sizeof(struct shmid_ds), _Alignof(struct shmid_ds)); +#endif + printf("ipc_perm %zu %zu\n", sizeof(struct ipc_perm), _Alignof(struct ipc_perm)); printf("msqid_ds %zu %zu\n", sizeof(struct msqid_ds), _Alignof(struct msqid_ds)); @@ -95,7 +106,9 @@ int main(int argc, char *argv[]) printf("utimbuf %zu %zu\n", sizeof(struct utimbuf), _Alignof(struct utimbuf)); +#ifndef __HAIKU__ printf("wordexp_t %zu %zu\n", sizeof(wordexp_t), _Alignof(wordexp_t)); +#endif printf("time_t %zu %zu\n", sizeof(time_t), _Alignof(time_t)); printf("timespec %zu %zu\n", sizeof(struct timespec), _Alignof(struct timespec)); diff --git a/tests/core/sys/posix/structs/structs.odin b/tests/core/sys/posix/structs/structs.odin index c94bb7c99..a05137e87 100644 --- a/tests/core/sys/posix/structs/structs.odin +++ b/tests/core/sys/posix/structs/structs.odin @@ -42,7 +42,10 @@ main :: proc() { fmt.println("pollfd", size_of(posix.pollfd), align_of(posix.pollfd)) fmt.println("passwd", size_of(posix.passwd), align_of(posix.passwd)) - fmt.println("shmid_ds", size_of(posix.shmid_ds), align_of(posix.shmid_ds)) + when ODIN_OS != .Haiku { + fmt.println("shmid_ds", size_of(posix.shmid_ds), align_of(posix.shmid_ds)) + } + fmt.println("ipc_perm", size_of(posix.ipc_perm), align_of(posix.ipc_perm)) fmt.println("msqid_ds", size_of(posix.msqid_ds), align_of(posix.msqid_ds)) @@ -70,8 +73,10 @@ main :: proc() { fmt.println("utimbuf", size_of(posix.utimbuf), align_of(posix.utimbuf)) - fmt.println("wordexp_t", size_of(posix.wordexp_t), align_of(posix.wordexp_t)) - + when ODIN_OS != .Haiku { + fmt.println("wordexp_t", size_of(posix.wordexp_t), align_of(posix.wordexp_t)) + } + fmt.println("time_t", size_of(posix.time_t), align_of(posix.time_t)) fmt.println("timespec", size_of(posix.timespec), align_of(posix.timespec)) fmt.println("clock_t", size_of(posix.clock_t), align_of(posix.clock_t))