| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- //go:build linux
- package serialtransport_test
- import (
- "testing"
- "time"
- "golang.org/x/sys/unix"
- "hth/internal/serialtransport"
- )
- func TestBackoffCapped(t *testing.T) {
- d := time.Duration(0)
- seen := map[time.Duration]bool{}
- for i := 0; i < 20; i++ {
- d = serialtransport.NextBackoff(d, serialtransport.MaxBackoff)
- if d > serialtransport.MaxBackoff {
- t.Fatal(d)
- }
- seen[d] = true
- }
- if !seen[serialtransport.MaxBackoff] {
- t.Fatal("never reached cap")
- }
- }
- func TestPTYOpenConfigure(t *testing.T) {
- m, hold, name, err := serialtransport.OpenPTY()
- if err != nil {
- t.Fatal(err)
- }
- defer m.Close()
- defer unixClose(hold)
- if name == "" {
- t.Fatal("slave name")
- }
- }
- func unixClose(fd int) {
- _ = unix.Close(fd)
- }
|