text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_suffix|>;
assert(close(fd) == 0);
}
<|fim_prefix|>#include <assert.h>
#include <fcntl.h>
#include <stdint.h>
#include <unistd.h>
#include <wasi/api_wasix.h>
int main(void) {
int fd = open("/tmp/dup2-huge-min", O_CREAT | O_RDWR, 0644);
assert(fd >= 0);
__wasi_fd_t ret = 0;
__wasi_errno_t err = __wasi_... | fim | wasmerio/wasmer | c |
<|fim_suffix|>ert(value == 'x');
assert(close(src_fd) == 0);
assert(close(dst_fd) == 0);
assert(unlink(other_path) == 0);
}
int main(void) {
unlink(path);
seed_file();
test_dup2_same_inode_replaces_target();
test_dup2_same_inode_repeated();
test_dup2_cross_inode_replaces_target();
assert(unlink(pa... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <wasi/api_wasi.h>
static void test_readonly_fd_stays_readonly(void) {
const char* path = "fd_open_readonly_file";
unlink(path);
int fd = open(path, O_CR... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <assert.h>
#include <errno.h>
#include <poll.h>
#include <unistd.h>
// Regression test for a bug where special handling of stdio was causing
// redirected stdio to error out on basic<|fim_suffix|>nts & POLLOUT);
close(fds[0]);
close(stdio_fd);
}
int main(void) {
assert_pollout_ready_afte... | fim | wasmerio/wasmer | c |
//#ExpectedStdout: race open/close test passed (20000 iterations)
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <sched.h>
#include <stdatomic.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#define ITERATIONS 20000
static pthread_barrier_t ... | fim | wasmerio/wasmer | c |
<|fim_suffix|> {
int fd = open("/tmp/renumber-negative-target", O_CREAT | O_RDWR, 0644);
assert(fd >= 0);
errno = 0;
assert(dup2(fd, -1) == -1);
assert(errno == EBADF);
errno = 0;
assert(dup2(-1, -1) == -1);
assert(errno == EBADF);
assert(close(fd) == 0);
}
<|fim_prefix|>#include <assert.h>
#includ... | fim | wasmerio/wasmer | c |
#include <assert.h>
#include <fcntl.h>
#include <unistd.h>
int main(void) {
int fd = open("/tmp/sparse", O_CREAT | O_RDWR, 0644);
write(fd, "12345678901234567", 17);
ftruncate(fd, 0);
write(fd, "Z", 1);
lseek(fd, 0, SEEK_SET);
char b[32] = {1};
assert(read(fd, b, sizeof(b)) == 18);
for (int i = 0; i <... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
int main(void) {
char buf[32];
struct stat st;
memset(buf, 'A', sizeof(buf));
int fd = open("/tmp/<|fim_suffix|>rrno == ENOENT);
fd = open("/tmp/test.txt"... | fim | wasmerio/wasmer | c |
<|fim_suffix|>("read");
close(fd);
return 1;
}
if (n == 0) {
break;
}
total += (size_t)n;
}
if (close(fd) != 0) {
perror("close verify path");
return 1;
}
if (total != sizeof(actual)) {
fprintf(stderr, "%s short path read: read %zu bytes\n", label, total);
ret... | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#BuildEnv: WASIXCC_WASM_EXCEPTIONS=no
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
int read_write() {
int pipefd[2];
if (pipe(pipefd) != 0) {
perror("pipe");
return 1;
}
if... | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#ExpectedStdout: proc_spawn2 dup2 test passed
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <spawn.h>
#include <stdio.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
#include <wasi/api_wasix.h>
#define TARGET_FD 10
static const char* src_path = "proc_spawn2_dup2_s... | fim | wasmerio/wasmer | c |
<|fim_suffix|>roc_spawn_fd_op_t op = {0};
op.cmd = __WASI_PROC_SPAWN_FD_OP_NAME_DUP2;
op.fd = 65536;
op.src_fd = (__wasi_fd_t)fd;
__wasi_pid_t pid = 0;
__wasi_errno_t err =
__wasi_proc_spawn2("missing-process", "", "", &op, 1, 0, 0, 0, "", &pid);
assert(err == __WASI_ERRNO_BADF);
assert(close(fd) ... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <assert.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <wasi/api_wasix.h>
int main(void) {
const char* path = "/tmp/proc-spawn2-open-huge-fd";
int fd = open(path, O_CREAT | O_RDWR, 0<|fim_suffix|>cmd = __WASI_PROC_SPAWN_FD_OP_NAME_OPEN;
op.fd = 65536;
op.path = (u... | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#ExpectedStdout: 0
#include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
int main() {
int fd;
char* data;
struct stat statbuf;
fd = open("/data/my_file.txt", O_CREAT | O_WRONLY, 0644);
if (fd == -1) {
goto fail;
}
data = "ABC";
if (pwrite(fd, data, 3, 0)... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
static int create_file(const char* name) {
int fd = open(name, O_CREAT | O_TRUNC<|fim_suffix|>_dup2_cloexec");
int dup_fd = fcntl(fd, F_DUPFD_CLOEXEC, 0);
assert(dup_fd >= 0);
int... | fim | wasmerio/wasmer | c |
#include <assert.h>
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <wasi/api.h>
#include <wasi/api_wasix.h>
// Scan a small fd window for the first preopened directory exposed by the
// current harness instead of assuming a fixed descriptor number.
#define PR... | fim | wasmerio/wasmer | c |
<|fim_suffix|>_wasi_errno_t ret = __wasi_fd_fdflags_set(fd, __WASI_FDFLAGSEXT_CLOEXEC);
assert(ret == __WASI_ERRNO_SUCCESS);
__wasi_fdflagsext_t flags = 0;
ret = __wasi_fd_fdflags_get(dup_fd, &flags);
assert(ret == __WASI_ERRNO_SUCCESS);
assert((flags & __WASI_FDFLAGSEXT_CLOEXEC) == 0);
ret = __wasi_fd_fd... | fim | wasmerio/wasmer | c |
<|fim_suffix|> != 0);
__wasi_rights_t orig_base = stat.fs_rights_base;
__wasi_rights_t orig_inherit = stat.fs_rights_inheriting;
__wasi_rights_t new_base =
orig_base & ~(__wasi_rights_t)__WASI_RIGHTS_FD_READ;
err = __wasi_fd_fdstat_set_rights(fd, new_base, orig_inherit);
assert(err == __WASI_ERRNO_SUC... | fim | wasmerio/wasmer | c |
#include <assert.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
static void test_initial_offset(void) {
printf("Test: Initial offset is 0\n");
FILE* f = tmpfile();
assert(f != NULL);
long pos = ftell(f);
assert(pos == 0);
printf(" Initial offset = 0... | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#ExpectedStdout: Clock works.
#include <stdio.h>
#include <time.h>
// Busy-wait loop for demonstration
void busy_work() {
volatile double x = 0.0;
for (long i = 0; i < 10000000; ++i) {
x += i * 0.000001;
}
}
int main() {
clock_t start = clock();
busy_work();
clock_t end = clock();
... | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#ExpectedStdout: getpass test - requires interactive terminal
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int main() {
// Note: getpass() requires terminal interaction, so this test
// will likely fail in automated testing without input piping.
// Marking <|fim_suffix|>printf("getp... | fim | wasmerio/wasmer | c |
//#ExpectedStdout: mmap anon memory works
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
int main(void) {
size_t size = 4096;
char* p =
mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
if (p == MAP_FAILED) {
perror("mmap");
return 1;
}
c... | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#BuildEnv: WASIXCC_WASM_EXCEPTIONS=no
//#Ignored: file-backed mmap writeback does not currently persist under WasiRunner
//#ExpectedStdout: 0
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
int main() {
int... | fim | wasmerio/wasmer | c |
//#BuildEnv: WASIXCC_WASM_EXCEPTIONS=no
//#Ignored: file-backed mmap writeback does not currently persist under WasiRunner
//#ExpectedStdout: 0
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
int main() {
int fd;
char* d... | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#BuildEnv: WASIXCC_WASM_EXCEPTIONS=no
//#Ignored: file-backed mmap writeback does not currently persist under WasiRunner
//#ExpectedStdout: 0
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
<|fim_suffix|>xit(1);
}
printf("0");
close(fd);
return 0;
}
<|fim_middle|>... | fim | wasmerio/wasmer | c |
<|fim_suffix|>
printf("open");
exit(1);
}
char buffer[filesize];
ssize_t bytes_read = read(fd, buffer, filesize);
if (bytes_read == -1) {
printf("read");
exit(1);
}
if (strncmp(buffer, "abchij", filesize) != 0) {
printf("Error: Expected content 'abchij', got '%s'\n", buffer);
exit(... | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#BuildEnv: WASIXCC_WASM_EXCEPTIONS=no
//#Ignored: file-backed mmap writeback does not currently persist under WasiRunner
//#ExpectedStdout: 0
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
<|fim_suffix|>en");
exit(1);
}
char buffer[filesize];
ssize_t bytes_read = read(fd, buffer, ... | fim | wasmerio/wasmer | c |
//#BuildEnv: WASIXCC_WASM_EXCEPTIONS=no
//#Ignored: file-backed mmap writeback does not currently persist under WasiRunner
//#ExpectedStdout: 0
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
int main() {
int fd;
char* d... | fim | wasmerio/wasmer | c |
<|fim_suffix|>) {
printf("open");
exit(1);
}
write(fd, "abcdef", 6);
struct stat statbuf;
fstat(fd, &statbuf);
size_t filesize = statbuf.st_size;
data = mmap(NULL, 2, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 2);
if (data == MAP_FAILED) {
printf("mmap");
exit(1);
}
memcpy(data, "hi",... | fim | wasmerio/wasmer | c |
//#BuildEnv: WASIXCC_WASM_EXCEPTIONS=no
//#ExpectedStdout: 0
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>
void sig_handler(int signo) { exit(signo != SIGHUP); }
int main(int argc, char* argv[]) {
pid_t pid;
int status;
pid = fork();
if (pid == -1) {
... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <ctype.h>
#include <std<|fim_suffix|>) {
custom_printf("Printing %i, %i, %d, %d\n", 5, 6, 0, GLOBAL);
return 0;
}
<|fim_middle|>io.h>
#include <unistd.h>
extern void custom_printf(const char* format, ...);
static int GLOBAL = 42;
int main(<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <stda<|fim_suffix|> va_start(args, format);
vprintf(format, args);
va_end(args);
}
<|fim_middle|>rg.h>
#include <stdio.h>
void custom_printf(const char* format, ...) {
va_list args;
<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_suffix|>cout << "TlsItem destructed"; }
};
thread_local TlsItem tls_item;
Item item;
extern "C" void* use_tls_item() { return &tls_item; }<|fim_prefix|>#include <iostream>
struct Item {
Item() { std::cout << "Item constructed";<|fim_middle|> }
~Item() { std::cout << "Item destructed"; }
};
struct TlsItem ... | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>#include <dlfcn.h>
#include <iostream>
#include <thread>
typedef void* (*side_type)();
int main() {
void* handle = dlopen("liblibrary.so", RTLD_NOW);
if (!handle) {
std<|fim_suffix|>ym(handle, "tls_item");
if (!tls_item_loaded) {
printf("dlsym failed: %s\n", dlerror());
return 1;
}
... | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>#include <iostream>
struct Item {
Item() { std::cout << "Item constructed"; }
~Item() { std::cout << "Item destructed"; }
};
struct TlsItem {
TlsItem() { std::cout << "TlsItem constructed"; }
~TlsItem() { std::cout << "TlsItem destructed"; }
};
thread_local TlsItem tls_item;
Item ite<|fim_suffix... | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>#include <dlfcn.h>
#include <iostream>
#include <thread>
int main() {
void* handle = dlopen("liblibrary.so", RTLD_NOW);
if (!handle) {
st<|fim_suffix|>
return 1;
}
dlclose(handle);
return 0;
}
<|fim_middle|>d::cerr << "dlopen failed: " << dlerror() << std::endl;<|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>#include <iostream>
struct Item {
I<|fim_suffix|>out << "TlsItem destructed"; }
};
thread_local TlsItem tls_item;
Item item;
extern "C" void* use_tls_item() { return &tls_item; }<|fim_middle|>tem() { std::cout << "Item constructed"; }
~Item() { std::cout << "Item destructed"; }
};
struct TlsItem {
... | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>fecycle-of-global-in-shared-library
return 0;
}
<|fim_prefix|>#include <dlfcn.h>
#include <iostream>
#include <thread>
int main() {
// For the same test, but without the TLS item being used, see<|fim_middle|>
// li<|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>#include <iostream>
struct Item {
Item() { std::cout << "I<|fim_suffix|>ucted"; }
~TlsItem() { std::cout << "TlsItem destructed"; }
};
thread_local TlsItem tls_item;
Item item;
extern "C" void* use_tls_item() { return &tls_item; }<|fim_middle|>tem constructed"; }
~Item() { std::cout << "Item dest... | fim | wasmerio/wasmer | cpp |
<|fim_suffix|><iostream>
#include <thread>
int main() { return 0; }
<|fim_prefix|>#include <dlfcn.h>
#inclu<|fim_middle|>de <|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>id* use_tls_item() { return &tls_item; }<|fim_prefix|>#include <iostream>
struct Item {
Item() { std::cout << "Item constructed"; }
~Item() { std::cout << "Item destructed"; }
};
struct TlsItem {
TlsItem() { std::cout << "TlsItem constructed"; }
~TlsItem() { std::cout << "TlsItem destructed"; }
}... | fim | wasmerio/wasmer | cpp |
#include <dlfcn.h>
#include <iostream>
#include <thread>
typedef void* (*side_type)();
int main() {
void* handle = dlopen("liblibrary.so", RTLD_NOW);
if (!handle) {
std::cerr << "dlopen failed: " << dlerror() << std::endl;
return 1;
}
side_type side = (side_type)dlsym(handle, "use_tls_item");
void*... | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>#include <iostream>
struc<|fim_suffix|>}
~Item() { std::cout << "Item destructed"; }
};
struct TlsItem {
TlsItem() { std::cout << "TlsItem constructed"; }
~TlsItem() { std::cout << "TlsItem destructed"; }
};
thread_local TlsItem tls_item;
Item item;
extern "C" void* use_tls_item() { return &tls_i... | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>S item being used, see
// lifecycle-of-global-in-shared-library
use_tls_item();
return 0;
}
<|fim_prefix|>#include <dlfcn.h>
#include <iostream>
#include <thread>
e<|fim_middle|>xtern "C" void* use_tls_item();
int main() {
// For the same test, but without the TL<|endoftext|> | fim | wasmerio/wasmer | cpp |
#include <iostream>
struct Item {
Item() { std::cout << "Item constructed"; }
~Item() { std::cout << "Item destructed"; }
};
struct TlsItem {
TlsItem() { std::cout << "TlsItem constructed"; }
~TlsItem() { std::cout << "TlsItem destructed"; }
};
thread_local TlsItem tls_item;
Item item;
extern "C" void* use_t... | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>#include <dlfcn.h>
#include <iostream>
#include <thread>
extern "C" void* use_tls_item();
int main() {
// For the sa<|fim_suffix|>eing used, see
// lifecycle-of-global-in-shared-library
use_tls_item();
return 0;
}
<|fim_middle|>me test, but without the TLS item b<|endoftext|> | fim | wasmerio/wasmer | cpp |
<|fim_prefix|>#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
int main() {
// Put variables on both ends to make sure the setjmp
// code doesn't overwrite anything by mistake
unsigned long long int b<|fim_suffix|>oops 2\n");
exit(2);
} else {
if (before != 10 || after ... | fim | wasmerio/wasmer | cpp |
<|fim_suffix|>, 1);
printf("This line will never be executed\n");
}
<|fim_prefix|>#include <setjmp.h>
#include <stdio.h>
extern jmp_buf buffer;
void ot<|fim_middle|>her() {
printf("b");
longjmp(buffer<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_prefix|>void othe<|fim_suffix|>
<|fim_middle|>r();<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_suffix|><|fim_prefix|>#include <setjmp.h>
#include <stdio.h>
#include "library.h"
jmp_buf buffer;
int main() {<|fim_middle|>
if (setjmp(buffer) == 0) {
// Initial call to setjmp returns 0
printf("a");
other();
} else {
printf("c\n");
}
return 0;
}
<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_suffix|>printf("This line will never be executed\n");
}
<|fim_prefix|>#i<|fim_middle|>nclude <setjmp.h>
#include <stdio.h>
jmp_buf buffer;
void other() {
printf("b");
longjmp(buffer, 1);
<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_suffix|>;
<|fim_prefix|>void oth<|fim_middle|>er()<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_suffix|> (setjmp(buffer) == 0) {
// Initial call to setjmp returns 0
printf("a");
other();
} else {
printf("c\n");
}
return 0;
}
<|fim_prefix|>#include <setjmp.h>
#include <stdio.h>
#<|fim_middle|>include "library.h"
extern jmp_buf buffer;
int main() {
if<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_suffix|>uffer) == 0) {
// Initial call to setjmp returns 0
printf("a");
other();
} else {
printf("c\n");
}
}
<|fim_prefix|>#include <setjmp.h>
#include <stdio.h>
jmp_buf<|fim_middle|> buffer;
void other() {
printf("b");
longjmp(buffer, 1);
printf("This line will never be executed\n");
... | fim | wasmerio/wasmer | c |
<|fim_suffix|>);
<|fim_prefix|>voi<|fim_middle|>d lib_main(<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <s<|fim_suffix|>eturn 0;
}
<|fim_middle|>etjmp.h>
#include <stdio.h>
#include "library.h"
int main() {
lib_main();
r<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#ExpectedStd<|fim_suffix|> else {
printf("c\n");
}
return 0;
}
<|fim_middle|>out: abc
#include <setjmp.h>
#include <stdio.h>
jmp_buf buffer;
void other() {
printf("b");
longjmp(buffer, 1);
printf("This line will never be executed\n");
}
int main() {
if (setjmp(buffer) == 0) {
// I... | fim | wasmerio/wasmer | c |
<|fim_suffix|>urce = build_test_path.join(filename);
let source = std::fs::read_to_string(&primary_source)
.with_context(|| format!("Failed to read {}", primary_source.display()))?;
let mut cmd = rustc_command(source.contains("#![feature(").then_some("nightly"));
cmd.... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#ExpectedStdout: 0
<|fim_suffix|>int status = EXIT_FAILURE;
if (chdir("/tmp") != 0) {
goto end;
}
if (getcwd(cwd, sizeof(cwd)) == NULL) {
goto end;
}
if (strcmp(cwd, "/tmp") == 0) {
status = EXIT_SUCCESS;
}
end:
printf("%d", status);
exit(status);
}
<|fim_middle|>#include... | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#ExpectedStdout: 0
#include <assert.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
typedef unsigned char bool;
#define false (0)
#define true (1)
int main() {
const size_t expected_count = 4;
const char* expected_entries[] = {".", "..", "main.... | fim | wasmerio/wasmer | c |
<|fim_suffix|>{
struct stat st;
if (stat(dir_name, &st) == 0 || errno != ENOENT) {
return -1;
}
errno = 0;
return 0;
}
void error(const char* message) {
perror(message);
exit(-1);
}
int main() {
if (mkdir("test1/test2", S_IRWXU | S_IRWXG | S_IRWXO) == 0) {
printf("Expected recursive director... | fim | wasmerio/wasmer | c |
<|fim_suffix|>ror(const char* message) {
perror(message);
exit(-1);
}
int main() {
if (mkdir("test1", S_IRWXU | S_IRWXG | S_IRWXO) != 0 ||
ensure_dir_accessible("test1") != 0) {
error("test1");
}
if (mkdir("./test2", S_IRWXU | S_IRWXG | S_IRWXO) != 0 ||
ensure_dir_accessible("test2") != 0) {... | fim | wasmerio/wasmer | c |
<|fim_suffix|>ccessible("test3") != 0) {
error("test3");
}
if (mkdirat(cwd_fd, "./test4", S_IRWXU | S_IRWXG | S_IRWXO) != 0 ||
ensure_dir_accessible("test4") != 0) {
error("test4");
}
printf("0");
return 0;
}
<|fim_prefix|>//#ExpectedStdout: 0
#include <fcntl.h>
#include <stdio.h>
#include <st... | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#ExpectedStdout: 0
// There used to be an issue where, when moving a file, you could no longer
// open it afterwards. This is a regression test for that issue.
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#... | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#ExpectedStdout: 0
#include <fcntl.h>
#include <st<|fim_suffix|>;
}<|fim_middle|>dio.h>
int main() {
int fd = open("hello.txt", O_RDWR);
printf("%d", (fd == -1));
return 0<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#ExpectedStdout: 0
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
static void fail(const char* message) {
perror(message);
exit(1);
}
static void write_all(int fd, const char* content... | fim | wasmerio/wasmer | c |
<|fim_suffix|>];
if (fgets(buffer, sizeof(buffer), f) != NULL) {
if (strcmp(buffer, "Hello, Wasix!\n") != 0) {
printf("Unexpected file content: %s", buffer);
return 1;
}
} else {
perror("Failed to read from file");
return 1;
}
fclose(f);
printf("0");
return 0;
}
<|fim_prefix|>//... | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#ExpectedStdout: 0
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
void error(const char* message) {
perror(message);
exit(-1);
}
int main() {
// Create two directories
if (mkdir("... | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#ExpectedStdout: 0
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
int<|fim_suffix|> 1;
if (mkdir("/tmp/my_test_dir", 0777) == -1) {
goto end;
}
status = access("/tmp/my_test_dir", F_OK) != 0;
end:
printf("%d", status);
}
<|fim_midd... | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#ExpectedStdout: 0
#include <errno.h>
#include <fcntl.h>
#include <stdio<|fim_suffix|>| O_RDWR, 0600);
if (fd != -1) {
fprintf(stderr, "open unexpectedly succeeded\n");
close(fd);
return 1;
}
if (errno != ENOTDIR) {
fprintf(stderr, "expected ENOTDIR, got %d\n", errno);
return ... | fim | wasmerio/wasmer | c |
<|fim_suffix|>-parent", 0755) == 0);
errno = 0;
int ret = rename("rename-parent", "rename-parent/child");
assert(ret == -1);
assert(errno == EINVAL);
assert(mkdir("rename-parent/still-here", 0755) == 0);
}
<|fim_prefix|>#include <assert.h>
#includ<|fim_middle|>e <errno.h>
#include <stdio.h>
#include <sys/sta... | fim | wasmerio/wasmer | c |
<|fim_suffix|>);
assert(fd >= 0);
assert(read(fd, buf, sizeof(buf)) == 2);
assert(strcmp(buf, "ok") == 0);
}
<|fim_prefix|>#include <assert.h>
#include <fcntl.h>
#include <stdi<|fim_middle|>o.h>
#include <string.h>
#include <unistd.h>
int main(void) {
int fd = open("/tmp/same-path", O_CREAT | O_RDWR, 0644);
... | fim | wasmerio/wasmer | c |
<|fim_suffix|>rlen(suffix)) < 0) {
fail("append through symlink");
}
if (close(fd) != 0) {
fail("close symlink fd");
}
fd = open(linkname, O_RDONLY);
if (fd < 0) {
fail("open symlink for read");
}
n = read(fd, buf, sizeof(buf) - 1);
if (n < 0) {
fail("read through symlink");
}
if (c... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <assert.h>
#include <stdint.h>
#include <stdio.h>
#include <wasi/api.h>
#include <wasi/api_wasix.h>
static void test_basic_create(void) {
printf("Test 1: epoll_create basic\n");
__wasi_fd_t epfd = 0;
__wasi_errno_t err = __wasi_epoll_create(&epfd);
assert(err == __WASI_ERRNO_SUCCESS);
... | fim | wasmerio/wasmer | c |
<|fim_prefix|>//#ExpectedStdout: 0
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/epoll.h>
#include <sys/eventfd.h>
#include <unistd.h>
int main() {
int status = EXIT_FAILURE;
int efd1 = -1, efd2 = -1, epoll_fd = -1;
struct epoll_event event;
struct epoll_event events[4];
efd1 = ev... | fim | wasmerio/wasmer | c |
<|fim_suffix|> the file.
char buf[256] = {0};
victim_fd = open("victim.php", O_RDONLY);
read(victim_fd, buf, sizeof(buf) - 1);
if (strstr(buf, "TLS_HANDSHAKE_BYTES") != NULL) return 1;
printf("0");
return 0;
}
<|fim_prefix|>//#ExpectedStdout: 0
#include <arpa/inet.h>
#include <fcntl.h>
#include <netinet/in.... | fim | wasmerio/wasmer | c |
#include <assert.h>
#include <poll.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
static void test_pollout(void) {
printf("Test 1: POLLOUT on pipe write end\n");
int fds[2];
assert(pipe(fds) == 0);
struct pollfd pfd = {.fd = fds[1], .events = POLLOUT, .revents = 0};
int ret = poll(&pfd, 1, -1... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <as<|fim_suffix|>subscriptions =
0; // Passing a 0 causes an infinite loop
__wasi_errno_t ret = __wasi_poll_oneoff(&sub, &out, nsubscriptions, &events);
assert(ret == __WASI_ERRNO_INVAL && "poll_oneoff(0) should return EINVAL");
atomic_store(&done, true);
return NULL;
}
int main(v... | fim | wasmerio/wasmer | c |
#include <assert.h>
#include <stdio.h>
#include <unistd.h>
#include <wasi/api_wasix.h>
int main(void) {
char cwd[256];
assert(getcwd(cwd, sizeof(cwd)) != NULL);
char name[512];
int name_len = snprintf(name, sizeof(name), "%s/proc_exec_child.wasm", cwd);
assert(name_len > 0 && name_len < (int)sizeof(name));
... | fim | wasmerio/wasmer | c |
<|fim_suffix|> == 0);
return 0;
}
<|fim_prefix|>#include <assert.h>
#include<|fim_middle|> <string.h>
int main(int argc, char** argv) {
assert(argc >= 2);
assert(strcmp(argv[1], "canary")<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <assert.h>
#include <stdio.h>
#inclu<|fim_suffix|>rgs));
const char* envs = "LTP_TEST_ENV_VAR=test";
__wasi_proc_exec2(name, args, envs);
assert(!"proc_exec2 returned");
}
<|fim_middle|>de <unistd.h>
#include <wasi/api_wasix.h>
int main(void) {
char cwd[256];
assert(getcwd(cwd, sizeo... | fim | wasmerio/wasmer | c |
<|fim_suffix|> assert(strcmp(v, "test") == 0);
return 0;
}
<|fim_prefix|>#include <assert.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char** argv) {
assert(argc >= 2<|fim_middle|>);
assert(strcmp(argv[1], "canary") == 0);
const char* v = getenv("LTP_TEST_ENV_VAR");
assert(v != NULL);
<|en... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <wasi/api_wasix.h>
int main(void) {
char cwd[256];
<|fim_suffix|> name);
assert(args_len > 0 && args_len < (int)sizeof(args));
__wasi_errno_t err = __wasi_proc_exec3(name, args, "", __WASI_BOOL_TRUE, cwd);
... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <assert.h>
#include <string.h>
int main(int argc, char** argv) {
asse<|fim_suffix|>urn 0;
}
<|fim_middle|>rt(argc >= 2);
assert(strcmp(argv[1], "canary") == 0);
ret<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_suffix|>
assert(err == __WASI_ERRNO_SUCCESS);
assert(!"proc_exec3 (empty argv) returned");
}
<|fim_prefix|>#include <assert.h>
#include <stdio.h>
#include <unistd.h>
#includ<|fim_middle|>e <wasi/api_wasix.h>
int main(void) {
char cwd[256];
assert(getcwd(cwd, sizeof(cwd)) != NULL);
char name[512];
in... | fim | wasmerio/wasmer | c |
<|fim_suffix|>c >= 1);
return 0;
}
<|fim_prefix|>#include <assert.h>
int main(int argc<|fim_middle|>, char** argv) {
(void)argv;
assert(arg<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <assert.h>
#include <errno.h>
#includ<|fim_suffix|>a', sizeof(long_name));
long_name[sizeof(long_name) - 1] = '\0';
expect_errno(long_name, __WASI_ERRNO_NAMETOOLONG);
return 0;
}
<|fim_middle|>e <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <wasi/api_wasix.h... | fim | wasmerio/wasmer | c |
<|fim_suffix|>=
snprintf(name, sizeof(name), "%s/proc_exec4_newline_arg_child.wasm", cwd);
assert(name_len > 0 && name_len < (int)sizeof(name));
const char* argv[] = {name, "line1\nline2"};
const uint8_t** argv_ptrs = (const uint8_t**)argv;
__wasi_errno_t err =
__wasi_proc_exec4(name, argv_ptrs, 2... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <assert.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char** argv) {
assert(argc >= 2);
assert(strcmp(argv[1], "<|fim_suffix|>
printf("proc_exec4 newline arg test passed\n");
return 0;
}
<|fim_middle|>line1\nline2") == 0);<|endoftext|> | fim | wasmerio/wasmer | c |
<|fim_suffix|>ame, sizeof(name), "%s/proc_exec4_newline_env_child.wasm", cwd);
assert(name_len > 0 && name_len < (int)sizeof(name));
const char* argv[] = {name};
const uint8_t** argv_ptrs = (const uint8_t**)argv;
const char* envp[] = {"NEWLINE_ENV=value\nwith\nnewlines"};
const uint8_t** envp_ptrs = (const ... | fim | wasmerio/wasmer | c |
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char** argv) {
(void)argc;
(void)argv;
const char* v = getenv("NEWLINE_ENV");
assert(v != NULL);
assert(strcmp(v, "value\nwith\nnewlines") == 0);
printf("proc_exec4 newline env test passed\n");
return 0;
}
... | fim | wasmerio/wasmer | c |
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
#include <wasi/api_wasix.h>
static int child_verify(int argc, char** argv) {
assert(argc >= 3);
assert(strcmp(argv[2], "line1\nline2") == 0);
return 0;
}
int main(int argc, char** argv) {
if (argc >= 2 && strc... | fim | wasmerio/wasmer | c |
<|fim_prefix|>#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
static int wait_word = 0;
int main(void) {
pid_t parent = getpid();
pid_t child = fork();
if (child < 0) {
perror("fork");
return EXIT_FAILURE;
}
if (child == 0) {
usleep(100 * 1000);
if (kill(pare... | fim | wasmerio/wasmer | c |
<|fim_suffix|>hild_pid) !=
0) {
perror("pthread_create");
_Exit(EXIT_FAILURE);
}
puts("vfork child waiting");
fflush(stdout);
__builtin_wasm_memory_atomic_wait32(&wait_word, 0, -1LL);
sleep(1);
_Exit(42);
}
if (wait_for_children(1) != EXIT_SUCCESS) {
return EXIT_FA... | fim | wasmerio/wasmer | c |
<|fim_suffix|>==========================================================================
// pipe2 O_CLOEXEC test
// =============================================================================
// BUG: pipe2(O_CLOEXEC) does not set FD_CLOEXEC on the created fds.
// This causes popen() to hang because the write end of t... | fim | wasmerio/wasmer | c |
<|fim_suffix|>;
}
<|fim_prefix|>//#MappedDirectory: $temp:/temp1
//#MappedDirectory: $temp:/temp2
//#ExpectedStdout: 0
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
void error_exit(const char* desc, const char* call) {
const char* err_desc = strerror(errno);
pri... | fim | wasmerio/wasmer | c |
<|fim_suffix|>S(status));
return 1;
}
return 0;
}
}
// Making sure CLOEXEC FDs are not closed with a failing exec call
int cloexec() {
int fd = open("/bin/file", O_RDONLY | O_CREAT | O_CLOEXEC);
int pid = fork();
if (pid == 0) {
execl("./not-here.wasm", NULL);
int flags = fcntl(fd, F_... | fim | wasmerio/wasmer | c |
<|fim_prefix|>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>
int main(int argc, char* argv[]) {
if (argc > 1 && argv[1] != NULL) {
return 0;
}
int status = 1;
pid_t pid = fork();
if (pid == -1) {
<|fim_suffix|>s, 0);
}
end:
printf("%d", status);
}
<|fim_middle... | fim | wasmerio/wasmer | c |
<|fim_suffix|>d:
printf("%d", status);
}
<|fim_prefix|>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>
int main(int argc, char* argv[]) {
if (argc > 1 && argv[1] != NULL) {
char* bar = getenv("foo");
return (bar == NULL);
}
int status = 1;
pid_t pid = fork();
if ... | fim | wasmerio/wasmer | c |
<|fim_suffix|>_direct") == 0) {
return do_posix_spawn_direct_test();
} else if (strcmp(argv[1], "pipe2_cloexec") == 0) {
return do_pipe2_cloexec_test();
} else if (strcmp(argv[1], "popen") == 0) {
return do_popen_test();
} else {
fprintf(stderr, "Unknown command: %s\n", argv[1]);
fprintf(
... | fim | wasmerio/wasmer | c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.