Browse Source

Merge pull request #1810 from Kong/fix/test-programs-tagged-unions

fix(tagged-union): changed test programs to use new tagged union
pull/1823/head
Pat Hickey 4 years ago
committed by GitHub
parent
commit
54694b8d0e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      crates/test-programs/wasi-tests/Cargo.lock
  2. 2
      crates/test-programs/wasi-tests/Cargo.toml
  3. 52
      crates/test-programs/wasi-tests/src/bin/poll_oneoff.rs
  4. 2
      crates/test-programs/wasi-tests/src/lib.rs

6
crates/test-programs/wasi-tests/Cargo.lock

@ -12,7 +12,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "wasi"
version = "0.9.0+wasi-snapshot-preview1"
version = "0.10.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@ -21,10 +21,10 @@ version = "0.17.0"
dependencies = [
"libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)",
"more-asserts 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)",
"wasi 0.10.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[metadata]
"checksum libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)" = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49"
"checksum more-asserts 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238"
"checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
"checksum wasi 0.10.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"

2
crates/test-programs/wasi-tests/Cargo.toml

@ -8,7 +8,7 @@ publish = false
[dependencies]
libc = "0.2.65"
wasi = "0.9.0"
wasi = "0.10.0"
more-asserts = "0.2.1"
# This crate is built with the wasm32-wasi target, so it's separate

52
crates/test-programs/wasi-tests/src/bin/poll_oneoff.rs

@ -40,8 +40,12 @@ unsafe fn test_timeout() {
};
let r#in = [wasi::Subscription {
userdata: CLOCK_ID,
r#type: wasi::EVENTTYPE_CLOCK,
u: wasi::SubscriptionU { clock },
u: wasi::SubscriptionU {
tag: wasi::EVENTTYPE_CLOCK,
u: wasi::SubscriptionUU {
clock
}
},
}];
let out = poll_oneoff_impl(&r#in, 1);
let event = &out[0];
@ -74,14 +78,22 @@ unsafe fn test_stdin_read() {
let r#in = [
wasi::Subscription {
userdata: CLOCK_ID,
r#type: wasi::EVENTTYPE_CLOCK,
u: wasi::SubscriptionU { clock },
u: wasi::SubscriptionU {
tag: wasi::EVENTTYPE_CLOCK,
u: wasi::SubscriptionUU {
clock
}
},
},
// Make sure that timeout is returned only once even if there are multiple read events
wasi::Subscription {
userdata: 1,
r#type: wasi::EVENTTYPE_FD_READ,
u: wasi::SubscriptionU { fd_readwrite },
u: wasi::SubscriptionU {
tag: wasi::EVENTTYPE_FD_READ,
u: wasi::SubscriptionUU {
fd_read: fd_readwrite
}
},
},
];
let out = poll_oneoff_impl(&r#in, 1);
@ -112,16 +124,20 @@ unsafe fn test_stdout_stderr_write() {
let r#in = [
wasi::Subscription {
userdata: 1,
r#type: wasi::EVENTTYPE_FD_WRITE,
u: wasi::SubscriptionU {
fd_readwrite: stdout_readwrite,
tag: wasi::EVENTTYPE_FD_WRITE,
u: wasi::SubscriptionUU {
fd_write: stdout_readwrite
},
},
},
wasi::Subscription {
userdata: 2,
r#type: wasi::EVENTTYPE_FD_WRITE,
u: wasi::SubscriptionU {
fd_readwrite: stderr_readwrite,
tag: wasi::EVENTTYPE_FD_WRITE,
u: wasi::SubscriptionUU {
fd_write: stderr_readwrite
}
},
},
];
@ -163,13 +179,21 @@ unsafe fn test_fd_readwrite(fd: wasi::Fd, error_code: wasi::Errno) {
let r#in = [
wasi::Subscription {
userdata: 1,
r#type: wasi::EVENTTYPE_FD_READ,
u: wasi::SubscriptionU { fd_readwrite },
u: wasi::SubscriptionU {
tag: wasi::EVENTTYPE_FD_READ,
u: wasi::SubscriptionUU {
fd_read: fd_readwrite
}
},
},
wasi::Subscription {
userdata: 2,
r#type: wasi::EVENTTYPE_FD_WRITE,
u: wasi::SubscriptionU { fd_readwrite },
u: wasi::SubscriptionU {
tag: wasi::EVENTTYPE_FD_WRITE,
u: wasi::SubscriptionUU {
fd_write: fd_readwrite
}
},
},
];
let out = poll_oneoff_impl(&r#in, 2);

2
crates/test-programs/wasi-tests/src/lib.rs

@ -15,7 +15,7 @@ pub fn open_scratch_directory(path: &str) -> Result<wasi::Fd, String> {
Ok(s) => s,
Err(_) => break,
};
if stat.pr_type != wasi::PREOPENTYPE_DIR {
if stat.tag != wasi::PREOPENTYPE_DIR {
continue;
}
let mut dst = Vec::with_capacity(stat.u.dir.pr_name_len);

Loading…
Cancel
Save