mirror of
https://github.com/bluenviron/mediamtx.git
synced 2026-01-10 12:22:07 -08:00
tests: fix race condition (#5316)
Some checks are pending
code_lint / go (push) Waiting to run
code_lint / go_mod (push) Waiting to run
code_lint / docs (push) Waiting to run
code_lint / api_docs (push) Waiting to run
code_test / test_64 (push) Waiting to run
code_test / test_32 (push) Waiting to run
code_test / test_e2e (push) Waiting to run
Some checks are pending
code_lint / go (push) Waiting to run
code_lint / go_mod (push) Waiting to run
code_lint / docs (push) Waiting to run
code_lint / api_docs (push) Waiting to run
code_test / test_64 (push) Waiting to run
code_test / test_32 (push) Waiting to run
code_test / test_e2e (push) Waiting to run
This commit is contained in:
parent
9cb64d98ac
commit
1d9b2ff7ea
2 changed files with 23 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package mpegts
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"net"
|
||||
"os"
|
||||
|
|
@ -117,7 +118,8 @@ func TestSourceUDP(t *testing.T) {
|
|||
Codec: &tscodecs.H264{},
|
||||
}
|
||||
|
||||
w := &mpegts.Writer{W: conn, Tracks: []*mpegts.Track{track}}
|
||||
bw := bufio.NewWriter(conn)
|
||||
w := &mpegts.Writer{W: bw, Tracks: []*mpegts.Track{track}}
|
||||
err = w.Initialize()
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
@ -126,11 +128,17 @@ func TestSourceUDP(t *testing.T) {
|
|||
}})
|
||||
require.NoError(t, err)
|
||||
|
||||
err = bw.Flush()
|
||||
require.NoError(t, err)
|
||||
|
||||
err = w.WriteH264(track, 0, 0, [][]byte{{ // non-IDR
|
||||
5, 2,
|
||||
}})
|
||||
require.NoError(t, err)
|
||||
|
||||
err = bw.Flush()
|
||||
require.NoError(t, err)
|
||||
|
||||
<-p.Unit
|
||||
|
||||
// the source must be listening on ReloadConf
|
||||
|
|
@ -189,7 +197,8 @@ func TestSourceUnixSocket(t *testing.T) {
|
|||
Codec: &tscodecs.H264{},
|
||||
}
|
||||
|
||||
w := &mpegts.Writer{W: conn, Tracks: []*mpegts.Track{track}}
|
||||
bw := bufio.NewWriter(conn)
|
||||
w := &mpegts.Writer{W: bw, Tracks: []*mpegts.Track{track}}
|
||||
err = w.Initialize()
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
@ -198,6 +207,9 @@ func TestSourceUnixSocket(t *testing.T) {
|
|||
}})
|
||||
require.NoError(t, err)
|
||||
|
||||
err = bw.Flush()
|
||||
require.NoError(t, err)
|
||||
|
||||
conn.Close() // trigger a flush
|
||||
|
||||
<-p.Unit
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package srt
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
|
@ -59,7 +60,8 @@ func TestSource(t *testing.T) {
|
|||
|
||||
track := &mpegts.Track{Codec: &tscodecs.H264{}}
|
||||
|
||||
w := &mpegts.Writer{W: conn, Tracks: []*mpegts.Track{track}}
|
||||
bw := bufio.NewWriter(conn)
|
||||
w := &mpegts.Writer{W: bw, Tracks: []*mpegts.Track{track}}
|
||||
err2 = w.Initialize()
|
||||
require.NoError(t, err2)
|
||||
|
||||
|
|
@ -68,11 +70,17 @@ func TestSource(t *testing.T) {
|
|||
}})
|
||||
require.NoError(t, err2)
|
||||
|
||||
err = bw.Flush()
|
||||
require.NoError(t, err)
|
||||
|
||||
err = w.WriteH264(track, 0, 0, [][]byte{{ // non-IDR
|
||||
5, 2,
|
||||
}})
|
||||
require.NoError(t, err)
|
||||
|
||||
err = bw.Flush()
|
||||
require.NoError(t, err)
|
||||
|
||||
<-p.Unit
|
||||
|
||||
// the source must be listening on ReloadConf
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue