From b0b66214892ff566c0f4342bb28eaacb1cfa8d68 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 20 Jul 2022 00:17:38 +0300 Subject: test: control_list: Use get() to test for control presence Now that the ControlList::get() function returns an std::optional<>, it is the preferred way to test if a control is present in a ControlList. Use it in the test to prepare for removal of ControlList::contains(). Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Umang Jain --- test/controls/control_list.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'test/controls') diff --git a/test/controls/control_list.cpp b/test/controls/control_list.cpp index 70cf61b8..c03f230e 100644 --- a/test/controls/control_list.cpp +++ b/test/controls/control_list.cpp @@ -50,7 +50,7 @@ protected: return TestFail; } - if (list.contains(controls::Brightness)) { + if (list.get(controls::Brightness)) { cout << "List should not contain Brightness control" << endl; return TestFail; } @@ -80,7 +80,7 @@ protected: return TestFail; } - if (!list.contains(controls::Brightness)) { + if (!list.get(controls::Brightness)) { cout << "List should contain Brightness control" << endl; return TestFail; } @@ -99,7 +99,7 @@ protected: return TestFail; } - if (list.contains(controls::Contrast)) { + if (list.get(controls::Contrast)) { cout << "List should not contain Contract control" << endl; return TestFail; } @@ -108,8 +108,8 @@ protected: list.set(controls::Brightness, 0.0f); list.set(controls::Contrast, 1.5f); - if (!list.contains(controls::Brightness) || - !list.contains(controls::Contrast)) { + if (!list.get(controls::Brightness) || + !list.get(controls::Contrast)) { cout << "List should contain Brightness and Contrast controls" << endl; return TestFail; @@ -145,7 +145,7 @@ protected: */ list.set(controls::AwbEnable, true); - if (list.contains(controls::AwbEnable)) { + if (list.get(controls::AwbEnable)) { cout << "List shouldn't contain AwbEnable control" << endl; return TestFail; } @@ -171,9 +171,9 @@ protected: return TestFail; } - if (!mergeList.contains(controls::Brightness) || - !mergeList.contains(controls::Contrast) || - !mergeList.contains(controls::Saturation)) { + if (!mergeList.get(controls::Brightness) || + !mergeList.get(controls::Contrast) || + !mergeList.get(controls::Saturation)) { cout << "Merged list does not contain all controls" << endl; return TestFail; } -- cgit v1.2.1 era/vivid.git/plain/utils/gen-formats.py?id=cc035f611f40f366c388bcc2627180349ac671f2'>plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2020, Google Inc.
#
# Author: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
#
# gen-formats.py - Generate formats definitions from YAML

import argparse
import re
import string
import sys
import yaml


class DRMFourCC(object):
    format_regex = re.compile(r"#define (DRM_FORMAT_[A-Z0-9_]+)[ \t]+fourcc_code\(('.', '.', '.', '.')\)")
    mod_vendor_regex = re.compile(r"#define DRM_FORMAT_MOD_VENDOR_([A-Z0-9_]+)[ \t]+([0-9a-fA-Fx]+)")
    mod_regex = re.compile(r"#define ([A-Za-z0-9_]+)[ \t]+fourcc_mod_code\(([A-Z0-9_]+), ([0-9a-fA-Fx]+)\)")

    def __init__(self, filename):
        self.formats = {}
        self.vendors = {}
        self.mods = {}

        for line in open(filename, 'rb').readlines():
            line = line.decode('utf-8')

            match = DRMFourCC.format_regex.match(line)
            if match:
                format, fourcc = match.groups()
                self.formats[format] = fourcc
                continue

            match = DRMFourCC.mod_vendor_regex.match(line)
            if match:
                vendor, value = match.groups()
                self.vendors[vendor] = int(value, 0)
                continue

            match = DRMFourCC.mod_regex.match(line)
            if match:
                mod, vendor, value = match.groups()
                self.mods[mod] = (vendor, int(value, 0))
                continue

    def fourcc(self, name):
        return self.formats[name]

    def mod(self, name):
        vendor, value = self.mods[name]
        return self.vendors[vendor], value


def generate_h(formats, drm_fourcc):
    template = string.Template('constexpr PixelFormat ${name}{ __fourcc(${fourcc}), __mod(${mod}) };')

    fmts = []

    for format in formats: