From b5f052feec329a39d4f176ef07f9b99370c7583d Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 27 May 2016 11:50:07 +0300 Subject: vsp-lib: Support optional features for tests Add a third argument to test_init() to pass a list of optional features. If more than one media device supports all the required features, select the one that supports the highest number of optional features. Signed-off-by: Laurent Pinchart --- scripts/vsp-lib.sh | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/vsp-lib.sh b/scripts/vsp-lib.sh index c5db772..d48108a 100755 --- a/scripts/vsp-lib.sh +++ b/scripts/vsp-lib.sh @@ -460,10 +460,13 @@ format_configure() { test_init() { logfile=${1/sh/log} features=$2 + optional_features=$3 rm -f $logfile rm -f *.bin + best_features_count=0 + for mdev in /dev/media* ; do match='true' for feature in $features ; do @@ -473,17 +476,37 @@ test_init() { } done - if [ $match == 'true' ] ; then + if [ $match == 'false' ] ; then + continue + fi + + if [ -z "$optional_features" ] ; then + best_mdev=$mdev break fi + + features_count=0 + for feature in $optional_features ; do + $(vsp1_has_feature $feature) && { + features_count=$((features_count+1)) + match='false'; + break; + } + done + + if [ $features_count -ge $best_features_count ] ; then + best_mdev=$mdev + best_features_count=$features_count + fi done - if [ $match == 'false' ] ; then + if [ -z $best_mdev ] ; then echo "No device found with feature set $features" | ./logger.sh config >> $logfile exit 1 fi - dev=$(vsp1_device $mdev) + mdev=$best_mdev + dev=$(vsp1_device $best_mdev) echo "Using device $mdev ($dev)" | ./logger.sh config >> $logfile vsp_runner=./vsp-runner.sh -- cgit v1.2.3