Osutil tests fail on golang 1.9

Hey, just a heads-up (probably mostly interesting to @mvo on artful)

[zyga@archlinux osutil]$ go version
go version go1.9 linux/amd64
[zyga@archlinux osutil]$ go test

----------------------------------------------------------------------
FAIL: exec_test.go:200: execSuite.TestStreamCommandHappy

exec_test.go:210:
    c.Check(wrf.(*os.File).Close(), Equals, syscall.EINVAL) // i.e. already closed
... obtained *os.PathError = &os.PathError{Op:"close", Path:"|0", Err:(*errors.errorString)(0xc420010160)} ("close |0: file already closed")
... expected syscall.Errno = 0x16 ("invalid argument")


----------------------------------------------------------------------
FAIL: exec_test.go:214: execSuite.TestStreamCommandSad

exec_test.go:224:
    c.Check(wrf.(*os.File).Close(), Equals, syscall.EINVAL) // i.e. already closed
... obtained *os.PathError = &os.PathError{Op:"close", Path:"|0", Err:(*errors.errorString)(0xc420010160)} ("close |0: file already closed")
... expected syscall.Errno = 0x16 ("invalid argument")

OOPS: 97 passed, 2 FAILED
--- FAIL: Test (1.43s)
FAIL
exit status 1
FAIL	github.com/snapcore/snapd/osutil	1.436s
[zyga@archlinux osutil]$ 

Iā€™m trying to understand why it fails and to fix it. I will have to do it to release snapd 2.27.6 for Arch which just got a new golang stack.

Thanks @zyga-snapd - fwiw, artful has 1.8. This looks like the error that go reports on Close() is more meaningful now. Instead of just returning the syscall error directly it seems to wrap it now but the error is the same. This makes the test slightly cumbersome of course :confused:

1 Like

This is now fixed with https://github.com/snapcore/snapd/pull/3888