Navigation Menu

Skip to content

Commit

Permalink
tests: Added testing IMaH v2 packages
Browse files Browse the repository at this point in the history
The tests currently fail. But at least they're there.
  • Loading branch information
mefistotelis committed Apr 14, 2021
1 parent 338209f commit f44c53b
Showing 1 changed file with 39 additions and 16 deletions.
55 changes: 39 additions & 16 deletions tests/test_imah_all.sh
Expand Up @@ -26,61 +26,65 @@ if [ ! -f "tests/test_dji_imah_fwsig_rebin1.sh" ]; then
exit 4
fi

declare -a FWPKG_LIST=(
declare -a FWPKG1_LIST=(
V01.03.0200_Mavic_dji_system.bin
V01.03.0900_Mavic_dji_system.bin
V01.04.0000_Mavic_dji_system.bin
V01.04.0500_Mavic_dji_system.bin
)

declare -a FWPKG2_LIST=(
V01.00.0500_Mavic_Mini_dji_system.tar
)

# In case we want to use Python from non-standard location
#PATH="/mingw64/bin:$PATH"

echo "Using Python: $(which python3)"

set -e

NUMFAILS=0
NUMSKIPS=0

for FWPKG in "${FWPKG_LIST[@]}"; do
FWDLURL=
FWDLNAME=
FWTSTFLG=0x00
function test_dji_imah_package {
FWPKG="$1"
FWDIR="$2"
FWDLURL="$3"
FWDLNAME="$4"
FWTSTFLG="$5"

# Download firmwares

if [ ! -f "fw_imah1/${FWPKG}" ]; then
if [ ! -f "${FWDIR}/${FWPKG}" ]; then

if [ ! -f "fw_imah1/${FWDLNAME}" ] && [ $((FWTSTFLG & 0x01)) -ne 0 ]; then
curl "${FWDLURL}" -o "fw_imah1/${FWDLNAME}"
if [ ! -f "${FWDIR}/${FWDLNAME}" ] && [ $((FWTSTFLG & 0x01)) -ne 0 ]; then
curl "${FWDLURL}" -o "${FWDIR}/${FWDLNAME}"
fi

if [ ! -f "fw_imah1/${FWDLNAME}" ]; then
if [ ! -f "${FWDIR}/${FWDLNAME}" ]; then
echo '### SKIP could not download firmware to test ###'
((NUMSKIPS++))
continue
return 1
fi

if [[ ${FWDLNAME} =~ [.]zip$ ]]; then
(unzip -j -o -d fw "fw_imah1/${FWDLNAME}")
(unzip -j -o -d fw "${FWDIR}/${FWDLNAME}")
elif [[ ${FWDLNAME} =~ [.]rar$ ]]; then
(cd fw && unrar e "${FWDLNAME}")
fi
fi

if [ ! -f "fw_imah1/${FWPKG}" ]; then
if [ ! -f "${FWDIR}/${FWPKG}" ]; then
echo '### SKIP could not extract firmware to test ###'
((NUMSKIPS++))
continue
return 1
fi

SIGDIR=
if [ ! -z "${FWPKG}" ]; then
SIGDIR=${FWPKG%.*}
# Extract the package TAR file
mkdir "${SIGDIR}"
tar -xf "fw_imah1/${FWPKG}" -C "${SIGDIR}"
tar -xf "${FWDIR}/${FWPKG}" -C "${SIGDIR}"
if [ $? -ne 0 ]; then
((NUMFAILS++))
fi
Expand Down Expand Up @@ -110,6 +114,25 @@ for FWPKG in "${FWPKG_LIST[@]}"; do
rm -d "${SIGDIR}"
fi

return 0
}

for FWPKG in "${FWPKG1_LIST[@]}"; do
FWDIR="fw_imah1"
FWDLURL=
FWDLNAME=
FWTSTFLG=0x00

test_dji_imah_package "${FWPKG}" "${FWDIR}" "${FWDLURL}" "${FWDLNAME}" "${FWTSTFLG}"
done

for FWPKG in "${FWPKG2_LIST[@]}"; do
FWDIR="fw_imah2"
FWDLURL=
FWDLNAME=
FWTSTFLG=0x00

test_dji_imah_package "${FWPKG}" "${FWDIR}" "${FWDLURL}" "${FWDLNAME}" "${FWTSTFLG}"
done

if [ ${NUMSKIPS} -gt 0 ]; then
Expand Down

0 comments on commit f44c53b

Please sign in to comment.