mirror of https://bitbucket.org/ausocean/av.git
Exit test for errors and fatals errors regardless of testVerbosity.
This commit is contained in:
parent
82522643bb
commit
8a23609f6e
|
@ -6,6 +6,8 @@ DESCRIPTION
|
|||
RTMP tests
|
||||
|
||||
AUTHORS
|
||||
Saxon Nelson-Milton <saxon@ausocean.org>
|
||||
Dan Kortschak <dan@ausocean.org>
|
||||
Alan Noble <alan@ausocean.org>
|
||||
|
||||
LICENSE
|
||||
|
@ -49,20 +51,22 @@ const (
|
|||
testDataDir = "../../test/test-data/av/input"
|
||||
)
|
||||
|
||||
// testVerbosity controls the amount of output
|
||||
// testVerbosity controls the amount of output.
|
||||
// NB: This is not the log level, which is DebugLevel.
|
||||
// 0: suppress logging completely
|
||||
// 1: log messages only
|
||||
// 2: log messages with errors, if any
|
||||
var testVerbosity = 1
|
||||
|
||||
// testKey is the RTMP key required for YouTube streaming (RTMP_TEST_KEY env var)
|
||||
// testKey is the YouTube RTMP key required for YouTube streaming (RTMP_TEST_KEY env var).
|
||||
// NB: don't share your key with others.
|
||||
var testKey string
|
||||
|
||||
// testFile is the test video file (RTMP_TEST_FILE env var)
|
||||
// testFile is the test video file (RTMP_TEST_FILE env var).
|
||||
// betterInput.h264 is a good one to use.
|
||||
var testFile string
|
||||
|
||||
// testLog is a bare bones logger that logs to stdout.
|
||||
// testLog is a bare bones logger that logs to stdout, and exits upon either an error or fatal error.
|
||||
func testLog(level int8, msg string, params ...interface{}) {
|
||||
logLevels := [...]string{"Debug", "Info", "Warn", "Error", "", "", "Fatal"}
|
||||
if testVerbosity == 0 {
|
||||
|
@ -71,8 +75,14 @@ func testLog(level int8, msg string, params ...interface{}) {
|
|||
if level < -1 || level > 5 {
|
||||
panic("Invalid log level")
|
||||
}
|
||||
if testVerbosity == 2 && len(params) >= 2 {
|
||||
// extract the params we know about, otherwise just print the message
|
||||
switch testVerbosity {
|
||||
case 0:
|
||||
// silence is golden
|
||||
case 1:
|
||||
fmt.Printf("%s: %s\n", logLevels[level+1], msg)
|
||||
case 2:
|
||||
// extract the first param if it is one we care about, otherwise just print the message
|
||||
if len(params) >= 2 {
|
||||
switch params[0].(string) {
|
||||
case "error":
|
||||
fmt.Printf("%s: %s, error=%v\n", logLevels[level+1], msg, params[1].(string))
|
||||
|
@ -84,8 +94,9 @@ func testLog(level int8, msg string, params ...interface{}) {
|
|||
} else {
|
||||
fmt.Printf("%s: %s\n", logLevels[level+1], msg)
|
||||
}
|
||||
if level == 5 {
|
||||
// Fatal
|
||||
}
|
||||
if level >= 4 {
|
||||
// Error or Fatal
|
||||
buf := make([]byte, 1<<16)
|
||||
size := runtime.Stack(buf, true)
|
||||
fmt.Printf("%s\n", string(buf[:size]))
|
||||
|
|
Loading…
Reference in New Issue