2023-01-27 21:37:20 +00:00
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2020-02-05 22:16:58 +00:00
|
|
|
|
|
|
|
package wgengine
|
|
|
|
|
|
|
|
import (
|
2021-03-27 15:10:26 +00:00
|
|
|
"runtime"
|
2020-02-05 22:16:58 +00:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestWatchdog(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
2021-03-27 15:10:26 +00:00
|
|
|
var maxWaitMultiple time.Duration = 1
|
|
|
|
if runtime.GOOS == "darwin" {
|
|
|
|
// Work around slow close syscalls on Big Sur with content filter Network Extensions installed.
|
|
|
|
// See https://github.com/tailscale/tailscale/issues/1598.
|
|
|
|
maxWaitMultiple = 15
|
|
|
|
}
|
|
|
|
|
2020-02-05 22:16:58 +00:00
|
|
|
t.Run("default watchdog does not fire", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
2021-03-01 18:08:53 +00:00
|
|
|
e, err := NewFakeUserspaceEngine(t.Logf, 0)
|
2020-02-05 22:16:58 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
e = NewWatchdog(e)
|
2021-03-27 15:10:26 +00:00
|
|
|
e.(*watchdogEngine).maxWait = maxWaitMultiple * 150 * time.Millisecond
|
2020-07-03 07:00:45 +00:00
|
|
|
e.(*watchdogEngine).logf = t.Logf
|
|
|
|
e.(*watchdogEngine).fatalf = t.Fatalf
|
2020-02-05 22:16:58 +00:00
|
|
|
|
|
|
|
e.RequestStatus()
|
|
|
|
e.RequestStatus()
|
|
|
|
e.RequestStatus()
|
|
|
|
e.Close()
|
|
|
|
})
|
|
|
|
}
|