~pieq/checkbox/add-30suspend-1reboot-cycles-support

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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
Checkbox/plainbox launchers tutorial
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This document provides an explanation of why launchers are necessary, what
you can achieve with them, and goes over several examples to better describe
their capabilities. For a detailed reference on which settings are supported
by launchers, and specific syntax for launcher files, look at
:doc:`/profiles`.


Legacy checkbox behavior control
================================

In the past, :term:`Checkbox`'s behavior was controlled by three mechanisms.

First, the functions of checkbox could be augmented by adding plugins.
For example, the ability to submit to certification website was added by
the checkbox-certification package using a plugin. The plugins included
by checkbox-certification and which add new behavior to base checkbox
were:

::

    /usr/share/checkbox-certification/plugins/certify_message.py
    /usr/share/checkbox-certification/plugins/submission_info.py
    /usr/share/checkbox-certification/plugins/backup.py
    /usr/share/checkbox-certification/plugins/certify_prompt.py
    /usr/share/checkbox-certification/plugins/certify_report.py
    /usr/share/checkbox-certification/plugins/certify_schemas.py

These added the way to prompt the user for submission-specific data, generate
the xml report, and other functions.

Next, the behaviors of the plugins could be configured or controlled
using configuration files, which are "cascaded". A config file can
include others and those can in turn include others.

This is an example of a project-specific project-qt.ini main config file. It's
the first file read when the project-specific client is launched. Some settings
are abbreviated:

::
    
    [DEFAULT]
    includes = %(checkbox_oem_share)s/configs/checkbox-project-base-qt.ini %(checkbox_project_share)s/configs/checkbox-project-base.ini
    
    [checkbox/plugins/environment_info]
    repositories = deb http://.*\(archive\|security\).ubuntu.com/ubuntu precise-security
    routers = multiple
    server_iperf = 10.20.30.40
    sources_list = /etc/apt/sources.list
    wpa_n_psk = password
    wpa_n_ssid = access-point
    
    [checkbox/plugins/user_interface]
    title = My project System Testing

Notice the includes line, this instructs it to load the config file for
checkbox-project-base-qt and checkbox-project-base. Checkbox-project-base-qt
loads the configs for checkbox-certification and checkbox-project. Settings are
cascaded so the config options near the top override the ones near the
bottom.

Finally, the "binary" used to invoke checkbox is a shell script that
defines where to find the things checkbox needs to run: you can define a
share directory, a specific data directory, point to a configuration
file and define some environment variables that you may need during
testing. Here's an example for checkbox-project-qt:

::

    #!/bin/bash
    export CHECKBOX_DATA=${CHECKBOX_DATA:-~/.checkbox}
    export CHECKBOX_SHARE=${CHECKBOX_SHARE:-/usr/share/checkbox}
    export CHECKBOX_OPTIONS=${CHECKBOX_OPTIONS:---log-level=debug --log=$CHECKBOX_DATA/checkbox-project.log}
    export CHECKBOX_CERTIFICATION_SHARE=${CHECKBOX_CERTIFICATION_SHARE:-/usr/share/checkbox-certification}
    export CHECKBOX_OEM_SHARE=${CHECKBOX_PROJECT_BASE_SHARE:-/usr/share/checkbox-project-base}
    export CHECKBOX_PROJECT_SHARE=${CHECKBOX_PROJECT_SHARE:-/usr/share/checkbox-project}
    
    # Convenience for defining the PYTHONPATH directory.
    if [ "$CHECKBOX_SHARE" != "/usr/share/checkbox" ]; then
        export PYTHONPATH="$CHECKBOX_SHARE:$PYTHONPATH"
    fi
    
    python3 $CHECKBOX_SHARE/run "$@" $CHECKBOX_PROJECT_SHARE/configs/$(basename $0).ini

Here you can see that it defines some locations and an important part is
the final python3 line, where it will locate and use the required .ini
config file we saw earlier.

This hierarchical organization was very powerful but was also difficult
to handle, and also had some limitations. Part of the work we did with
checkbox was to integrate all the project-specific plugins into checkbox
trunk, this way all the core code is in one place, and the project-specific
variants only supply jobs, whitelists, data and configuration, without adding
new behavior.

New plainbox behavior control
=============================

Unlike checkbox, plainbox's core is monolythic, and it has no concept of
plugins. This makes it easier to understand and work with. The plainbox
core has implementations for all the functions in the old checkbox
packages, so no additions are necessary to use features such as
submission to certification or report generation.


What we call plainbox is the library that implements all the
functionality, as can be seen :doc:`here</stack>`.

Plainbox provides tools to help test developers write and package tests.
These are delivered in "providers", which are entities designed to
encapsulate test descriptions, custom scripts for testing, whitelists
and assorted data. They were designed to allow teams to
write and deliver their custom tests without worrying too much about the
underlying plainbox code.

To get information on how to write tests and providers, see the :ref:`Provider
Tutorial<tutorial>`

However, when actually using these tests to verify a real system, we
wanted to provide something easier and closer to the user experience of
checkbox. We created two clients, checkbox-gui and checkbox-cli, which
had some hardcoded behaviors, and we also started creating other clients
which were based on these but were purpose specific. For instance, we
had a version of checkbox for SRU testing, another for server
certification, and so on.

But then we realized that a lot of the code was duplicated and the
behaviors were common except for a few changes. So we came up with the
concept of "launchers", which are somewhat similar to checkbox's
configuration files and shell script launchers.

The idea is that checkbox-gui and checkbox-cli have some very basic
behaviors, since they are the clients that are shipped by default with
ubuntu. They can show all the available whitelists, show a predefined
welcome message, and at the end will let the user see the html report
and submit it to launchpad using their e-mail address, similar to the
version of checkbox that shipped with Ubuntu.

Instead of using complicated command line switches, launchers allow you
to configure some optional behaviors to customize your testing
experience. A launcher contains settings, and is similar to a shell
script, but the interpreter will be either checkbox-gui or
checkbox-launcher.

Here are a few examples of what can be done with launchers.

As a surprise, checkbox-cli is itself a launcher:

::

    #!/usr/bin/env checkbox-launcher
    [welcome]
    text = Welcome to System Testing!
        Checkbox provides tests to confirm that your system is working properly.
        Once you are finished running the tests, you can view a summary report for
        your system.
        Warning: Some tests could cause your system to freeze or become
        unresponsive. Please save all your work and close all other running
        applications before beginning the testing process.
    
    [suite]
    whitelist_filter = ^default$
    whitelist_selection = ^default$
    skip_whitelist_selection = True
    
    [transport]
    submit_to = launchpad

You can see here we customize a few options: it shows a welcome message,
automatically selects the default whitelist, and will submit to
launchpad when it's finished.

A graphical launcher example is canonical-certification-client.

::

    #!/usr/bin/checkbox-gui
    
    [welcome]
    title = "System Certification"
    text = "<p>Welcome to System Certification!</p><p></p><p>This application will
    gather information from your system. Then you will be asked manual tests to
    confirm that the system is working properly. Finally, you will be asked for
    the Secure ID of the computer to submit the information to the certification
    database.</p><p></p><p> To learn how to create or locate the Secure ID,
    please see here: <a href=\"https://certification.canonical.com\">certification.canonical.com</a></p><p></p>"
    
    [suite]
    whitelist_filter = "^client-(cert|selftest).*"
    
    [submission]
    input_type = "regex"
    input_placeholder = "Secure ID (15 or 18 characters)"
    ok_btn_text = "Submit Results"
    submit_to_hexr = "true"
    
    [exporter]
    xml_export_path = "/tmp/submission.xml"
    
    [transport]
    submit_to = "certification"


Graphical launchers are a bit more complicated, but essentially it's
similar, what it allows is for you to define some parameters to
customize your testing experience.

A very simple text-mode launcher is canonical-hw-collection which just
runs the basic hardware information tests and uploads them to a hardware
database:

::

    [welcome]
    title = Gathering hardware information
    text = Gathering hardware information.  You may be prompted for your password.
           This process will take approximately 30 seconds and you will be provided
           with a URL through which you can confirm and register your hardware
           submission.
    
    [suite]
    whitelist_filter = ^hwsubmit$
    whitelist_selection = ^hwsubmit$
    skip_whitelist_selection = True
    skip_test_selection = True
    
    [submission]
    # A bogus secure_id ensures we don't ask it
    # It can always be overridden in the .conf file.
    secure_id = 000
    
    [transport]
    submit_to = certification
    submit_url = https://hardware-server.example.com/

FInally, canonical-driver-test-suite provides both a graphical and a
text mode launcher, which are functionally equivalent:

::

    #!/usr/bin/checkbox-gui
    
    [welcome]
    title = "Canonical Driver Test Suite"
    text = "<p>Welcome to the Canonical Driver Test Suite.</p>
     <p></p>
     <p>This program contains automated and manual tests to help you discover
     issues that will arise when running your device drivers on Ubuntu.</p>
     <p></p>
     <p>This application will step the user through these tests in a
     predetermined order and automatically collect both system information as
     well as test results. It will also prompt the user for input when manual
     testing is required.</p>
     <p></p>
     <p>The run time for the tests is determined by which tests you decide to
     execute. The user will have the opportunity to customize the test run to
     accommodate the driver and the amount of time available for testing.</p>
     <p></p>
     <p>To begin, simply click the Continue button below and follow the onscreen
     instructions.</p><p></p>"
    
    [suite]
    whitelist_filter = "^ihv-.*"
    
    [submission]
    ok_btn_text = "Save Results"
    input_type = "none"
    
    [exporter]
    xml_export_path = ""
    
    [transport]
    submit_to = "local"

Text mode:

::

    #!/usr/bin/env checkbox-launcher
    [welcome]
    text = Welcome to the Canonical Driver Test Suite
        This program contains automated and manual tests to help you discover
        issues that will arise when running your device drivers on Ubuntu.
        This application will step the user through these tests in a
        predetermined order and automatically collect both system information as
        well as test results. It will also prompt the user for input when manual
        testing is required.
        The run time for the tests is determined by which tests you decide to
        execute. The user will have the opportunity to customize the test run to
        accommodate the driver and the amount of time available for testing.
        To begin, simply click the Continue button below and follow the onscreen
        instructions.
    
    [suite]
    # Whitelist(s) displayed in the suite selection screen
    whitelist_filter = ^ihv-.*
    # Whitelist_selection is mandatory so we set it to a bogus value so
    # no whitelists are preselected.
    whitelist_selection = bogus