You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
782 B

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