Modify av1_c_vs_simd_enc_test script
Enabled av1_c_vs_simd_enc_test in Jenkins.
Modified the test script to make it work with existing testing
mechanism.
BUG=aomedia:3472
Change-Id: Iedebd7a57632ab52da54c7d436076180a1eb64af
diff --git a/test/av1_c_vs_simd_encode.sh b/test/av1_c_vs_simd_encode.sh
old mode 100644
new mode 100755
index cc547c8..631b56d
--- a/test/av1_c_vs_simd_encode.sh
+++ b/test/av1_c_vs_simd_encode.sh
@@ -10,6 +10,8 @@
##
## This script checks the bit exactness between C and SIMD
## implementations of AV1 encoder.
+##
+. $(dirname $0)/tools_common.sh
PRESETS="good rt"
LOWBD_CLIPS="yuv_raw_input yuv_480p_raw_input y4m_720p_input y4m_screen_input"
@@ -17,7 +19,6 @@
OUT_FILE_SUFFIX=".ivf"
SCRIPT_DIR=$(dirname "$0")
LIBAOM_SOURCE_DIR=$(cd ${SCRIPT_DIR}/..; pwd)
-devnull='> /dev/null 2>&1'
# Clips used in test.
YUV_RAW_INPUT="${LIBAOM_TEST_DATA_PATH}/hantro_collage_w352h288.yuv"
@@ -93,9 +94,11 @@
fi
}
-cleanup() {
- rm -rf ${AOM_TEST_OUTPUT_DIR}
-}
+# This is not needed since tools_common.sh does the same cleanup.
+# Keep the code here for our reference.
+# cleanup() {
+# rm -rf ${AOM_TEST_OUTPUT_DIR}
+# }
# Echo AOM_SIMD_CAPS_MASK for different instruction set architecture.
avx512f() {
@@ -208,8 +211,8 @@
has_x86_isa_extn() {
instruction_set=$1
- grep -q "$instruction_set" /proc/cpuinfo
- if [ $? -eq 1 ]; then
+ if ! grep -q "$instruction_set" /proc/cpuinfo; then
+ # This instruction set is not supported.
return 1
fi
}
@@ -322,9 +325,8 @@
local clip=$3
local bitrate=$4
local preset=$5
- diff ${AOM_TEST_OUTPUT_DIR}/Out-generic-"${clip}"-${preset}-${bitrate}kbps-cpu${cpu}${OUT_FILE_SUFFIX} \
- ${AOM_TEST_OUTPUT_DIR}/Out-${target}-"${clip}"-${preset}-${bitrate}kbps-cpu${cpu}${OUT_FILE_SUFFIX} > /dev/null
- if [ $? -eq 1 ]; then
+ if ! diff -q ${AOM_TEST_OUTPUT_DIR}/Out-generic-"${clip}"-${preset}-${bitrate}kbps-cpu${cpu}${OUT_FILE_SUFFIX} \
+ ${AOM_TEST_OUTPUT_DIR}/Out-${target}-"${clip}"-${preset}-${bitrate}kbps-cpu${cpu}${OUT_FILE_SUFFIX}; then
elog "C vs ${target} encode mismatches for ${clip}, at ${bitrate} kbps, speed ${cpu}, ${preset} preset"
return 1
fi
@@ -371,8 +373,8 @@
${devnull}
if [ "${target}" != "generic" ]; then
- compare_enc_output ${target} $cpu ${clip} $bitrate ${preset}
- if [ $? -eq 1 ]; then
+ if ! compare_enc_output ${target} $cpu ${clip} $bitrate ${preset}; then
+ # Found a mismatch
return 1
fi
fi
@@ -392,7 +394,7 @@
# The cmake command line option -DENABLE_MMX=0 flag disables all SIMD
# optimizations, and generates a C-only binary.
local cmake_command="cmake $LIBAOM_SOURCE_DIR -DENABLE_MMX=0 \
- -DCMAKE_TOOLCHAIN_FILE=${LIBAOM_SOURCE_DIR}/build/cmake/toolchains/${arch}-linux.cmake"
+ -DCMAKE_TOOLCHAIN_FILE=${LIBAOM_SOURCE_DIR}/build/cmake/toolchains/i686-linux-gcc.cmake"
fi
echo "Build for: Generic ${arch}"
@@ -424,8 +426,7 @@
av1_test_x86() {
local arch=$1
- uname -m | grep -q "x86"
- if [ $? -eq 1 ]; then
+ if ! uname -m | grep -q "x86"; then
elog "Machine architecture is not x86 or x86_64"
return 0
fi
@@ -434,7 +435,7 @@
local target="x86-linux"
local cmake_command="cmake \
$LIBAOM_SOURCE_DIR \
- -DCMAKE_TOOLCHAIN_FILE=${LIBAOM_SOURCE_DIR}/build/cmake/toolchains/${target}.cmake"
+ -DCMAKE_TOOLCHAIN_FILE=${LIBAOM_SOURCE_DIR}/build/cmake/toolchains/i686-linux-gcc.cmake"
elif [ $arch = "x86_64" ]; then
local target="x86_64-linux"
local cmake_command="cmake $LIBAOM_SOURCE_DIR"
@@ -448,14 +449,14 @@
for preset in $PRESETS; do
local encoder="$(av1_enc_tool_path "${target}" "${preset}")"
for isa in $x86_isa_variants; do
- has_x86_isa_extn $isa
- if [ $? -eq 1 ]; then
+ # Note that if has_x86_isa_extn returns 1, it is false, and vice versa.
+ if ! has_x86_isa_extn $isa; then
echo "${isa} is not supported in this machine"
continue
fi
export AOM_SIMD_CAPS_MASK=$($isa)
- av1_enc_test $encoder "${target}" "${preset}"
- if [ $? -eq 1 ]; then
+ if ! av1_enc_test $encoder "${target}" "${preset}"; then
+ # Found a mismatch
return 1
fi
unset AOM_SIMD_CAPS_MASK
@@ -479,8 +480,8 @@
continue
fi
local encoder="$(av1_enc_tool_path "${target}" "${preset}")"
- av1_enc_test "qemu-aarch64 -L /usr/aarch64-linux-gnu ${encoder}" "${target}" "${preset}"
- if [ $? -eq 1 ]; then
+ if ! av1_enc_test "qemu-aarch64 -L /usr/aarch64-linux-gnu ${encoder}" "${target}" "${preset}"; then
+ # Found a mismatch
return 1
fi
done
@@ -488,14 +489,15 @@
av1_c_vs_simd_enc_test () {
# Test x86 (32 bit)
+ # x86 requires the i686-linux-gnu toolchain:
+ # $ sudo apt-get install g++-i686-linux-gnu
echo "av1 test for x86 (32 bit): Started."
# Encode 'C' only
av1_test_generic "x86"
-
# Encode with SIMD optimizations enabled
- av1_test_x86 "x86"
- if [ $? -eq 1 ]; then
+ if ! av1_test_x86 "x86"; then
echo "av1 test for x86 (32 bit): Done, test failed."
+ return 1
else
echo "av1 test for x86 (32 bit): Done, all tests passed."
fi
@@ -506,9 +508,9 @@
# Encode 'C' only
av1_test_generic "x86_64"
# Encode with SIMD optimizations enabled
- av1_test_x86 "x86_64"
- if [ $? -eq 1 ]; then
+ if ! av1_test_x86 "x86_64"; then
echo "av1 test for x86_64 (64 bit): Done, test failed."
+ return 1
else
echo "av1 test for x86_64 (64 bit): Done, all tests passed."
fi
@@ -516,20 +518,12 @@
# Test ARM
echo "av1_test_arm: Started."
- av1_test_arm
- if [ $? -eq 1 ]; then
+ if ! av1_test_arm; then
echo "av1 test for arm: Done, test failed."
+ return 1
else
echo "av1 test for arm: Done, all tests passed."
fi
}
-# Setup a trap function to clean up build, and output files after tests complete.
-trap cleanup EXIT
-
-av1_c_vs_simd_enc_verify_environment
-if [ $? -eq 1 ]; then
- echo "Environment check failed."
- exit 1
-fi
-av1_c_vs_simd_enc_test
+run_tests av1_c_vs_simd_enc_verify_environment av1_c_vs_simd_enc_test
diff --git a/test/examples.sh b/test/examples.sh
index 771a7b6..87d8c2b 100755
--- a/test/examples.sh
+++ b/test/examples.sh
@@ -15,7 +15,7 @@
example_tests=$(ls -r $(dirname $0)/*.sh)
# List of script names to exclude.
-exclude_list="best_encode examples run_encodes tools_common av1_c_vs_simd_encode"
+exclude_list="best_encode examples run_encodes tools_common"
if [ "$(realtime_only_build)" = "yes" ]; then
exclude_list="${exclude_list} twopass_encoder simple_decoder lightfield_test"
diff --git a/test/tools_common.sh b/test/tools_common.sh
index f2d1802..cb9eba1 100755
--- a/test/tools_common.sh
+++ b/test/tools_common.sh
@@ -312,7 +312,11 @@
# Combine environment and actual tests.
local tests_to_run="${env_tests} ${tests_to_filter}"
- check_version_strings
+ # av1_c_vs_simd_encode is a standalone test, and it doesn't need to check the
+ # version string.
+ if [ "${test_name}" != "av1_c_vs_simd_encode" ]; then
+ check_version_strings
+ fi
# Run tests.
for test in ${tests_to_run}; do
@@ -464,6 +468,8 @@
AOM_TEST_PRESERVE_OUTPUT=${AOM_TEST_PRESERVE_OUTPUT:-no}
+# This checking requires config/aom_config.c that is available in Jenkins
+# testing.
if [ "$(is_windows_target)" = "yes" ]; then
AOM_TEST_EXE_SUFFIX=".exe"
fi