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.
12 func testSetGetenv(t
*testing
.T
, key
, value
string) {
13 err
:= syscall
.Setenv(key
, value
)
15 t
.Fatalf("Setenv failed to set %q: %v", value
, err
)
17 newvalue
, found
:= syscall
.Getenv(key
)
19 t
.Fatalf("Getenv failed to find %v variable (want value %q)", key
, value
)
21 if newvalue
!= value
{
22 t
.Fatalf("Getenv(%v) = %q; want %q", key
, newvalue
, value
)
26 func TestEnv(t
*testing
.T
) {
27 testSetGetenv(t
, "TESTENV", "AVALUE")
28 // make sure TESTENV gets set to "", not deleted
29 testSetGetenv(t
, "TESTENV", "")