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