Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit ed0f100

Browse files
author
Pat Hickey
committed
rejigger test generation and suites
fix the build and macros, separate wasi test suite from "command" test suite, test suite for preview 1 should always panic
1 parent e8cf28b commit ed0f100

File tree

9 files changed

+818
-355
lines changed

9 files changed

+818
-355
lines changed

Cargo.lock

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ members = [
88
"verify",
99
"host",
1010
"test-programs",
11+
"test-programs/command-tests",
1112
"test-programs/wasi-tests",
1213
"test-programs/reactor-tests",
1314
"wasi-common",

host/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ tokio = { version = "1", features = ["full"] }
1818
[dev-dependencies]
1919
tracing = { workspace = true }
2020
cap-rand = { workspace = true }
21-
test-programs-macros = { path = "../test-programs/macros" }
21+
test-programs = { path = "../test-programs" }
2222
test-log = { version = "0.2", default-features = false, features = ["trace"] }
2323
tempfile = "3.3.0"
2424
lazy_static = "1"

host/tests/command.rs

Lines changed: 1 addition & 273 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,7 @@ lazy_static::lazy_static! {
3131
};
3232
}
3333
// uses ENGINE, creates a fn get_component(&str) -> Component
34-
test_programs_macros::command_components!();
35-
36-
// A bunch of these test cases are expected to fail. We wrap up their execution in this
37-
// function so that we see if changes make them start passing.
38-
// Note that we need to be careful not to check in any tests that panic for this approach
39-
// to work.
40-
fn expect_fail(r: Result<()>) -> Result<()> {
41-
match r {
42-
Ok(_) => Err(anyhow::anyhow!("expected failure")),
43-
Err(_) => Ok(()),
44-
}
45-
}
34+
test_programs::command_tests_components!();
4635

4736
struct CommandCtx {
4837
table: Table,
@@ -436,262 +425,6 @@ async fn default_clocks() -> Result<()> {
436425
.map_err(|()| anyhow::anyhow!("command returned with failing exit status"))
437426
}
438427

439-
async fn run_with_temp_dir(component: &str) -> Result<()> {
440-
let mut builder = WasiCtxBuilder::new();
441-
442-
if cfg!(windows) {
443-
builder = builder
444-
.push_env("ERRNO_MODE_WINDOWS", "1")
445-
.push_env("NO_FDFLAGS_SYNC_SUPPORT", "1")
446-
.push_env("NO_DANGLING_FILESYSTEM", "1")
447-
.push_env("NO_RENAME_DIR_TO_EMPTY_DIR", "1");
448-
}
449-
if cfg!(all(unix, not(target_os = "macos"))) {
450-
builder = builder.push_env("ERRNO_MODE_UNIX", "1");
451-
}
452-
if cfg!(target_os = "macos") {
453-
builder = builder.push_env("ERRNO_MODE_MACOS", "1");
454-
}
455-
456-
let dir = tempfile::tempdir()?;
457-
let open_dir = Dir::open_ambient_dir(dir.path(), ambient_authority())?;
458-
459-
let mut table = Table::new();
460-
let wasi = builder
461-
.preopened_dir(open_dir, "/foo")
462-
.set_args(&["program", "/foo"])
463-
.build(&mut table)?;
464-
465-
let (mut store, command) =
466-
instantiate(get_component(component), CommandCtx { table, wasi }).await?;
467-
468-
command
469-
.call_main(&mut store)
470-
.await?
471-
.map_err(|()| anyhow::anyhow!("command returned with failing exit status"))
472-
}
473-
474-
#[test_log::test(tokio::test)]
475-
async fn big_random_buf() -> Result<()> {
476-
run_with_temp_dir("big_random_buf").await
477-
}
478-
479-
#[test_log::test(tokio::test)]
480-
async fn clock_time_get() -> Result<()> {
481-
run_with_temp_dir("clock_time_get").await
482-
}
483-
484-
#[test_log::test(tokio::test)]
485-
async fn close_preopen() -> Result<()> {
486-
run_with_temp_dir("close_preopen").await
487-
}
488-
489-
#[test_log::test(tokio::test)]
490-
async fn overwrite_preopen() -> Result<()> {
491-
run_with_temp_dir("overwrite_preopen").await
492-
}
493-
494-
#[test_log::test(tokio::test)]
495-
async fn dangling_fd() -> Result<()> {
496-
run_with_temp_dir("dangling_fd").await
497-
}
498-
499-
#[test_log::test(tokio::test)]
500-
async fn dangling_symlink() -> Result<()> {
501-
run_with_temp_dir("dangling_symlink").await
502-
}
503-
504-
#[test_log::test(tokio::test)]
505-
async fn directory_seek() -> Result<()> {
506-
run_with_temp_dir("directory_seek").await
507-
}
508-
509-
#[test_log::test(tokio::test)]
510-
async fn fd_advise() -> Result<()> {
511-
run_with_temp_dir("fd_advise").await
512-
}
513-
514-
#[test_log::test(tokio::test)]
515-
async fn fd_filestat_get() -> Result<()> {
516-
run_with_temp_dir("fd_filestat_get").await
517-
}
518-
519-
#[test_log::test(tokio::test)]
520-
async fn fd_filestat_set() -> Result<()> {
521-
run_with_temp_dir("fd_filestat_set").await
522-
}
523-
524-
#[test_log::test(tokio::test)]
525-
async fn fd_flags_set() -> Result<()> {
526-
run_with_temp_dir("fd_flags_set").await
527-
}
528-
529-
#[test_log::test(tokio::test)]
530-
async fn fd_readdir() -> Result<()> {
531-
run_with_temp_dir("fd_readdir").await
532-
}
533-
534-
#[test_log::test(tokio::test)]
535-
async fn file_allocate() -> Result<()> {
536-
run_with_temp_dir("file_allocate").await
537-
}
538-
539-
#[test_log::test(tokio::test)]
540-
async fn file_pread_pwrite() -> Result<()> {
541-
run_with_temp_dir("file_pread_pwrite").await
542-
}
543-
544-
#[test_log::test(tokio::test)]
545-
async fn file_seek_tell() -> Result<()> {
546-
run_with_temp_dir("file_seek_tell").await
547-
}
548-
549-
#[test_log::test(tokio::test)]
550-
async fn file_truncation() -> Result<()> {
551-
run_with_temp_dir("file_truncation").await
552-
}
553-
554-
#[test_log::test(tokio::test)]
555-
async fn file_unbuffered_write() -> Result<()> {
556-
run_with_temp_dir("file_unbuffered_write").await
557-
}
558-
559-
#[test_log::test(tokio::test)]
560-
async fn interesting_paths() -> Result<()> {
561-
if cfg!(windows) {
562-
expect_fail(run_with_temp_dir("interesting_paths").await)
563-
} else {
564-
run_with_temp_dir("interesting_paths").await
565-
}
566-
}
567-
568-
#[test_log::test(tokio::test)]
569-
async fn isatty() -> Result<()> {
570-
run_with_temp_dir("isatty").await
571-
}
572-
573-
#[test_log::test(tokio::test)]
574-
async fn nofollow_errors() -> Result<()> {
575-
run_with_temp_dir("nofollow_errors").await
576-
}
577-
578-
#[test_log::test(tokio::test)]
579-
async fn path_exists() -> Result<()> {
580-
run_with_temp_dir("path_exists").await
581-
}
582-
583-
#[test_log::test(tokio::test)]
584-
async fn path_filestat() -> Result<()> {
585-
run_with_temp_dir("path_filestat").await
586-
}
587-
588-
#[test_log::test(tokio::test)]
589-
async fn path_link() -> Result<()> {
590-
run_with_temp_dir("path_link").await
591-
}
592-
593-
#[test_log::test(tokio::test)]
594-
async fn path_open_create_existing() -> Result<()> {
595-
run_with_temp_dir("path_open_create_existing").await
596-
}
597-
598-
#[test_log::test(tokio::test)]
599-
async fn path_open_dirfd_not_dir() -> Result<()> {
600-
run_with_temp_dir("path_open_dirfd_not_dir").await
601-
}
602-
603-
#[test_log::test(tokio::test)]
604-
async fn path_open_missing() -> Result<()> {
605-
run_with_temp_dir("path_open_missing").await
606-
}
607-
608-
#[test_log::test(tokio::test)]
609-
async fn path_rename() -> Result<()> {
610-
run_with_temp_dir("path_rename").await
611-
}
612-
613-
#[test_log::test(tokio::test)]
614-
async fn path_rename_dir_trailing_slashes() -> Result<()> {
615-
run_with_temp_dir("path_rename_dir_trailing_slashes").await
616-
}
617-
618-
#[test_log::test(tokio::test)]
619-
async fn path_rename_file_trailing_slashes() -> Result<()> {
620-
// renaming a file with trailing slash in destination name expected to fail, but succeeds: line 18
621-
expect_fail(run_with_temp_dir("path_rename_file_trailing_slashes").await)
622-
}
623-
624-
#[test_log::test(tokio::test)]
625-
async fn path_symlink_trailing_slashes() -> Result<()> {
626-
run_with_temp_dir("path_symlink_trailing_slashes").await
627-
}
628-
629-
#[test_log::test(tokio::test)]
630-
async fn poll_oneoff_files() -> Result<()> {
631-
if cfg!(windows) {
632-
expect_fail(run_with_temp_dir("poll_oneoff_files").await)
633-
} else {
634-
run_with_temp_dir("poll_oneoff_files").await
635-
}
636-
}
637-
638-
#[test_log::test(tokio::test)]
639-
async fn poll_oneoff_stdio() -> Result<()> {
640-
expect_fail(run_with_temp_dir("poll_oneoff_stdio").await)
641-
}
642-
643-
#[test_log::test(tokio::test)]
644-
async fn readlink() -> Result<()> {
645-
run_with_temp_dir("readlink").await
646-
}
647-
648-
#[test_log::test(tokio::test)]
649-
async fn remove_directory_trailing_slashes() -> Result<()> {
650-
// removing a directory with a trailing slash in the path succeeded under preview 1,
651-
// fails now returning INVAL
652-
expect_fail(run_with_temp_dir("remove_directory_trailing_slashes").await)
653-
}
654-
655-
#[test_log::test(tokio::test)]
656-
async fn remove_nonempty_directory() -> Result<()> {
657-
run_with_temp_dir("remove_nonempty_directory").await
658-
}
659-
660-
#[test_log::test(tokio::test)]
661-
async fn renumber() -> Result<()> {
662-
run_with_temp_dir("renumber").await
663-
}
664-
665-
#[test_log::test(tokio::test)]
666-
async fn sched_yield() -> Result<()> {
667-
run_with_temp_dir("sched_yield").await
668-
}
669-
670-
#[test_log::test(tokio::test)]
671-
async fn stdio() -> Result<()> {
672-
run_with_temp_dir("stdio").await
673-
}
674-
675-
#[test_log::test(tokio::test)]
676-
async fn symlink_create() -> Result<()> {
677-
run_with_temp_dir("symlink_create").await
678-
}
679-
680-
#[test_log::test(tokio::test)]
681-
async fn symlink_filestat() -> Result<()> {
682-
run_with_temp_dir("symlink_filestat").await
683-
}
684-
685-
#[test_log::test(tokio::test)]
686-
async fn symlink_loop() -> Result<()> {
687-
run_with_temp_dir("symlink_loop").await
688-
}
689-
690-
#[test_log::test(tokio::test)]
691-
async fn unlink_file_trailing_slashes() -> Result<()> {
692-
run_with_temp_dir("unlink_file_trailing_slashes").await
693-
}
694-
695428
#[test_log::test(tokio::test)]
696429
async fn export_cabi_realloc() -> Result<()> {
697430
let mut table = Table::new();
@@ -734,8 +467,3 @@ async fn read_only() -> Result<()> {
734467
.await?
735468
.map_err(|()| anyhow::anyhow!("command returned with failing exit status"))
736469
}
737-
738-
#[test_log::test(tokio::test)]
739-
async fn dir_fd_op_failures() -> Result<()> {
740-
run_with_temp_dir("dir_fd_op_failures").await
741-
}

host/tests/reactor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ lazy_static::lazy_static! {
2020
}
2121

2222
// uses ENGINE, creates a fn get_component(&str) -> Component
23-
test_programs_macros::reactor_components!();
23+
test_programs::reactor_tests_components!();
2424

2525
wasmtime::component::bindgen!({
2626
path: "../test-programs/reactor-tests/wit",

0 commit comments

Comments
 (0)