1 // Copyright 2013 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.
5 // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
13 "golang.org/x/sys/unix"
16 func testSetGetenv(t *testing.T, key, value string) {
17 err := unix.Setenv(key, value)
19 t.Fatalf("Setenv failed to set %q: %v", value, err)
21 newvalue, found := unix.Getenv(key)
23 t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value)
25 if newvalue != value {
26 t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value)
30 func TestEnv(t *testing.T) {
31 testSetGetenv(t, "TESTENV", "AVALUE")
32 // make sure TESTENV gets set to "", not deleted
33 testSetGetenv(t, "TESTENV", "")
36 func TestItoa(t *testing.T) {
37 // Make most negative integer: 0x8000...
48 t.Fatalf("itoa(%d) = %s, want %s", i, s, f)
52 func TestUname(t *testing.T) {
53 var utsname unix.Utsname
54 err := unix.Uname(&utsname)
56 t.Fatalf("Uname: %v", err)
59 t.Logf("OS: %s/%s %s", utsname.Sysname[:], utsname.Machine[:], utsname.Release[:])
62 // Test that this compiles. (Issue #31735)
63 func TestStatFieldNames(t *testing.T) {
69 _ = int64(st.Mtim.Sec)
70 _ = int64(st.Mtim.Nsec)