shithub: libvpx

Download patch

ref: b120ba5781a520c015b356a7c77c89545ccdee32
parent: 3d28ff98039134325cf689d8d08996fc8dabb225
author: James Zern <[email protected]>
date: Tue Apr 28 14:51:01 EDT 2020

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

--- a/test/cx_set_ref.sh
+++ b/test/cx_set_ref.sh
@@ -38,7 +38,7 @@
 
   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
 }
--- a/test/decode_to_md5.sh
+++ b/test/decode_to_md5.sh
@@ -40,7 +40,7 @@
   fi
 
   eval "${VPX_TEST_PREFIX}" "${decoder}" "${input_file}" "${output_file}" \
-      ${devnull}
+      ${devnull} || return 1
 
   [ -e "${output_file}" ] || return 1
 
--- a/test/decode_with_drops.sh
+++ b/test/decode_with_drops.sh
@@ -40,7 +40,7 @@
   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_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_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
 }
 
--- a/test/postproc.sh
+++ b/test/postproc.sh
@@ -38,7 +38,7 @@
   fi
 
   eval "${VPX_TEST_PREFIX}" "${decoder}" "${input_file}" "${output_file}" \
-      ${devnull}
+      ${devnull} || return 1
 
   [ -e "${output_file}" ] || return 1
 }
--- a/test/resize_util.sh
+++ b/test/resize_util.sh
@@ -41,7 +41,7 @@
     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
--- a/test/set_maps.sh
+++ b/test/set_maps.sh
@@ -36,7 +36,7 @@
 
   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
 }
--- a/test/simple_decoder.sh
+++ b/test/simple_decoder.sh
@@ -38,7 +38,7 @@
   fi
 
   eval "${VPX_TEST_PREFIX}" "${decoder}" "${input_file}" "${output_file}" \
-      ${devnull}
+      ${devnull} || return 1
 
   [ -e "${output_file}" ] || return 1
 }
--- a/test/simple_encoder.sh
+++ b/test/simple_encoder.sh
@@ -36,7 +36,7 @@
 
   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
 }
--- a/test/stress.sh
+++ b/test/stress.sh
@@ -52,7 +52,7 @@
   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
--- a/test/twopass_encoder.sh
+++ b/test/twopass_encoder.sh
@@ -37,7 +37,7 @@
 
   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
 }
--- a/test/vp8_multi_resolution_encoder.sh
+++ b/test/vp8_multi_resolution_encoder.sh
@@ -71,7 +71,7 @@
         ${layer_bitrates} \
         ${temporal_layers} \
         "${keyframe_insert}" \
-        0
+        0 || return 1
 
       for output_file in ${output_files}; do
         if [ ! -e "${output_file}" ]; then
--- a/test/vpx_temporal_svc_encoder.sh
+++ b/test/vpx_temporal_svc_encoder.sh
@@ -58,19 +58,19 @@
         "${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
 }
--- a/test/vpxdec.sh
+++ b/test/vpxdec.sh
@@ -86,7 +86,7 @@
      [ "$(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
 }
--- a/test/vpxenc.sh
+++ b/test/vpxenc.sh
@@ -131,7 +131,7 @@
       --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 $(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 @@
     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 @@
       --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 @@
       --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 @@
       --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 @@
       --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 @@
       --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 @@
     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_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 @@
           --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 @@
       --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 @@
       --ivf \
       --output="${output}" \
       "${passes}" \
-      --lossless=1
+      --lossless=1 || return 1
 
     if [ ! -e "${output}" ]; then
       elog "Output file does not exist."
@@ -376,7 +378,7 @@
       --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 @@
       --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 @@
       --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 @@
         --end-usage=q \
         --cq-level=40 \
         --output="${output}" \
-        "${passes}"
+        "${passes}" || return 1
 
       if [ ! -e "${output}" ]; then
         elog "Output file does not exist."