aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2019-01-28 11:09:24 (GMT)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2019-01-28 11:09:24 (GMT)
commit0caa3c7d126cc4c2ee53e075cda16368ff295255 (patch)
tree3ec79b2c3b4d5e5944461550103ba59110ff8d27
parent93d0305be64995d918a203c3b6c96fbca3fae4b0 (diff)
v4l-utils: add test-media regression tests
This is the first version of the regression tests. To do: - It assumes that all video devices are at the same number (e.g. video0 is always the first vivid capture device). Instead it should discover this based on media driver names and bus_info. Once this in place it is likely that the test-media-unload.pl script can be dropped, and that these drivers can also be compiled directly into the kernel instead of as modules. - There are still a few fails due to kernel code that has not yet been merged. - The vicodec driver isn't included in the tests as it needs more work, both in the driver itself and in the compliance tests. - vivid generates a few warnings. Work is progressing to fix those. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rwxr-xr-xcontrib/test/test-media134
-rwxr-xr-xcontrib/test/test-media-unload.pl160
2 files changed, 294 insertions, 0 deletions
diff --git a/contrib/test/test-media b/contrib/test/test-media
new file mode 100755
index 0000000..0a8cc1a
--- /dev/null
+++ b/contrib/test/test-media
@@ -0,0 +1,134 @@
+#!/bin/bash
+
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Copyright 2013 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
+
+vivid=0
+vim2m=0
+vimc=0
+cec=0
+cecpwr=--skip-test-standby-resume
+
+if [ -z "$1" ]; then
+ echo "usage: test-media all|mc|vivid|vim2m|vimc|cec|cec-pwr"
+ echo
+ echo Run as root.
+ echo
+ echo "'all' equals 'vivid vim2m vimc cec cec-pwr'"
+ echo "'mc' equals 'vivid vim2m vimc'"
+ echo "'cec' adds the CEC compliance tests, 'cec-pwr' adds the CEC standby/wakeup tests."
+ exit 0
+fi
+
+if [ `id -u` -ne 0 ]; then
+ echo "$0 must be run as root"
+ exit -1
+fi
+
+while [ ! -z "$1" ]; do
+ case "$1" in
+ all)
+ vivid=1
+ vim2m=1
+ vimc=1
+ cec=1
+ cecpwr=
+ ;;
+ mc)
+ vivid=1
+ vim2m=1
+ vimc=1
+ ;;
+ vivid)
+ vivid=1
+ ;;
+ vim2m)
+ vim2m=1
+ ;;
+ vimc)
+ vimc=1
+ ;;
+ cec)
+ cec=1
+ ;;
+ cec-pwr)
+ cecpwr=
+ ;;
+ esac
+ shift
+done
+
+test-media-unload.pl
+
+modprobe vivid n_devs=3 multiplanar=1,2,2 #allocators=0,1,1
+modprobe vim2m
+modprobe vimc
+sleep 1
+
+v4l2-ctl -d0 -i3 -v width=3840,height=2160,pixelformat=NV24
+v4l2-ctl -d1 -o1 -x width=3840,height=2160,pixelformat=NV24
+v4l2-ctl -d2 -i3 -v width=3840,height=2160,pixelformat=NM16
+v4l2-ctl -d3 -o1 -x width=3840,height=2160,pixelformat=NM16
+v4l2-ctl -d4 -i3 -v width=3840,height=2160,pixelformat=NV24
+v4l2-ctl -d5 -o1 -x width=3840,height=2160,pixelformat=NM16
+
+media-ctl -d /dev/media4 -V '1:0[fmt:SBGGR8_1X8/640x480]'
+media-ctl -d /dev/media4 -V '5:0[fmt:SBGGR8_1X8/640x480]'
+v4l2-ctl -d9 -v width=1920,height=1440
+v4l2-ctl -d9 -v width=1920,height=1440
+v4l2-ctl -d7 -v pixelformat=BA81
+echo
+
+tmp=`mktemp`
+
+if [ $vivid -eq 1 ]; then
+ stdbuf -oL v4l2-compliance -m0 -e4 -s10 -a 2>&1 | tee -a $tmp
+ echo
+ stdbuf -oL v4l2-compliance -m1 -e5 -s10 -a 2>&1 | tee -a $tmp
+ echo
+fi
+
+if [ $cec -eq 1 ]; then
+ cec-ctl -s -d0 --tv
+ cec-ctl -s -d1 --playback
+ trap 'kill $f0 $f1 2>/dev/null' INT
+ cec-follower -s -d0 2>&1 >/dev/null &
+ f0=$!
+ cec-follower -s -d1 2>&1 >/dev/null &
+ f1=$!
+ stdbuf -oL cec-compliance -d0 -A -r4 -t10 $cecpwr 2>&1 | tee -a $tmp
+ sleep 5
+ stdbuf -oL cec-compliance -d1 -A -r0 -t10 $cecpwr 2>&1 | tee -a $tmp
+ kill $f0
+ kill $f1
+ echo
+fi
+
+if [ $vim2m -eq 1 ]; then
+ stdbuf -oL v4l2-compliance -m3 -e4 -s10 -a 2>&1 | tee -a $tmp
+ echo
+fi
+
+if [ $vimc -eq 1 ]; then
+ stdbuf -oL v4l2-compliance -m4 -e4 -s10 -a 2>&1 | tee -a $tmp
+ echo
+fi
+
+echo Summary:
+echo
+
+grep 'Total' $tmp
+grep 'Grand Total' $tmp | perl -e '
+while (<>) {
+ ($succeeded, $failed, $warnings) = /Succeeded: (\d+), Failed: (\d+), Warnings: (\d+)/;
+ $tot_succeeded += $succeeded;
+ $tot_failed += $failed;
+ $tot_warnings += $warnings;
+}
+
+printf("\nFinal Summary: %d, Succeeded: %d, Failed: %d, Warnings: %d\n",
+ $tot_succeeded + $tot_failed, $tot_succeeded, $tot_failed, $tot_warnings);
+'
+
+rm -f $tmp
diff --git a/contrib/test/test-media-unload.pl b/contrib/test/test-media-unload.pl
new file mode 100755
index 0000000..524b1f8
--- /dev/null
+++ b/contrib/test/test-media-unload.pl
@@ -0,0 +1,160 @@
+#!/usr/bin/perl
+
+# Copyright (c) 2006-2010 by Mauro Carvalho Chehab <mchehab@redhat.com>
+#
+# Licensed under the terms of the GNU GPL License version 2
+
+use strict;
+use File::Find;
+
+my %depend = ();
+my %depend2 = ();
+my %rmlist = ();
+my @nodep;
+my @modlist;
+my @allmodules;
+my %reqmodules;
+my %loaded = ();
+my $i=0;
+
+sub findprog($)
+{
+ foreach(split(/:/, $ENV{PATH}),qw(/sbin /usr/sbin /usr/local/sbin)) {
+ return "$_/$_[0]" if(-x "$_/$_[0]");
+ }
+ die "Can't find needed utility '$_[0]'";
+}
+
+sub parse_dir {
+ my $file = $File::Find::name;
+ my $modinfo = findprog('modinfo');
+
+ if (!($file =~ /[.]ko$/)) {
+ return;
+ }
+
+ my $module = $file;
+ $module =~ s|.*\/([^/]+)\.ko|\1|;
+
+ open IN, "$modinfo $module.ko|" or die "can't run $modinfo $file";
+ while (<IN>) {
+ if (m/depends:\s*(.*)/) {
+ my $deps = $1;
+ $deps =~ s/\n//;
+ $deps =~ s/[,]/ /g;
+ $deps = " $deps ";
+ $depend{$module} = $deps;
+ push @allmodules, $module;
+ $i++;
+ }
+ }
+ close IN;
+}
+
+sub parse_loaded {
+ open IN, "/proc/modules";
+ while (<IN>) {
+ m/^([\w\d_-]+)/;
+ $loaded{$1}=1;
+ }
+ close IN;
+}
+
+sub cleandep()
+{
+ my $dep;
+
+ while ( my ($k, $v) = each(%depend) ) {
+ my $arg=$v;
+ my $arg2=" ";
+ while (!($arg =~ m/^\s*$/)) {
+ if ($arg =~ m/^ ([^ ]+) /) {
+ my $val=$1;
+ if (exists($depend{$val})) {
+ $arg2="$arg2 $val ";
+ } else {
+ $reqmodules{$val}=1;
+ }
+ }
+ $arg =~ s/^ [^ ]+//;
+ $arg2 =~ s/\s\s+/ /;
+ }
+ $depend2 { $k } = $arg2;
+ }
+
+}
+
+sub rmdep()
+{
+ my $dep;
+
+ while ($dep=pop @nodep) {
+ while ( my ($k, $v) = each(%depend2) ) {
+ if ($v =~ m/\s($dep)\s/) {
+ $v =~ s/\s${dep}\s/ /;
+ $v =~ s/\s${dep}\s/ /;
+ $v =~ s/\s${dep}\s/ /;
+ $depend2 {$k} = $v;
+ }
+ }
+ }
+}
+
+sub orderdep ()
+{
+ my $old;
+ do {
+ $old=$i;
+ while ( my ($key, $value) = each(%depend2) ) {
+ if ($value =~ m/^\s*$/) {
+ push @nodep, $key;
+ push @modlist, $key;
+ $i=$i-1;
+ delete $depend2 {$key};
+ }
+ }
+ rmdep();
+ } until ($old==$i);
+ while ( my ($key, $value) = each(%depend2) ) {
+ printf "ERROR: bad dependencies - $key ($value)\n";
+ }
+}
+
+sub rmmod(@)
+{
+ my $rmmod = findprog('rmmod');
+ my @not;
+ foreach (reverse @_) {
+ s/-/_/g;
+ if (exists ($loaded{$_})) {
+ print "$rmmod $_\n";
+ unshift @not, $_ if (system "$rmmod $_");
+ }
+ }
+ return @not;
+}
+
+sub prepare_cmd()
+{
+ my $ver=qx(uname -r);
+ $ver =~ s/\s+$//;
+ die "Couldn't get kernel version" if (!$ver);
+
+ print "Seeking media drivers at /lib/modules/$ver/kernel/drivers/media/\n";
+ find(\&parse_dir, "/lib/modules/$ver/kernel/drivers/media/");
+ print "Seeking media drivers at /lib/modules/$ver/kernel/drivers/staging/media/\n";
+ find(\&parse_dir, "/lib/modules/$ver/kernel/drivers/staging/media/");
+ printf "found $i modules\n";
+
+ cleandep();
+ orderdep();
+}
+
+prepare_cmd;
+parse_loaded;
+
+my @notunloaded = rmmod(@modlist);
+@notunloaded = rmmod(@notunloaded) if (@notunloaded);
+if (@notunloaded) {
+ print "Couldn't unload: ", join(' ', @notunloaded), "\n";
+}

Privacy Policy