update_device_data¶
Source code: update_device_data.py
Updates Device Data (manually or from predefined values in test list).
Description¶
The Device Data (cros.factory.test.device_data
) is a special data structure
for manipulating DUT information. This test can determine Device Data
information (usually for VPD) without using shopfloor backend, usually
including:
serials.serial_number
: The device serial number.vpd.ro.region
: Region data (RO region).vpd.rw.ubind_attribute
andvpd.rw.gbind_attribute
: User and group registration codes.Or other values specified in argument
fields
orconfig_name
.
When argument manual_input is True, every values specified in fields
will
be displayed on screen with an edit box before written into device data.
Note all the values will be written as string in manual mode.
The fields
argument is a sequence in format
(data_key, value, display_name, value_check)
:
Name |
Description |
---|---|
|
The Device Data key name to write. |
|
The value to be written, can be modified if |
|
The label or name to be displayed on UI. |
|
To validate the input value. Can be a regular expression,
list of strings, list of integers, boolean values, or
None.
When |
If you want to manually configure without default values, the sequence can be replaced by a simple string of key name.
The config_name
refers to a JSON config file loaded by
cros.factory.py.utils.config_utils
with single dictionary that the keys
and values will be directly sent to Device Data. This is helpful if you need to
define board-specific data.
config_name
and fields
are both optional, but you must specify at least
one.
If you want to set device data (especially VPD values) using shopfloor or pre-defined values:
Use
shopfloor_service
test with method=GetDeviceInfo to retrievevpd.{ro,rw}.*
.Use
update_device_data
test to write pre-defined or update values tovpd.{ro,rw}.*
.Use
write_device_data_to_vpd
to flush data into firmware VPD sections.
Test Procedure¶
If argument manual_input
is not True, this will be an automated test
without user interaction.
If argument manual_input
is True, the test will go through all the fields:
Display the name and key of the value.
Display an input edit box for simple values, or a list of selection if the
value_check
is a sequence of strings or boolean values.Wait for operator to select or input right value.
If operator presses ESC, abandon changes and keep original value.
If operator clicks Enter, validate the input by
value_check
argument. If failed, prompt and go back to 3. Otherwise, write into device data and move to next field.Pass when all fields were processed.
Dependency¶
None. This test only deals with the device_data
module inside factory
software framework.
Examples¶
To silently load device-specific data defined in board overlay
py/config/default_device_data.json
, add this in test list:
{
"pytest_name": "update_device_data",
"args": {
"config_name": "default",
"manual_input": false
}
}
To silently set a device data ‘component.has_touchscreen’ to True:
{
"pytest_name": "update_device_data",
"args": {
"fields": [
[
"component.has_touchscreen",
true,
"Device has touch screen",
null
]
],
"manual_input": false
}
}
For RMA process to set serial number, region, registration codes, and specify if the device has peripherals like touchscreen:
{
"pytest_name": "update_device_data",
"args": {
"fields": [
[
"serials.serial_number",
null,
"Device Serial Number",
"[A-Z0-9]+"
],
["vpd.ro.region", "us", "Region", null],
["vpd.rw.ubind_attribute", null, "User ECHO", null],
["vpd.rw.gbind_attribute", null, "Group ECHO", null],
[
"component.has_touchscreen",
null,
"Has touchscreen",
[true, false]
]
]
}
}
If you don’t need default values, there’s an alternative to list only key names:
{
"pytest_name": "update_device_data",
"args": {
"fields": [
"serials.serial_number",
"vpd.ro.region",
"vpd.rw.ubind_attribute",
"vpd.rw.gbind_attribute"
]
}
}
Test Arguments¶
Name |
Type |
Description |
---|---|---|
manual_input |
bool |
(optional; default: |
config_name |
str, None |
(optional; default: |
fields |
list, None |
(optional; default: |