mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-28 08:12:28 +00:00
Add execve / fexecve support to ZIpOS (#727)
This commit is contained in:
parent
0312898979
commit
5923d483a4
5 changed files with 143 additions and 22 deletions
|
@ -17,6 +17,8 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/fmt/itoa.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
@ -58,3 +60,27 @@ TEST(execve, testArgPassing) {
|
|||
EXITS(0);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(execve, ziposELF) {
|
||||
if (!IsLinux() && !IsFreebsd()) {
|
||||
EXPECT_SYS(ENOSYS, -1,
|
||||
execve("/zip/life.elf", (char *const[]){0}, (char *const[]){0}));
|
||||
return;
|
||||
}
|
||||
SPAWN(fork);
|
||||
execve("/zip/life.elf", (char *const[]){0}, (char *const[]){0});
|
||||
notpossible;
|
||||
EXITS(42);
|
||||
}
|
||||
|
||||
TEST(execve, ziposAPE) {
|
||||
if (!IsLinux()) {
|
||||
EXPECT_EQ(-1, execve("/zip/life-nomod.com", (char *const[]){0},
|
||||
(char *const[]){0}));
|
||||
return;
|
||||
}
|
||||
SPAWN(fork);
|
||||
execve("/zip/life-nomod.com", (char *const[]){0}, (char *const[]){0});
|
||||
notpossible;
|
||||
EXITS(42);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include "libc/testlib/testlib.h"
|
||||
// clang-format off
|
||||
|
||||
STATIC_YOINK("zip_uri_support");
|
||||
|
||||
int fds[2];
|
||||
char buf[8];
|
||||
char testlib_enable_tmp_setup_teardown;
|
||||
|
@ -97,3 +99,35 @@ TEST(fexecve, APE) {
|
|||
fexecve(fd, (char *const[]){0}, (char *const[]){0});
|
||||
EXITS(42);
|
||||
}
|
||||
|
||||
TEST(fexecve, APE_cloexec) {
|
||||
if (!IsLinux() && !IsFreebsd()) return;
|
||||
testlib_extract("/zip/life-nomod.com", "life-nomod.com", 0555);
|
||||
SPAWN(fork);
|
||||
int fd = open("life-nomod.com", O_RDONLY | O_CLOEXEC);
|
||||
ASSERT_NE(-1, fd);
|
||||
if (fd == -1 && errno == ENOSYS) _Exit(42);
|
||||
fexecve(fd, (char *const[]){0}, (char *const[]){0});
|
||||
EXITS(42);
|
||||
}
|
||||
|
||||
TEST(fexecve, zipos) {
|
||||
if (!IsLinux() && !IsFreebsd()) return;
|
||||
int fd = open("/zip/life.elf", O_RDONLY);
|
||||
SPAWN(fork);
|
||||
if (fd == -1 && errno == ENOSYS) _Exit(42);
|
||||
fexecve(fd, (char *const[]){0}, (char *const[]){0});
|
||||
EXITS(42);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
TEST(fexecve, ziposAPE) {
|
||||
if (!IsLinux() && !IsFreebsd()) return;
|
||||
int fd = open("/zip/life-nomod.com", O_RDONLY);
|
||||
SPAWN(fork);
|
||||
ASSERT_NE(-1, fd);
|
||||
if (fd == -1 && errno == ENOSYS) _Exit(42);
|
||||
fexecve(fd, (char *const[]){0}, (char *const[]){0});
|
||||
EXITS(42);
|
||||
close(fd);
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@ o/$(MODE)/test/libc/calls/fexecve_test.com.dbg: \
|
|||
$(TEST_LIBC_CALLS_DEPS) \
|
||||
o/$(MODE)/test/libc/calls/fexecve_test.o \
|
||||
o/$(MODE)/test/libc/calls/calls.pkg \
|
||||
o/$(MODE)/test/libc/mem/prog/life.elf.zip.o \
|
||||
o/$(MODE)/tool/build/echo.zip.o \
|
||||
o/$(MODE)/test/libc/calls/life-nomod.com.zip.o \
|
||||
$(LIBC_TESTMAIN) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue