Haiku: add posix tests

This commit is contained in:
avanspector
2025-01-10 06:42:19 +01:00
parent 5d3a069e7a
commit a704000c34
4 changed files with 54 additions and 18 deletions
+32 -14
View File
@@ -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 {