wasi: improve stdin support for nonblocking, fix stdout (#1542)

Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
This commit is contained in:
Edoardo Vacchi
2023-06-29 01:51:23 +02:00
committed by GitHub
parent df428249a3
commit 39f2ff23a6
7 changed files with 107 additions and 35 deletions

View File

@@ -69,6 +69,17 @@ type stdioFile struct {
st fsapi.Stat_t
}
// SetAppend implements File.SetAppend
func (f *stdioFile) SetAppend(bool) syscall.Errno {
// Ignore for stdio.
return 0
}
// IsAppend implements File.SetAppend
func (f *stdioFile) IsAppend() bool {
return true
}
// IsDir implements File.IsDir
func (f *stdioFile) IsDir() (bool, syscall.Errno) {
return false, 0

View File

@@ -131,6 +131,16 @@ func TestFileSetAppend(t *testing.T) {
requireFileContent("wazero6789wazero")
}
func TestStdioFile_SetAppend(t *testing.T) {
// SetAppend should not affect Stdio.
file, err := NewStdioFile(false, os.Stdout)
require.NoError(t, err)
errno := file.SetAppend(true)
require.EqualErrno(t, 0, errno)
_, errno = file.Write([]byte{})
require.EqualErrno(t, 0, errno)
}
func TestFileIno(t *testing.T) {
tmpDir := t.TempDir()
dirFS, embedFS, mapFS := dirEmbedMapFS(t, tmpDir)