]> Cypherpunks repositories - gostls13.git/commit
syscall: in TestDirent, make as many ReadDirent calls as are needed
authorBryan C. Mills <bcmills@google.com>
Fri, 7 Jan 2022 14:54:44 +0000 (09:54 -0500)
committerBryan Mills <bcmills@google.com>
Fri, 7 Jan 2022 21:15:14 +0000 (21:15 +0000)
commitbe26ca972d2149df09e70789fdf284da01c5e9d8
tree55032574b7b6c37cf887fb1cb17fffce81cfb1c0
parentf1596d76f488e4d82d217418df4191f34b71d117
syscall: in TestDirent, make as many ReadDirent calls as are needed

ReadDirent returns only as many directory entries as will fit in the
buffer, and each entry is variable-length — so we have no guarantee in
general that a buffer of a given arbitrary size can hold even one
entry, let alone all ten entries expected by the test.

Instead, iterate calls to ReadDirent until one of the calls returns
zero entries and no error, indicating that the directory has been read
to completion.

Fixes #37323

Change-Id: I7f1cedde7666107256604e4ea1ac13c71f22151a
Reviewed-on: https://go-review.googlesource.com/c/go/+/376334
Trust: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/syscall/dirent_test.go