mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 08:08:50 +00: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
|
package tests_core_posix
|
||||||
|
|
||||||
import "core:log"
|
import "core:log"
|
||||||
@@ -65,8 +65,17 @@ test_dirent :: proc(t: ^testing.T) {
|
|||||||
for entry in entries {
|
for entry in entries {
|
||||||
defer posix.free(entry)
|
defer posix.free(entry)
|
||||||
|
|
||||||
if entry.d_type != .REG {
|
when ODIN_OS == .Haiku {
|
||||||
continue
|
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[:])))
|
name := string(cstring(raw_data(entry.d_name[:])))
|
||||||
@@ -86,8 +95,17 @@ test_dirent :: proc(t: ^testing.T) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if entry.d_type != .REG {
|
when ODIN_OS == .Haiku {
|
||||||
continue
|
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[:])))
|
name := string(cstring(raw_data(entry.d_name[:])))
|
||||||
@@ -140,15 +158,15 @@ test_langinfo :: proc(t: ^testing.T) {
|
|||||||
@(test)
|
@(test)
|
||||||
test_libgen :: proc(t: ^testing.T) {
|
test_libgen :: proc(t: ^testing.T) {
|
||||||
tests := [][3]cstring{
|
tests := [][3]cstring{
|
||||||
{ "usr", ".", "usr" },
|
{ "usr", ".", "usr" },
|
||||||
{ "usr/", ".", "usr" },
|
{ "usr/", ".", "usr" },
|
||||||
{ "", ".", "." },
|
{ "", ".", "." },
|
||||||
{ "/", "/", "/" },
|
{ "/", "/", "/" },
|
||||||
{ "///", "/", "/" },
|
{ "///", "/", "/" },
|
||||||
{ "/usr/", "/", "usr" },
|
{ "/usr/", "/", "usr" },
|
||||||
{ "/usr/lib", "/usr", "lib" },
|
{ "/usr/lib", "/usr", "lib" },
|
||||||
{ "//usr//lib//", "//usr", "lib" },
|
{ "//usr//lib//", "//usr" + ("/" when ODIN_OS == .Haiku else ""), "lib" },
|
||||||
{ "/home//dwc//test", "/home//dwc", "test" },
|
{ "/home//dwc//test", "/home//dwc" + ("/" when ODIN_OS == .Haiku else ""), "test" },
|
||||||
}
|
}
|
||||||
|
|
||||||
for test in tests {
|
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
|
package tests_core_posix
|
||||||
|
|
||||||
import "core:log"
|
import "core:log"
|
||||||
|
|||||||
@@ -10,7 +10,11 @@
|
|||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
|
||||||
|
#ifndef __HAIKU__
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sys/ipc.h>
|
#include <sys/ipc.h>
|
||||||
#include <sys/msg.h>
|
#include <sys/msg.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
@@ -25,7 +29,11 @@
|
|||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
|
|
||||||
|
#ifndef __HAIKU__
|
||||||
#include <wordexp.h>
|
#include <wordexp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
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));
|
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));
|
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("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));
|
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));
|
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));
|
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("time_t %zu %zu\n", sizeof(time_t), _Alignof(time_t));
|
||||||
printf("timespec %zu %zu\n", sizeof(struct timespec), _Alignof(struct timespec));
|
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("pollfd", size_of(posix.pollfd), align_of(posix.pollfd))
|
||||||
fmt.println("passwd", size_of(posix.passwd), align_of(posix.passwd))
|
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("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))
|
fmt.println("msqid_ds", size_of(posix.msqid_ds), align_of(posix.msqid_ds))
|
||||||
|
|
||||||
@@ -70,7 +73,9 @@ main :: proc() {
|
|||||||
|
|
||||||
fmt.println("utimbuf", size_of(posix.utimbuf), align_of(posix.utimbuf))
|
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("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("timespec", size_of(posix.timespec), align_of(posix.timespec))
|
||||||
|
|||||||
Reference in New Issue
Block a user