tree: 692e21a04ded0525851a19d409f99b05cf7a9c4a [path history] [tgz]
  1. audio_diagnostic_static/
  2. audio_loop_static/
  3. audio_quality_static/
  4. bad_blocks_static/
  5. battery_cycle_static/
  6. blocking_charge_static/
  7. brightness/
  8. camera_static/
  9. chameleon_static/
  10. compass_static/
  11. countdown_static/
  12. display_images_static/
  13. display_point_static/
  14. display_static/
  15. exec_shell_static/
  16. external_display_static/
  17. fan_speed_static/
  18. keyboard_smt_static/
  19. keyboard_static/
  20. led_static/
  21. light_sensor_calibration_static/
  22. light_sensor_static/
  23. model_sku_static/
  24. network_setup/
  25. offline_test/
  26. plankton_display_static/
  27. probe/
  28. removable_storage_static/
  29. rf_graphyte/
  30. station_setup_static/
  31. stylus_static/
  32. summary_static/
  33. sync_factory_server_static/
  34. tablet_mode_static/
  35. tablet_rotation_static/
  36. touchpad_static/
  37. touchscreen_calibration/
  38. touchscreen_static/
  39. update_device_data_static/
  40. video_playback_static/
  41. vswr/
  42. webgl_aquarium_static/
  43. __init__.py
  44. ac_power.py
  45. accelerometers_calibration.py
  46. accelerometers_lid_angle.py
  47. audio.py
  48. audio_basic.py
  49. audio_diagnostic.py
  50. audio_loop.py
  51. audio_quality.py
  52. backlight.py
  53. bad_blocks.py
  54. battery.py
  55. battery_basic.py
  56. battery_current.py
  57. battery_cycle.py
  58. battery_sysfs.py
  59. bft_fixture.py
  60. blocking_charge.py
  61. bluetooth.py
  62. bluetooth_host.py
  63. button.py
  64. buzzer.py
  65. camera.py
  66. cellular_switch_firmware.py
  67. chameleon.py
  68. charger.py
  69. check_image_version.py
  70. compass.py
  71. countdown.py
  72. display.py
  73. display_images.py
  74. display_point.py
  75. dsm_calibration.py
  76. ethernet.py
  77. exec_python.py
  78. exec_shell.py
  79. external_display.py
  80. factory_state.py
  81. factory_state_unittest.py
  82. fan_speed.py
  83. fastboot_flash.py
  84. finalize.py
  85. fingerprint_mcu.py
  86. flash_netboot.py
  87. gps.py
  88. gyroscope.py
  89. hwid.py
  90. interrupt.py
  91. keyboard.py
  92. keyboard_backlight.py
  93. keyboard_smt.py
  94. led.py
  95. lid_switch.py
  96. light_sensor.py
  97. light_sensor_calibration.json
  98. light_sensor_calibration.py
  99. light_sensor_calibration.schema.json
  100. lightbar.py
  101. line_check_item.py
  102. lte_verify_config.py
  103. memory_size.py
  104. message.py
  105. model_sku.json
  106. model_sku.py
  107. model_sku.schema.json
  108. mrc_cache.py
  109. nop.py
  110. partition_table.py
  111. ping_test.py
  112. plankton_cc2_pull_test.py
  113. plankton_cc_flip_check.py
  114. plankton_charge.py
  115. plankton_display.py
  116. power_under_stress.py
  117. probe_cellular_info.py
  118. probe_cellular_info_unittest.py
  119. probe_sim.py
  120. probe_sim_card_tray.py
  121. read_device_data_from_vpd.py
  122. README.md
  123. removable_storage.py
  124. retrieve_config.py
  125. robot_movement.py
  126. robot_movement_unittest.py
  127. sample_customized_test.py
  128. scan.py
  129. select_for_sampling.py
  130. serial_echo.py
  131. serial_echo_unittest.py
  132. shopfloor_service.py
  133. shutdown.py
  134. spatial_sensor_calibration.py
  135. start.py
  136. station_entry.py
  137. station_entry_unittest.py
  138. station_setup.py
  139. storage_simple_stress.py
  140. stressapptest.py
  141. stylus.py
  142. summary.py
  143. suspend_resume.py
  144. sync_factory_server.py
  145. sync_time.py
  146. tablet_mode.py
  147. tablet_rotation.py
  148. thermal_load.py
  149. thermal_sensors.py
  150. thermal_slope.py
  151. touch_device_fw_update.py
  152. touch_uniformity.py
  153. touchpad.py
  154. touchpad_hover.py
  155. touchscreen.py
  156. tpm_clear_owner.py
  157. tpm_diagnosis.py
  158. tpm_verify_ek.py
  159. update_cr50_firmware.py
  160. update_device_data.py
  161. update_firmware.py
  162. update_kernel.py
  163. urandom.py
  164. usb.py
  165. verify_root_partition.py
  166. video_playback.py
  167. wait_external_test.py
  168. webgl_aquarium.py
  169. wifi_check_calibration.py
  170. wifi_throughput.py
  171. wireless_antenna.py
  172. wireless_radiotap.py
  173. write_device_data_to_vpd.py
  174. write_protect_switch.py
py/test/pytests/README.md

Chrome OS Reference Python Factory Tests

This folder contains all reference factory tests for Chrome OS Factory Software.

For more details of individual test, please look at the SDK document or read the source of individual tests.

Writing a new test

All the tests must be have implementation file named in lowercase_with_underline style and the Python class named in CamelCase style, following PEP-8 and Chrome OS Factory Coding Style. You can write test as a single Python file like nop.py, or implement it as Python package in its own folder like start/.

Tests should be implemented using Python unittest framework. Take nop.py as a simple example to create your own test.

To use your test (say mytest.py), define an entry in test list:

  {
    "pytest_name": "mytest"
  }

Using arguments

To read arguments specified from test list, use cros.factory.utils.arg_utils.Arg by adding declarations as class variable. For example:

  ARGS = [Arg('wait_secs', int, 'Wait for N seconds.', default=0)]

Then you can use this by reading self.args.wait_secs.

Since JSON serialization doesn‘t support tuple type, new pytests shouldn’t use tuple in argument type, and should use list instead.

Using user interface

The Chrome OS Factory Software provides a web based user interface. If you need to render anything on screen, try to import and initialize a cros.factory.test.test_ui object, with one of the templates from cros.factory.test.ui_templates.

The extra files needed by test, for example HTML or JavaScript files, can be put in a folder as ${pytest_name}_static, for example test countdown has its files in countdown_static. Or, if the test has its own package folder, put in a static folder inside the package; for example keyboard/static.

Test Documentation

To help both developers and non-developers understand better how these tests works, how to use it and what's needed to make it run, we have defined a template for documentation. The tests will be processed by Sphinx Documentation, so you just need to write the module doc string in reStructedText format with following sections:

"""Test summary here.

Description
-----------
A section for who wants to know what this test is, and how to use it.

You probably want to write the first section as a general description, and
remaining sections to explain more details, and how to assign the arguments
if the test arguments are pretty complicated (or try using a JSON configuration
via `config_utils` instead).

Test Procedure
--------------
Write "This is an automated test without user interaction." as first line if
the test does not need user interaction.

This is a section as "reference to write SOP for operators". Use simpler words
and abstraction of what will happen.

Dependency
----------
This is a section about "what people will need when they want to port the test
for a new platform, for example Android or even Windows.

Try to list everything needed outside Chrome OS factory repo, especially
kernel and driver dependency.

If you are using Device API (`cros.factory.device.*`), try to list the explicit
API you are using, with few typical dependency that it needs.

Examples
--------
Examples of how to use this test (in test list). Usually we want a "minimal" one
explaining what default behavior it will do, with few more examples to
demonstrate how to use the arguments.
"""

To preview your changes to doc, run make doc in chroot and browse build/doc/pytests/index.html.

For more examples on how to write these docs and how they looks on SDK site, try to look at following tests: