runtime: scan register backing store on ia64
[official-gcc.git] / libgo / go / runtime / env_test.go
blob2399e46faa91e8bc850aa5e303687d7128ca0f35
1 // Copyright 2015 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 runtime_test
7 import (
8 "runtime"
9 "syscall"
10 "testing"
13 func TestFixedGOROOT(t *testing.T) {
14 if runtime.GOOS == "plan9" {
15 t.Skipf("skipping plan9, it is inconsistent by allowing GOROOT to be updated by Setenv")
18 // Restore both the real GOROOT environment variable, and runtime's copies:
19 if orig, ok := syscall.Getenv("GOROOT"); ok {
20 defer syscall.Setenv("GOROOT", orig)
21 } else {
22 defer syscall.Unsetenv("GOROOT")
24 envs := runtime.Envs()
25 oldenvs := append([]string{}, envs...)
26 defer runtime.SetEnvs(oldenvs)
28 // attempt to reuse existing envs backing array.
29 want := runtime.GOROOT()
30 runtime.SetEnvs(append(envs[:0], "GOROOT="+want))
32 if got := runtime.GOROOT(); got != want {
33 t.Errorf(`initial runtime.GOROOT()=%q, want %q`, got, want)
35 if err := syscall.Setenv("GOROOT", "/os"); err != nil {
36 t.Fatal(err)
38 if got := runtime.GOROOT(); got != want {
39 t.Errorf(`after setenv runtime.GOROOT()=%q, want %q`, got, want)
41 if err := syscall.Unsetenv("GOROOT"); err != nil {
42 t.Fatal(err)
44 if got := runtime.GOROOT(); got != want {
45 t.Errorf(`after unsetenv runtime.GOROOT()=%q, want %q`, got, want)