#!/bin/sh

set -e

DEB_BUILD_MULTIARCH=`dpkg-architecture -qDEB_BUILD_MULTIARCH`
TEMP=${AUTOPKGTEST_TMP:-${TMPDIR:-$(mktemp -d)}}
TDIR=$(mktemp -d $TEMP/lscompbellXXXXXX)

if [ -e /usr/lib/"$DEB_BUILD_MULTIARCH"/libomxil-bellagio.so.0 ]; then
    echo "Test for multi-arch"
    gst-omx-listcomponents \
	/usr/lib/"$DEB_BUILD_MULTIARCH"/libomxil-bellagio.so.0 \
	> "$TDIR"/list1.txt
elif [ -e /usr/lib/libomxil-bellagio.so.0 ]; then
    echo "Test for non-multiarch"
    gst-omx-listcomponents \
	/usr/lib/libomxil-bellagio.so.0 \
	> "$TDIR"/list1.txt
else
    echo "Did not found libomxil-bellagio.so.0"
    exit 1
fi

grep -q "OMX.st.audio_decoder.mp3.mad" "$TDIR"/list1.txt
if [ $? -eq 0 ] ; then
    echo "Pass - OMX.st.audio_decoder.mp3.mad"
else
    echo "Fail - OMX.st.audio_decoder.mp3.mad"
    exit 4
fi
