Commit c24b5d43 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

[release-branch.go1.7] syscall: use MNT_NOWAIT in TestGetfsstat

Fixes test failure when VMWare's shared folder filesystem is present.

MNT_NOWAIT is what the mount(8) command does.

Fixes #16937

Change-Id: Id436185f544b7069db46c8716d6a0bf580b31da0
Reviewed-on: https://go-review.googlesource.com/28550
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
Reviewed-on: https://go-review.googlesource.com/28650
Run-TryBot: Chris Broadfoot <cbro@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent dc3612e0
......@@ -7,28 +7,45 @@
package syscall_test
import (
"os/exec"
"syscall"
"testing"
)
const MNT_WAIT = 1
const MNT_NOWAIT = 2
func TestGetfsstat(t *testing.T) {
n, err := syscall.Getfsstat(nil, MNT_WAIT)
const flags = MNT_NOWAIT // see Issue 16937
n, err := syscall.Getfsstat(nil, flags)
t.Logf("Getfsstat(nil, %d) = (%v, %v)", flags, n, err)
if err != nil {
t.Fatal(err)
}
data := make([]syscall.Statfs_t, n)
n, err = syscall.Getfsstat(data, MNT_WAIT)
n2, err := syscall.Getfsstat(data, flags)
t.Logf("Getfsstat([]syscall.Statfs_t, %d) = (%v, %v)", flags, n2, err)
if err != nil {
t.Fatal(err)
}
empty := syscall.Statfs_t{}
for _, stat := range data {
if stat == empty {
t.Fatal("an empty Statfs_t struct was returned")
if n != n2 {
t.Errorf("Getfsstat(nil) = %d, but subsequent Getfsstat(slice) = %d", n, n2)
}
for i, stat := range data {
if stat == (syscall.Statfs_t{}) {
t.Errorf("index %v is an empty Statfs_t struct", i)
}
}
if t.Failed() {
for i, stat := range data[:n2] {
t.Logf("data[%v] = %+v", i, stat)
}
mount, err := exec.Command("mount").CombinedOutput()
if err != nil {
t.Logf("mount: %v\n%s", err, mount)
} else {
t.Logf("mount: %s", mount)
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment