Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test for reading a file #64

Merged
merged 1 commit into from
Apr 27, 2024

Conversation

dierbei
Copy link
Contributor

@dierbei dierbei commented Apr 17, 2024

Please review this for me, thank you!,#59

@dierbei dierbei force-pushed the wasi-readfile-test branch 2 times, most recently from 170e483 to 19d9973 Compare April 17, 2024 11:00
Copy link
Contributor

@saza-ku saza-ku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR 🎉

I left a few comments. Just a little more!

src/wasi.zig Outdated Show resolved Hide resolved
log.fatal.printf("fd_read failed: {d}\n", .{@intFromEnum(res)});
return false;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add verification of the content?

You can use std.mem.eql to compare two strings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made changes to the original code, but I've run into a new problem.

Run the command: zig build -Dtest=true -Doptimize=ReleaseFast -Dlog-level=debug run for testing time. Some times it succeeds and some times it fails, I don't know why.

[LOG DEBUG]: WASI path_open: fd:3, dirflags:0, path_offset:4, path_length:8, oflags:0, rights_bas:0, rights_inferiting:0, fdflags:0, opened_fd_addr:0
[LOG DEBUG]: file path: test.txt
[LOG DEBUG]: WASI fd_read: fd=7 buf_iovec_addr=0xc8 vec_len=1 size_addr=0x64
[LOG DEBUG]: WASI fd_close: 7
[LOG FATAL]: Integration test passed
+ QEMU_RETURN_CODE=1
+ RETURN_CODE=0
+ exit 0
+ grep -q 'Integration test passed' build/test/output.txt
+ echo -e '\nIntegration Test PASSED!!'
[LOG DEBUG]: interrupt
[LOG INFO]: client socket test: sock_connect succeeded
[LOG DEBUG]: WASI fd_write: 4 12 2 52
[LOG DEBUG]: interrupt
[LOG DEBUG]: interrupt
[LOG DEBUG]: interrupt
[LOG INFO]: client socket test: fd_write succeeded
[LOG DEBUG]: WASI sock_getlocaladdr: 4 4 40 44
[LOG INFO]: sock_getlocaladdr failed: 112.193.56.4
+ exit 1
run ./scripts/integration-test.sh: error: the following command exited with error code 1:
./scripts/integration-test.sh 
Build Summary: 8/10 steps succeeded; 1 failed (disable with --summary none)
run transitive failure
└─ run ./scripts/integration-test.sh failure
error: the following build command failed with exit code 1:

Copy link
Contributor

@saza-ku saza-ku Apr 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh it's really strange. Does this problem occur only when adding the verification of the file content?

Copy link
Contributor Author

@dierbei dierbei Apr 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh it's really strange. Does this problem occur only when adding the verification of the file content?

It seems that the occurrence doesn't happen with the testReadfile() function, because the error still occurs after commenting.

Right now I'm not clear on what this is and may need to keep learning.

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the problem is not triggered by this PR, right?

We might need to open a new issue. But I've not come across this error, so we need to know the condition.

Does it reproduce on Codespaces?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm using devcontainer. i get the occasional error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've confirmed it reproduces on Codespaces on main branch.

So this problem is not related to this PR. I'll create a new issue and merge this PR.

@dierbei dierbei force-pushed the wasi-readfile-test branch 2 times, most recently from 0dcd273 to 12f2eee Compare April 21, 2024 08:08
submodules/lwip Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/mewz-project/mewz/actions/runs/8771224567/job/24070669535?pr=64

b413b0 doesn't seem to exist.

How am I supposed to do that? Is it ok to use this command: git submodule update --init

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will fix this.
Or, you can manually checkout to 0dcd273.

cd submodules/lwip
git checkout 0dcd273

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, you can manually checkout to 0dcd273.

root@ser300462488588:/data/mewz/submodules/lwip# git checkout 0dcd273
error: pathspec '0dcd273' did not match any file(s) known to git

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this will work

git checkout 1cc153

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's switched over. Try again.

@saza-ku
Copy link
Contributor

saza-ku commented Apr 27, 2024

@dierbei Thanks for your contribution 🎉

@saza-ku saza-ku merged commit a469e31 into mewz-project:main Apr 27, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants