control_test.go 640 B

1234567891011121314151617181920212223242526272829303132
  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 ipv6
  5. import (
  6. "sync"
  7. "testing"
  8. )
  9. func TestControlFlags(t *testing.T) {
  10. tf := FlagInterface | FlagPathMTU
  11. opt := rawOpt{cflags: tf | FlagHopLimit}
  12. type ffn func(ControlFlags)
  13. var wg sync.WaitGroup
  14. for _, fn := range []ffn{opt.set, opt.clear, opt.clear} {
  15. wg.Add(1)
  16. go func(fn ffn) {
  17. defer wg.Done()
  18. opt.Lock()
  19. defer opt.Unlock()
  20. fn(tf)
  21. }(fn)
  22. }
  23. wg.Wait()
  24. if opt.isset(tf) {
  25. t.Fatalf("got %#x; expected %#x", opt.cflags, FlagHopLimit)
  26. }
  27. }