1
0
intel-media-ffmpeg/scripts/test-image.sh
James Ketrenos bc93cb5c47 Updated to latest xe-solutions and migrate RHEL from 8.0 to 8.1
Signed-off-by: James Ketrenos <james.p.ketrenos@intel.com>
2020-03-17 16:45:16 -07:00

99 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
# Bring in the variables from SOLUTION file, supporting
# nested substitution
. SOLUTION
VARS=($(sed -nE "s,(^[^#][^=]*).*$,\1,pg" SOLUTION))
for var in ${VARS[@]}; do
export ${var}
done
RELEASE_INFO=${RELEASE_INFO:-N/A}
[[ "${RELEASE_INFO}" == "N/A" ]] && {
TAG=${TAG:-test-build-${OS_DISTRO}-${PACKAGE_STREAM}-$(date +%Y%m%d)}
} || {
TAG=${TAG:-test-${OS_DISTRO}-${PACKAGE_STREAM}-${RELEASE_INFO}}
}
function fail {
>&2 echo "$*"
exit -1
}
VIDEO=$(getent group video | sed -E 's,^video:[^:]*:([^:]*):.*$,\1,')
RENDER=$(getent group render | sed -E 's,^render:[^:]*:([^:]*):.*$,\1,')
function usage {
cat << EOF
usage: scripts/test-image.sh [OPTIONS]
Options:
-l Use the local image (vs. from ${REGISTRY})
EOF
}
LOCAL=0
while getopts l opt; do
case "${opt}" in
l)
LOCAL=1
;;
[?])
>&2 echo -e "\nInvalid parameter: ${opt}\n"
usage >&2
exit 1
;;
esac
done
shift $(( OPTIND-1 ))
(( ! LOCAL )) && {
IMAGE=${REGISTRY_URL}/${CONTAINER}:${TAG}
docker pull ${IMAGE} || fail "Unable to pull ${IMAGE}"
} || {
IMAGE=${CONTAINER}:${TAG}
}
# Take entry-point from command line arguments, or set to 'test'
# if nothing provided
ENTRY="${*}"
[[ "${ENTRY}" == "" ]] && {
DOCKER_ARGS=""
ENTRY="test"
} || {
DOCKER_ARGS=" -it --rm \
"
}
[[ "${VIDEO}" != "" ]] || fail "No video group found."
ADD_GROUPS="--group-add ${VIDEO}"
[[ "${RENDER}" != "" ]] && ADD_GROUPS+=" --group-add ${RENDER}"
[[ -e data/ ]] || mkdir data || fail "Unable to make data volume directory"
chmod a+rwX data || fail "Unable to chmod data volume to a+rwX"
CMD="docker run \
${ADD_GROUPS} ${DOCKER_ARGS} \
--rm \
--device=/dev/dri \
-v $(pwd)/data:/data \
${IMAGE}"
cat << EOF
-------------------------------------------------------------------------------
Running test with:
video group GID: ${VIDEO}
$( [[ "${RENDER}" != "" ]] && echo -e " render group GID: ${RENDER}\n" )
Running container via:
$( echo " ${CMD} ${ENTRY}" | sed -e "s, , \\\\\n ,g")
-------------------------------------------------------------------------------
EOF
${CMD} info || fail "Unable to execute 'info' on ${IMAGE}."
${CMD} ${ENTRY} || fail "Unable to execute 'test' on ${IMAGE}."