diff options
-rwxr-xr-x | bin/camera_test_rpi.py | 63 | ||||
-rw-r--r-- | units/camera/jobs.pxu | 30 | ||||
-rw-r--r-- | units/camera/manifest.pxu | 4 | ||||
-rw-r--r-- | units/camera/test-plan.pxu | 26 |
4 files changed, 122 insertions, 1 deletions
diff --git a/bin/camera_test_rpi.py b/bin/camera_test_rpi.py new file mode 100755 index 00000000..467ac13c --- /dev/null +++ b/bin/camera_test_rpi.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python3 +# This file is part of Checkbox. +# +# Copyright 2020 Canonical Ltd. +# Written by: +# Jonathan Cave <jonathan.cave@canonical.com> +# +# Checkbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3, +# as published by the Free Software Foundation. +# +# Checkbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Checkbox. If not, see <http://www.gnu.org/licenses/>. + +import argparse +import os +import sys +import time + +import picamera + +# resolutions and framerates corresponding to sensor modes at: +# https://picamera.readthedocs.io/en/release-1.13/fov.html#camera-modes +test_res = [ + ((1920, 1080), 2), + ((2592, 1944), 2), + ((2592, 1944), (1, 8)), + ((1296, 972), 5), + ((1296, 730), 20), + ((640, 480), 50), + ((640, 480), 80), +] + + +def capture(): + path = os.path.expandvars('$PLAINBOX_SESSION_SHARE') + print('Images will be written to:\n{}\n'.format(path), flush=True) + for mode_no, (res, fr) in enumerate(test_res): + with picamera.PiCamera(resolution=res, framerate=fr) as camera: + print('Camera initialised, wait to settle...', flush=True) + time.sleep(2) + print('Resolution: {}'.format(camera.resolution)) + print('Framerate: {}'.format(camera.framerate)) + file = 'picam_{}.jpg'.format(mode_no+1) + camera.capture(os.path.join(path, file)) + print('Image {} captured\n'.format(file)) + + +def main(): + parser = argparse.ArgumentParser(description='PiCamera Tests') + parser.add_argument('--device', default="/dev/vchiq", type=str) + args = parser.parse_args() + print('Resolutions test on device: {}'.format(args.device), flush=True) + return capture() + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/units/camera/jobs.pxu b/units/camera/jobs.pxu index 0605d182..d7ad2aa4 100644 --- a/units/camera/jobs.pxu +++ b/units/camera/jobs.pxu @@ -6,7 +6,19 @@ requires: device.category == 'CAPTURE' command: camera_test detect -_description: This Automated test attempts to detect a camera. +_summary: This Automated test attempts to detect a camera. +user: root + +plugin: shell +category_id: com.canonical.plainbox::camera +id: camera/detect-rpi +estimated_duration: 1.0 +imports: from com.canonical.plainbox import manifest +requires: + manifest.has_rpi_camera == 'True' +command: + udev_resource -f MMAL | grep "category: MMAL" +_summary: Detect presence of a MMAL camera. unit: template template-resource: device @@ -103,3 +115,19 @@ _description: Takes multiple pictures based on the resolutions supported by the camera and validates their size and that they are of a valid format. +unit: template +template-resource: device +template-filter: device.category == 'MMAL' and device.name != '' +template-unit: job +plugin: shell +category_id: com.canonical.plainbox::camera +id: camera/multiple-resolution-images-rpi_{name} +_summary: Webcam multiple resolution capture test for Pi Camera +estimated_duration: 16.0 +depends: camera/detect-rpi +command: + camera_test_rpi.py --device /dev/{name} +_description: + Takes multiple pictures based on the resolutions supported by the camera and + validates their size and that they are of a valid format. +user: root \ No newline at end of file diff --git a/units/camera/manifest.pxu b/units/camera/manifest.pxu new file mode 100644 index 00000000..de127989 --- /dev/null +++ b/units/camera/manifest.pxu @@ -0,0 +1,4 @@ +unit: manifest entry +id: has_rpi_camera +_name: RaspberryPi Camera Module +value-type: bool \ No newline at end of file diff --git a/units/camera/test-plan.pxu b/units/camera/test-plan.pxu index 578a7ce7..c3b8378b 100644 --- a/units/camera/test-plan.pxu +++ b/units/camera/test-plan.pxu @@ -60,3 +60,29 @@ include: after-suspend-manual-camera/display_.* certification-status=blocker bootstrap_include: device + +id: camera-full +unit: test plan +_name: Camera tests +_description: Camera tests for Ubuntu Core devices +include: +nested_part: + camera-automated + camera-manual + +id: camera-manual +unit: test plan +_name: Manual camera tests +_description: Manual camera tests for Ubuntu Core devices +include: + +id: camera-automated +unit: test plan +_name: Automated camera tests +_description: Automated camera tests for Ubuntu Core devices +estimated_duration: 1h30m +include: + camera/multiple-resolution-images-_.* + camera/multiple-resolution-images-rpi_.* +bootstrap_include: + device |