Skip to content

Commit d0a2e17

Browse files
Fix utitiles readiness for ce-oem-mipi-camera tests (Bugfix) (#2361)
* add camera related utilities check add camera related utilities check, all capture and recording tests will be skipped if camera related utilities are not available. * fix issues fix issues * revised argument revised argument * Apply suggestion from @seankingyang Co-authored-by: Isaac Yang <47034756+seankingyang@users.noreply.github.com> * Update contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/camera/jobs.pxu Co-authored-by: stanley31huang <stanley.huang@canonical.com> * fix pep8 issue fix pep8 issue --------- Co-authored-by: Isaac Yang <47034756+seankingyang@users.noreply.github.com>
1 parent e806296 commit d0a2e17

3 files changed

Lines changed: 46 additions & 8 deletions

File tree

contrib/checkbox-ce-oem/checkbox-provider-ce-oem/bin/camera_test.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
list_device_by_v4l2_ctl,
3636
check_nonzero_files,
3737
CameraInterface,
38+
GST_LAUNCH_BIN,
39+
V4L2_CTL_CMD,
40+
MEDIA_CTL_CMD,
3841
)
3942

4043
logging.basicConfig(
@@ -226,6 +229,9 @@ def register_arguments() -> argparse.Namespace:
226229
help=("Path of the specified test configuration file."),
227230
)
228231

232+
# subparser for readiness
233+
subparsers.add_parser("readiness")
234+
229235
# Subparser for testing
230236
parser_testing = subparsers.add_parser(
231237
"testing",
@@ -457,6 +463,28 @@ def _run_camera_test(args: argparse.Namespace) -> None:
457463
_cleanup_artifacts_if_needed(args, artifact_store_path)
458464

459465

466+
def readiness_test():
467+
result = True
468+
469+
utilities_mapping = {
470+
"gst-launch-1.0": GST_LAUNCH_BIN,
471+
"media-ctl": MEDIA_CTL_CMD,
472+
"v4l2-ctl": V4L2_CTL_CMD,
473+
}
474+
for util, binary in utilities_mapping.items():
475+
if not binary:
476+
result = False
477+
logging.error("%s is not available", util)
478+
if not os.path.exists(binary):
479+
result = False
480+
logging.error("%s path is not exists", util)
481+
else:
482+
logging.info("the location of %s is %s", util, binary)
483+
484+
if not result:
485+
raise SystemExit("the test utilities for camera test are not ready")
486+
487+
460488
def main() -> None:
461489
args = register_arguments()
462490

@@ -466,6 +494,11 @@ def main() -> None:
466494

467495
if args.action == "testing":
468496
_run_camera_test(args)
497+
return
498+
499+
if args.action == "readiness":
500+
readiness_test()
501+
return
469502

470503

471504
if __name__ == "__main__":

contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/camera/jobs.pxu

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ environ: MIPI_SCENARIO_DEFINITION_FILE_PATH
88
command:
99
camera_test.py generate_resource -sf "$MIPI_SCENARIO_DEFINITION_FILE_PATH"
1010

11+
id: ce-oem-mipi-camera/readiness
12+
_summary: Verify installation of V4L2 and GStreamer tools
13+
_description: Checks if the system has the necessary binaries installed to proceed with camera testing.
14+
estimated_duration: 2s
15+
category_id: com.canonical.plainbox::camera
16+
plugin: shell
17+
environ: GST_LAUNCH_BIN MEDIA_CTL_CMD V4L2_CTL_CMD
18+
command:
19+
camera_test.py readiness
20+
1121
unit: template
1222
template-engine: jinja2
1323
template-resource: mipi_camera_resource
@@ -23,14 +33,11 @@ plugin: shell
2333
category_id: com.canonical.plainbox::camera
2434
estimated_duration: 10s
2535
flags: also-after-suspend
36+
depends: ce-oem-mipi-camera/readiness
2637
imports:
2738
from com.canonical.certification import executable
2839
from com.canonical.plainbox import manifest
2940
requires:
30-
executable.name == "v4l2-ctl"
31-
executable.name == "media-ctl"
32-
executable.name == "gst-launch-1.0"
33-
executable.name == "gst-discoverer-1.0"
3441
manifest.has_vendor_specific_mipi_camera == "True"
3542
environ: PLATFORM_NAME MIPI_CAMERA_SETUP_CONF_FILE_PATH
3643
command:
@@ -51,14 +58,11 @@ plugin: shell
5158
category_id: com.canonical.plainbox::camera
5259
estimated_duration: 10s
5360
flags: also-after-suspend
61+
depends: ce-oem-mipi-camera/readiness
5462
imports:
5563
from com.canonical.certification import executable
5664
from com.canonical.plainbox import manifest
5765
requires:
58-
executable.name == "v4l2-ctl"
59-
executable.name == "media-ctl"
60-
executable.name == "gst-launch-1.0"
61-
executable.name == "gst-discoverer-1.0"
6266
manifest.has_vendor_specific_mipi_camera == "True"
6367
environ: PLATFORM_NAME MIPI_CAMERA_SETUP_CONF_FILE_PATH
6468
command:

contrib/checkbox-ce-oem/checkbox-provider-ce-oem/units/camera/test-plan.pxu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ _description: Automated tests for MIPI Camera in before suspend and post suspend
2121
bootstrap_include:
2222
mipi_camera_resource
2323
include:
24+
ce-oem-mipi-camera/readiness
2425
ce-oem-mipi-camera/capture-image-scenario
2526
ce-oem-mipi-camera/record-video-scenario

0 commit comments

Comments
 (0)