Skip to content

Commit 5141578

Browse files
authored
Fix async tests with latest wasip3 changes (#1301)
This involved deleting one test in Rust due to #1300 meaning that the previous behavior cannot be modeled in Rust at this time. Note though that this is still modeled in C which suffices for testing.
1 parent 54eac63 commit 5141578

File tree

13 files changed

+37
-86
lines changed

13 files changed

+37
-86
lines changed

tests/runtime-async/async/cancel-import/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ test_callback_code_t exports_test_async_pending_import_callback(test_event_t *ev
3535
} else {
3636
assert(event->event == TEST_EVENT_FUTURE_READ);
3737
assert(event->waitable == task->future);
38-
assert(TEST_WAITABLE_STATE(event->code) == TEST_WAITABLE_COMPLETED);
38+
assert(TEST_WAITABLE_STATE(event->code) == TEST_WAITABLE_CLOSED);
3939
assert(TEST_WAITABLE_COUNT(event->code) == 1);
4040
exports_test_async_pending_import_return();
4141
}

tests/runtime-async/async/future-cancel-write/runner.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ int main() {
5353
assert(status2 == RUNNER_SUBTASK_RETURNED);
5454

5555
status = test_future_string_cancel_write(writer);
56-
assert(RUNNER_WAITABLE_STATE(status) == RUNNER_WAITABLE_COMPLETED);
56+
assert(RUNNER_WAITABLE_STATE(status) == RUNNER_WAITABLE_CLOSED);
5757
assert(RUNNER_WAITABLE_COUNT(status) == 1);
5858

5959
test_future_string_close_writable(writer);

tests/runtime-async/async/future-cancel-write/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ void exports_test_take_then_close(exports_test_future_string_t x) {
1010
test_callback_code_t exports_test_async_read_and_drop(exports_test_future_string_t x) {
1111
test_string_t string;
1212
test_waitable_status_t status = exports_test_future_string_read(x, &string);
13-
assert(TEST_WAITABLE_STATE(status) == TEST_WAITABLE_COMPLETED);
13+
assert(TEST_WAITABLE_STATE(status) == TEST_WAITABLE_CLOSED);
1414
assert(TEST_WAITABLE_COUNT(status) == 1);
1515

1616
exports_test_future_string_close_readable(x);

tests/runtime-async/async/pending-import/runner.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ int main() {
1313
assert(subtask != 0);
1414

1515
runner_waitable_status_t status2 = test_future_void_write(writer);
16-
assert(RUNNER_WAITABLE_STATE(status2) == RUNNER_WAITABLE_COMPLETED);
16+
assert(RUNNER_WAITABLE_STATE(status2) == RUNNER_WAITABLE_CLOSED);
1717
assert(RUNNER_WAITABLE_COUNT(status2) == 1);
1818
test_future_void_close_writable(writer);
1919

tests/runtime-async/async/pending-import/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ test_callback_code_t exports_test_async_pending_import_callback(test_event_t *ev
2626
struct my_task *task = test_context_get();
2727
assert(event->event == TEST_EVENT_FUTURE_READ);
2828
assert(event->waitable == task->future);
29-
assert(TEST_WAITABLE_STATE(event->code) == TEST_WAITABLE_COMPLETED);
29+
assert(TEST_WAITABLE_STATE(event->code) == TEST_WAITABLE_CLOSED);
3030
assert(TEST_WAITABLE_COUNT(event->code) == 1);
3131
exports_test_async_pending_import_return();
3232

tests/runtime-async/async/ping-pong/runner.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ int main() {
2121
runner_string_t string_tmp;
2222
runner_string_set(&string_tmp, "hello");
2323
runner_waitable_status_t status2 = test_future_string_write(writer, &string_tmp);
24-
assert(RUNNER_WAITABLE_STATE(status2) == RUNNER_WAITABLE_COMPLETED);
24+
assert(RUNNER_WAITABLE_STATE(status2) == RUNNER_WAITABLE_CLOSED);
2525
assert(RUNNER_WAITABLE_COUNT(status2) == 1);
2626
test_future_string_close_writable(writer);
2727

@@ -39,7 +39,7 @@ int main() {
3939

4040
// Read the result from our future
4141
status2 = test_future_string_read(ping_result, &string_tmp);
42-
assert(RUNNER_WAITABLE_STATE(status2) == RUNNER_WAITABLE_COMPLETED);
42+
assert(RUNNER_WAITABLE_STATE(status2) == RUNNER_WAITABLE_CLOSED);
4343
assert(RUNNER_WAITABLE_COUNT(status2) == 1);
4444
assert(memcmp(string_tmp.ptr, "helloworld", string_tmp.len) == 0);
4545
test_future_string_close_readable(ping_result);
@@ -53,7 +53,7 @@ int main() {
5353

5454
// Write our string to the "pong" subtask
5555
status2 = test_future_string_write(writer, &string_tmp);
56-
assert(RUNNER_WAITABLE_STATE(status2) == RUNNER_WAITABLE_COMPLETED);
56+
assert(RUNNER_WAITABLE_STATE(status2) == RUNNER_WAITABLE_CLOSED);
5757
assert(RUNNER_WAITABLE_COUNT(status2) == 1);
5858
runner_string_free(&string_tmp);
5959
test_future_string_close_writable(writer);

tests/runtime-async/async/ping-pong/test.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ test_callback_code_t exports_test_async_ping_callback(test_event_t *event) {
4545
// future.
4646
assert(event->event == TEST_EVENT_FUTURE_READ);
4747
assert(event->waitable == task->future);
48-
assert(TEST_WAITABLE_STATE(event->code) == TEST_WAITABLE_COMPLETED);
48+
assert(TEST_WAITABLE_STATE(event->code) == TEST_WAITABLE_CLOSED);
4949
assert(TEST_WAITABLE_COUNT(event->code) == 1);
5050
test_waitable_join(task->future, 0);
5151
exports_test_future_string_close_readable(task->future);
@@ -83,7 +83,7 @@ test_callback_code_t exports_test_async_ping_callback(test_event_t *event) {
8383
// of the future.
8484
assert(event->event == TEST_EVENT_FUTURE_WRITE);
8585
assert(event->waitable == task->writer);
86-
assert(TEST_WAITABLE_STATE(event->code) == TEST_WAITABLE_COMPLETED);
86+
assert(TEST_WAITABLE_STATE(event->code) == TEST_WAITABLE_CLOSED);
8787
assert(TEST_WAITABLE_COUNT(event->code) == 1);
8888
test_waitable_join(task->writer, 0);
8989
exports_test_future_string_close_writable(task->writer);
@@ -134,7 +134,7 @@ test_callback_code_t exports_test_async_pong_callback(test_event_t *event) {
134134
// assert this event is a future read completion
135135
assert(event->event == TEST_EVENT_FUTURE_READ);
136136
assert(event->waitable == task->future);
137-
assert(TEST_WAITABLE_STATE(event->code) == TEST_WAITABLE_COMPLETED);
137+
assert(TEST_WAITABLE_STATE(event->code) == TEST_WAITABLE_CLOSED);
138138
assert(TEST_WAITABLE_COUNT(event->code) == 1);
139139

140140
// deallocate/destroy our future

tests/runtime-async/async/simple-future/runner.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ int main() {
3737
runner_waitable_set_wait(set, &event);
3838
assert(event.event == RUNNER_EVENT_FUTURE_WRITE);
3939
assert(event.waitable == writer);
40-
assert(RUNNER_WAITABLE_STATE(event.code) == RUNNER_WAITABLE_COMPLETED);
40+
assert(RUNNER_WAITABLE_STATE(event.code) == RUNNER_WAITABLE_CLOSED);
4141
assert(RUNNER_WAITABLE_COUNT(event.code) == 1);
4242

4343
test_future_void_close_writable(writer);

tests/runtime-async/async/simple-future/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
test_subtask_status_t exports_test_async_read_future(exports_test_future_void_t future) {
77
test_waitable_status_t status = exports_test_future_void_read(future);
8-
assert(TEST_WAITABLE_STATE(status) == TEST_WAITABLE_COMPLETED);
8+
assert(TEST_WAITABLE_STATE(status) == TEST_WAITABLE_CLOSED);
99
assert(TEST_WAITABLE_COUNT(status) == 1);
1010
exports_test_future_void_close_readable(future);
1111
exports_test_async_read_future_return();

tests/runtime-async/async/simple-stream-payload/runner.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@ int main() {
4444
assert(event.event == RUNNER_EVENT_STREAM_WRITE);
4545
assert(event.waitable == writer);
4646
assert(RUNNER_WAITABLE_STATE(event.code) == RUNNER_WAITABLE_COMPLETED);
47-
assert(RUNNER_WAITABLE_COUNT(event.code) == 1);
48-
49-
// write the second item
50-
status = test_stream_u8_write(writer, buf + 1, 1);
51-
assert(RUNNER_WAITABLE_STATE(status) == RUNNER_WAITABLE_COMPLETED);
52-
assert(RUNNER_WAITABLE_COUNT(status) == 1);
47+
assert(RUNNER_WAITABLE_COUNT(event.code) == 2);
5348

5449
// clean up the writer
5550
runner_waitable_join(writer, 0);

0 commit comments

Comments
 (0)