syscall_plan9_test.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2018 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package syscall_test
  5. import (
  6. "syscall"
  7. "testing"
  8. )
  9. // testalias checks for aliasing of error strings returned by sys1 and sys2,
  10. // which both call the function named fn in package syscall
  11. func testalias(t *testing.T, fn string, sys1, sys2 func() error) {
  12. err := sys1().Error()
  13. errcopy := string([]byte(err))
  14. sys2()
  15. if err != errcopy {
  16. t.Errorf("syscall.%s error string changed from %q to %q\n", fn, errcopy, err)
  17. }
  18. }
  19. // issue 13770: errors cannot be nested in Plan 9
  20. func TestPlan9Syserr(t *testing.T) {
  21. testalias(t,
  22. "Syscall",
  23. func() error {
  24. return syscall.Mkdir("/", 0)
  25. },
  26. func() error {
  27. return syscall.Mkdir("#", 0)
  28. })
  29. testalias(t,
  30. "Syscall6",
  31. func() error {
  32. return syscall.Mount(0, 0, "", 0, "")
  33. },
  34. func() error {
  35. return syscall.Mount(-1, 0, "", 0, "")
  36. })
  37. // originally failed only on plan9_arm
  38. testalias(t,
  39. "seek",
  40. func() error {
  41. _, err := syscall.Seek(0, 0, -1)
  42. return err
  43. },
  44. func() error {
  45. _, err := syscall.Seek(-1, 0, 0)
  46. return err
  47. })
  48. }