1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401
|
use super::*;
use std::path::Path;
use test_programs_artifacts::*;
use wasmtime_wasi::add_to_linker_async;
use wasmtime_wasi::bindings::Command;
async fn run(path: &str, inherit_stdio: bool) -> Result<()> {
let path = Path::new(path);
let name = path.file_stem().unwrap().to_str().unwrap();
let engine = test_programs_artifacts::engine(|config| {
config.async_support(true);
});
let mut linker = Linker::new(&engine);
add_to_linker_async(&mut linker)?;
let (mut store, _td) = store(&engine, name, |builder| {
if inherit_stdio {
builder.inherit_stdio();
}
})?;
let component = Component::from_file(&engine, path)?;
let command = Command::instantiate_async(&mut store, &component, &linker).await?;
command
.wasi_cli_run()
.call_run(&mut store)
.await?
.map_err(|()| anyhow::anyhow!("run returned a failure"))
}
foreach_preview1!(assert_test_exists);
foreach_preview2!(assert_test_exists);
// Below here is mechanical: there should be one test for every binary in
// wasi-tests.
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_big_random_buf() {
run(PREVIEW1_BIG_RANDOM_BUF_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_clock_time_get() {
run(PREVIEW1_CLOCK_TIME_GET_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_close_preopen() {
run(PREVIEW1_CLOSE_PREOPEN_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_dangling_fd() {
run(PREVIEW1_DANGLING_FD_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_dangling_symlink() {
run(PREVIEW1_DANGLING_SYMLINK_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_directory_seek() {
run(PREVIEW1_DIRECTORY_SEEK_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_dir_fd_op_failures() {
run(PREVIEW1_DIR_FD_OP_FAILURES_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_fd_advise() {
run(PREVIEW1_FD_ADVISE_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_fd_filestat_get() {
run(PREVIEW1_FD_FILESTAT_GET_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_fd_filestat_set() {
run(PREVIEW1_FD_FILESTAT_SET_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_fd_flags_set() {
run(PREVIEW1_FD_FLAGS_SET_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_fd_readdir() {
run(PREVIEW1_FD_READDIR_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_file_allocate() {
run(PREVIEW1_FILE_ALLOCATE_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_file_pread_pwrite() {
run(PREVIEW1_FILE_PREAD_PWRITE_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_file_read_write() {
run(PREVIEW1_FILE_READ_WRITE_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_file_seek_tell() {
run(PREVIEW1_FILE_SEEK_TELL_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_file_truncation() {
run(PREVIEW1_FILE_TRUNCATION_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_file_unbuffered_write() {
run(PREVIEW1_FILE_UNBUFFERED_WRITE_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_interesting_paths() {
run(PREVIEW1_INTERESTING_PATHS_COMPONENT, true)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_regular_file_isatty() {
run(PREVIEW1_REGULAR_FILE_ISATTY_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_nofollow_errors() {
run(PREVIEW1_NOFOLLOW_ERRORS_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_overwrite_preopen() {
run(PREVIEW1_OVERWRITE_PREOPEN_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_path_exists() {
run(PREVIEW1_PATH_EXISTS_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_path_filestat() {
run(PREVIEW1_PATH_FILESTAT_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_path_link() {
run(PREVIEW1_PATH_LINK_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_path_open_create_existing() {
run(PREVIEW1_PATH_OPEN_CREATE_EXISTING_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_path_open_read_write() {
run(PREVIEW1_PATH_OPEN_READ_WRITE_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_path_open_dirfd_not_dir() {
run(PREVIEW1_PATH_OPEN_DIRFD_NOT_DIR_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_path_open_missing() {
run(PREVIEW1_PATH_OPEN_MISSING_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_path_open_nonblock() {
run(PREVIEW1_PATH_OPEN_NONBLOCK_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_path_rename_dir_trailing_slashes() {
run(PREVIEW1_PATH_RENAME_DIR_TRAILING_SLASHES_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_path_rename() {
run(PREVIEW1_PATH_RENAME_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_path_symlink_trailing_slashes() {
run(PREVIEW1_PATH_SYMLINK_TRAILING_SLASHES_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_poll_oneoff_files() {
run(PREVIEW1_POLL_ONEOFF_FILES_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_poll_oneoff_stdio() {
run(PREVIEW1_POLL_ONEOFF_STDIO_COMPONENT, true)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_readlink() {
run(PREVIEW1_READLINK_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_remove_directory() {
run(PREVIEW1_REMOVE_DIRECTORY_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_remove_nonempty_directory() {
run(PREVIEW1_REMOVE_NONEMPTY_DIRECTORY_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_renumber() {
run(PREVIEW1_RENUMBER_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_sched_yield() {
run(PREVIEW1_SCHED_YIELD_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_stdio() {
run(PREVIEW1_STDIO_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_stdio_isatty() {
// If the test process is setup such that stdio is a terminal:
if test_programs_artifacts::stdio_is_terminal() {
// Inherit stdio, test asserts each is not tty:
run(PREVIEW1_STDIO_ISATTY_COMPONENT, true).await.unwrap()
}
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_stdio_not_isatty() {
// Don't inherit stdio, test asserts each is not tty:
run(PREVIEW1_STDIO_NOT_ISATTY_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_symlink_create() {
run(PREVIEW1_SYMLINK_CREATE_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_symlink_filestat() {
run(PREVIEW1_SYMLINK_FILESTAT_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_symlink_loop() {
run(PREVIEW1_SYMLINK_LOOP_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_unlink_file_trailing_slashes() {
run(PREVIEW1_UNLINK_FILE_TRAILING_SLASHES_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_path_open_preopen() {
run(PREVIEW1_PATH_OPEN_PREOPEN_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_unicode_output() {
run(PREVIEW1_UNICODE_OUTPUT_COMPONENT, true).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_file_write() {
run(PREVIEW1_FILE_WRITE_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview1_path_open_lots() {
run(PREVIEW1_PATH_OPEN_LOTS_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview2_sleep() {
run(PREVIEW2_SLEEP_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview2_random() {
run(PREVIEW2_RANDOM_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview2_ip_name_lookup() {
run(PREVIEW2_IP_NAME_LOOKUP_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview2_tcp_sockopts() {
run(PREVIEW2_TCP_SOCKOPTS_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview2_tcp_sample_application() {
run(PREVIEW2_TCP_SAMPLE_APPLICATION_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview2_tcp_states() {
run(PREVIEW2_TCP_STATES_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview2_tcp_streams() {
run(PREVIEW2_TCP_STREAMS_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview2_tcp_bind() {
run(PREVIEW2_TCP_BIND_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview2_tcp_connect() {
run(PREVIEW2_TCP_CONNECT_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview2_udp_sockopts() {
run(PREVIEW2_UDP_SOCKOPTS_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview2_udp_sample_application() {
run(PREVIEW2_UDP_SAMPLE_APPLICATION_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview2_udp_states() {
run(PREVIEW2_UDP_STATES_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview2_udp_bind() {
run(PREVIEW2_UDP_BIND_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview2_udp_connect() {
run(PREVIEW2_UDP_CONNECT_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview2_stream_pollable_correct() {
run(PREVIEW2_STREAM_POLLABLE_CORRECT_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview2_stream_pollable_traps() {
let e = run(PREVIEW2_STREAM_POLLABLE_TRAPS_COMPONENT, false)
.await
.unwrap_err();
assert_eq!(
format!("{}", e.source().expect("trap source")),
"resource has children"
)
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview2_pollable_correct() {
run(PREVIEW2_POLLABLE_CORRECT_COMPONENT, false)
.await
.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview2_pollable_traps() {
let e = run(PREVIEW2_POLLABLE_TRAPS_COMPONENT, false)
.await
.unwrap_err();
assert_eq!(
format!("{}", e.source().expect("trap source")),
"empty poll list"
)
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview2_adapter_badfd() {
run(PREVIEW2_ADAPTER_BADFD_COMPONENT, false).await.unwrap()
}
#[test_log::test(tokio::test(flavor = "multi_thread"))]
async fn preview2_file_read_write() {
run(PREVIEW2_FILE_READ_WRITE_COMPONENT, false)
.await
.unwrap()
}
|