Fix wiggle trace example

This commit is contained in:
Alex Crichton
2021-02-17 14:56:00 -08:00
committed by Andrew Brown
parent 26e9ea433e
commit 136755ade2

View File

@@ -15,15 +15,14 @@ pub enum RichError {
// trivial function. // trivial function.
wiggle::from_witx!({ wiggle::from_witx!({
witx_literal: " witx_literal: "
(typename $errno (enum u8 $ok $invalid_arg $picket_line)) (typename $errno (enum (@witx tag u8) $ok $invalid_arg $picket_line))
(typename $s (struct (field $f1 (@witx usize)) (field $f2 (@witx pointer u8)))) (typename $s (record (field $f1 (@witx usize)) (field $f2 (@witx pointer u8))))
(typename $t (struct (field $f1 u32) (field $f2 f32))) (typename $t (record (field $f1 u32) (field $f2 f32)))
(module $one_error_conversion (module $one_error_conversion
(@interface func (export \"foo\") (@interface func (export \"foo\")
(param $strike u32) (param $strike u32)
(param $s $s) (param $s $s)
(result $err $errno) (result $err (expected $t (error $errno)))))
(result $t $t)))
", ",
ctx: WasiCtx, ctx: WasiCtx,
errors: { errno => RichError }, errors: { errno => RichError },
@@ -90,7 +89,7 @@ fn main() {
let r0 = one_error_conversion::foo(&ctx, &host_memory, 0, 0, 8); let r0 = one_error_conversion::foo(&ctx, &host_memory, 0, 0, 8);
assert_eq!( assert_eq!(
r0, r0,
Ok(i32::from(types::Errno::Ok)), Ok(types::Errno::Ok as i32),
"Expected return value for strike=0" "Expected return value for strike=0"
); );
assert!(ctx.log.borrow().is_empty(), "No error log for strike=0"); assert!(ctx.log.borrow().is_empty(), "No error log for strike=0");
@@ -99,7 +98,7 @@ fn main() {
let r1 = one_error_conversion::foo(&ctx, &host_memory, 1, 0, 8); let r1 = one_error_conversion::foo(&ctx, &host_memory, 1, 0, 8);
assert_eq!( assert_eq!(
r1, r1,
Ok(i32::from(types::Errno::PicketLine)), Ok(types::Errno::PicketLine as i32),
"Expected return value for strike=1" "Expected return value for strike=1"
); );
assert_eq!( assert_eq!(
@@ -112,7 +111,7 @@ fn main() {
let r2 = one_error_conversion::foo(&ctx, &host_memory, 2, 0, 8); let r2 = one_error_conversion::foo(&ctx, &host_memory, 2, 0, 8);
assert_eq!( assert_eq!(
r2, r2,
Ok(i32::from(types::Errno::InvalidArg)), Ok(types::Errno::InvalidArg as i32),
"Expected return value for strike=2" "Expected return value for strike=2"
); );
assert_eq!( assert_eq!(