1 // Copyright 2011 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.
18 // This is really an os package test but here for convenience.
19 func testSetEnv(t
*testing
.T
) {
20 if runtime
.GOOS
== "windows" {
21 // Go uses SetEnvironmentVariable on windows. Howerver,
22 // C runtime takes a *copy* at process startup of thei
23 // OS environment, and stores it in environ/envp.
24 // It is this copy that getenv/putenv manipulate.
25 t
.Logf("skipping test")
28 const key
= "CGO_OS_TEST_KEY"
29 const val
= "CGO_OS_TEST_VALUE"
31 keyc
:= C
.CString(key
)
32 defer C
.free(unsafe
.Pointer(keyc
))
34 if uintptr(unsafe
.Pointer(v
)) == 0 {
35 t
.Fatal("getenv returned NULL")
39 t
.Fatalf("getenv() = %q; want %q", vs
, val
)