Fix pylint error for camera_V4L2
Also remove unused run_v4l2_default_capture_test().
BUG=chromium:708396
TEST=test_that -b ${BOARD} ${IP} camera_V4L2
Change-Id: I258aa3e7dda1aff24807e6c693ae890c0b9a33fd
Reviewed-on: https://chromium-review.googlesource.com/475530
Commit-Ready: Heng-ruey Hsu <henryhsu@chromium.org>
Tested-by: Heng-ruey Hsu <henryhsu@chromium.org>
Reviewed-by: Wu-cheng Li <wuchengli@chromium.org>
diff --git a/client/site_tests/camera_V4L2/camera_V4L2.py b/client/site_tests/camera_V4L2/camera_V4L2.py
index 9ad1ffd..841d98b 100644
--- a/client/site_tests/camera_V4L2/camera_V4L2.py
+++ b/client/site_tests/camera_V4L2/camera_V4L2.py
@@ -2,7 +2,11 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-import glob, logging, os, re, stat
+import glob
+import logging
+import os
+import re
+import stat
from autotest_lib.client.bin import test, utils
from autotest_lib.client.common_lib import error
from autotest_lib.client.cros.graphics import graphics_utils
@@ -15,56 +19,47 @@
v4l2_minor_dev_num_min = 0
v4l2_minor_dev_num_max = 64
-
def setup(self):
# TODO(jiesun): make binary here when cross compile issue is resolved.
os.chdir(self.srcdir)
utils.make('clean')
utils.make()
-
def run_once(self, run_unit_tests=True, run_capture_tests=True,
- run_default_capture_test=False, time=0,
assert_mandatory_controls=False):
self.assert_mandatory_controls = assert_mandatory_controls
self.find_video_capture_devices()
- time = time / len(self.v4l2_devices)
for device in self.v4l2_devices:
if run_unit_tests:
self.run_v4l2_unittests(device)
if run_capture_tests:
self.run_v4l2_capture_tests(device)
- if run_default_capture_test:
- self.run_v4l2_default_capture_test(device, time)
-
def is_v4l2_capture_device(self, device):
executable = os.path.join(self.bindir, "media_v4l2_is_capture_device")
cmd = "%s %s" % (executable, device)
logging.info("Running %s" % cmd)
- return (utils.system(cmd, ignore_status=True) == 0)
-
+ return utils.system(cmd, ignore_status=True) == 0
def find_video_capture_devices(self):
self.v4l2_devices = []
for device in glob.glob("/dev/video*"):
statinfo = os.stat(device)
if (stat.S_ISCHR(statinfo.st_mode) and
- os.major(statinfo.st_rdev) == self.v4l2_major_dev_num and
- os.minor(statinfo.st_rdev) >= self.v4l2_minor_dev_num_min and
- os.minor(statinfo.st_rdev) < self.v4l2_minor_dev_num_max and
- self.is_v4l2_capture_device(device)):
+ os.major(statinfo.st_rdev) == self.v4l2_major_dev_num and
+ os.minor(statinfo.st_rdev) >=
+ self.v4l2_minor_dev_num_min and
+ os.minor(statinfo.st_rdev) < self.v4l2_minor_dev_num_max and
+ self.is_v4l2_capture_device(device)):
self.v4l2_devices.append(device)
logging.info("Detected devices: %s\n" % self.v4l2_devices)
if not self.v4l2_devices:
raise error.TestFail("No V4L2 devices found!")
-
def unittest_passed(self, testname, stdout):
- return re.search(r"OK \] V4L2DeviceTest\." + testname, stdout);
-
+ return re.search(r"OK \] V4L2DeviceTest\." + testname, stdout)
def run_v4l2_unittests(self, device):
self.executable = os.path.join(self.bindir, "media_v4l2_unittest")
@@ -91,7 +86,7 @@
raise error.TestError(device + " does support enum controls!")
pattern = re.compile(r"Control (\w+) is enabled\((\d+)-(\d+):(\d+)\)")
control_info = pattern.findall(stdout)
- self.supported_controls = [ x[0] for x in control_info ]
+ self.supported_controls = [x[0] for x in control_info]
logging.info("Supported Controls: %s\n" % self.supported_controls)
# TODO(jiesun): what is required?
@@ -103,7 +98,7 @@
"Gamma"]
for control in mandatory_controls:
if self.assert_mandatory_controls and \
- control not in self.supported_controls:
+ control not in self.supported_controls:
raise error.TestError(device + " does not support " + control)
# 5. SetControl is mandatory.
@@ -142,7 +137,6 @@
# 10. Get/SetParam for framerate is optional.
# 11. EnumFrameSize is optional on some kernel/v4l2 version.
-
def run_v4l2_capture_test(self, fail_okay, options):
executable = os.path.join(self.bindir, "media_v4l2_test")
try:
@@ -159,16 +153,8 @@
else:
return (True, stdout)
-
- def run_v4l2_default_capture_test(self, device, time):
- options = ["--device=%s" % device ]
- if time:
- options.append("--time=%d" % time)
- okay, stdout = self.run_v4l2_capture_test(False, options)
-
-
def run_v4l2_capture_tests(self, device):
- default_options = ["--device=%s" % device ]
+ default_options = ["--device=%s" % device]
# If the device claims to support read/write i/o.
if self.support_readwrite:
@@ -187,7 +173,6 @@
if not userp_okay and not mmap_okay:
raise error.TestFail("Stream i/o failed!")
-
# TODO(jiesun): test with different mandatory resultions that
# the capture device must support without scaling by ourselves.
required_resolutions = [
@@ -206,10 +191,10 @@
r" (....) picture at (\d+) fps")
match = re.search(pattern, stdout)
if (not match or
- int(match.group(1)) != width or
- int(match.group(2)) != height or
- match.group(3) != self.supported_formats[0] or
- int(match.group(4)) < minfps):
+ int(match.group(1)) != width or
+ int(match.group(2)) != height or
+ match.group(3) != self.supported_formats[0] or
+ int(match.group(4)) < minfps):
raise error.TestError("capture test failed")
okay, stdout = self.run_v4l2_capture_test(False, option)