[FFmpeg-devel] [PATCH 1/2] avutil/opt: Also test/compare the av_log output i the selftest

Michael Niedermayer michaelni at gmx.at
Sat Feb 28 00:11:19 CET 2015


Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavutil/opt.c    |    8 +++
 tests/ref/fate/opt |  203 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 211 insertions(+)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 5de891b..007f51d 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1964,10 +1964,18 @@ static const AVClass test_class = {
     test_options
 };
 
+static void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
+{
+    vfprintf(stdout, fmt, vl);
+}
+
 int main(void)
 {
     int i;
 
+    av_log_set_level(AV_LOG_DEBUG);
+    av_log_set_callback(log_callback_help);
+
     printf("Testing default values\n");
     {
         TestContext test_ctx = { 0 };
diff --git a/tests/ref/fate/opt b/tests/ref/fate/opt
index 084a222..2ab96d4 100644
--- a/tests/ref/fate/opt
+++ b/tests/ref/fate/opt
@@ -66,76 +66,279 @@ name:       dbl default:1 error:
 
 Test av_opt_serialize()
 num=0,toggle=1,rational=1/1,string=default,escape=\\\=\,,flags=0x00000001,size=200x300,pix_fmt=0bgr,sample_fmt=s16,video_rate=25/1,duration=0:00:00.001000,color=0xffc0cbff,cl=0x137,bin=62696E00,bin1=,bin2=,num64=1,flt=0.333333,dbl=0.333333
+Setting entry with key 'num' to value '0'
+Setting entry with key 'toggle' to value '1'
+Setting entry with key 'rational' to value '1/1'
+Setting entry with key 'string' to value 'default'
+Setting entry with key 'escape' to value '\=,'
+Setting entry with key 'flags' to value '0x00000001'
+Setting entry with key 'size' to value '200x300'
+Setting entry with key 'pix_fmt' to value '0bgr'
+Setting entry with key 'sample_fmt' to value 's16'
+Setting entry with key 'video_rate' to value '25/1'
+Setting entry with key 'duration' to value '0:00:00.001000'
+Setting entry with key 'color' to value '0xffc0cbff'
+Setting entry with key 'cl' to value '0x137'
+Setting entry with key 'bin' to value '62696E00'
+Setting entry with key 'bin1' to value ''
+Setting entry with key 'bin2' to value ''
+Setting entry with key 'num64' to value '1'
+Setting entry with key 'flt' to value '0.333333'
+Setting entry with key 'dbl' to value '0.333333'
 num=0,toggle=1,rational=1/1,string=default,escape=\\\=\,,flags=0x00000001,size=200x300,pix_fmt=0bgr,sample_fmt=s16,video_rate=25/1,duration=0:00:00.001000,color=0xffc0cbff,cl=0x137,bin=62696E00,bin1=,bin2=,num64=1,flt=0.333333,dbl=0.333333
 
 Testing av_set_options_string()
+Setting options string ''
 OK    ''
+Setting options string ':'
+Missing key or no key/value separator found after key ':'
 Error ':'
+Setting options string '='
+Missing key or no key/value separator found after key ''
 Error '='
+Setting options string 'foo=:'
+Setting entry with key 'foo' to value ''
+Key 'foo' not found.
 Error 'foo=:'
+Setting options string ':=foo'
+Setting entry with key ':' to value 'foo'
+Key ':' not found.
 Error ':=foo'
+Setting options string '=foo'
+Missing key or no key/value separator found after key ''
 Error '=foo'
+Setting options string 'foo='
+Setting entry with key 'foo' to value ''
+Key 'foo' not found.
 Error 'foo='
+Setting options string 'foo'
+Missing key or no key/value separator found after key 'foo'
 Error 'foo'
+Setting options string 'foo=val'
+Setting entry with key 'foo' to value 'val'
+Key 'foo' not found.
 Error 'foo=val'
+Setting options string 'foo==val'
+Setting entry with key 'foo' to value '=val'
+Key 'foo' not found.
 Error 'foo==val'
+Setting options string 'toggle=:'
+Setting entry with key 'toggle' to value ''
+Undefined constant or missing '(' in ''
+Unable to parse option value ""
 Error 'toggle=:'
+Setting options string 'string=:'
+Setting entry with key 'string' to value ''
 OK    'string=:'
+Setting options string 'toggle=1 : foo'
+Setting entry with key 'toggle' to value '1'
+Missing key or no key/value separator found after key 'foo'
 Error 'toggle=1 : foo'
+Setting options string 'toggle=100'
+Setting entry with key 'toggle' to value '100'
+Value 100.000000 for parameter 'toggle' out of range [0 - 1]
 Error 'toggle=100'
+Setting options string 'toggle==1'
+Setting entry with key 'toggle' to value '=1'
+Undefined constant or missing '(' in '=1'
+Unable to parse option value "=1"
 Error 'toggle==1'
+Setting options string 'flags=+mu-lame : num=42: toggle=0'
+Setting entry with key 'flags' to value '+mu-lame'
+Setting entry with key 'num' to value '42'
+Setting entry with key 'toggle' to value '0'
 OK    'flags=+mu-lame : num=42: toggle=0'
+Setting options string 'num=42 : string=blahblah'
+Setting entry with key 'num' to value '42'
+Setting entry with key 'string' to value 'blahblah'
 OK    'num=42 : string=blahblah'
+Setting options string 'rational=0 : rational=1/2 : rational=1/-1'
+Setting entry with key 'rational' to value '0'
+Setting entry with key 'rational' to value '1/2'
+Setting entry with key 'rational' to value '1/-1'
+Value -1.000000 for parameter 'rational' out of range [0 - 10]
+Value -1.000000 for parameter 'rational' out of range [0 - 10]
 Error 'rational=0 : rational=1/2 : rational=1/-1'
+Setting options string 'rational=-1/0'
+Setting entry with key 'rational' to value '-1/0'
+Value -inf for parameter 'rational' out of range [0 - 10]
+Value -inf for parameter 'rational' out of range [0 - 10]
 Error 'rational=-1/0'
+Setting options string 'size=1024x768'
+Setting entry with key 'size' to value '1024x768'
 OK    'size=1024x768'
+Setting options string 'size=pal'
+Setting entry with key 'size' to value 'pal'
 OK    'size=pal'
+Setting options string 'size=bogus'
+Setting entry with key 'size' to value 'bogus'
+Unable to parse option value "bogus" as image size
 Error 'size=bogus'
+Setting options string 'pix_fmt=yuv420p'
+Setting entry with key 'pix_fmt' to value 'yuv420p'
 OK    'pix_fmt=yuv420p'
+Setting options string 'pix_fmt=2'
+Setting entry with key 'pix_fmt' to value '2'
 OK    'pix_fmt=2'
+Setting options string 'pix_fmt=bogus'
+Setting entry with key 'pix_fmt' to value 'bogus'
+Unable to parse option value "bogus" as pixel format
 Error 'pix_fmt=bogus'
+Setting options string 'sample_fmt=s16'
+Setting entry with key 'sample_fmt' to value 's16'
 OK    'sample_fmt=s16'
+Setting options string 'sample_fmt=2'
+Setting entry with key 'sample_fmt' to value '2'
 OK    'sample_fmt=2'
+Setting options string 'sample_fmt=bogus'
+Setting entry with key 'sample_fmt' to value 'bogus'
+Unable to parse option value "bogus" as sample format
 Error 'sample_fmt=bogus'
+Setting options string 'video_rate=pal'
+Setting entry with key 'video_rate' to value 'pal'
 OK    'video_rate=pal'
+Setting options string 'video_rate=25'
+Setting entry with key 'video_rate' to value '25'
 OK    'video_rate=25'
+Setting options string 'video_rate=30000/1001'
+Setting entry with key 'video_rate' to value '30000/1001'
 OK    'video_rate=30000/1001'
+Setting options string 'video_rate=30/1.001'
+Setting entry with key 'video_rate' to value '30/1.001'
 OK    'video_rate=30/1.001'
+Setting options string 'video_rate=bogus'
+Setting entry with key 'video_rate' to value 'bogus'
+Undefined constant or missing '(' in 'bogus'
+Unable to parse option value "bogus" as video rate
 Error 'video_rate=bogus'
+Setting options string 'duration=bogus'
+Setting entry with key 'duration' to value 'bogus'
+Unable to parse option value "bogus" as duration
 Error 'duration=bogus'
+Setting options string 'duration=123.45'
+Setting entry with key 'duration' to value '123.45'
 OK    'duration=123.45'
+Setting options string 'duration=1\:23\:45.67'
+Setting entry with key 'duration' to value '1:23:45.67'
 OK    'duration=1\:23\:45.67'
+Setting options string 'color=blue'
+Setting entry with key 'color' to value 'blue'
 OK    'color=blue'
+Setting options string 'color=0x223300'
+Setting entry with key 'color' to value '0x223300'
 OK    'color=0x223300'
+Setting options string 'color=0x42FF07AA'
+Setting entry with key 'color' to value '0x42FF07AA'
 OK    'color=0x42FF07AA'
+Setting options string 'cl=stereo+downmix'
+Setting entry with key 'cl' to value 'stereo+downmix'
 OK    'cl=stereo+downmix'
+Setting options string 'cl=foo'
+Setting entry with key 'cl' to value 'foo'
+Unable to parse option value "foo" as channel layout
 Error 'cl=foo'
+Setting options string 'bin=boguss'
+Setting entry with key 'bin' to value 'boguss'
 Error 'bin=boguss'
+Setting options string 'bin=111'
+Setting entry with key 'bin' to value '111'
 Error 'bin=111'
+Setting options string 'bin=ffff'
+Setting entry with key 'bin' to value 'ffff'
 OK    'bin=ffff'
+Setting options string 'num64=bogus'
+Setting entry with key 'num64' to value 'bogus'
+Undefined constant or missing '(' in 'bogus'
+Unable to parse option value "bogus"
 Error 'num64=bogus'
+Setting options string 'num64=44'
+Setting entry with key 'num64' to value '44'
 OK    'num64=44'
+Setting options string 'num64=44.4'
+Setting entry with key 'num64' to value '44.4'
 OK    'num64=44.4'
+Setting options string 'num64=-1'
+Setting entry with key 'num64' to value '-1'
+Value -1.000000 for parameter 'num64' out of range [0 - 100]
 Error 'num64=-1'
+Setting options string 'num64=101'
+Setting entry with key 'num64' to value '101'
+Value 101.000000 for parameter 'num64' out of range [0 - 100]
 Error 'num64=101'
+Setting options string 'flt=bogus'
+Setting entry with key 'flt' to value 'bogus'
+Undefined constant or missing '(' in 'bogus'
+Unable to parse option value "bogus"
 Error 'flt=bogus'
+Setting options string 'flt=2'
+Setting entry with key 'flt' to value '2'
 OK    'flt=2'
+Setting options string 'flt=2.2'
+Setting entry with key 'flt' to value '2.2'
 OK    'flt=2.2'
+Setting options string 'flt=-1'
+Setting entry with key 'flt' to value '-1'
+Value -1.000000 for parameter 'flt' out of range [0 - 100]
 Error 'flt=-1'
+Setting options string 'flt=101'
+Setting entry with key 'flt' to value '101'
+Value 101.000000 for parameter 'flt' out of range [0 - 100]
 Error 'flt=101'
+Setting options string 'dbl=bogus'
+Setting entry with key 'dbl' to value 'bogus'
+Undefined constant or missing '(' in 'bogus'
+Unable to parse option value "bogus"
 Error 'dbl=bogus'
+Setting options string 'dbl=2'
+Setting entry with key 'dbl' to value '2'
 OK    'dbl=2'
+Setting options string 'dbl=2.2'
+Setting entry with key 'dbl' to value '2.2'
 OK    'dbl=2.2'
+Setting options string 'dbl=-1'
+Setting entry with key 'dbl' to value '-1'
+Value -1.000000 for parameter 'dbl' out of range [0 - 100]
 Error 'dbl=-1'
+Setting options string 'dbl=101'
+Setting entry with key 'dbl' to value '101'
+Value 101.000000 for parameter 'dbl' out of range [0 - 100]
 Error 'dbl=101'
 
 Testing av_opt_set_from_string()
+Setting options string ''
 OK    ''
+Setting options string '5'
+Setting 'num' to value '5'
 OK    '5'
+Setting options string '5:hello'
+Setting 'num' to value '5'
+Setting 'string' to value 'hello'
 OK    '5:hello'
+Setting options string '5:hello:size=pal'
+Setting 'num' to value '5'
+Setting 'string' to value 'hello'
+Setting 'size' to value 'pal'
 OK    '5:hello:size=pal'
+Setting options string '5:size=pal:hello'
+Setting 'num' to value '5'
+Setting 'size' to value 'pal'
+No option name near 'hello'
 Error '5:size=pal:hello'
+Setting options string ':'
+Setting 'num' to value ''
+Undefined constant or missing '(' in ''
+Unable to parse option value ""
 Error ':'
+Setting options string '='
+Setting '' to value ''
+Option '' not found
 Error '='
+Setting options string ' 5 : hello : size = pal '
+Setting 'num' to value '5'
+Setting 'string' to value 'hello'
+Setting 'size' to value 'pal'
 OK    ' 5 : hello : size = pal '
+Setting options string 'a_very_long_option_name_that_will_need_to_be_ellipsized_around_here=42'
+Setting 'a_very_long_option_name_that_will_need_to_be_ellipsized_around_here' to value '42'
+Option 'a_very_long_option_name_that_will_need_to_be_ellipsized_around_here' not found
 Error 'a_very_long_option_name_that_will_need_to_be_ellipsized_around_here=42'
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list