-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1213: Fixed WASI isatty r=syrusakbary a=syrusakbary <!-- Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test: https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests --> # Description Current WASI implementation returns a wrong response when libc `isatty` is used for `stdin`, `stdout` or `stderr`. This PR fixes it. <!-- Provide details regarding the change including motivation, links to related issues, and the context of the PR. --> # Review - [x] Add a short description of the the change to the CHANGELOG.md file Co-authored-by: Syrus <[email protected]> Co-authored-by: Syrus Akbary <[email protected]>
- Loading branch information
Showing
8 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// !!! THIS IS A GENERATED FILE !!! | ||
// ANY MANUAL EDITS MAY BE OVERWRITTEN AT ANY TIME | ||
// Files autogenerated with cargo build (build/wasitests.rs). | ||
|
||
#[test] | ||
fn test_isatty() { | ||
assert_wasi_output!( | ||
"../../wasitests/isatty.wasm", | ||
"isatty", | ||
vec![], | ||
vec![], | ||
vec![], | ||
"../../wasitests/isatty.out" | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
stdin: 1 | ||
stdout: 1 | ||
stderr: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// We don't have access to libc, so we just use isatty | ||
// as an external function | ||
// use libc::isatty; | ||
|
||
extern "C" { | ||
pub fn isatty(fd: i32) -> i32; | ||
} | ||
|
||
fn main() { | ||
#[cfg(target = "wasi")] { | ||
println!("stdin: {}", unsafe { isatty(0) }); | ||
println!("stdout: {}", unsafe { isatty(1) }); | ||
println!("stderr: {}", unsafe { isatty(2) }); | ||
} | ||
#[cfg(not(target = "wasi"))] { | ||
println!("stdin: 1"); | ||
println!("stdout: 1"); | ||
println!("stderr: 1"); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters