mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-21 15:05:45 -07:00
Haiku: add posix tests
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd
|
||||
#+build linux, darwin, freebsd, openbsd, netbsd, haiku
|
||||
package tests_core_posix
|
||||
|
||||
import "core:log"
|
||||
|
||||
@@ -10,7 +10,11 @@
|
||||
#include <netdb.h>
|
||||
#include <poll.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#ifndef __HAIKU__
|
||||
#include <sys/shm.h>
|
||||
#endif
|
||||
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/msg.h>
|
||||
#include <sys/un.h>
|
||||
@@ -25,7 +29,11 @@
|
||||
#include <sys/statvfs.h>
|
||||
#include <sys/time.h>
|
||||
#include <utime.h>
|
||||
|
||||
#ifndef __HAIKU__
|
||||
#include <wordexp.h>
|
||||
#endif
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
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));
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user