# Copyright (c) 2026 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
source HPKBUILD > /dev/null 2>&1
logfile=${LYCIUM_THIRDPARTY_ROOT}/${pkgname}/${pkgname}_${ARCH}_${OHOS_SDK_VER}_test.log
openharmonycheck() {
rm -f "$logfile"
res=0
export LD_PRELOAD="$LYCIUM_ROOT/usr/fribidi/$ARCH/lib/libfribidi.so"
cd "${builddir}/MediaCore/${ARCH}-build/"
cp -f "../script/gen_test_assets.sh" ./
chmod +x ./gen_test_assets.sh
./gen_test_assets.sh >> "${logfile}" 2>&1
if [ $? -ne 0 ]; then
return 1
fi
echo "[Success] Test assets generated successfully." >> "${logfile}" 2>&1
test_executables=()
for file in *Test; do
if [ -f "$file" ] && [ -x "$file" ]; then
test_executables+=("$file")
fi
done
total_tests=${#test_executables[@]}
passed=0
failed=0
if [ "$total_tests" -eq 0 ]; then
echo "No executable tests found matching '*Test'." >> "${logfile}" 2>&1
cd "$OLDPWD"
return 0
fi
INPUT_MP4="test.mp4"
OUTPUT_MP4="output.mp4"
INPUT_SUB="test.srt"
declare -A test_args=(
["MediaEncoderTest"]="$INPUT_MP4 $OUTPUT_MP4"
["SnapshotTest"]="$INPUT_MP4"
["MediaReaderTest"]="$INPUT_MP4"
["OverviewTest"]="$INPUT_MP4"
["MultiTrackVideoTest"]="$INPUT_MP4"
["MultiTrackAudioTest"]="$INPUT_MP4"
["SubtitleReaderTest"]="$INPUT_SUB"
["UnitTest"]="CreateVideoReaderInstance"
)
for test_exe in "${test_executables[@]}"; do
args="${test_args[$test_exe]}"
echo "Running $test_exe $args ..." >> "${logfile}"
"./$test_exe" $args >> "${logfile}" 2>&1
test_res=$?
if [ $test_res -eq 0 ]; then
((passed++))
echo "[PASSED] $test_exe $args" >> "${logfile}"
else
((failed++))
res=$test_res
echo "[FAILED] $test_exe (Exit code: $test_res)" >> "${logfile}"
fi
done
echo "Test completed. Passed: $passed, Failed: $failed, Total: $total_tests" >> "${logfile}" 2>&1
cd "$OLDPWD"
return $res
}