(t *testing.T)
| 204 | } |
| 205 | |
| 206 | func TestUpDown(t *testing.T) { |
| 207 | goroutineLeakCheck(t) |
| 208 | const itrials = 50 |
| 209 | const otrials = 10 |
| 210 | |
| 211 | for n := 0; n < otrials; n++ { |
| 212 | pair := genTestPair(t, false) |
| 213 | for i := range pair { |
| 214 | for k := range pair[i].dev.peers.keyMap { |
| 215 | pair[i].dev.IpcSet(fmt.Sprintf("public_key=%s\npersistent_keepalive_interval=1\n", hex.EncodeToString(k[:]))) |
| 216 | } |
| 217 | } |
| 218 | var wg sync.WaitGroup |
| 219 | wg.Add(len(pair)) |
| 220 | for i := range pair { |
| 221 | go func(d *Device) { |
| 222 | defer wg.Done() |
| 223 | for i := 0; i < itrials; i++ { |
| 224 | if err := d.Up(); err != nil { |
| 225 | t.Errorf("failed up bring up device: %v", err) |
| 226 | } |
| 227 | time.Sleep(time.Duration(rand.Intn(int(time.Nanosecond * (0x10000 - 1))))) |
| 228 | if err := d.Down(); err != nil { |
| 229 | t.Errorf("failed to bring down device: %v", err) |
| 230 | } |
| 231 | time.Sleep(time.Duration(rand.Intn(int(time.Nanosecond * (0x10000 - 1))))) |
| 232 | } |
| 233 | }(pair[i].dev) |
| 234 | } |
| 235 | wg.Wait() |
| 236 | for i := range pair { |
| 237 | pair[i].dev.Up() |
| 238 | pair[i].dev.Close() |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | // TestConcurrencySafety does other things concurrently with tunnel use. |
| 244 | // It is intended to be used with the race detector to catch data races. |
nothing calls this directly
no test coverage detected