From: James Zern Date: Wed, 29 Apr 2020 01:51:01 +0000 (-0700) Subject: test/*.sh: add explicit error checks/returns X-Git-Tag: v1.9.0-rc1~25 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b120ba5781a520c015b356a7c77c89545ccdee32;p=libvpx test/*.sh: add explicit error checks/returns there was an assumption that function calls would terminate early with an error given 'set -e' was being used. this is true, but only when the function is part of a simple command otherwise it won't inherit the behavior. many of the call sites use 'func || return 1' syntax meaning the function would continue to completion return with the status of the last command executed. this hid errors with e.g., eval statements. inner calls within the functions are now explicitly tested for failure. BUG=aomedia:2669 Change-Id: Ie33a5ac4023dcc800bd302cb8cc54c6c3f2282f5 --- diff --git a/test/cx_set_ref.sh b/test/cx_set_ref.sh index 0a58dc187..0a3d50ce1 100755 --- a/test/cx_set_ref.sh +++ b/test/cx_set_ref.sh @@ -38,7 +38,7 @@ vpx_set_ref() { eval "${VPX_TEST_PREFIX}" "${encoder}" "${YUV_RAW_INPUT_WIDTH}" \ "${YUV_RAW_INPUT_HEIGHT}" "${YUV_RAW_INPUT}" "${output_file}" \ - "${ref_frame_num}" ${devnull} + "${ref_frame_num}" ${devnull} || return 1 [ -e "${output_file}" ] || return 1 } diff --git a/test/decode_to_md5.sh b/test/decode_to_md5.sh index 854b74f84..15eee39fa 100755 --- a/test/decode_to_md5.sh +++ b/test/decode_to_md5.sh @@ -40,7 +40,7 @@ decode_to_md5() { fi eval "${VPX_TEST_PREFIX}" "${decoder}" "${input_file}" "${output_file}" \ - ${devnull} + ${devnull} || return 1 [ -e "${output_file}" ] || return 1 diff --git a/test/decode_with_drops.sh b/test/decode_with_drops.sh index 9b2edb642..2c826045b 100755 --- a/test/decode_with_drops.sh +++ b/test/decode_with_drops.sh @@ -40,7 +40,7 @@ decode_with_drops() { fi eval "${VPX_TEST_PREFIX}" "${decoder}" "${input_file}" "${output_file}" \ - "${drop_mode}" ${devnull} + "${drop_mode}" ${devnull} || return 1 [ -e "${output_file}" ] || return 1 } @@ -52,10 +52,10 @@ decode_with_drops() { decode_with_drops_vp8() { if [ "$(vp8_decode_available)" = "yes" ]; then # Test sequence mode: Drop frames 2-28. - decode_with_drops "${VP8_IVF_FILE}" "vp8" "2-28" + decode_with_drops "${VP8_IVF_FILE}" "vp8" "2-28" || return 1 # Test pattern mode: Drop 3 of every 4 frames. - decode_with_drops "${VP8_IVF_FILE}" "vp8" "3/4" + decode_with_drops "${VP8_IVF_FILE}" "vp8" "3/4" || return 1 fi } @@ -66,10 +66,10 @@ decode_with_drops_vp8() { decode_with_drops_vp9() { if [ "$(vp9_decode_available)" = "yes" ]; then # Test sequence mode: Drop frames 2-28. - decode_with_drops "${VP9_IVF_FILE}" "vp9" "2-19" + decode_with_drops "${VP9_IVF_FILE}" "vp9" "2-19" || return 1 # Test pattern mode: Drop 3 of every 4 frames. - decode_with_drops "${VP9_IVF_FILE}" "vp9" "3/4" + decode_with_drops "${VP9_IVF_FILE}" "vp9" "3/4" || return 1 fi } diff --git a/test/postproc.sh b/test/postproc.sh index 939a3e762..91ca9b26f 100755 --- a/test/postproc.sh +++ b/test/postproc.sh @@ -38,7 +38,7 @@ postproc() { fi eval "${VPX_TEST_PREFIX}" "${decoder}" "${input_file}" "${output_file}" \ - ${devnull} + ${devnull} || return 1 [ -e "${output_file}" ] || return 1 } diff --git a/test/resize_util.sh b/test/resize_util.sh index 5e472716d..a9b0f81e2 100755 --- a/test/resize_util.sh +++ b/test/resize_util.sh @@ -41,7 +41,7 @@ resize_util() { eval "${VPX_TEST_PREFIX}" "${resizer}" "${YUV_RAW_INPUT}" \ "${YUV_RAW_INPUT_WIDTH}x${YUV_RAW_INPUT_HEIGHT}" \ "${target_dimensions}" "${output_file}" ${frames_to_resize} \ - ${devnull} + ${devnull} || return 1 [ -e "${output_file}" ] || return 1 fi diff --git a/test/set_maps.sh b/test/set_maps.sh index e7c8d43fa..f45dc51f4 100755 --- a/test/set_maps.sh +++ b/test/set_maps.sh @@ -36,7 +36,7 @@ set_maps() { eval "${VPX_TEST_PREFIX}" "${encoder}" "${codec}" "${YUV_RAW_INPUT_WIDTH}" \ "${YUV_RAW_INPUT_HEIGHT}" "${YUV_RAW_INPUT}" "${output_file}" \ - ${devnull} + ${devnull} || return 1 [ -e "${output_file}" ] || return 1 } diff --git a/test/simple_decoder.sh b/test/simple_decoder.sh index 7eeaf71b1..65fc4828e 100755 --- a/test/simple_decoder.sh +++ b/test/simple_decoder.sh @@ -38,7 +38,7 @@ simple_decoder() { fi eval "${VPX_TEST_PREFIX}" "${decoder}" "${input_file}" "${output_file}" \ - ${devnull} + ${devnull} || return 1 [ -e "${output_file}" ] || return 1 } diff --git a/test/simple_encoder.sh b/test/simple_encoder.sh index ee633ae99..dc7f46ff3 100755 --- a/test/simple_encoder.sh +++ b/test/simple_encoder.sh @@ -36,7 +36,7 @@ simple_encoder() { eval "${VPX_TEST_PREFIX}" "${encoder}" "${codec}" "${YUV_RAW_INPUT_WIDTH}" \ "${YUV_RAW_INPUT_HEIGHT}" "${YUV_RAW_INPUT}" "${output_file}" 9999 0 100 \ - ${devnull} + ${devnull} || return 1 [ -e "${output_file}" ] || return 1 } diff --git a/test/stress.sh b/test/stress.sh index fdec764c7..b11c658a9 100755 --- a/test/stress.sh +++ b/test/stress.sh @@ -52,7 +52,7 @@ stress_verify_environment() { fi for file in "${YUV}" "${VP8}" "${VP9}"; do if [ ! -e "${file}" ] ; then - download_and_check_file "${file}" + download_and_check_file "${file}" || return 1 fi done if [ ! -e "${YUV}" ] || [ ! -e "${VP8}" ] || [ ! -e "${VP9}" ] ; then diff --git a/test/twopass_encoder.sh b/test/twopass_encoder.sh index eaeaabdfd..69ecbacd0 100755 --- a/test/twopass_encoder.sh +++ b/test/twopass_encoder.sh @@ -37,7 +37,7 @@ twopass_encoder() { eval "${VPX_TEST_PREFIX}" "${encoder}" "${codec}" "${YUV_RAW_INPUT_WIDTH}" \ "${YUV_RAW_INPUT_HEIGHT}" "${YUV_RAW_INPUT}" "${output_file}" 100 \ - ${devnull} + ${devnull} || return 1 [ -e "${output_file}" ] || return 1 } diff --git a/test/vp8_multi_resolution_encoder.sh b/test/vp8_multi_resolution_encoder.sh index bd45b5381..1e96f94cc 100755 --- a/test/vp8_multi_resolution_encoder.sh +++ b/test/vp8_multi_resolution_encoder.sh @@ -71,7 +71,7 @@ vp8_multi_resolution_encoder_three_formats() { ${layer_bitrates} \ ${temporal_layers} \ "${keyframe_insert}" \ - 0 + 0 || return 1 for output_file in ${output_files}; do if [ ! -e "${output_file}" ]; then diff --git a/test/vpx_temporal_svc_encoder.sh b/test/vpx_temporal_svc_encoder.sh index 5e5bac8fa..69c734daf 100755 --- a/test/vpx_temporal_svc_encoder.sh +++ b/test/vpx_temporal_svc_encoder.sh @@ -58,19 +58,19 @@ vpx_tsvc_encoder() { "${output_file}" "${codec}" "${YUV_RAW_INPUT_WIDTH}" \ "${YUV_RAW_INPUT_HEIGHT}" "${timebase_num}" "${timebase_den}" \ "${speed}" "${frame_drop_thresh}" "${error_resilient}" "${threads}" \ - "$@" ${devnull} + "$@" ${devnull} || return 1 # Test for y4m input. eval "${VPX_TEST_PREFIX}" "${encoder}" "${Y4M_720P_INPUT}" \ "${output_file}" "${codec}" "${Y4M_720P_INPUT_WIDTH}" \ "${Y4M_720P_INPUT_HEIGHT}" "${timebase_num}" "${timebase_den_y4m}" \ "${speed}" "${frame_drop_thresh}" "${error_resilient}" "${threads}" \ - "$@" ${devnull} + "$@" ${devnull} || return 1 else eval "${VPX_TEST_PREFIX}" "${encoder}" "${YUV_RAW_INPUT}" \ "${output_file}" "${codec}" "${YUV_RAW_INPUT_WIDTH}" \ "${YUV_RAW_INPUT_HEIGHT}" "${timebase_num}" "${timebase_den}" \ "${speed}" "${frame_drop_thresh}" "${error_resilient}" "${threads}" \ - "$@" "8" ${devnull} + "$@" "8" ${devnull} || return 1 fi done } diff --git a/test/vpxdec.sh b/test/vpxdec.sh index 044aa7e16..199feae5f 100755 --- a/test/vpxdec.sh +++ b/test/vpxdec.sh @@ -86,7 +86,7 @@ vpxdec_vp9_webm_frame_parallel() { [ "$(webm_io_available)" = "yes" ]; then for threads in 2 3 4 5 6 7 8; do vpxdec "${VP9_FPM_WEBM_FILE}" --summary --noblit --threads=$threads \ - --frame-parallel + --frame-parallel || return 1 done fi } diff --git a/test/vpxenc.sh b/test/vpxenc.sh index f94e2e094..172349a2b 100755 --- a/test/vpxenc.sh +++ b/test/vpxenc.sh @@ -131,7 +131,7 @@ vpxenc_vp8_ivf() { --codec=vp8 \ --limit="${TEST_FRAMES}" \ --ivf \ - --output="${output}" + --output="${output}" || return 1 if [ ! -e "${output}" ]; then elog "Output file does not exist." @@ -147,7 +147,7 @@ vpxenc_vp8_webm() { vpxenc $(yuv_input_hantro_collage) \ --codec=vp8 \ --limit="${TEST_FRAMES}" \ - --output="${output}" + --output="${output}" || return 1 if [ ! -e "${output}" ]; then elog "Output file does not exist." @@ -162,7 +162,8 @@ vpxenc_vp8_webm_rt() { local output="${VPX_TEST_OUTPUT_DIR}/vp8_rt.webm" vpxenc $(yuv_input_hantro_collage) \ $(vpxenc_rt_params vp8) \ - --output="${output}" + --output="${output}" || return 1 + if [ ! -e "${output}" ]; then elog "Output file does not exist." return 1 @@ -178,7 +179,7 @@ vpxenc_vp8_webm_2pass() { --codec=vp8 \ --limit="${TEST_FRAMES}" \ --output="${output}" \ - --passes=2 + --passes=2 || return 1 if [ ! -e "${output}" ]; then elog "Output file does not exist." @@ -199,7 +200,7 @@ vpxenc_vp8_webm_lag10_frames20() { --lag-in-frames="${lag_frames}" \ --output="${output}" \ --auto-alt-ref=1 \ - --passes=2 + --passes=2 || return 1 if [ ! -e "${output}" ]; then elog "Output file does not exist." @@ -215,7 +216,7 @@ vpxenc_vp8_ivf_piped_input() { --codec=vp8 \ --limit="${TEST_FRAMES}" \ --ivf \ - --output="${output}" + --output="${output}" || return 1 if [ ! -e "${output}" ]; then elog "Output file does not exist." @@ -233,7 +234,7 @@ vpxenc_vp9_ivf() { --limit="${TEST_FRAMES}" \ "${passes}" \ --ivf \ - --output="${output}" + --output="${output}" || return 1 if [ ! -e "${output}" ]; then elog "Output file does not exist." @@ -251,7 +252,7 @@ vpxenc_vp9_webm() { --codec=vp9 \ --limit="${TEST_FRAMES}" \ "${passes}" \ - --output="${output}" + --output="${output}" || return 1 if [ ! -e "${output}" ]; then elog "Output file does not exist." @@ -266,7 +267,7 @@ vpxenc_vp9_webm_rt() { local output="${VPX_TEST_OUTPUT_DIR}/vp9_rt.webm" vpxenc $(yuv_input_hantro_collage) \ $(vpxenc_rt_params vp9) \ - --output="${output}" + --output="${output}" || return 1 if [ ! -e "${output}" ]; then elog "Output file does not exist." @@ -290,7 +291,7 @@ vpxenc_vp9_webm_rt_multithread_tiled() { $(vpxenc_rt_params vp9) \ --threads=${threads} \ --tile-columns=${tile_cols} \ - --output="${output}" + --output="${output}" || return 1 if [ ! -e "${output}" ]; then elog "Output file does not exist." @@ -318,7 +319,8 @@ vpxenc_vp9_webm_rt_multithread_tiled_frameparallel() { --threads=${threads} \ --tile-columns=${tile_cols} \ --frame-parallel=1 \ - --output="${output}" + --output="${output}" || return 1 + if [ ! -e "${output}" ]; then elog "Output file does not exist." return 1 @@ -337,7 +339,7 @@ vpxenc_vp9_webm_2pass() { --codec=vp9 \ --limit="${TEST_FRAMES}" \ --output="${output}" \ - --passes=2 + --passes=2 || return 1 if [ ! -e "${output}" ]; then elog "Output file does not exist." @@ -356,7 +358,7 @@ vpxenc_vp9_ivf_lossless() { --ivf \ --output="${output}" \ "${passes}" \ - --lossless=1 + --lossless=1 || return 1 if [ ! -e "${output}" ]; then elog "Output file does not exist." @@ -376,7 +378,7 @@ vpxenc_vp9_ivf_minq0_maxq0() { --output="${output}" \ "${passes}" \ --min-q=0 \ - --max-q=0 + --max-q=0 || return 1 if [ ! -e "${output}" ]; then elog "Output file does not exist." @@ -398,7 +400,7 @@ vpxenc_vp9_webm_lag10_frames20() { --lag-in-frames="${lag_frames}" \ --output="${output}" \ "${passes}" \ - --auto-alt-ref=1 + --auto-alt-ref=1 || return 1 if [ ! -e "${output}" ]; then elog "Output file does not exist." @@ -417,7 +419,7 @@ vpxenc_vp9_webm_non_square_par() { --codec=vp9 \ --limit="${TEST_FRAMES}" \ "${passes}" \ - --output="${output}" + --output="${output}" || return 1 if [ ! -e "${output}" ]; then elog "Output file does not exist." @@ -443,7 +445,7 @@ vpxenc_vp9_webm_sharpness() { --end-usage=q \ --cq-level=40 \ --output="${output}" \ - "${passes}" + "${passes}" || return 1 if [ ! -e "${output}" ]; then elog "Output file does not exist."