syscall_test.go 773 B

12345678910111213141516171819202122232425262728293031
  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.
  4. package plan9_test
  5. import (
  6. "testing"
  7. "code.google.com/p/go.sys/plan9"
  8. )
  9. func testSetGetenv(t *testing.T, key, value string) {
  10. err := plan9.Setenv(key, value)
  11. if err != nil {
  12. t.Fatalf("Setenv failed to set %q: %v", value, err)
  13. }
  14. newvalue, found := plan9.Getenv(key)
  15. if !found {
  16. t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value)
  17. }
  18. if newvalue != value {
  19. t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value)
  20. }
  21. }
  22. func TestEnv(t *testing.T) {
  23. testSetGetenv(t, "TESTENV", "AVALUE")
  24. // make sure TESTENV gets set to "", not deleted
  25. testSetGetenv(t, "TESTENV", "")
  26. }