2013-12-05 Richard Biener <rguenther@suse.de>
[official-gcc.git] / libgo / go / syscall / syscall_test.go
blob2a39b54f1b2dffb6f064e1b7cb76e2442fcbadfc
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 package syscall_test
7 import (
8 "syscall"
9 "testing"
12 func testSetGetenv(t *testing.T, key, value string) {
13 err := syscall.Setenv(key, value)
14 if err != nil {
15 t.Fatalf("Setenv failed to set %q: %v", value, err)
17 newvalue, found := syscall.Getenv(key)
18 if !found {
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", "")