text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_suffix|>le_create.dir/new_file")
.unwrap()
.is_file());
assert!(fs::remove_file("/fyi/fs_file_create.dir/new_file").is_ok());
}
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
use std::fs;
fn main() {
assert!(fs::File::create("/fyi/fs_file_create.dir/<|fim_middle|>new_file").is_ok())... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: <|fim_suffix|>tory.dir/directory").unwrap();
assert!(metadata.is_dir());
}
<|fim_middle|>wasi-fyi.config
use std::fs;
fn main() {
let metadata = fs::metadata("/fyi/fs_metadata-direc<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//<|fim_suffix|>() {
let metadata = fs::metadata("/fyi/fs_metadata-file.dir/file").unwrap();
assert!(metadata.is_file());
}
<|fim_middle|>#AbstractConfigFile: wasi-fyi.config
use std::fs;
fn main<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
use std::{
fs,
io::{Seek, SeekFrom, Write},
};
fn main() {
let fi<|fim_suffix|> with append should not affect the offset of f0.
let _f1 = fs::OpenOptions::new()
.create(true)
.write(true)
.append(true)
.open(file)
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> 0,
0,
1024,
);
assert_eq!(
errno, ERRNO_EXIST,
"opening an existing directory with excl should fail"
);
let _ = fs::remove_file("/fyi/fs_open_dir_excl.dir/file");
let errno = path_open(
fd,
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>len() as i32,
0,
RIGHTS_FD_WRITE,
0,
0,
1024,
);
assert_eq!(
errno, ERRNO_ISDIR,
"opening a dir with rights::fd_write should fail"
);
}
}
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
#[l... | fim | wasmerio/wasmer | rust |
//#AbstractConfigFile: wasi-fyi.config
#[link(wasm_import_module = "wasi_snapshot_preview1")]
extern "C" {
pub fn path_open(
fd: i32,
dirflags: i32,
path: i32,
path_len: i32,
oflags: i32,
fs_rights_base: i64,
fs_rights_inheriting: i64,
fdflags: i32,
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
use std::fs;
fn main() {
assert!(fs::create_dir_all("/fyi/foo/bar").is_ok());
assert!(fs::create_dir_all("/fyi/foo/b<|fim_suffix|>z").is_ok());
assert_eq!(
fs::read_dir("/fyi/foo")
.unwrap()
.map(|e| e.unwrap().file_name()... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#Abs<|fim_suffix|>t old_path = "/fyi/fs_rename-directory.dir/old_directory";
let new_path = "/fyi/fs_rename-directory.dir/new_directory";
assert!(fs::rename(old_path, new_path).is_ok());
assert!(fs::rename(new_path, old_path).is_ok());
}
<|fim_middle|>tractConfigFile: wasi-fyi.config
use st... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.confi<|fim_suffix|>));
}
<|fim_middle|>g
use std::fs;
fn main() {
let old_path = "/fyi/fs_rename-file.dir/old_file";
let new_path = "/fyi/fs_rename-file.dir/new_file";
assert!(fs::rename(old_path, new_path).is_ok());
let error = fs::metadata(old_path).unw... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> 0,
&mut fd as *mut i32 as i32,
);
assert_eq!(errno, ERRNO_PERM, "symlink cannot escape fs sandbox");
let errno = path_open(
5,
LOOKUPFLAGS_SYMLINK_FOLLOW,
link_path_non_existant.as_ptr() as i32,
link_path_non_existant.l... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
use std::fs::OpenOptions;
use std::io::prelude::*;
use std::io::SeekFrom;
fn main() {
let mut file = OpenOpti<|fim_suffix|> offset, which is immediately set to the end of the file
// with a write.
let _ = file.rewind();
// file offset must be 2 now
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
<|fim_suffix|>m::Start(0)).unwrap(), 0);
write!(file, "eh").unwrap();
// We overwrote the first 2 bytes, should still have 4 bytes
let md = metadata("file").unwrap();
assert_eq!(md.len(), 4);
assert_eq!(file.seek(SeekFrom::Start(0)).unwrap(), 0... | fim | wasmerio/wasmer | rust |
//#AbstractConfigFile: wasi-fyi.config
//#ExpectedStderrFile: io_stderr-beowulf.stderr
use std::io;
use std::io::Write;
fn main() {
assert!(io::stderr().write_all(include_bytes!("io_stderr-beowulf.stderr")).is_ok());
}
<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_suffix|>err().write_all(include_bytes!("io_stderr-hello.stderr")).is_ok());
}
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
//#ExpectedStderrFile: io_stderr-hello.stderr
use std::io;
use std::io::Write;
fn main() {
assert!(io::<|fim_middle|>std<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
//#StdinFile: io_stdin-beowulf.stdin
use std::io;
use std::io::Read;
fn main() {
let mut stdin = Str<|fim_suffix|>
);
}
<|fim_middle|>ing::new();
assert!(io::stdin().read_to_string(&mut stdin).is_ok());
assert_eq!(
stdin,
String::from... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
//#StdinFile: io_stdin-hello.stdin
use std::io;
use std::io::Read;
fn main() {
let mut stdin = String::new();
assert!(io::stdin().read_to_string(&mut stdin).is_ok());
a<|fim_suffix|>!("io_stdin-hello.stdin"))
);
}
<|fim_middle|>ssert_eq!(
std... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
//#ExpectedStdoutFile: io_stdout-beowulf.stdout
use std::io;
use std::io::Write;
fn main() {
assert!(io::stdout().w<|fim_suffix|>tdout-beowulf.stdout")).is_ok());
}
<|fim_middle|>rite_all(include_bytes!("io_s<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_suffix|>e std::io::Write;
fn main() {
assert!(io::stdout().write_all(include_bytes!("io_stdout-hello.stdout")).is_ok());
}
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config<|fim_middle|>
//#ExpectedStdoutFile: io_stdout-hello.stdout
use std::io;
us<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: w<|fim_suffix|> {}
<|fim_middle|>asi-fyi.config
fn main()<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_suffix|>).unwrap();
println!("{}", result);
}
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.c<|fim_middle|>onfig
//#ExpectedStdoutFile: port_unix_open_special_files.stdout
// WASI:
// mapdir: /dev:/dev
use std::fs;
use std::io::Write;
fn main() {
let mut f = fs::OpenOptions::new()
.write(true)
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#Abstr<|fim_suffix|>rt_module = "wasi_unstable")]
extern "C" {
fn fd_close(fd: u32) -> u16;
fn fd_fdstat_set_flags(fd: u32, flags: u16) -> u16;
}
const FIRST_PREOPEN_FD: u32 = 4;
fn main() {
let result = unsafe { fd_fdstat_set_flags(FIRST_PREOPEN_FD, 1 << 2) };
println!(
"acces... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>(file.write(b"hello").unwrap(), 5);
file.flush().unwrap();
file.seek(SeekFrom::Start(0)).unwrap();
let mut in_str = String::new();
file.read_to_string(&mut in_str).unwrap();
assert_eq!(&in_str, "hello");
}
fs::remove_file(&test_file).unwrap();
println!(... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
//#Env: DOG=1
//#Env: CAT=2
//#ExpectedStdoutFile: ported_envvar.stdout
// WASI:
// env: DOG=1
// env: CAT=2
use std::env;
fn get_env_var(var_name: &str) <|fim_suffix|>(|(key, value)| format!("{}={}", key, value))
.collect::<Vec<String>>();
env_vars.so... | fim | wasmerio/wasmer | rust |
//#AbstractConfigFile: wasi-fyi.config
//#ExpectedStdoutFile: ported_fd_allocate.stdout
// WASI:
// tempdir: .
use std::fs;
#[cfg(target_os = "wasi")]
use std::os::wasi::prelude::AsRawFd;
use std::path::PathBuf;
#[cfg(target_os = "wasi")]
#[link(wasm_import_module = "wasi_unstable")]
extern "C" {
fn fd_allocate(f... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>;
}
{
let mut file_handle = OpenOptions::new()
.read(true)
.open(&file)
.expect("Couldn't reopen file to read");
let mut test = String::new();
file_handle.read_to_string(&mut test).unwrap();
assert_eq!(&test, &format!("{}{}", S... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>ntln!("Could not close stdin");
}
let result = unsafe { fd_close(stdout_fd) };
if result == 0 {
println!("Successfully closed stdout!")
} else {
println!("Could not close stdout");
}
}
#[cfg(not(target_os = "wasi"))]
{
pri... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> );
}
nread
}
fn main() {
let mut base = PathBuf::from("/hamlet");
base.push("act3/scene4.txt");
let file = fs::File::open(&base).expect("Could not open file");
let mut buffer = [0u8; 64];
#[cfg(target_os = "wasi")]
{
let raw_fd = file.as_raw_fd() as u32;
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
//#ExpectedStdoutFile: ported_fd_read.stdout
// WASI:
// mapdir: .:test_fs/hamlet
// this program is used in the pause/resume test
use std::fs;
#[cfg(target_os = "wasi")]
use std::os::wasi::prelude::AsRawFd;
use std::path::PathBuf;
#[cfg(target_os = "wasi")]
#[rep... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>", idx));
fs::rename(old_path, &new_path).expect("cannot rename the directory");
fs::remove_dir(&new_path).expect("cannot remove the directory");
}
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
//#ExpectedStdoutFile: ported_fd_rename_path.stdout
// WASI:
// dir: test_fs
use std::fs;
use ... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
//#ExpectedStdoutFile: ported_fd_rights.stdout
// WASI:
// tempdir: .
use std::io::{Read, Write};
use std::path::PathBuf;
fn main<|fim_suffix|>fs::remove_file(&file).unwrap();
}
<|fim_middle|>() {
let file = {
let mut base = PathBuf::from(".");
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>should act towards one another in a spirit of brotherhood.").unwrap();
file.sync_all().unwrap();
let len = file.metadata().unwrap().len();
println!("{}", len);
assert_eq!(len, 170);
file.set_len(170 + 1234).unwrap();
file.sync_all().u... | fim | wasmerio/wasmer | rust |
//#AbstractConfigFile: wasi-fyi.config
//#ExpectedStdoutFile: ported_file_metadata.stdout
// WASI:
// dir: test_fs
use std::fs;
fn main() {
let this_file = fs::File::open("/hamlet/act1/scene1.txt").expect("could not find file");
let md = this_file.metadata().unwrap();
println!("is dir: {}", md.is_dir());
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> let result = std::fs::read_dir("..");
#[cfg(not(target = "wasi"))]
let result: Result<(), String> = Err("placeholder".to_string());
println!(
"Reading the parent directory was okay? {:?}",
result.is_ok()
);
}
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
//<|fim_m... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
//#ExpectedStdoutFile: ported_fseek.stdout
// WASI:
// mapdir: .:test_fs/ha<|fim_suffix|>act1/scene3.txt");
let mut file = fs::File::open(&base).expect("Could not open file");
let mut buffer = [0u8; 32];
assert_eq!(file.read(&mut buffer).unwrap(), 32);... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi<|fim_suffix|>ello, world!");
}
<|fim_middle|>.config
//#ExpectedStdoutFile: ported_hello.stdout
fn main() {
println!("H<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_suffix|> meta4.ino() {
println!("Warning, same files have different dev/inod");
}
println!("all done");
}
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
//#ExpectedStdoutFile: ported_inode.stdout
// WASI:
// dir: test_fs
#![feature(wasi_ext)]
use std::fs;
use std::os::wasi::fs::MetadataExt... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
//#ExpectedStdoutFile: ported_isatty.stdout
// We don't have access to libc, so we jus<|fim_suffix|>tty
// as an external function
// use libc::isatty;
extern "C" {
pub fn isatty(fd: i32) -> i32;
}
fn main() {
println!("stdin: {}", unsafe { isatty(0) });
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> println!("{}", p);
}
}
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
//#ExpectedStdoutFile: ported_mapdir.stdout
// WASI:
// mapdir: .:test_fs/hamlet
use std::fs;
fn main() {
std::env::set_current_dir("/hamlet").unwrap();
let read_dir = fs::read_dir(".").unwrap();
let mut o... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> let mut f = fs::File::open(&base).unwrap();
let mut s = String::new();
f.read_to_string(&mut s).unwrap();
println!("{}", s.chars().take(252).collect::<String>());
}
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
//#ExpectedStdoutFile: ported_mapdir_with_leading_slash.stdout
// WASI:
//... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>std::str::from_utf8(&buffer[..]).unwrap());
for b in buffer.iter_mut() {
*b = 0;
}
let mut f = fs::OpenOptions::new()
.read(true)
.open("/hamlet/act5/scene1.txt")
.unwrap();
f.read_exact(&mut buffer).unwrap();
println... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> .create_new(true)
.write(true)
.open(&file_to_create)
.unwrap();
let string = "Hello world";
let bytes: Vec<u8> = string.bytes().collect();
f.write_all(&bytes[..]).unwrap();
}
std::fs::rename(&file_to_create, &file_to_rename... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>et scene1 = symlink_loc.join("scene1.txt");
#[allow(deprecated)]
std::fs::soft_link(&symlink_target, &symlink_loc).unwrap();
let mut file = fs::File::open(&scene1).expect("Could not open file");
let mut buffer = [0u8; 64];
assert_eq!(file.read(&mut buffer).unwrap(), 64);
let st... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
//#StdinFile: ported_pipe_reverse.stdin
//#ExpectedStdoutFile: ported<|fim_suffix|>ut = String::new();
io::stdin().read_line(&mut input).unwrap();
let output: String = input.chars().rev().collect();
println!("{}", output);
}
<|fim_middle|>_pipe_reverse.... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>ll(fds.as_slice(), &[true], &[false]).is_ok() {
"OK"
} else {
"ERROR"
}
);
let fds = vec![std::io::stdout().as_raw_fd() as u32];
print!("Stdout: ");
println!(
"{}",
if poll(fds.as_slice(), &[fal... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> we want to sandbox these tests to `test_fs`, in the future
// `test_fs` will be implicit.
fn main() {
let mut this_file = fs::File::open("/hamlet/act1/scene2.txt").expect("could not find src file");
let _ = this_file.metadata().unwrap();
let mut in_str = String::new();
this_file.read_to_s... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>ect("Could not read link");
println!("{}", link_path.to_string_lossy());
let mut some_contents =
std::fs::File::open(sym_link_path).expect("Could not open file via symlink");
let mut buffer = [0; 128];
assert_eq!(
some_contents
.read(&mut buffer)
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
//#ExpectedStdoutFile: ported_wasi_sees_virtual_root.stdout
// WA<|fim_suffix|>).write(true).open("/abc");
if f.is_ok() {
out.push("ROOT IS NOT SAFE".to_string());
} else {
out.push("ROOT IS SAFE".to_string());
}
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>rue)
.write(true)
.open(path)
.unwrap();
f.write_all(BYTE_STR).unwrap();
}
println!("{}", fs::read_to_string(alt_path).unwrap());
fs::remove_file(path).unwrap();
let file_path = std::path::Path::new(path);
if file_path.exists() {
pr... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>ss;
fn main() {
process::exit(0);
}
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
//#ExpectedExitC<|fim_middle|>ode: 0
use std::proce<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_suffix|>use std::process;
fn main() {
process::exit(1);
}
<|fim_prefix|>//#AbstractConfigFile: wasi-fyi.config
//#Expecte<|fim_middle|>dExitCode: 1
<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractCo<|fim_suffix|>rocess::exit(120);
}
<|fim_middle|>nfigFile: wasi-fyi.config
//#ExpectedExitCode: 120
use std::process;
fn main() {
p<|endoftext|> | fim | wasmerio/wasmer | rust |
//#AbstractConfigFile: wasi-wast.config
//#MappedDirectory: test_fs/hamlet:/hamlet
//#ExpectedStdoutFile: close_preopen_fd.stdout
use std::fs;
use std::path::PathBuf;
#[cfg(target_os = "wasi")]
#[link(wasm_import_module = "wasi_unstable")]
extern "C" {
fn fd_close(fd: u32) -> u16;
fn fd_fdstat_set_flags(fd: u... | fim | wasmerio/wasmer | rust |
//#AbstractConfigFile: wasi-wast.config
//#MappedDirectory: test_fs:/test_fs
//#ExpectedStdoutFile: create_dir.stdout
use std::fs;
use std::io::{Read, Seek, SeekFrom, Write};
use std::path::*;
fn main() {
let mut path = PathBuf::from("test_fs/wasitests/testing/nested/directories");
let test_file = path.join("... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-wast.config
//#Env: DOG=1
//#Env: CAT=2
//#ExpectedStdoutFile: envvar.stdout
use std::env;
fn get_env_var(var_name: &str) -> <|fim_suffix|>nv::VarError> {
#[cfg(not(target = "wasi"))]
match var_name {
"DOG" => Ok("1".to_string()),
"CAT" => Ok("2".to_st... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>h reason and conscience and should act towards one another in a spirit of brotherhood.\n").unwrap();
let raw_fd = file.as_raw_fd() as u32;
file.flush();
let len = file.metadata().unwrap().len();
println!("{}", len);
assert_eq!(len, 171);
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-wast.config
//#CurrentDirectory: /tmp
//#MappedDirectory: $temp:/tmp
//#ExpectedStdoutFile: fd_append.stdout
use std::fs::OpenOptions;
use std::io::{Read, Write};
use std::path::PathBuf;
static STR1: &str = "Hello, world!\n";
static STR2: &str = "Goodbye, world!\n";
fn main(... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>ly closed stdin!");
}
}
<|fim_prefix|>//#AbstractConfigFile: wasi-wast.config
//#MappedDirectory: test_fs/hamlet:/hamlet
//#ExpectedStdoutFile: fd_close.stdout
use std::fs;
#[cfg(target_os = "wasi")]
use std::os::wasi::prelude::AsRawFd;
use std::path::PathBuf;
#[cfg(target_os = "wasi")]
#[link(wasm_... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-wast.config
//#MappedDirectory: test_fs:/test_fs
//#ExpectedStdoutFile: fd_pread.stdout
use std::fs;
#[cfg(target_os = "wasi")]
use std::os::wasi::prelude::AsRawFd;
use std::path::PathBuf;
#[cfg(target_os = "wasi")]
#[repr(C)]
struct WasiIovec {
pub buf: u32,
pub buf_... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>&mut buffer]);
&buffer == b"NIUS \n\nL"
}
<|fim_prefix|>//#AbstractConfigFile: wasi-wast.config
//#MappedDirectory: test_fs/hamlet:/hamlet
//#ExpectedStdoutFile: fd_read.stdout
// this program is used in the pause/resume test
use std::fs;
#[cfg(target_os = "wasi")]
use std::os::wasi::prelude::AsRaw... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> fs::remove_dir(&new_path).expect("cannot remove the directory");
}
<|fim_prefix|>//#AbstractConfigFile: wasi-wast.config
//#MappedDirectory: test_fs:/test_fs
use std::fs;
use std::path::PathBuf;
fn main() {
let mut idx = 0;
fs::create_dir_all(PathBuf::from("test_fs/wasitests")).expect("cannot c... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>sh("foo.txt");
base
};
let mut filehandle = std::fs::OpenOptions::new()
.read(false)
.write(true)
.create(true)
.open(&file)
.unwrap();
filehandle.write_all(b"test").unwrap();
let mut contents = String::new();
assert!(filehandle.read_to... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>().unwrap().len();
println!("{}", len);
assert_eq!(len, 170);
file.set_len(170 + 1234);
file.sync_all();
let len = file.metadata().unwrap().len();
println!("{}", len);
assert_eq!(len, 1234 + 170);
}
}
#[cfg... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>is_symlink()
);
println!("file info: {}", md.len());
}
<|fim_prefix|>//#AbstractConfigFile: wasi-wast.config
//#MappedDirectory: test_fs:/test_fs
//#ExpectedStdoutFile: file_metadata.stdout
use std::fs;
use std::io::Read;
fn main() {
let mut this_file =
fs::File::open("test_fs/hamlet... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-wast.config
//#ExpectedStdoutFile: fs_sandbox_test.stdout
fn main() {
#[cfg(target = "wasi")]
let result = std::fs::read_dir("..");
#[cfg(n<|fim_suffix|>(target = "wasi"))]
let result: Result<(), String> = Err("placeholder".to_string());
println!(
"... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-wast.config
//#MappedDirectory: test_fs/hamlet:/hamlet
//#ExpectedStdoutFil<|fim_suffix|>l.trim_end());
assert_eq!(file.seek(SeekFrom::Current(50)).unwrap(), 6481);
assert_eq!(file.read(&mut buffer).unwrap(), 32);
let str_val = std::str::from_utf8(&buffer[..]).unwr... | fim | wasmerio/wasmer | rust |
<|fim_suffix|> println!("Hello, world!");
}
<|fim_prefix|>//#Abstr<|fim_middle|>actConfigFile: wasi-wast.config
//#ExpectedStdoutFile: hello.stdout
fn main() {
<|endoftext|> | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-wast.config
//#MappedDirectory: test_fs:/test_fs
//#ExpectedStdoutFile: inode.stdout
use std::fs;
use std::io;
#[cfg(ta<|fim_suffix|> if meta1.dev() == meta2.dev() && meta1.ino() == meta2.ino() {
println!("Warning, different files from same folder have same d... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>2;
}
fn main() {
#[cfg(target = "wasi")]
{
println!("stdin: {}", unsafe { isatty(0) });
println!("stdout: {}", unsafe { isatty(1) });
println!("stderr: {}", unsafe { isatty(2) });
}
#[cfg(not(target = "wasi"))]
{
println!("stdin: 1");
println!("... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-wast.config
//#MappedDirectory: test_fs/hamlet:/hamlet
//#ExpectedStdoutFile: mapdir.stdout
use std::fs;
fn main() {
#[cfg(not(target_os = "wasi"))]
std::env::set_current_dir("test_fs/hamlet").unwrap();
#[cfg(target_os = "wasi")]
std:<|fim_suffix|>mlet").unwra... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>!(
"{}",
excerpt
.lines()
.map(str::trim_end)
.collect::<Vec<_>>()
.join("\n")
);
}
<|fim_prefix|>//#AbstractConfigFile: wasi-wast.config
//#MappedDirectory: test_fs/hamlet:/hamlet
//#ExpectedStdoutFile: mapdir_with_leading_slash.stdout
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-wast.config
//#MappedDirectory: test_fs/hamlet/act5:/act5
//#MappedDirectory: $temp:/temp
//#ExpectedStdoutFile: path_link.stdout
use std::fs;
use std::io::Read;
fn main() {
#[cfg(not(target_os = "wasi"))]
{
let out_str = "ACT V
SCENE I. A churchyard.
Ent... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-was<|fim_suffix|>色の毛色が枯れ柴に似ている(柴赤)ことから
小さなものを表す古語の「柴」から
の3つの説が代表的。";
f.write_all(shiba_string.as_bytes()).unwrap();
}
{
let mut f = std::fs::OpenOptions::new()
.create_new(true)
.write(true)
.open(&file_to_rename... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//<|fim_suffix|>n!("{}", str_val);
std::fs::remove_file(symlink_loc).unwrap();
}
<|fim_middle|>#AbstractConfigFile: wasi-wast.config
//#MappedDirectory: $temp:/temp
//#MappedDirectory: test_fs/hamlet:/hamlet
//#ExpectedStdoutFile: path_symlink.stdout
use std::fs;
use std::io::{Read, Seek, SeekFrom};... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-wast.config
//#Stdin: Hello, world!
//#ExpectedStdoutFile: pipe_reverse.stdout
use std::io;
fn main() <|fim_suffix|>String = input.chars().rev().collect();
println!("{}", output);
}
<|fim_middle|>{
let mut input = String::new();
io::stdin().read_line(&mut input).... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>w_fd() as u32];
print!("Stderr: ");
println!(
"{}",
if poll(fds.as_slice(), &[false], &[true]).is_ok() {
"OK"
} else {
"ERROR"
}
);
}
#[cfg(not(target... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>se std::fs;
use std::io::Read;
// NOTE: This program is no longer a quine because we want to sandbox these tests to `test_fs`, in the future
// `test_fs` will be implicit.
fn main() {
let mut this_file =
fs::File::open("test_fs/hamlet/act1/scene2.txt").expect("could not find src file");
l... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>ue
use std::io::Read;
fn main() {
let sym_link_path = "test_fs/hamlet/bookmarks/2019-07-16";
let p = std::path::Path::new(sym_link_path);
eprintln!("{:?}", &p);
println!("{}", p.exists());
let link_path = std::fs::read_link(sym_link_path).expect("Could not read link");
println!(... | fim | wasmerio/wasmer | rust |
//#AbstractConfigFile: wasi-wast.config
//#FileSystems: host
//#MappedDirectory: /dev:/dev
//#ExpectedStdoutFile: unix_open_special_files.stdout
//#UnixOnly: true
use std::fs;
use std::io::Write;
fn main() {
let mut f = fs::OpenOptions::new()
.write(true)
.open("/dev/null")
.unwrap();
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//#AbstractConfigFile: wasi-wast.config
//#MappedDirectory: test_fs/ha<|fim_suffix|> for path_str in &start {
out.push(path_str.to_string());
}
}
out.push("ROOT IS SAFE".to_string());
out
};
#[cfg(target_os = "wasi")]
let results = {
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>alt_path).unwrap());
fs::remove_file(path).unwrap();
let file_path = std::path::Path::new(path);
if file_path.exists() {
println!("file is here");
} else {
println!("file is gone")
}
}
<|fim_prefix|>//#AbstractConfigFile: wasi-wast.config
//#MappedDirectory: test_fs/ha... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>#!/usr/bin/env python3
#
# Wasmer maps JIT-compiled code directly into memory, so resolving function names
# from an instruction pointer (IP) address is not straightforward. Use
# `--profiler=perfmap`, then run this script to look up the function name and
# offset from the generated map file (`/tmp/perf-*... | fim | wasmerio/wasmer | python |
<|fim_prefix|>#! /usr/bin/env python3
from itertools import takewhile
import os
import time
import sys
import subprocess
import tempfile
import datetime
import re
RELEASE_VERSION = ""
DATE = datetime.date.today().strftime("%d/%m/%Y")
SIGNOFF_REVIEWER = "Arshia001"
TAG = "main"
RELEASE_SUBMODULES = ("lib/napi",)
if l... | fim | wasmerio/wasmer | python |
#! /usr/bin/env python3
"""This is a script for publishing the wasmer crates to crates.io.
It should be run in the root of wasmer like `python3 scripts/publish.py --help`.
Please lint with pylint and format with black.
$ pylint scripts/publish.py
--------------------------------------------------------------------
... | fim | wasmerio/wasmer | python |
<|fim_prefix|>#!/usr/bin/python
import os
import re
PREVIOUS_VERSION = "7.2.0-alpha.2"
NEXT_VERSION = "7.2.0-alpha.3"
def make_prerelease_version(version: str) -> str:
parts = version.split(".", 2)
if len(parts) != 3:
raise ValueError(f"Invalid version format: {version} - {parts}")
major, minor,... | fim | wasmerio/wasmer | python |
<|fim_prefix|>#!/usr/bin/env python3
# /// script
# dependencies = [
# "termcolor",
# ]
# ///
"""Run Wasmer with perf/perfmap and annotate hot JIT functions.
The script profiles a Wasmer run with Linux perf, captures JIT symbol mappings from the latest /tmp/perf-*.map,
and converts perf.data to JSON for analysis. ... | fim | wasmerio/wasmer | python |
<|fim_prefix|>#include <assert.h>
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <wasi/api.h>
#include <wasi/api_wasix.h>
#ifndef __WASI_SOCK_RECV_INPUT_DONT_WAIT
#define __WASI_SOCK_RECV_INPUT_DONT_WAIT ((__wasi_riflags_t)(1 << 3))
#endif
static int failure... | fim | wasmerio/wasmer | c |
use std::{fs, path::PathBuf};
use anyhow::Result;
use wasmer::Module;
use wasmer_types::Features;
const ARTIFACT_FILES: [&str; 3] = ["bash.wasm", "cowsay.wasm", "python-3.11.3.wasm"];
#[compiler_test(artifact)]
fn artifact_serialization_roundtrip(config: crate::Config) -> Result<()> {
for file_name in ARTIFACT_... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use std::path::PathBuf;
use std::sync::Arc;
use wasmer::sys::Features;
use wasmer::{
Store,
sys::{CompilerConfig, ModuleMiddleware},
};
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Compiler {
LLVM,
Cranelift,
Singlepass,
V8,
}
#[derive(Clone)]
pub struct Config {
pub compi... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>d") =>
{
// Skip the test in that case.
return Ok(());
}
Ok(module) => module,
Err(e) => return Err(e.into()),
};
let first = module.serialize()?;
// compile for second time
let module = Module::new(&store, wasm)?;
let second = m... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>odule, &imports! {})?;
instance.exports.get_memory("memory")?.clone()
};
let wat = r#"(module
(import "env" "memory" (memory $mem 1) )
(func $get_at (type $get_at_t) (param $idx i32) (result i32)
(i32.load (local.get $idx)))
(type $get_at_t (func (param i32) (result i32)... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>at case.
return;
}
Ok(module) => module,
_ => unreachable!(),
};
let instance = Instance::new(&mut store, &module, &imports! {}).unwrap();
let result = instance
.exports
.get_function("f")
.unwrap()
.call(&mut store, &[])
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! This test suite does all the tests that involve any compiler
//! implementation, such as: singlepass, cranelift or llvm depending
//! on wh<|fim_suffix|>od typed_functions;
mod wast;
pub use crate::config::{Compiler, Config};
pub use crate::wast::run_wast;
<|fim_middle|>at's available on the target.
... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>local.set $l0
loop $L1
local.get $l0
local.get $p0
i32.lt_s
i32.eqz
br_if $B0
local.get $l0
i32.const 1
i32.rem_s
i32.const 0
i32.eq
if $I2
local.... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>leMiddleware>,
]);
let mut store = config.store();
let wat = r#"(module
(func (export "add") (param i32 i32) (result i32)
(i32.add (local.get 0)
(local.get 1)))
)"#;
let module = Module::new(&store, wat).unwrap();
let import_object = imports! {};
... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>//! Testing the imports with different provided functions.
//! This tests checks that the provided functions (both native and
//! dynamic ones) work properly.
macro_rules! mvr_test {
($test_name:ident, $( $result_type:ty ),* ) => {
mod $test_name {
use wasmer::*;
use c... | fim | wasmerio/wasmer | rust |
use anyhow::Result;
use std::sync::{Arc, Mutex};
use wasmer::{sys::NativeEngineExt, wat2wasm};
use wasmer_types::{CompilationProgressCallback, CompileError, UserAbort};
const SIMPLE_WAT: &str = r#"(module
(import "env" "div" (func $div (param i32 i32) (result i32)))
(func (export "add") (param i32 i32) (result i3... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>
let headless_store = config.headless_store();
let deserialized_module = unsafe { Module::deserialize(&headless_store, serialized_bytes)? };
assert_eq!(deserialized_module.name(), Some("name"));
assert_eq!(
deserialized_module.exports().collect::<Vec<_>>(),
module.exports()... | fim | wasmerio/wasmer | rust |
<|fim_prefix|>use anyhow::Result;
use std::panic::{self, AssertUnwindSafe};
use wasmer::*;
use crate::Compiler;
#[compiler_test(traps)]
fn test_trap_return(config: crate::Config) -> Result<()> {
let mut store = config.store();
let wat = r#"
(module
(func $hello (import "" "hello"))
(fu... | fim | wasmerio/wasmer | rust |
<|fim_suffix|>e> {
Ok((d * 4.0, c * 3.0, b * 2, a))
}
#[allow(clippy::too_many_arguments)]
fn long_f(
a: u32,
b: u32,
c: u32,
d: u32,
e: u32,
f: u16,
g: u64,
h: u64,
i: u16,
j: u32,
) -> (u32, u64, u32) {
(
... | fim | wasmerio/wasmer | rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.