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
|
RTMP tests
|
||||||
|
|
||||||
AUTHORS
|
AUTHORS
|
||||||
|
Saxon Nelson-Milton <saxon@ausocean.org>
|
||||||
|
Dan Kortschak <dan@ausocean.org>
|
||||||
Alan Noble <alan@ausocean.org>
|
Alan Noble <alan@ausocean.org>
|
||||||
|
|
||||||
LICENSE
|
LICENSE
|
||||||
|
@ -49,20 +51,22 @@ const (
|
||||||
testDataDir = "../../test/test-data/av/input"
|
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.
|
// NB: This is not the log level, which is DebugLevel.
|
||||||
// 0: suppress logging completely
|
// 0: suppress logging completely
|
||||||
// 1: log messages only
|
// 1: log messages only
|
||||||
// 2: log messages with errors, if any
|
// 2: log messages with errors, if any
|
||||||
var testVerbosity = 1
|
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
|
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
|
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{}) {
|
func testLog(level int8, msg string, params ...interface{}) {
|
||||||
logLevels := [...]string{"Debug", "Info", "Warn", "Error", "", "", "Fatal"}
|
logLevels := [...]string{"Debug", "Info", "Warn", "Error", "", "", "Fatal"}
|
||||||
if testVerbosity == 0 {
|
if testVerbosity == 0 {
|
||||||
|
@ -71,21 +75,28 @@ func testLog(level int8, msg string, params ...interface{}) {
|
||||||
if level < -1 || level > 5 {
|
if level < -1 || level > 5 {
|
||||||
panic("Invalid log level")
|
panic("Invalid log level")
|
||||||
}
|
}
|
||||||
if testVerbosity == 2 && len(params) >= 2 {
|
switch testVerbosity {
|
||||||
// extract the params we know about, otherwise just print the message
|
case 0:
|
||||||
switch params[0].(string) {
|
// silence is golden
|
||||||
case "error":
|
case 1:
|
||||||
fmt.Printf("%s: %s, error=%v\n", logLevels[level+1], msg, params[1].(string))
|
fmt.Printf("%s: %s\n", logLevels[level+1], msg)
|
||||||
case "size":
|
case 2:
|
||||||
fmt.Printf("%s: %s, size=%d\n", logLevels[level+1], msg, params[1].(int))
|
// extract the first param if it is one we care about, otherwise just print the message
|
||||||
default:
|
if len(params) >= 2 {
|
||||||
|
switch params[0].(string) {
|
||||||
|
case "error":
|
||||||
|
fmt.Printf("%s: %s, error=%v\n", logLevels[level+1], msg, params[1].(string))
|
||||||
|
case "size":
|
||||||
|
fmt.Printf("%s: %s, size=%d\n", logLevels[level+1], msg, params[1].(int))
|
||||||
|
default:
|
||||||
|
fmt.Printf("%s: %s\n", logLevels[level+1], msg)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
fmt.Printf("%s: %s\n", logLevels[level+1], msg)
|
fmt.Printf("%s: %s\n", logLevels[level+1], msg)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
fmt.Printf("%s: %s\n", logLevels[level+1], msg)
|
|
||||||
}
|
}
|
||||||
if level == 5 {
|
if level >= 4 {
|
||||||
// Fatal
|
// Error or Fatal
|
||||||
buf := make([]byte, 1<<16)
|
buf := make([]byte, 1<<16)
|
||||||
size := runtime.Stack(buf, true)
|
size := runtime.Stack(buf, true)
|
||||||
fmt.Printf("%s\n", string(buf[:size]))
|
fmt.Printf("%s\n", string(buf[:size]))
|
||||||
|
|
Loading…
Reference in New Issue