A lightweight mechanism to provide an *instant kickstart* to a Go web server instance upon changing any Go source files under the project directory (and its subdirectories).

syscall_bsd_test.go 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2014 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. // +build darwin dragonfly freebsd openbsd
  5. package unix_test
  6. import (
  7. "os/exec"
  8. "runtime"
  9. "testing"
  10. "golang.org/x/sys/unix"
  11. )
  12. const MNT_WAIT = 1
  13. const MNT_NOWAIT = 2
  14. func TestGetfsstat(t *testing.T) {
  15. const flags = MNT_NOWAIT // see golang.org/issue/16937
  16. n, err := unix.Getfsstat(nil, flags)
  17. if err != nil {
  18. t.Fatal(err)
  19. }
  20. data := make([]unix.Statfs_t, n)
  21. n2, err := unix.Getfsstat(data, flags)
  22. if err != nil {
  23. t.Fatal(err)
  24. }
  25. if n != n2 {
  26. t.Errorf("Getfsstat(nil) = %d, but subsequent Getfsstat(slice) = %d", n, n2)
  27. }
  28. for i, stat := range data {
  29. if stat == (unix.Statfs_t{}) {
  30. t.Errorf("index %v is an empty Statfs_t struct", i)
  31. }
  32. }
  33. if t.Failed() {
  34. for i, stat := range data[:n2] {
  35. t.Logf("data[%v] = %+v", i, stat)
  36. }
  37. mount, err := exec.Command("mount").CombinedOutput()
  38. if err != nil {
  39. t.Logf("mount: %v\n%s", err, mount)
  40. } else {
  41. t.Logf("mount: %s", mount)
  42. }
  43. }
  44. }
  45. func TestSysctlRaw(t *testing.T) {
  46. if runtime.GOOS == "openbsd" {
  47. t.Skip("kern.proc.pid does not exist on OpenBSD")
  48. }
  49. _, err := unix.SysctlRaw("kern.proc.pid", unix.Getpid())
  50. if err != nil {
  51. t.Fatal(err)
  52. }
  53. }