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

flakes #48

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions imports/wasi_snapshot_preview1/testdata/zig-cc/wasi.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ void main_nonblock(char* fpath) {
ssize_t newLen = 0;
while (newLen == 0) {
newLen = read(fd, buf, sizeof(buf));
if strlen(buf) == 0 {
newLen = 0;
}
if (errno == EAGAIN || newLen == 0) {
printf(".");
nanosleep(&tim , &tim2) ;
Expand Down
25 changes: 10 additions & 15 deletions internal/sysfs/poll_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func TestPoll_Windows(t *testing.T) {
r, w, err := os.Pipe()
require.NoError(t, err)
rh := syscall.Handle(r.Fd())
wh := syscall.Handle(w.Fd())

// Ensure the pipe has no data.
n, err := peekNamedPipe(rh)
Expand All @@ -45,8 +44,8 @@ func TestPoll_Windows(t *testing.T) {
// Write to the channel.
msg, err := syscall.ByteSliceFromString("test\n")
require.NoError(t, err)
_, err = syscall.Write(wh, msg)
require.NoError(t, err)
_, err = write(w, msg)
require.EqualErrno(t, 0, err)

// Ensure the pipe has data.
n, err = peekNamedPipe(rh)
Expand Down Expand Up @@ -144,13 +143,12 @@ func TestPoll_Windows(t *testing.T) {
r, w, err := os.Pipe()
require.NoError(t, err)
fds := []pollFd{{fd: r.Fd(), events: _POLLIN}}
wh := syscall.Handle(w.Fd())

// Write to the channel immediately.
msg, err := syscall.ByteSliceFromString("test\n")
require.NoError(t, err)
_, err = syscall.Write(wh, msg)
require.NoError(t, err)
_, err = write(w, msg)
require.EqualErrno(t, 0, err)

// Verify that the write is reported.
n, err := _poll(fds, 0)
Expand All @@ -173,7 +171,6 @@ func TestPoll_Windows(t *testing.T) {
t.Run("poll should wait forever when duration is nil", func(t *testing.T) {
r, w, err := os.Pipe()
require.NoError(t, err)
wh := syscall.Handle(w.Fd())

ch := make(chan result, 1)
go pollToChannel(r.Fd(), -1, ch)
Expand All @@ -185,8 +182,8 @@ func TestPoll_Windows(t *testing.T) {
// Write a message to the pipe.
msg, err := syscall.ByteSliceFromString("test\n")
require.NoError(t, err)
_, err = syscall.Write(wh, msg)
require.NoError(t, err)
_, err = write(w, msg)
require.EqualErrno(t, 0, err)

// Ensure that the write occurs (panic after an arbitrary timeout).
select {
Expand All @@ -201,7 +198,6 @@ func TestPoll_Windows(t *testing.T) {
t.Run("poll should wait for the given duration", func(t *testing.T) {
r, w, err := os.Pipe()
require.NoError(t, err)
wh := syscall.Handle(w.Fd())

ch := make(chan result, 1)
go pollToChannel(r.Fd(), 500, ch)
Expand All @@ -213,8 +209,8 @@ func TestPoll_Windows(t *testing.T) {
// Write a message to the pipe.
msg, err := syscall.ByteSliceFromString("test\n")
require.NoError(t, err)
_, err = syscall.Write(wh, msg)
require.NoError(t, err)
_, err = write(w, msg)
require.EqualErrno(t, 0, err)

// Ensure that the write occurs before the timer expires.
select {
Expand Down Expand Up @@ -242,7 +238,6 @@ func TestPoll_Windows(t *testing.T) {
t.Run("poll should return when a write occurs before the given duration", func(t *testing.T) {
r, w, err := os.Pipe()
require.NoError(t, err)
wh := syscall.Handle(w.Fd())

ch := make(chan result, 1)
go pollToChannel(r.Fd(), 800, ch)
Expand All @@ -252,8 +247,8 @@ func TestPoll_Windows(t *testing.T) {

msg, err := syscall.ByteSliceFromString("test\n")
require.NoError(t, err)
_, err = syscall.Write(wh, msg)
require.NoError(t, err)
_, err = write(w, msg)
require.EqualErrno(t, 0, err)

res := <-ch
require.Zero(t, res.err)
Expand Down
Loading