-
Notifications
You must be signed in to change notification settings - Fork 34
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
WASI tests #790
WASI tests #790
Conversation
cbf1c6a
to
b6b0fa5
Compare
Codecov Report
@@ Coverage Diff @@
## master #790 +/- ##
==========================================
+ Coverage 99.10% 99.12% +0.02%
==========================================
Files 86 85 -1
Lines 13017 13010 -7
==========================================
- Hits 12900 12896 -4
+ Misses 117 114 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
|
If this way is easier, I'm fine with this. Do you have estimate how much uvwasi methods are we are going to need? |
It seems it's about one uvwasi funciton per one WASI function + some serialization functions that we may or may not want to mock. |
fff0787
to
8c58abc
Compare
21dd342
to
3d9fa22
Compare
Obeservations about serizaliation part of uvwasi:
So I think passing the memory size here is correct: Line 45 in 2ea01bc
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good.
Some additional questions:
- This seems not using GMock. Is the include even needed?
- We considered before to create separate unit tests executable for wasi, e.g.
fizzy-unittests-wasi
to decouple this subproject and its dependencies. This would also allow us to create separate directory for wasi unit tests and split these into more files.
tools/wasi/uvwasi.hpp
Outdated
class UVWASI | ||
{ | ||
public: | ||
virtual ~UVWASI(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
= default
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This produces error: 'UVWASI' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit [clang-diagnostic-weak-vtables,-warnings-as-errors]
tools/wasi/wasi.hpp
Outdated
@@ -13,6 +13,9 @@ struct Instance; | |||
|
|||
namespace wasi | |||
{ | |||
class UVWASI; | |||
extern UVWASI* uvwasi; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed for mocking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
Alternatively maybe It could be declared in wasi_test.cpp
and another time in wasi.cpp
13995b6
to
72e7826
Compare
@gumb0 can you rebase this? |
767a55e
to
39f0c06
Compare
Rebased. |
test/unittests/wasi_test.cpp
Outdated
|
||
EXPECT_TRUE(mock_uvwasi->init_called); | ||
ASSERT_TRUE(mock_uvwasi->write_fd.has_value()); | ||
EXPECT_EQ(*mock_uvwasi->write_fd, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the tests, write_fd
should be a vector too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean, WASI fd_write
calls uvwasi_fd_write
only once, with one fd
argument, and this is what the mock saves in write_fd
and the test checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the current tests, but eventually can imagine multiple calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then it would rather be vector like vector<pair<fd, write_data>>
to record all calls... not sure it's worth to complicate it now.
test/unittests/wasi_test.cpp
Outdated
/* wat2wasm | ||
(func (import "wasi_snapshot_preview1" "fd_write") (param i32 i32 i32 i32) (result i32)) | ||
(memory (export "memory") 1) | ||
(data (i32.const 0) "\00\00\01\00") ;; buf ptr - out of memory bounds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this only checks the offset against pages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the test tries to check that error value returned from uvwasi is correctly propagated. I don't think we should test all possible errors that uvwasi returns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant this only checks against exceeding memory pages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test tries to get the data to write from the address out of memory bounds (0x10000 = 65536), so this is just one possible way to make fd_write
fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay for now I think.
No description provided.