aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-05-20 18:00:35 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2016-05-20 19:32:02 +0200
commitb50bd695168976b70e5fab2f2f3a9b0ef8063157 (patch)
treeec61c7cee58bcf0ff67e5d7824610e665a049f15
parente0706e9cc8f30a8242d2b140edace7bf76170506 (diff)
downloadffmpeg-b50bd695168976b70e5fab2f2f3a9b0ef8063157.tar.gz
avutil/eval-test: Check av_expr_parse_and_eval() for failure and also check it in the fate test
Fixes CID1361940 Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavutil/eval-test.c17
-rw-r--r--tests/ref/fate/eval26
2 files changed, 39 insertions, 4 deletions
diff --git a/libavutil/eval-test.c b/libavutil/eval-test.c
index 8e53f488c7..17a63cc25d 100644
--- a/libavutil/eval-test.c
+++ b/libavutil/eval-test.c
@@ -139,33 +139,42 @@ int main(int argc, char **argv)
"clip(0, 0/0, 1)",
NULL
};
+ int ret;
for (expr = exprs; *expr; expr++) {
printf("Evaluating '%s'\n", *expr);
- av_expr_parse_and_eval(&d, *expr,
+ ret = av_expr_parse_and_eval(&d, *expr,
const_names, const_values,
NULL, NULL, NULL, NULL, NULL, 0, NULL);
if (isnan(d))
printf("'%s' -> nan\n\n", *expr);
else
printf("'%s' -> %f\n\n", *expr, d);
+ if (ret < 0)
+ printf("av_expr_parse_and_eval failed\n");
}
- av_expr_parse_and_eval(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
+ ret = av_expr_parse_and_eval(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
const_names, const_values,
NULL, NULL, NULL, NULL, NULL, 0, NULL);
printf("%f == 12.7\n", d);
- av_expr_parse_and_eval(&d, "80G/80Gi",
+ if (ret < 0)
+ printf("av_expr_parse_and_eval failed\n");
+ ret = av_expr_parse_and_eval(&d, "80G/80Gi",
const_names, const_values,
NULL, NULL, NULL, NULL, NULL, 0, NULL);
printf("%f == 0.931322575\n", d);
+ if (ret < 0)
+ printf("av_expr_parse_and_eval failed\n");
if (argc > 1 && !strcmp(argv[1], "-t")) {
for (i = 0; i < 1050; i++) {
START_TIMER;
- av_expr_parse_and_eval(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
+ ret = av_expr_parse_and_eval(&d, "1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)",
const_names, const_values,
NULL, NULL, NULL, NULL, NULL, 0, NULL);
+ if (ret < 0)
+ printf("av_expr_parse_and_eval failed\n");
STOP_TIMER("av_expr_parse_and_eval");
}
}
diff --git a/tests/ref/fate/eval b/tests/ref/fate/eval
index 914b13ccfa..5b4d93f427 100644
--- a/tests/ref/fate/eval
+++ b/tests/ref/fate/eval
@@ -1,6 +1,7 @@
Evaluating ''
'' -> nan
+av_expr_parse_and_eval failed
Evaluating '1;2'
'1;2' -> 2.000000
@@ -28,45 +29,58 @@ Evaluating '1Gi'
Evaluating '1gi'
'1gi' -> nan
+av_expr_parse_and_eval failed
Evaluating '1GiFoo'
'1GiFoo' -> nan
+av_expr_parse_and_eval failed
Evaluating '1k+1k'
'1k+1k' -> 2000.000000
Evaluating '1Gi*3foo'
'1Gi*3foo' -> nan
+av_expr_parse_and_eval failed
Evaluating 'foo'
'foo' -> nan
+av_expr_parse_and_eval failed
Evaluating 'foo('
'foo(' -> nan
+av_expr_parse_and_eval failed
Evaluating 'foo()'
'foo()' -> nan
+av_expr_parse_and_eval failed
Evaluating 'foo)'
'foo)' -> nan
+av_expr_parse_and_eval failed
Evaluating 'sin'
'sin' -> nan
+av_expr_parse_and_eval failed
Evaluating 'sin('
'sin(' -> nan
+av_expr_parse_and_eval failed
Evaluating 'sin()'
'sin()' -> nan
+av_expr_parse_and_eval failed
Evaluating 'sin)'
'sin)' -> nan
+av_expr_parse_and_eval failed
Evaluating 'sin 10'
'sin 10' -> nan
+av_expr_parse_and_eval failed
Evaluating 'sin(1,2,3)'
'sin(1,2,3)' -> nan
+av_expr_parse_and_eval failed
Evaluating 'sin(1 )'
'sin(1 )' -> 0.841471
@@ -76,15 +90,19 @@ Evaluating '1'
Evaluating '1foo'
'1foo' -> nan
+av_expr_parse_and_eval failed
Evaluating 'bar + PI + E + 100f*2 + foo'
'bar + PI + E + 100f*2 + foo' -> nan
+av_expr_parse_and_eval failed
Evaluating '13k + 12f - foo(1, 2)'
'13k + 12f - foo(1, 2)' -> nan
+av_expr_parse_and_eval failed
Evaluating '1gi'
'1gi' -> nan
+av_expr_parse_and_eval failed
Evaluating '1Gi'
'1Gi' -> 1073741824.000000
@@ -127,6 +145,7 @@ Evaluating 'st(1, 1); st(2, 2); st(0, 1); while(lte(ld(0),10), st(3, ld(1)+ld(2)
Evaluating 'while(0, 10)'
'while(0, 10)' -> nan
+av_expr_parse_and_eval failed
Evaluating 'st(0, 1); while(lte(ld(0),100), st(1, ld(1)+ld(0)); st(0, ld(0)+1))'
'st(0, 1); while(lte(ld(0),100), st(1, ld(1)+ld(0)); st(0, ld(0)+1))' -> 101.000000
@@ -151,6 +170,7 @@ Evaluating 'isinf(INF)'
Evaluating 'floor(NAN)'
'floor(NAN)' -> nan
+av_expr_parse_and_eval failed
Evaluating 'floor(123.123)'
'floor(123.123)' -> 123.000000
@@ -202,6 +222,7 @@ Evaluating 'PI^1.23'
Evaluating 'pow(-1,1.23)'
'pow(-1,1.23)' -> nan
+av_expr_parse_and_eval failed
Evaluating 'if(1, 2)'
'if(1, 2)' -> 2.000000
@@ -259,6 +280,7 @@ Evaluating 'bitand(42, 12)'
Evaluating 'bitand(NAN, 1)'
'bitand(NAN, 1)' -> nan
+av_expr_parse_and_eval failed
Evaluating 'between(10, -3, 10)'
'between(10, -3, 10)' -> 1.000000
@@ -268,14 +290,18 @@ Evaluating 'between(-4, -2, -1)'
Evaluating 'between(1,2)'
'between(1,2)' -> nan
+av_expr_parse_and_eval failed
Evaluating 'clip(0, 2, 1)'
'clip(0, 2, 1)' -> nan
+av_expr_parse_and_eval failed
Evaluating 'clip(0/0, 1, 2)'
'clip(0/0, 1, 2)' -> nan
+av_expr_parse_and_eval failed
Evaluating 'clip(0, 0/0, 1)'
'clip(0, 0/0, 1)' -> nan
+av_expr_parse_and_eval failed
12.700000 == 12.7
0.931323 == 0.931322575