diff options
author | Mary Ruthven <mruthven@chromium.org> | 2021-01-05 13:05:59 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-01-06 21:56:52 +0000 |
commit | 2495bc0a9744f9733c59daeeb81c8be3c54243d8 (patch) | |
tree | 443dc5b7de1eb98c17e2e9119db2d4ffb57c2dc9 | |
parent | c677f06db48a415c982b10f9dd6a57096cfd7570 (diff) | |
download | chrome-ec-2495bc0a9744f9733c59daeeb81c8be3c54243d8.tar.gz |
coil: remove unused tests
We're deleting unused code to reduce coil terms in platform/cr50. Remove
unused tests to make this easier.
BUG=b:175244613
TEST=make buildall -j
Change-Id: I593caf5edfabda6ef24cc9eede2a8bb829c01b83
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2613134
Reviewed-by: Namyoon Woo <namyoon@chromium.org>
84 files changed, 0 insertions, 16226 deletions
diff --git a/test/battery_get_params_smart.c b/test/battery_get_params_smart.c deleted file mode 100644 index e2a3a81309..0000000000 --- a/test/battery_get_params_smart.c +++ /dev/null @@ -1,94 +0,0 @@ -/* Copyright 2014 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test the logic of battery_get_params() to be sure it sets the correct flags - * when i2c reads fail. - */ - -#include "battery.h" -#include "battery_smart.h" -#include "common.h" -#include "console.h" -#include "i2c.h" -#include "test_util.h" -#include "util.h" - -/* Test state */ -static int fail_on_first, fail_on_last; -static int read_count, write_count; -struct batt_params batt; - - -void battery_compensate_params(struct batt_params *batt) -{ -} - -static void reset_and_fail_on(int first, int last) -{ - /* We're not initializing the fake battery, so everything reads zero */ - memset(&batt, 0, sizeof(typeof(batt))); - read_count = write_count = 0; - fail_on_first = first; - fail_on_last = last; -} - -/* Mocked functions */ -int sb_read(int cmd, int *param) -{ - read_count++; - if (read_count >= fail_on_first && read_count <= fail_on_last) - return EC_ERROR_UNKNOWN; - - return i2c_read16(I2C_PORT_BATTERY, BATTERY_ADDR_FLAGS, - cmd, param); -} -int sb_write(int cmd, int param) -{ - write_count++; - return i2c_write16(I2C_PORT_BATTERY, BATTERY_ADDR_FLAGS, - cmd, param); -} - - -/* Tests */ -static int test_param_failures(void) -{ - int i, num_reads; - - /* No failures */ - reset_and_fail_on(0, 0); - battery_get_params(&batt); - TEST_ASSERT(batt.flags & BATT_FLAG_RESPONSIVE); - TEST_ASSERT(!(batt.flags & BATT_FLAG_BAD_ANY)); - num_reads = read_count; - - /* Just a single failure */ - for (i = 1; i <= num_reads; i++) { - reset_and_fail_on(i, i); - battery_get_params(&batt); - TEST_ASSERT(batt.flags & BATT_FLAG_BAD_ANY); - TEST_ASSERT(batt.flags & BATT_FLAG_RESPONSIVE); - } - - /* Once it fails, it keeps failing */ - for (i = 1; i <= num_reads; i++) { - reset_and_fail_on(i, num_reads); - battery_get_params(&batt); - TEST_ASSERT(batt.flags & BATT_FLAG_BAD_ANY); - if (i == 1) - /* If every read fails, it's not responsive */ - TEST_ASSERT(!(batt.flags & BATT_FLAG_RESPONSIVE)); - else - TEST_ASSERT(batt.flags & BATT_FLAG_RESPONSIVE); - } - - return EC_SUCCESS; -} - -void run_test(void) -{ - RUN_TEST(test_param_failures); - - test_print_result(); -} diff --git a/test/battery_get_params_smart.tasklist b/test/battery_get_params_smart.tasklist deleted file mode 100644 index c2eb8159a9..0000000000 --- a/test/battery_get_params_smart.tasklist +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2014 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST /* No test task */ diff --git a/test/bklight_lid.c b/test/bklight_lid.c deleted file mode 100644 index f3a14b2570..0000000000 --- a/test/bklight_lid.c +++ /dev/null @@ -1,106 +0,0 @@ -/* Copyright 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test backlight control based on lid - */ - -#include "backlight.h" -#include "common.h" -#include "console.h" -#include "hooks.h" -#include "host_command.h" -#include "lid_switch.h" -#include "test_util.h" -#include "timer.h" -#include "util.h" - -static int mock_lid = 1; -static int backlight_en; - -int gpio_get_level(enum gpio_signal signal) -{ - if (signal == GPIO_LID_OPEN) - return mock_lid; - return 0; -} - -void gpio_set_level(enum gpio_signal signal, int level) -{ - if (signal == GPIO_ENABLE_BACKLIGHT) - backlight_en = level; -} - -void set_lid_state(int is_open) -{ - mock_lid = is_open; - lid_interrupt(GPIO_LID_OPEN); - msleep(40); -} - -static int send_bklight_hostcmd(int enabled) -{ - struct ec_params_switch_enable_backlight p; - p.enabled = enabled; - - return test_send_host_command(EC_CMD_SWITCH_ENABLE_BKLIGHT, 0, &p, - sizeof(p), NULL, 0); -} - -static int test_passthrough(void) -{ - /* Initial state */ - TEST_ASSERT(mock_lid == 1); - TEST_ASSERT(backlight_en); - - /* Close lid. Backlight should turn off */ - set_lid_state(0); - TEST_ASSERT(!backlight_en); - - /* Open lid. Backlight turns on */ - set_lid_state(1); - TEST_ASSERT(backlight_en); - - return EC_SUCCESS; -} - -static int test_hostcommand(void) -{ - /* Open lid */ - set_lid_state(1); - TEST_ASSERT(backlight_en); - - /* Disable by host command */ - send_bklight_hostcmd(0); - TEST_ASSERT(!backlight_en); - - /* Close and open lid. Backlight should come up */ - set_lid_state(0); - set_lid_state(1); - TEST_ASSERT(backlight_en); - - /* Close lid */ - set_lid_state(0); - TEST_ASSERT(!backlight_en); - - /* Enable by host command */ - send_bklight_hostcmd(1); - TEST_ASSERT(backlight_en); - - /* Disable backlight by lid */ - set_lid_state(1); - set_lid_state(0); - TEST_ASSERT(!backlight_en); - - return EC_SUCCESS; -} - -void run_test(void) -{ - test_reset(); - - RUN_TEST(test_passthrough); - RUN_TEST(test_hostcommand); - - test_print_result(); -} diff --git a/test/bklight_lid.tasklist b/test/bklight_lid.tasklist deleted file mode 100644 index da0ab6211a..0000000000 --- a/test/bklight_lid.tasklist +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST /* No test task */ diff --git a/test/bklight_passthru.c b/test/bklight_passthru.c deleted file mode 100644 index 3727447cd7..0000000000 --- a/test/bklight_passthru.c +++ /dev/null @@ -1,140 +0,0 @@ -/* Copyright 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test x86 backlight passthrough. - */ - -#include "backlight.h" -#include "common.h" -#include "console.h" -#include "hooks.h" -#include "host_command.h" -#include "lid_switch.h" -#include "test_util.h" -#include "timer.h" -#include "util.h" - -static int mock_lid = 1; -static int mock_pch_bklten; -static int backlight_en; - -int gpio_get_level(enum gpio_signal signal) -{ - if (signal == GPIO_LID_OPEN) - return mock_lid; - if (signal == GPIO_PCH_BKLTEN) - return mock_pch_bklten; - return 0; -} - -void gpio_set_level(enum gpio_signal signal, int level) -{ - if (signal == GPIO_ENABLE_BACKLIGHT) - backlight_en = level; -} - -void set_lid_state(int is_open) -{ - mock_lid = is_open; - lid_interrupt(GPIO_LID_OPEN); - msleep(40); -} - -void set_pch_bklten(int enabled) -{ - int orig = mock_pch_bklten; - mock_pch_bklten = enabled; - if (orig != enabled) - backlight_interrupt(GPIO_PCH_BKLTEN); -} - -static int send_bklight_hostcmd(int enabled) -{ - struct ec_params_switch_enable_backlight p; - p.enabled = enabled; - - return test_send_host_command(EC_CMD_SWITCH_ENABLE_BKLIGHT, 0, &p, - sizeof(p), NULL, 0); -} - -static int test_passthrough(void) -{ - /* Initial state */ - TEST_ASSERT(mock_lid == 1 && mock_pch_bklten == 0); - TEST_ASSERT(!backlight_en); - - /* Enable backlight */ - set_pch_bklten(1); - TEST_ASSERT(backlight_en); - - /* Disable backlight */ - set_pch_bklten(0); - TEST_ASSERT(!backlight_en); - - /* Enable backlight again */ - set_pch_bklten(1); - TEST_ASSERT(backlight_en); - - /* Close lid. Backlight should turn off */ - set_lid_state(0); - TEST_ASSERT(!backlight_en); - - /* Open lid. Backlight turns on */ - set_lid_state(1); - TEST_ASSERT(backlight_en); - - /* Close lid and disable backlight */ - set_lid_state(0); - set_pch_bklten(0); - TEST_ASSERT(!backlight_en); - - /* Open lid now. Backlight stays off */ - set_lid_state(1); - TEST_ASSERT(!backlight_en); - - return EC_SUCCESS; -} - -static int test_hostcommand(void) -{ - /* Open lid and enable backlight */ - set_lid_state(1); - set_pch_bklten(1); - TEST_ASSERT(backlight_en); - - /* Disable by host command */ - send_bklight_hostcmd(0); - TEST_ASSERT(!backlight_en); - - /* Close and open lid. Backlight should come up */ - set_lid_state(0); - set_lid_state(1); - TEST_ASSERT(backlight_en); - - /* Close lid and disable backlight */ - set_lid_state(0); - set_pch_bklten(0); - TEST_ASSERT(!backlight_en); - - /* Enable by host command */ - send_bklight_hostcmd(1); - TEST_ASSERT(backlight_en); - - /* Disable backlight by lid */ - set_lid_state(1); - set_lid_state(0); - TEST_ASSERT(!backlight_en); - - return EC_SUCCESS; -} - -void run_test(void) -{ - test_reset(); - - RUN_TEST(test_passthrough); - RUN_TEST(test_hostcommand); - - test_print_result(); -} diff --git a/test/bklight_passthru.tasklist b/test/bklight_passthru.tasklist deleted file mode 100644 index da0ab6211a..0000000000 --- a/test/bklight_passthru.tasklist +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST /* No test task */ diff --git a/test/build.mk b/test/build.mk index 143041ee7f..ec40d00b95 100644 --- a/test/build.mk +++ b/test/build.mk @@ -13,41 +13,22 @@ test-list-host=$(TEST_LIST_HOST) else test-list-host = aes test-list-host += base32 -test-list-host += battery_get_params_smart -test-list-host += bklight_lid -test-list-host += bklight_passthru test-list-host += button test-list-host += cec -test-list-host += charge_manager -test-list-host += charge_manager_drp_charging -test-list-host += charge_ramp test-list-host += console_edit test-list-host += crc32 test-list-host += ec_comm test-list-host += entropy -test-list-host += extpwr_gpio -test-list-host += fan test-list-host += flash test-list-host += flash_log test-list-host += float test-list-host += fp -test-list-host += fpsensor test-list-host += hooks test-list-host += host_command -test-list-host += inductive_charging test-list-host += interrupt test-list-host += is_enabled test-list-host += is_enabled_error -test-list-host += kb_8042 -test-list-host += kb_mkbp -#test-list-host += kb_scan # crbug.com/976974 -test-list-host += lid_sw -test-list-host += lightbar test-list-host += math_util -test-list-host += motion_angle -test-list-host += motion_angle_tablet -test-list-host += motion_lid -test-list-host += motion_sense_fifo test-list-host += mutex test-list-host += nvmem test-list-host += pingpong @@ -59,7 +40,6 @@ test-list-host += rma_auth test-list-host += rsa test-list-host += rsa3 test-list-host += rtc -test-list-host += sbs_charging_v2 test-list-host += sha256 test-list-host += sha256_unrolled test-list-host += shmalloc @@ -69,21 +49,6 @@ test-list-host += system test-list-host += thermal test-list-host += timer_dos test-list-host += uptime -test-list-host += usb_common -test-list-host += usb_pd_int -test-list-host += usb_pd -test-list-host += usb_pd_giveback -test-list-host += usb_pd_rev30 -test-list-host += usb_ppc -test-list-host += usb_sm_framework_h3 -test-list-host += usb_sm_framework_h2 -test-list-host += usb_sm_framework_h1 -test-list-host += usb_sm_framework_h0 -test-list-host += usb_typec_vpd -test-list-host += usb_typec_ctvpd -test-list-host += usb_typec_drp_acc_trysrc -test-list-host += usb_prl -test-list-host += usb_pe_drp test-list-host += utils test-list-host += utils_str test-list-host += vboot @@ -92,38 +57,19 @@ endif aes-y=aes.o base32-y=base32.o -battery_get_params_smart-y=battery_get_params_smart.o -bklight_lid-y=bklight_lid.o -bklight_passthru-y=bklight_passthru.o button-y=button.o cec-y=cec.o -charge_manager-y=charge_manager.o -charge_manager_drp_charging-y=charge_manager.o -charge_ramp-y+=charge_ramp.o console_edit-y=console_edit.o crc32-y=crc32.o ec_comm-y=ec_comm.o entropy-y=entropy.o -extpwr_gpio-y=extpwr_gpio.o -fan-y=fan.o flash-y=flash.o flash_log-y=flash_log.o -fpsensor-y=fpsensor.o hooks-y=hooks.o host_command-y=host_command.o -inductive_charging-y=inductive_charging.o interrupt-y=interrupt.o is_enabled-y=is_enabled.o -kb_8042-y=kb_8042.o -kb_mkbp-y=kb_mkbp.o -kb_scan-y=kb_scan.o -lid_sw-y=lid_sw.o -lightbar-y=lightbar.o math_util-y=math_util.o -motion_angle-y=motion_angle.o motion_angle_data_literals.o motion_common.o -motion_angle_tablet-y=motion_angle_tablet.o motion_angle_data_literals_tablet.o motion_common.o -motion_lid-y=motion_lid.o -motion_sense_fifo-y=motion_sense_fifo.o mutex-y=mutex.o nvmem-y=nvmem.o nvmem_tpm2_mock.o pingpong-y=pingpong.o @@ -136,8 +82,6 @@ rma_auth-y=rma_auth.o rsa-y=rsa.o rsa3-y=rsa.o rtc-y=rtc.o -sbs_charging-y=sbs_charging.o -sbs_charging_v2-y=sbs_charging_v2.o sha256-y=sha256.o sha256_unrolled-y=sha256.o shmalloc-y=shmalloc.o @@ -148,23 +92,6 @@ thermal-y=thermal.o timer_calib-y=timer_calib.o timer_dos-y=timer_dos.o uptime-y=uptime.o -usb_common-y=usb_common_test.o -usb_pd_int-y=usb_pd_int.o -usb_pd-y=usb_pd.o -usb_pd_giveback-y=usb_pd.o -usb_pd_rev30-y=usb_pd.o -usb_ppc-y=usb_ppc.o -usb_sm_framework_h3-y=usb_sm_framework_h3.o -usb_sm_framework_h2-y=usb_sm_framework_h3.o -usb_sm_framework_h1-y=usb_sm_framework_h3.o -usb_sm_framework_h0-y=usb_sm_framework_h3.o -usb_typec_vpd-y=usb_typec_ctvpd.o vpd_api.o usb_sm_checks.o -usb_typec_ctvpd-y=usb_typec_ctvpd.o vpd_api.o usb_sm_checks.o -usb_typec_drp_acc_trysrc-y=usb_typec_drp_acc_trysrc.o vpd_api.o \ - usb_sm_checks.o -usb_prl-y=usb_prl.o usb_sm_checks.o -usb_pe_drp-y=usb_pe_drp.o usb_sm_checks.o \ - fake_battery.o fake_prl.o fake_usbc.o utils-y=utils.o utils_str-y=utils_str.o vboot-y=vboot.o diff --git a/test/charge_manager.c b/test/charge_manager.c deleted file mode 100644 index 7fb8685aef..0000000000 --- a/test/charge_manager.c +++ /dev/null @@ -1,805 +0,0 @@ -/* Copyright 2014 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test charge manager module. - */ - -#include "battery.h" -#include "charge_manager.h" -#include "common.h" -#include "ec_commands.h" -#include "test_util.h" -#include "timer.h" -#include "usb_pd.h" -#include "util.h" - -#define CHARGE_MANAGER_SLEEP_MS 50 - -/* Charge supplier priority: lower number indicates higher priority. */ -const int supplier_priority[] = { - [CHARGE_SUPPLIER_TEST1] = 0, - [CHARGE_SUPPLIER_TEST2] = 1, - [CHARGE_SUPPLIER_TEST3] = 1, - [CHARGE_SUPPLIER_TEST4] = 1, - [CHARGE_SUPPLIER_TEST5] = 3, - [CHARGE_SUPPLIER_TEST6] = 3, - [CHARGE_SUPPLIER_TEST7] = 5, - [CHARGE_SUPPLIER_TEST8] = 6, - [CHARGE_SUPPLIER_TEST9] = 6, - [CHARGE_SUPPLIER_TEST10] = 7, -}; -BUILD_ASSERT((int)CHARGE_SUPPLIER_COUNT == (int)CHARGE_SUPPLIER_TEST_COUNT); -BUILD_ASSERT(ARRAY_SIZE(supplier_priority) == CHARGE_SUPPLIER_COUNT); - -static unsigned int active_charge_limit = CHARGE_SUPPLIER_NONE; -static unsigned int active_charge_port = CHARGE_PORT_NONE; -static unsigned int charge_port_to_reject = CHARGE_PORT_NONE; -static int new_power_request[CONFIG_USB_PD_PORT_MAX_COUNT]; -static int power_role[CONFIG_USB_PD_PORT_MAX_COUNT]; - -/* Callback functions called by CM on state change */ -void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) -{ - active_charge_limit = charge_ma; -} - -/* Sets a charge port that will be rejected as the active port. */ -static void set_charge_port_to_reject(int port) -{ - charge_port_to_reject = port; -} - -int board_set_active_charge_port(int charge_port) -{ - if (charge_port != CHARGE_PORT_NONE && - charge_port == charge_port_to_reject) - return EC_ERROR_INVAL; - - active_charge_port = charge_port; - return EC_SUCCESS; -} - -void board_charge_manager_override_timeout(void) -{ -} - -void pd_set_new_power_request(int port) -{ - new_power_request[port] = 1; -} - -enum battery_present battery_is_present(void) -{ - return BP_YES; -} - -static void clear_new_power_requests(void) -{ - int i; - for (i = 0; i < board_get_usb_pd_port_count(); ++i) - new_power_request[i] = 0; -} - -static void pd_set_role(int port, int role) -{ - power_role[port] = role; -} - -int pd_get_role(int port) -{ - return power_role[port]; -} - -void pd_request_power_swap(int port) -{ - if (power_role[port] == PD_ROLE_SINK) - power_role[port] = PD_ROLE_SOURCE; - else - power_role[port] = PD_ROLE_SINK; -} - -static void wait_for_charge_manager_refresh(void) -{ - msleep(CHARGE_MANAGER_SLEEP_MS); -} - -static void initialize_charge_table(int current, int voltage, int ceil) -{ - int i, j; - struct charge_port_info charge; - - charge_manager_set_override(OVERRIDE_OFF); - set_charge_port_to_reject(CHARGE_PORT_NONE); - charge.current = current; - charge.voltage = voltage; - - for (i = 0; i < board_get_usb_pd_port_count(); ++i) { - for (j = 0; j < CEIL_REQUESTOR_COUNT; ++j) - charge_manager_set_ceil(i, j, ceil); - charge_manager_update_dualrole(i, CAP_DEDICATED); - pd_set_role(i, PD_ROLE_SINK); - for (j = 0; j < CHARGE_SUPPLIER_COUNT; ++j) - charge_manager_update_charge(j, i, &charge); - } - wait_for_charge_manager_refresh(); -} - -static int test_initialization(void) -{ - int i, j; - struct charge_port_info charge; - - /* - * No charge port should be selected until all ports + suppliers - * have reported in with an initial charge. - */ - TEST_ASSERT(active_charge_port == CHARGE_PORT_NONE); - charge.current = 1000; - charge.voltage = 5000; - - /* Initialize all supplier/port pairs, except for the last one */ - for (i = 0; i < CHARGE_SUPPLIER_COUNT; ++i) - for (j = 0; j < board_get_usb_pd_port_count(); ++j) { - if (i == 0) - charge_manager_update_dualrole(j, - CAP_DEDICATED); - if (i == CHARGE_SUPPLIER_COUNT - 1 && - j == board_get_usb_pd_port_count() - 1) - break; - charge_manager_update_charge(i, j, &charge); - } - - /* Verify no active charge port, since all pairs haven't updated */ - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == CHARGE_PORT_NONE); - - /* Update last pair and verify a charge port has been selected */ - charge_manager_update_charge(CHARGE_SUPPLIER_COUNT-1, - board_get_usb_pd_port_count()-1, - &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port != CHARGE_PORT_NONE); - - return EC_SUCCESS; -} - -static int test_safe_mode(void) -{ - int port = 0; - struct charge_port_info charge; - - /* Initialize table to no charge */ - initialize_charge_table(0, 5000, 5000); - - /* - * Set a 2A non-dedicated charger on port 0 and verify that - * it is selected, due to safe mode. - */ - charge_manager_update_dualrole(port, CAP_DUALROLE); - charge.current = 2000; - charge.voltage = 5000; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST2, port, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == port); - TEST_ASSERT(active_charge_limit == 2000); - - /* Verify ceil is ignored, due to safe mode. */ - charge_manager_set_ceil(port, 0, 500); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_limit == 2000); - - /* - * Leave safe mode and verify normal port selection rules go - * into effect. - */ - charge_manager_leave_safe_mode(); - wait_for_charge_manager_refresh(); -#ifdef CONFIG_CHARGE_MANAGER_DRP_CHARGING - TEST_ASSERT(active_charge_port == port); - TEST_ASSERT(active_charge_limit == 500); -#else - TEST_ASSERT(active_charge_port == CHARGE_PORT_NONE); -#endif - - /* For subsequent tests, safe mode is exited. */ - return EC_SUCCESS; -} - -static int test_priority(void) -{ - struct charge_port_info charge; - - /* Initialize table to no charge */ - initialize_charge_table(0, 5000, 5000); - TEST_ASSERT(active_charge_port == CHARGE_PORT_NONE); - - /* - * Set a 1A charge via a high-priority supplier and a 2A charge via - * a low-priority supplier, and verify the HP supplier is chosen. - */ - charge.current = 2000; - charge.voltage = 5000; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST6, 0, &charge); - charge.current = 1000; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST2, 1, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 1); - TEST_ASSERT(active_charge_limit == 1000); - - /* - * Set a higher charge on a LP supplier and verify we still use the - * lower charge. - */ - charge.current = 1500; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST7, 1, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 1); - TEST_ASSERT(active_charge_limit == 1000); - - /* - * Zero our HP charge and verify fallback to next highest priority, - * which happens to be a different port. - */ - charge.current = 0; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST2, 1, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 0); - TEST_ASSERT(active_charge_limit == 2000); - - /* Add a charge at equal priority and verify highest charge selected */ - charge.current = 2500; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST5, 0, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 0); - TEST_ASSERT(active_charge_limit == 2500); - - charge.current = 3000; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST6, 1, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 1); - TEST_ASSERT(active_charge_limit == 3000); - - /* - * Add a charge at equal priority and equal power, verify that the - * active port doesn't change since the first plugged port is - * selected as the tiebreaker. - */ - charge.current = 3000; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST6, 0, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 1); - TEST_ASSERT(active_charge_limit == 3000); - - return EC_SUCCESS; -} - -static int test_charge_ceil(void) -{ - int port; - struct charge_port_info charge; - - /* Initialize table to 1A @ 5V, and verify port + limit */ - initialize_charge_table(1000, 5000, 1000); - TEST_ASSERT(active_charge_port != CHARGE_PORT_NONE); - TEST_ASSERT(active_charge_limit == 1000); - - /* Set a 500mA ceiling, verify port is unchanged */ - port = active_charge_port; - charge_manager_set_ceil(port, 0, 500); - wait_for_charge_manager_refresh(); - TEST_ASSERT(port == active_charge_port); - TEST_ASSERT(active_charge_limit == 500); - - /* Raise the ceiling to 2A, verify limit goes back to 1A */ - charge_manager_set_ceil(port, 0, 2000); - wait_for_charge_manager_refresh(); - TEST_ASSERT(port == active_charge_port); - TEST_ASSERT(active_charge_limit == 1000); - - /* Verify that ceiling is ignored in determining active charge port */ - charge.current = 2000; - charge.voltage = 5000; - charge_manager_update_charge(0, 0, &charge); - charge.current = 2500; - charge_manager_update_charge(0, 1, &charge); - charge_manager_set_ceil(1, 0, 750); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 1); - TEST_ASSERT(active_charge_limit == 750); - - /* Set a secondary lower ceiling and verify it takes effect */ - charge_manager_set_ceil(1, 1, 500); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 1); - TEST_ASSERT(active_charge_limit == 500); - - /* Raise the secondary ceiling and verify the primary takes effect */ - charge_manager_set_ceil(1, 1, 800); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 1); - TEST_ASSERT(active_charge_limit == 750); - - /* Remove the primary celing and verify the secondary takes effect */ - charge_manager_set_ceil(1, 0, CHARGE_CEIL_NONE); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 1); - TEST_ASSERT(active_charge_limit == 800); - - /* Remove all ceilings */ - charge_manager_set_ceil(1, 1, CHARGE_CEIL_NONE); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 1); - TEST_ASSERT(active_charge_limit == 2500); - - /* Verify forced ceil takes effect immediately */ - charge_manager_force_ceil(1, 500); - TEST_ASSERT(active_charge_port == 1); - TEST_ASSERT(active_charge_limit == 500); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 1); - TEST_ASSERT(active_charge_limit == 500); - - return EC_SUCCESS; -} - -static int test_new_power_request(void) -{ - struct charge_port_info charge; - - /* Initialize table to no charge */ - initialize_charge_table(0, 5000, 5000); - /* Clear power requests, and verify they are zero'd */ - clear_new_power_requests(); - wait_for_charge_manager_refresh(); - TEST_ASSERT(new_power_request[0] == 0); - TEST_ASSERT(new_power_request[1] == 0); - - /* Charge from port 1 and verify NPR on port 1 only */ - charge.current = 1000; - charge.voltage = 5000; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST2, 1, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(new_power_request[0] == 0); - TEST_ASSERT(new_power_request[1] == 1); - clear_new_power_requests(); - - /* Reduce port 1 through ceil and verify no NPR */ - charge_manager_set_ceil(1, 0, 500); - wait_for_charge_manager_refresh(); - TEST_ASSERT(new_power_request[0] == 0); - TEST_ASSERT(new_power_request[1] == 0); - clear_new_power_requests(); - - /* Change port 1 voltage and verify NPR on port 1 */ - charge.voltage = 4000; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST2, 1, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(new_power_request[0] == 0); - TEST_ASSERT(new_power_request[1] == 1); - clear_new_power_requests(); - - /* Add low-priority source and verify no NPRs */ - charge_manager_update_charge(CHARGE_SUPPLIER_TEST6, 0, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(new_power_request[0] == 0); - TEST_ASSERT(new_power_request[1] == 0); - clear_new_power_requests(); - - /* - * Add higher-priority source and verify NPR on both ports, - * since we're switching charge ports. - */ - charge_manager_update_charge(CHARGE_SUPPLIER_TEST1, 0, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(new_power_request[0] == 1); - TEST_ASSERT(new_power_request[1] == 1); - clear_new_power_requests(); - - return EC_SUCCESS; -} - -static int test_override(void) -{ - struct charge_port_info charge; - - /* Initialize table to no charge */ - initialize_charge_table(0, 5000, 1000); - - /* - * Set a low-priority supplier on p0 and high-priority on p1, then - * verify that p1 is selected. - */ - charge.current = 500; - charge.voltage = 5000; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST2, 0, &charge); - charge_manager_update_charge(CHARGE_SUPPLIER_TEST1, 1, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 1); - TEST_ASSERT(active_charge_limit == 500); - - /* Set override to p0 and verify p0 is selected */ - charge_manager_set_override(0); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 0); - - /* Remove override and verify p1 is again selected */ - charge_manager_set_override(OVERRIDE_OFF); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 1); - - /* - * Set override again to p0, but set p0 charge to 0, and verify p1 - * is again selected. - */ - charge.current = 0; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST2, 0, &charge); - charge_manager_set_override(0); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 1); - - /* Set non-zero charge on port 0 and verify override was auto-removed */ - charge.current = 250; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST5, 0, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 1); - - /* - * Verify current limit is still selected according to supplier - * priority on the override port. - */ - charge.current = 300; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST2, 0, &charge); - charge_manager_set_override(0); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 0); - TEST_ASSERT(active_charge_limit == 300); - charge.current = 100; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST1, 0, &charge); - charge_manager_set_override(0); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 0); - TEST_ASSERT(active_charge_limit == 100); - - /* - * Verify that a don't charge override request on a dual-role - * port causes a swap to source. - */ - pd_set_role(0, PD_ROLE_SINK); - charge_manager_update_dualrole(0, CAP_DUALROLE); - charge_manager_set_override(OVERRIDE_DONT_CHARGE); - wait_for_charge_manager_refresh(); - TEST_ASSERT(pd_get_role(0) == PD_ROLE_SOURCE); - - /* - * Verify that an override request to a dual-role source port - * causes a role swap to sink. - */ - charge_manager_set_override(0); - wait_for_charge_manager_refresh(); - charge.current = 200; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST1, 0, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 0); - TEST_ASSERT(active_charge_limit == 200); - TEST_ASSERT(pd_get_role(0) == PD_ROLE_SINK); - - /* Set override to "don't charge", then verify we're not charging */ - charge_manager_set_override(OVERRIDE_DONT_CHARGE); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == CHARGE_PORT_NONE); - TEST_ASSERT(active_charge_limit == 0); - TEST_ASSERT(pd_get_role(0) == PD_ROLE_SOURCE); - - /* Update a charge supplier, verify that we still aren't charging */ - charge.current = 200; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST1, 0, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == CHARGE_PORT_NONE); - TEST_ASSERT(active_charge_limit == 0); - TEST_ASSERT(pd_get_role(0) == PD_ROLE_SOURCE); - - /* Turn override off, verify that we go back to the correct charge */ - charge_manager_set_override(OVERRIDE_OFF); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 1); - TEST_ASSERT(active_charge_limit == 500); - TEST_ASSERT(pd_get_role(0) == PD_ROLE_SOURCE); - - return EC_SUCCESS; -} - -static int test_dual_role(void) -{ - struct charge_port_info charge; - - /* Initialize table to no charge. */ - initialize_charge_table(0, 5000, 1000); - - /* Mark P0 as dual-role and set a charge. */ - charge_manager_update_dualrole(0, CAP_DUALROLE); - charge.current = 500; - charge.voltage = 5000; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST2, 0, &charge); - wait_for_charge_manager_refresh(); -#ifdef CONFIG_CHARGE_MANAGER_DRP_CHARGING - /* Verify we do charge from dual-role port */ - TEST_ASSERT(active_charge_port == 0); - TEST_ASSERT(active_charge_limit == 500); -#else - /* Verify we don't charge from dual-role port */ - TEST_ASSERT(active_charge_port == CHARGE_PORT_NONE); - TEST_ASSERT(active_charge_limit == 0); -#endif - - /* Mark P0 as the override port, verify that we now charge. */ - charge_manager_set_override(0); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 0); - TEST_ASSERT(active_charge_limit == 500); - TEST_ASSERT(pd_get_role(0) == PD_ROLE_SINK); - - /* Remove override and verify we go back to previous state */ - charge_manager_set_override(OVERRIDE_OFF); - wait_for_charge_manager_refresh(); -#ifdef CONFIG_CHARGE_MANAGER_DRP_CHARGING - TEST_ASSERT(active_charge_port == 0); - TEST_ASSERT(active_charge_limit == 500); -#else - TEST_ASSERT(active_charge_port == CHARGE_PORT_NONE); - TEST_ASSERT(active_charge_limit == 0); - TEST_ASSERT(pd_get_role(0) == PD_ROLE_SOURCE); -#endif - - /* Mark P0 as the override port, verify that we again charge. */ - charge_manager_set_override(0); - charge.current = 550; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST2, 0, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 0); - TEST_ASSERT(active_charge_limit == 550); - TEST_ASSERT(pd_get_role(0) == PD_ROLE_SINK); - - /* - * Insert a dual-role charger into P1 and set the override. Verify - * that the override correctly changes. - */ - charge_manager_update_dualrole(1, CAP_DUALROLE); - charge_manager_set_override(1); - charge.current = 500; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST6, 1, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 1); - TEST_ASSERT(active_charge_limit == 500); - TEST_ASSERT(pd_get_role(1) == PD_ROLE_SINK); - TEST_ASSERT(pd_get_role(0) == PD_ROLE_SOURCE); - - /* Set override back to P0 and verify switch */ - charge_manager_set_override(0); - charge.current = 600; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST2, 0, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 0); - TEST_ASSERT(active_charge_limit == 600); - TEST_ASSERT(pd_get_role(0) == PD_ROLE_SINK); - TEST_ASSERT(pd_get_role(1) == PD_ROLE_SOURCE); - - /* Insert a dedicated charger and verify override is removed */ - charge.current = 0; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST6, 1, &charge); - wait_for_charge_manager_refresh(); - charge_manager_update_dualrole(1, CAP_DEDICATED); - charge.current = 400; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST6, 1, &charge); - wait_for_charge_manager_refresh(); -#ifdef CONFIG_CHARGE_MANAGER_DRP_CHARGING - TEST_ASSERT(active_charge_port == 0); - TEST_ASSERT(active_charge_limit == 600); -#else - TEST_ASSERT(active_charge_port == 1); - TEST_ASSERT(active_charge_limit == 400); - TEST_ASSERT(pd_get_role(0) == PD_ROLE_SOURCE); -#endif - - /* - * Verify the port is handled normally if the dual-role source is - * unplugged and replaced with a dedicated source. - */ - charge_manager_update_dualrole(0, CAP_DEDICATED); - charge.current = 0; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST2, 0, &charge); - charge.current = 500; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST2, 0, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 0); - TEST_ASSERT(active_charge_limit == 500); - - /* - * Test one port connected to dedicated charger and one connected - * to dual-role device. - */ - charge_manager_update_dualrole(0, CAP_DUALROLE); - charge.current = 0; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST2, 0, &charge); - charge.current = 500; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST2, 0, &charge); - charge.current = 200; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST6, 1, &charge); - wait_for_charge_manager_refresh(); -#ifdef CONFIG_CHARGE_MANAGER_DRP_CHARGING - /* Verify we charge from port with higher priority */ - TEST_ASSERT(active_charge_port == 0); - TEST_ASSERT(active_charge_limit == 500); -#else - /* - * Verify that we charge from the dedicated port if a dual-role - * source is also attached. - */ - TEST_ASSERT(active_charge_port == 1); - TEST_ASSERT(active_charge_limit == 200); - TEST_ASSERT(pd_get_role(0) == PD_ROLE_SOURCE); -#endif - - return EC_SUCCESS; -} - -static int test_rejected_port(void) -{ - struct charge_port_info charge; - - /* Initialize table to no charge. */ - initialize_charge_table(0, 5000, 1000); - TEST_ASSERT(active_charge_port == CHARGE_PORT_NONE); - - /* Set a charge on P0. */ - charge.current = 500; - charge.voltage = 5000; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST2, 0, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 0); - TEST_ASSERT(active_charge_limit == 500); - - /* Set P0 as rejected, and verify that it doesn't become active. */ - set_charge_port_to_reject(1); - charge.current = 1000; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST1, 1, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 0); - TEST_ASSERT(active_charge_limit == 500); - - /* Don't reject P0, and verify it can become active. */ - set_charge_port_to_reject(CHARGE_PORT_NONE); - charge_manager_update_charge(CHARGE_SUPPLIER_TEST1, 1, &charge); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 1); - TEST_ASSERT(active_charge_limit == 1000); - - return EC_SUCCESS; -} - -static int test_unknown_dualrole_capability(void) -{ - struct charge_port_info charge; - - /* Initialize table to no charge. */ - initialize_charge_table(0, 5000, 2000); - TEST_ASSERT(active_charge_port == CHARGE_PORT_NONE); - - /* Set a charge on P0 with unknown dualrole capability, */ - charge.current = 500; - charge.voltage = 5000; - charge_manager_update_dualrole(0, CAP_UNKNOWN); - charge_manager_update_charge(CHARGE_SUPPLIER_TEST2, 0, &charge); - wait_for_charge_manager_refresh(); -#ifdef CONFIG_CHARGE_MANAGER_DRP_CHARGING - /* Verify we do charge from that port */ - TEST_ASSERT(active_charge_port == 0); - TEST_ASSERT(active_charge_limit == 500); -#else - /* Verify that we don't charge from the port. */ - TEST_ASSERT(active_charge_port == CHARGE_PORT_NONE); -#endif - - /* Toggle to dedicated and verify port becomes active. */ - charge_manager_update_dualrole(0, CAP_DEDICATED); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 0); - - /* Add dualrole charger in port 1 */ - charge.current = 1000; - charge_manager_update_dualrole(1, CAP_DUALROLE); - charge_manager_update_charge(CHARGE_SUPPLIER_TEST2, 1, &charge); - wait_for_charge_manager_refresh(); -#ifdef CONFIG_CHARGE_MANAGER_DRP_CHARGING - TEST_ASSERT(active_charge_port == 1); - TEST_ASSERT(active_charge_limit == 1000); -#else - TEST_ASSERT(active_charge_port == 0); -#endif - - /* Remove charger on port 0 */ - charge.current = 0; - charge_manager_update_dualrole(0, CAP_UNKNOWN); - charge_manager_update_charge(CHARGE_SUPPLIER_TEST2, 0, &charge); - wait_for_charge_manager_refresh(); -#ifdef CONFIG_CHARGE_MANAGER_DRP_CHARGING - TEST_ASSERT(active_charge_port == 1); - TEST_ASSERT(active_charge_limit == 1000); -#else - TEST_ASSERT(active_charge_port == CHARGE_PORT_NONE); -#endif - - /* Set override to charge on port 1 */ - charge_manager_set_override(1); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 1); - - /* - * Toggle port 0 to dedicated, verify that override is still kept - * because there's no charge on the port. - */ - charge_manager_update_dualrole(0, CAP_DEDICATED); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 1); - - /* Insert UNKNOWN capability charger on port 0 */ - charge_manager_update_dualrole(0, CAP_UNKNOWN); - charge.current = 2000; - charge_manager_update_charge(CHARGE_SUPPLIER_TEST2, 0, &charge); - wait_for_charge_manager_refresh(); - wait_for_charge_manager_refresh(); - wait_for_charge_manager_refresh(); -#ifdef CONFIG_CHARGE_MANAGER_DRP_CHARGING - /* Verify override is removed */ - TEST_ASSERT(active_charge_port == 0); - TEST_ASSERT(active_charge_limit == 2000); -#else - /* Verify override is still kept */ - TEST_ASSERT(active_charge_port == 1); -#endif - - /* Toggle to dualrole */ - charge_manager_update_dualrole(0, CAP_DUALROLE); - wait_for_charge_manager_refresh(); -#ifdef CONFIG_CHARGE_MANAGER_DRP_CHARGING - /* Verify no change */ - TEST_ASSERT(active_charge_port == 0); -#else - /* Verify override is still kept */ - TEST_ASSERT(active_charge_port == 1); -#endif - - /* Toggle to dedicated */ - charge_manager_update_dualrole(0, CAP_UNKNOWN); - wait_for_charge_manager_refresh(); -#ifdef CONFIG_CHARGE_MANAGER_DRP_CHARGING - /* Verify no change */ - TEST_ASSERT(active_charge_port == 0); -#else - /* Verify override is still kept */ - TEST_ASSERT(active_charge_port == 1); -#endif - charge_manager_update_dualrole(0, CAP_DEDICATED); - wait_for_charge_manager_refresh(); - TEST_ASSERT(active_charge_port == 0); - - return EC_SUCCESS; -} - -void run_test(void) -{ - test_reset(); - - RUN_TEST(test_initialization); - RUN_TEST(test_safe_mode); - RUN_TEST(test_priority); - RUN_TEST(test_charge_ceil); - RUN_TEST(test_new_power_request); - RUN_TEST(test_override); - RUN_TEST(test_dual_role); - RUN_TEST(test_rejected_port); - RUN_TEST(test_unknown_dualrole_capability); - - test_print_result(); -} diff --git a/test/charge_manager.tasklist b/test/charge_manager.tasklist deleted file mode 100644 index 1f6f139a63..0000000000 --- a/test/charge_manager.tasklist +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2014 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST /* No test task */ diff --git a/test/charge_manager_drp_charging.tasklist b/test/charge_manager_drp_charging.tasklist deleted file mode 100644 index e39c934e44..0000000000 --- a/test/charge_manager_drp_charging.tasklist +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2015 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST /* No test task */ diff --git a/test/charge_ramp.c b/test/charge_ramp.c deleted file mode 100644 index f6f8bd542e..0000000000 --- a/test/charge_ramp.c +++ /dev/null @@ -1,528 +0,0 @@ -/* Copyright 2015 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test AC input current ramp. - */ - -#include "charge_manager.h" -#include "charge_ramp.h" -#include "common.h" -#include "console.h" -#include "gpio.h" -#include "hooks.h" -#include "task.h" -#include "test_util.h" -#include "timer.h" -#include "util.h" - -#define TASK_EVENT_OVERCURRENT (1 << 0) - -#define RAMP_STABLE_DELAY (120*SECOND) - -/* - * Time to delay for detecting the charger type. This value follows - * the value in common/charge_ramp.c, but must be less than the real - * CHARGE_DETECT_DELAY so we guarantee we wake up before the ramp - * has started. - */ -#define CHARGE_DETECT_DELAY_TEST (CHARGE_DETECT_DELAY - 100*MSEC) - -static int system_load_current_ma; -static int vbus_low_current_ma = 500; -static int overcurrent_current_ma = 3000; - -static int charge_limit_ma; - -/* Mock functions */ - -/* Override test_mockable implementations in charge_ramp module */ -int chg_ramp_allowed(int supplier) -{ - /* Ramp for TEST4-TEST8 */ - return supplier > CHARGE_SUPPLIER_TEST3; -} - -int chg_ramp_max(int supplier, int sup_curr) -{ - if (supplier == CHARGE_SUPPLIER_TEST7) - return 1600; - else if (supplier == CHARGE_SUPPLIER_TEST8) - return 2400; - else - return 3000; -} - -/* These usb_charger functions are unused, but necessary to link */ -int usb_charger_ramp_allowed(int supplier) -{ - return 0; -} - -int usb_charger_ramp_max(int supplier, int sup_curr) -{ - return 0; -} - -int charge_is_consuming_full_input_current(void) -{ - return charge_limit_ma <= system_load_current_ma; -} - -int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state) -{ - return MIN(system_load_current_ma, charge_limit_ma) > - vbus_low_current_ma; -} - -void board_set_charge_limit(int port, int supplier, int limit_ma, - int max_ma, int max_mv) -{ - charge_limit_ma = limit_ma; - if (charge_limit_ma > overcurrent_current_ma) - task_set_event(TASK_ID_TEST_RUNNER, TASK_EVENT_OVERCURRENT, 0); -} - -/* Test utilities */ - -static void plug_charger_with_ts(int supplier_type, int port, int min_current, - int vbus_low_current, int overcurrent_current, - timestamp_t reg_time) -{ - vbus_low_current_ma = vbus_low_current; - overcurrent_current_ma = overcurrent_current; - chg_ramp_charge_supplier_change(port, supplier_type, min_current, - reg_time, 0); -} - -static void plug_charger(int supplier_type, int port, int min_current, - int vbus_low_current, int overcurrent_current) -{ - plug_charger_with_ts(supplier_type, port, min_current, - vbus_low_current, overcurrent_current, - get_time()); -} - -static void unplug_charger(void) -{ - chg_ramp_charge_supplier_change(CHARGE_PORT_NONE, CHARGE_SUPPLIER_NONE, - 0, get_time(), 0); -} - -static int unplug_charger_and_check(void) -{ - unplug_charger(); - usleep(CHARGE_DETECT_DELAY_TEST); - return charge_limit_ma == 0; -} - -static int wait_stable_no_overcurrent(void) -{ - return task_wait_event(RAMP_STABLE_DELAY) != TASK_EVENT_OVERCURRENT; -} - -static int is_in_range(int x, int min, int max) -{ - return x >= min && x <= max; -} - -/* Tests */ - -static int test_no_ramp(void) -{ - system_load_current_ma = 3000; - /* A powerful charger, but hey, you're not allowed to ramp! */ - plug_charger(CHARGE_SUPPLIER_TEST1, 0, 500, 3000, 3000); - /* - * NOTE: Since this is currently the first test being run, give the - * charge ramp task enough time to actually transition states and set - * the charge limit. This just needs at least transition to the - * CHG_RAMP_OVERCURRENT_DETECT state. - */ - usleep(CHARGE_DETECT_DELAY_TEST + 200*MSEC); - /* That's right. Start at 500 mA */ - TEST_ASSERT(charge_limit_ma == 500); - TEST_ASSERT(wait_stable_no_overcurrent()); - /* ... and stays at 500 mA */ - TEST_ASSERT(charge_limit_ma == 500); - - TEST_ASSERT(unplug_charger_and_check()); - return EC_SUCCESS; -} - -static int test_full_ramp(void) -{ - system_load_current_ma = 3000; - /* Now you get to ramp with this 3A charger */ - plug_charger(CHARGE_SUPPLIER_TEST4, 0, 500, 3000, 3000); - usleep(CHARGE_DETECT_DELAY_TEST); - /* Start with something around 500 mA */ - TEST_ASSERT(is_in_range(charge_limit_ma, 500, 800)); - TEST_ASSERT(wait_stable_no_overcurrent()); - /* And ramp up to 3A */ - TEST_ASSERT(charge_limit_ma == 3000); - - TEST_ASSERT(unplug_charger_and_check()); - return EC_SUCCESS; -} - -static int test_vbus_dip(void) -{ - system_load_current_ma = 3000; - /* VBUS dips too low right before the charger shuts down */ - plug_charger(CHARGE_SUPPLIER_TEST5, 0, 1000, 1500, 1600); - - TEST_ASSERT(wait_stable_no_overcurrent()); - TEST_ASSERT(is_in_range(charge_limit_ma, 1300, 1500)); - - TEST_ASSERT(unplug_charger_and_check()); - return EC_SUCCESS; -} - -static int test_overcurrent(void) -{ - system_load_current_ma = 3000; - /* Huh...VBUS doesn't dip before the charger shuts down */ - plug_charger(CHARGE_SUPPLIER_TEST6, 0, 500, 3000, 1500); - usleep(CHARGE_DETECT_DELAY_TEST); - /* Ramp starts at 500 mA */ - TEST_ASSERT(is_in_range(charge_limit_ma, 500, 700)); - - while (task_wait_event(RAMP_STABLE_DELAY) == TASK_EVENT_OVERCURRENT) { - /* Charger goes away but comes back after 0.6 seconds */ - unplug_charger(); - usleep(MSEC * 600); - plug_charger(CHARGE_SUPPLIER_TEST6, 0, 500, 3000, 1500); - usleep(CHARGE_DETECT_DELAY_TEST); - /* Ramp restarts at 500 mA */ - TEST_ASSERT(is_in_range(charge_limit_ma, 500, 700)); - } - - TEST_ASSERT(is_in_range(charge_limit_ma, 1300, 1500)); - - TEST_ASSERT(unplug_charger_and_check()); - return EC_SUCCESS; -} - -static int test_switch_outlet(void) -{ - int i; - - system_load_current_ma = 3000; - /* Here's a nice powerful charger */ - plug_charger(CHARGE_SUPPLIER_TEST6, 0, 500, 3000, 3000); - - /* - * Now the user decides to move it to a nearby outlet...actually - * they decide to move it 5 times! - */ - for (i = 0; i < 5; ++i) { - usleep(SECOND * 20); - unplug_charger(); - usleep(SECOND * 1.5); - plug_charger(CHARGE_SUPPLIER_TEST6, 0, 500, 3000, 3000); - usleep(CHARGE_DETECT_DELAY_TEST); - /* Ramp restarts at 500 mA */ - TEST_ASSERT(is_in_range(charge_limit_ma, 500, 700)); - } - - /* Should still ramp up to 3000 mA */ - TEST_ASSERT(wait_stable_no_overcurrent()); - TEST_ASSERT(charge_limit_ma == 3000); - - TEST_ASSERT(unplug_charger_and_check()); - return EC_SUCCESS; -} - -static int test_fast_switch(void) -{ - int i; - - system_load_current_ma = 3000; - plug_charger(CHARGE_SUPPLIER_TEST4, 0, 500, 3000, 3000); - - /* - * Here comes that naughty user again, and this time they are switching - * outlet really quickly. Fortunately this time they only do it twice. - */ - for (i = 0; i < 2; ++i) { - usleep(SECOND * 20); - unplug_charger(); - usleep(600 * MSEC); - plug_charger(CHARGE_SUPPLIER_TEST4, 0, 500, 3000, 3000); - usleep(CHARGE_DETECT_DELAY_TEST); - /* Ramp restarts at 500 mA */ - TEST_ASSERT(is_in_range(charge_limit_ma, 500, 700)); - } - - /* Should still ramp up to 3000 mA */ - TEST_ASSERT(wait_stable_no_overcurrent()); - TEST_ASSERT(charge_limit_ma == 3000); - - TEST_ASSERT(unplug_charger_and_check()); - return EC_SUCCESS; -} - -static int test_overcurrent_after_switch_outlet(void) -{ - system_load_current_ma = 3000; - /* Here's a less powerful charger */ - plug_charger(CHARGE_SUPPLIER_TEST5, 0, 500, 3000, 1500); - usleep(SECOND * 5); - - /* Now the user decides to move it to a nearby outlet */ - unplug_charger(); - usleep(SECOND * 1.5); - plug_charger(CHARGE_SUPPLIER_TEST5, 0, 500, 3000, 1500); - - /* Okay the user is satisified */ - while (task_wait_event(RAMP_STABLE_DELAY) == TASK_EVENT_OVERCURRENT) { - /* Charger goes away but comes back after 0.6 seconds */ - unplug_charger(); - usleep(MSEC * 600); - plug_charger(CHARGE_SUPPLIER_TEST5, 0, 500, 3000, 1500); - usleep(CHARGE_DETECT_DELAY_TEST); - /* Ramp restarts at 500 mA */ - TEST_ASSERT(is_in_range(charge_limit_ma, 500, 700)); - } - - TEST_ASSERT(is_in_range(charge_limit_ma, 1300, 1500)); - - TEST_ASSERT(unplug_charger_and_check()); - return EC_SUCCESS; -} - -static int test_partial_load(void) -{ - /* We have a 3A charger, but we just want 1.5A */ - system_load_current_ma = 1500; - plug_charger(CHARGE_SUPPLIER_TEST4, 0, 500, 3000, 2500); - - /* We should end up with a little bit more than 1.5A */ - TEST_ASSERT(wait_stable_no_overcurrent()); - TEST_ASSERT(is_in_range(charge_limit_ma, 1500, 1600)); - - /* Ok someone just started watching YouTube */ - system_load_current_ma = 2000; - TEST_ASSERT(wait_stable_no_overcurrent()); - TEST_ASSERT(is_in_range(charge_limit_ma, 2000, 2100)); - - /* Somehow the system load increases again */ - system_load_current_ma = 2600; - while (task_wait_event(RAMP_STABLE_DELAY) == TASK_EVENT_OVERCURRENT) { - /* Charger goes away but comes back after 0.6 seconds */ - unplug_charger(); - usleep(MSEC * 600); - plug_charger(CHARGE_SUPPLIER_TEST4, 0, 500, 3000, 2500); - usleep(CHARGE_DETECT_DELAY_TEST); - /* Ramp restarts at 500 mA */ - TEST_ASSERT(is_in_range(charge_limit_ma, 500, 700)); - } - - /* Alright the charger isn't powerful enough, so we'll stop at 2.5A */ - TEST_ASSERT(is_in_range(charge_limit_ma, 2300, 2500)); - - TEST_ASSERT(unplug_charger_and_check()); - return EC_SUCCESS; -} - -static int test_charge_supplier_stable(void) -{ - system_load_current_ma = 3000; - /* The charger says it's of type TEST4 initially */ - plug_charger(CHARGE_SUPPLIER_TEST4, 0, 500, 1500, 1600); - /* - * And then it decides it's actually TEST2 after 0.5 seconds, - * why? Well, this charger is just evil. - */ - usleep(500 * MSEC); - plug_charger(CHARGE_SUPPLIER_TEST2, 0, 3000, 3000, 3000); - /* We should get 3A right away. */ - usleep(SECOND); - TEST_ASSERT(charge_limit_ma == 3000); - - TEST_ASSERT(unplug_charger_and_check()); - return EC_SUCCESS; -} - -static int test_charge_supplier_stable_ramp(void) -{ - system_load_current_ma = 3000; - /* This time we start with a non-ramp charge supplier */ - plug_charger(CHARGE_SUPPLIER_TEST3, 0, 500, 3000, 3000); - /* - * After 0.5 seconds, it's decided that the supplier is actually - * a 1.5A ramp supplier. - */ - usleep(500 * MSEC); - plug_charger(CHARGE_SUPPLIER_TEST5, 0, 500, 1400, 1500); - TEST_ASSERT(wait_stable_no_overcurrent()); - TEST_ASSERT(is_in_range(charge_limit_ma, 1200, 1400)); - - TEST_ASSERT(unplug_charger_and_check()); - return EC_SUCCESS; -} - -static int test_charge_supplier_change(void) -{ - system_load_current_ma = 3000; - /* Start with a 3A ramp charge supplier */ - plug_charger(CHARGE_SUPPLIER_TEST4, 0, 500, 3000, 3000); - TEST_ASSERT(wait_stable_no_overcurrent()); - TEST_ASSERT(charge_limit_ma == 3000); - - /* The charger decides to change type to a 1.5A non-ramp supplier */ - plug_charger(CHARGE_SUPPLIER_TEST1, 0, 1500, 3000, 3000); - usleep(500 * MSEC); - TEST_ASSERT(charge_limit_ma == 1500); - TEST_ASSERT(wait_stable_no_overcurrent()); - TEST_ASSERT(charge_limit_ma == 1500); - - TEST_ASSERT(unplug_charger_and_check()); - return EC_SUCCESS; -} - -static int test_charge_port_change(void) -{ - system_load_current_ma = 3000; - /* Start with a 1.5A ramp charge supplier on port 0 */ - plug_charger(CHARGE_SUPPLIER_TEST5, 0, 500, 1400, 1500); - TEST_ASSERT(wait_stable_no_overcurrent()); - TEST_ASSERT(is_in_range(charge_limit_ma, 1200, 1400)); - - /* Here comes a 2.1A ramp charge supplier on port 1 */ - plug_charger(CHARGE_SUPPLIER_TEST6, 0, 500, 2000, 2100); - TEST_ASSERT(wait_stable_no_overcurrent()); - TEST_ASSERT(is_in_range(charge_limit_ma, 1800, 2000)); - - /* Now we have a 2.5A non-ramp charge supplier on port 0 */ - plug_charger(CHARGE_SUPPLIER_TEST1, 0, 2500, 3000, 3000); - usleep(SECOND); - TEST_ASSERT(charge_limit_ma == 2500); - TEST_ASSERT(wait_stable_no_overcurrent()); - TEST_ASSERT(charge_limit_ma == 2500); - - /* Unplug on port 0 */ - plug_charger(CHARGE_SUPPLIER_TEST6, 0, 500, 2000, 2100); - TEST_ASSERT(wait_stable_no_overcurrent()); - TEST_ASSERT(is_in_range(charge_limit_ma, 1800, 2000)); - - TEST_ASSERT(unplug_charger_and_check()); - return EC_SUCCESS; -} - -static int test_vbus_shift(void) -{ - system_load_current_ma = 3000; - /* - * At first, the charger is able to supply up to 1900 mA before - * the VBUS voltage starts to drop. - */ - plug_charger(CHARGE_SUPPLIER_TEST6, 0, 500, 1900, 2000); - TEST_ASSERT(wait_stable_no_overcurrent()); - TEST_ASSERT(is_in_range(charge_limit_ma, 1700, 1900)); - - /* The charger heats up and VBUS voltage drops by 100mV */ - vbus_low_current_ma = 1800; - TEST_ASSERT(wait_stable_no_overcurrent()); - TEST_ASSERT(is_in_range(charge_limit_ma, 1600, 1800)); - - TEST_ASSERT(unplug_charger_and_check()); - return EC_SUCCESS; -} - -static int test_equal_priority_overcurrent(void) -{ - int overcurrent_count = 0; - timestamp_t oc_time = get_time(); - - system_load_current_ma = 3000; - - /* - * Now we have two charge suppliers of equal priorties plugged into - * port 0 and port 1. If the active one browns out, charge manager - * switches to the other one. - */ - while (1) { - plug_charger_with_ts(CHARGE_SUPPLIER_TEST4, 0, 500, 3000, - 2000, oc_time); - oc_time = get_time(); - oc_time.val += 600 * MSEC; - if (wait_stable_no_overcurrent()) - break; - plug_charger_with_ts(CHARGE_SUPPLIER_TEST4, 1, 500, 3000, - 2000, oc_time); - oc_time = get_time(); - oc_time.val += 600 * MSEC; - if (wait_stable_no_overcurrent()) - break; - if (overcurrent_count++ >= 10) { - /* - * Apparently we are in a loop and can never reach - * stable state. - */ - unplug_charger(); - return EC_ERROR_UNKNOWN; - } - } - - TEST_ASSERT(unplug_charger_and_check()); - return EC_SUCCESS; -} - -static int test_ramp_limit(void) -{ - system_load_current_ma = 3000; - - /* Plug in supplier that is limited to 1.6A */ - plug_charger(CHARGE_SUPPLIER_TEST7, 0, 500, 3000, 3000); - usleep(SECOND); - TEST_ASSERT(is_in_range(charge_limit_ma, 500, 700)); - TEST_ASSERT(wait_stable_no_overcurrent()); - TEST_ASSERT(charge_limit_ma == 1600); - - /* Switch to supplier that is limited to 2.4A */ - plug_charger(CHARGE_SUPPLIER_TEST8, 1, 500, 3000, 3000); - usleep(SECOND); - TEST_ASSERT(is_in_range(charge_limit_ma, 500, 700)); - TEST_ASSERT(wait_stable_no_overcurrent()); - TEST_ASSERT(charge_limit_ma == 2400); - - /* Go back to 1.6A limited, but VBUS goes low before that point */ - plug_charger(CHARGE_SUPPLIER_TEST7, 0, 500, 1200, 1300); - usleep(SECOND); - TEST_ASSERT(is_in_range(charge_limit_ma, 500, 700)); - TEST_ASSERT(wait_stable_no_overcurrent()); - TEST_ASSERT(is_in_range(charge_limit_ma, 1000, 1200)); - - TEST_ASSERT(unplug_charger_and_check()); - return EC_SUCCESS; -} - -void run_test(void) -{ - test_reset(); - - /* - * If the following test order changes, make sure to add enough time for - * the charge ramp task to make its first transition after plugging in a - * charger. See the comment in test_no_ramp(). - */ - RUN_TEST(test_no_ramp); - RUN_TEST(test_full_ramp); - RUN_TEST(test_vbus_dip); - RUN_TEST(test_overcurrent); - RUN_TEST(test_switch_outlet); - RUN_TEST(test_fast_switch); - RUN_TEST(test_overcurrent_after_switch_outlet); - RUN_TEST(test_partial_load); - RUN_TEST(test_charge_supplier_stable); - RUN_TEST(test_charge_supplier_stable_ramp); - RUN_TEST(test_charge_supplier_change); - RUN_TEST(test_charge_port_change); - RUN_TEST(test_vbus_shift); - RUN_TEST(test_equal_priority_overcurrent); - RUN_TEST(test_ramp_limit); - - test_print_result(); -} diff --git a/test/charge_ramp.tasklist b/test/charge_ramp.tasklist deleted file mode 100644 index 1e18846c75..0000000000 --- a/test/charge_ramp.tasklist +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2015 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST \ - TASK_TEST(CHG_RAMP, chg_ramp_task, NULL, SMALLER_TASK_STACK_SIZE) diff --git a/test/extpwr_gpio.c b/test/extpwr_gpio.c deleted file mode 100644 index d118c54a54..0000000000 --- a/test/extpwr_gpio.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test GPIO extpower module. - */ - -#include "common.h" -#include "console.h" -#include "extpower.h" -#include "gpio.h" -#include "hooks.h" -#include "host_command.h" -#include "test_util.h" -#include "timer.h" -#include "util.h" - -static int ac_hook_count; - -static void set_ac(int val) -{ - gpio_set_level(GPIO_AC_PRESENT, val); - msleep(50); -} - -static void ac_change_hook(void) -{ - ac_hook_count++; -} -DECLARE_HOOK(HOOK_AC_CHANGE, ac_change_hook, HOOK_PRIO_DEFAULT); - -static int test_hook(void) -{ - /* Remove AC for testing */ - set_ac(0); - ac_hook_count = 0; - host_clear_events(0xffffffff); - - set_ac(1); - TEST_ASSERT(ac_hook_count == 1); - TEST_ASSERT(extpower_is_present()); - TEST_ASSERT(host_get_events() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_AC_CONNECTED)); - - set_ac(0); - TEST_ASSERT(ac_hook_count == 2); - TEST_ASSERT(!extpower_is_present()); - TEST_ASSERT(host_get_events() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_AC_DISCONNECTED)); - - return EC_SUCCESS; -} - -void run_test(void) -{ - test_reset(); - - RUN_TEST(test_hook); - - test_print_result(); -} diff --git a/test/extpwr_gpio.tasklist b/test/extpwr_gpio.tasklist deleted file mode 100644 index da0ab6211a..0000000000 --- a/test/extpwr_gpio.tasklist +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST /* No test task */ diff --git a/test/fake_battery.c b/test/fake_battery.c deleted file mode 100644 index 4442300572..0000000000 --- a/test/fake_battery.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Fake BATTERY module. - */ -#include "battery.h" -#include "common.h" - -int battery_design_voltage(int *voltage) -{ - *voltage = 0; - return 0; -} - -enum battery_present battery_is_present(void) -{ - return BP_NO; -} - -int battery_design_capacity(int *capacity) -{ - *capacity = 0; - return 0; -} - -int battery_full_charge_capacity(int *capacity) -{ - *capacity = 0; - return 0; -} - -int battery_remaining_capacity(int *capacity) -{ - *capacity = 0; - return 0; -} - -int battery_status(int *status) -{ - return EC_ERROR_UNIMPLEMENTED; -} diff --git a/test/fake_prl.c b/test/fake_prl.c deleted file mode 100644 index 77e3331729..0000000000 --- a/test/fake_prl.c +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Fake Protocol Layer module. - */ -#include "common.h" -#include "usb_emsg.h" -#include "usb_prl_sm.h" - -struct extended_msg emsg[CONFIG_USB_PD_PORT_MAX_COUNT]; - -void prl_end_ams(int port) -{} - -void prl_execute_hard_reset(int port) -{} - -enum pd_rev_type prl_get_rev(int port, enum tcpm_transmit_type partner) -{ - return PD_REV30; -} - -void prl_hard_reset_complete(int port) -{} - -int prl_is_running(int port) -{ - return 0; -} - -void prl_reset(int port) -{} - -static enum pd_ctrl_msg_type last_ctrl_msg[CONFIG_USB_PD_PORT_MAX_COUNT]; -void prl_send_ctrl_msg(int port, enum tcpm_transmit_type type, - enum pd_ctrl_msg_type msg) -{ - last_ctrl_msg[port] = msg; -} - -void prl_send_data_msg(int port, enum tcpm_transmit_type type, - enum pd_data_msg_type msg) -{} - -void prl_send_ext_data_msg(int port, enum tcpm_transmit_type type, - enum pd_ext_msg_type msg) -{} - -void prl_set_rev(int port, enum tcpm_transmit_type partner, - enum pd_rev_type rev) -{} - -void prl_start_ams(int port) -{} - - -enum pd_ctrl_msg_type fake_prl_get_last_sent_ctrl_msg(int port) -{ - return last_ctrl_msg[port]; -} diff --git a/test/fake_usbc.c b/test/fake_usbc.c deleted file mode 100644 index b0137cb893..0000000000 --- a/test/fake_usbc.c +++ /dev/null @@ -1,122 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test USB Type-C module. - */ -#include "common.h" -#include "usb_tc_sm.h" -#include "usb_pd.h" - -int pd_is_vbus_present(int port) -{ - return 0; -} - -void pd_request_data_swap(int port) -{} - -void pd_request_power_swap(int port) -{} - -void pd_request_vconn_swap_off(int port) -{} - -void pd_request_vconn_swap_on(int port) -{} - - -static enum pd_data_role data_role; -enum pd_data_role tc_get_data_role(int port) -{ - return data_role; -} -void tc_set_data_role(int port, enum pd_data_role role) -{ - data_role = role; -} - -static enum pd_power_role power_role; -enum pd_power_role tc_get_power_role(int port) -{ - return power_role; -} -void tc_set_power_role(int port, enum pd_power_role role) -{ - power_role = role; -} - -enum pd_cable_plug tc_get_cable_plug(int port) -{ - return PD_PLUG_FROM_DFP_UFP; -} - -int tc_check_vconn_swap(int port) -{ - return 0; -} - -void tc_ctvpd_detected(int port) -{} - -void tc_disc_ident_complete(int port) -{} - -static int attached_snk; -int tc_is_attached_snk(int port) -{ - return attached_snk; -} - -static int attached_src; -int tc_is_attached_src(int port) -{ - return attached_src; -} - -int tc_is_vconn_src(int port) -{ - return 0; -} - -void tc_hard_reset(int port) -{} - -void tc_partner_dr_data(int port, int en) -{} - -void tc_partner_dr_power(int port, int en) -{} - -void tc_partner_extpower(int port, int en) -{} - -void tc_partner_usb_comm(int port, int en) -{} - -void tc_pd_connection(int port, int en) -{} - -void tc_pr_swap_complete(int port) -{} - -void tc_prs_snk_src_assert_rp(int port) -{ - attached_snk = 0; - attached_src = 1; -} - -void tc_prs_src_snk_assert_rd(int port) -{ - attached_snk = 1; - attached_src = 0; -} - -void tc_set_timeout(int port, uint64_t timeout) -{} - -void tc_start_error_recovery(int port) -{} - -void tc_snk_power_off(int port) -{} diff --git a/test/fan.c b/test/fan.c deleted file mode 100644 index e565dd9a60..0000000000 --- a/test/fan.c +++ /dev/null @@ -1,114 +0,0 @@ -/* Copyright 2014 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test thermal engine. - */ - -#include "common.h" -#include "console.h" -#include "fan.h" -#include "hooks.h" -#include "host_command.h" -#include "printf.h" -#include "temp_sensor.h" -#include "test_util.h" -#include "thermal.h" -#include "timer.h" -#include "util.h" - -#define FAN_RPM(fan) fans[fan].rpm - -/*****************************************************************************/ -/* Tests */ - -void set_thermal_control_enabled(int fan, int enable); - -static int test_fan(void) -{ - /* "actual" fan speed from board/host/fan.c */ - extern int mock_rpm; - - sleep(2); - - /* With nothing else to do, fans default to CONFIG_FAN_INIT_SPEED*/ - TEST_ASSERT(fan_get_rpm_actual(0) == - fan_percent_to_rpm(0, CONFIG_FAN_INIT_SPEED)); - - set_thermal_control_enabled(0, 1); - - /* - * fan_set_percent_needed() is normally called once a second by the - * thermal task, but we're not using a thermal test in this test so - * we can dink around with the fans without having to wait. The host - * implementation just sets mock_rpm to whatever it's asked for. - */ - - /* Off */ - fan_set_percent_needed(0, 0); - TEST_ASSERT(fan_get_rpm_actual(0) == 0); - fan_set_percent_needed(0, 0); - TEST_ASSERT(fan_get_rpm_actual(0) == 0); - - /* On, but just barely */ - fan_set_percent_needed(0, 1); - TEST_ASSERT(fan_get_rpm_actual(0) == FAN_RPM(0)->rpm_start); - /* fan is above min speed now, so should be set to min */ - fan_set_percent_needed(0, 1); - TEST_ASSERT(fan_get_rpm_actual(0) == FAN_RPM(0)->rpm_min); - - /* Full speed */ - fan_set_percent_needed(0, 100); - TEST_ASSERT(fan_get_rpm_actual(0) == FAN_RPM(0)->rpm_max); - fan_set_percent_needed(0, 100); - TEST_ASSERT(fan_get_rpm_actual(0) == FAN_RPM(0)->rpm_max); - - /* Slow again */ - fan_set_percent_needed(0, 1); - TEST_ASSERT(fan_get_rpm_actual(0) == FAN_RPM(0)->rpm_min); - fan_set_percent_needed(0, 1); - TEST_ASSERT(fan_get_rpm_actual(0) == FAN_RPM(0)->rpm_min); - - /* Off */ - fan_set_percent_needed(0, 0); - TEST_ASSERT(fan_get_rpm_actual(0) == 0); - fan_set_percent_needed(0, 0); - TEST_ASSERT(fan_get_rpm_actual(0) == 0); - - /* On, but just barely */ - fan_set_percent_needed(0, 1); - TEST_ASSERT(fan_get_rpm_actual(0) == FAN_RPM(0)->rpm_start); - /* Force the mock_rpm to be slow, to simulate dragging */ - mock_rpm = FAN_RPM(0)->rpm_min - 105; - /* It should keep trying for the start speed */ - fan_set_percent_needed(0, 1); - TEST_ASSERT(fan_get_rpm_actual(0) == FAN_RPM(0)->rpm_start); - /* But we have to keep forcing the mock_rpm back down */ - mock_rpm = FAN_RPM(0)->rpm_min - 105; - fan_set_percent_needed(0, 1); - TEST_ASSERT(fan_get_rpm_actual(0) == FAN_RPM(0)->rpm_start); - /* Now let it turn just under rpm_min. Should be okay there. */ - mock_rpm = FAN_RPM(0)->rpm_min - 10; - fan_set_percent_needed(0, 1); - TEST_ASSERT(fan_get_rpm_actual(0) == FAN_RPM(0)->rpm_min); - /* Let it go a little faster, still okay */ - mock_rpm = FAN_RPM(0)->rpm_min + 10; - fan_set_percent_needed(0, 1); - TEST_ASSERT(fan_get_rpm_actual(0) == FAN_RPM(0)->rpm_min); - /* But if it drops too low, it should go back to the start speed */ - mock_rpm = FAN_RPM(0)->rpm_min - 105; - fan_set_percent_needed(0, 1); - TEST_ASSERT(fan_get_rpm_actual(0) == FAN_RPM(0)->rpm_start); - /* And then relax */ - fan_set_percent_needed(0, 1); - TEST_ASSERT(fan_get_rpm_actual(0) == FAN_RPM(0)->rpm_min); - - return EC_SUCCESS; -} - -void run_test(void) -{ - RUN_TEST(test_fan); - - test_print_result(); -} diff --git a/test/fan.tasklist b/test/fan.tasklist deleted file mode 100644 index 25dcf124db..0000000000 --- a/test/fan.tasklist +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2014 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST /* No test task */ diff --git a/test/fpsensor.c b/test/fpsensor.c deleted file mode 100644 index 490c903ba3..0000000000 --- a/test/fpsensor.c +++ /dev/null @@ -1,817 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "common.h" -#include "ec_commands.h" -#include "fpsensor_crypto.h" -#include "fpsensor_state.h" -#include "host_command.h" -#include "mock/timer_mock.h" -#include "test_util.h" -#include "util.h" - -static const uint8_t fake_rollback_secret[] = { - 0xcf, 0xe3, 0x23, 0x76, 0x35, 0x04, 0xc2, 0x0f, - 0x0d, 0xb6, 0x02, 0xa9, 0x68, 0xba, 0x2a, 0x61, - 0x86, 0x2a, 0x85, 0xd1, 0xca, 0x09, 0x54, 0x8a, - 0x6b, 0xe2, 0xe3, 0x38, 0xde, 0x5d, 0x59, 0x14, -}; - -static const uint8_t fake_tpm_seed[] = { - 0xd9, 0x71, 0xaf, 0xc4, 0xcd, 0x36, 0xe3, 0x60, - 0xf8, 0x5a, 0xa0, 0xa6, 0x2c, 0xb3, 0xf5, 0xe2, - 0xeb, 0xb9, 0xd8, 0x2f, 0xb5, 0x78, 0x5c, 0x79, - 0x82, 0xce, 0x06, 0x3f, 0xcc, 0x23, 0xb9, 0xe7, -}; - -static const uint8_t fake_positive_match_salt[] = { - 0x04, 0x1f, 0x5a, 0xac, 0x5f, 0x79, 0x10, 0xaf, - 0x04, 0x1d, 0x46, 0x3a, 0x5f, 0x08, 0xee, 0xcb, -}; - -static const uint8_t fake_user_id[] = { - 0x28, 0xb5, 0x5a, 0x55, 0x57, 0x1b, 0x26, 0x88, - 0xce, 0xc5, 0xd1, 0xfe, 0x1d, 0x58, 0x5b, 0x94, - 0x51, 0xa2, 0x60, 0x49, 0x9f, 0xea, 0xb1, 0xea, - 0xf7, 0x04, 0x2f, 0x0b, 0x20, 0xa5, 0x93, 0x64, -}; - -/* - * |expected_positive_match_secret_for_empty_user_id| is obtained by running - * BoringSSL locally. - * From https://boringssl.googlesource.com/boringssl - * commit 365b7a0fcbf273b1fa704d151059e419abd6cfb8 - * - * Steps to reproduce: - * - * Open boringssl/crypto/hkdf/hkdf_test.cc - * Add the following case to static const HKDFTestVector kTests[] - * - * // test positive match secret - * { - * EVP_sha256, - * { - * // IKM: - * // fake_rollback_secret - * [ ***Copy 32 octets of fake_rollback_secret here*** ] - * // fake_tpm_seed - * [ ***Copy 32 octets of fake_tpm_seed here*** ] - * }, 64, - * { - * // fake_positive_match_salt - * [ ***Copy 16 octets of fake_positive_match_salt here*** ] - * }, 16, - * { - * // Info: - * // "positive_match_secret for user " - * 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x76, 0x65, - * 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x73, - * 0x65, 0x63, 0x72, 0x65, 0x74, 0x20, 0x66, 0x6f, - * 0x72, 0x20, 0x75, 0x73, 0x65, 0x72, 0x20, - * // user_id - * [ ***Type 32 octets of 0x00 here*** ] - * }, 63, - * { // Expected PRK: - * 0xc2, 0xff, 0x50, 0x2d, 0xb1, 0x7e, 0x87, 0xb1, - * 0x25, 0x36, 0x3a, 0x88, 0xe1, 0xdb, 0x4f, 0x98, - * 0x22, 0xb5, 0x66, 0x8c, 0xab, 0xb7, 0xc7, 0x5e, - * 0xd7, 0x56, 0xbe, 0xde, 0x82, 0x3f, 0xd0, 0x62, - * }, 32, - * 32, { // 32 = L = FP_POSITIVE_MATCH_SECRET_BYTES - * // Expected positive match secret: - * [ ***Copy 32 octets of expected positive_match_secret here*** ] - * } - * }, - * - * Then from boringssl/ execute: - * mkdir build - * cd build - * cmake .. - * make - * cd .. - * go run util/all_tests.go - */ -static const uint8_t expected_positive_match_secret_for_empty_user_id[] = { - 0x8d, 0xc4, 0x5b, 0xdf, 0x55, 0x1e, 0xa8, 0x72, - 0xd6, 0xdd, 0xa1, 0x4c, 0xb8, 0xa1, 0x76, 0x2b, - 0xde, 0x38, 0xd5, 0x03, 0xce, 0xe4, 0x74, 0x51, - 0x63, 0x6c, 0x6a, 0x26, 0xa9, 0xb7, 0xfa, 0x68, -}; - -/* - * Same as |expected_positive_match_secret_for_empty_user_id| but use - * |fake_user_id| instead of all-zero user_id. - */ -static const uint8_t expected_positive_match_secret_for_fake_user_id[] = { - 0x0d, 0xf5, 0xac, 0x7c, 0xad, 0x37, 0x0a, 0x66, - 0x2f, 0x71, 0xf6, 0xc6, 0xca, 0x8a, 0x41, 0x69, - 0x8a, 0xd3, 0xcf, 0x0b, 0xc4, 0x5a, 0x5f, 0x4d, - 0x54, 0xeb, 0x7b, 0xad, 0x5d, 0x1b, 0xbe, 0x30, -}; - -static int rollback_should_fail; - -/* Mock the rollback for unit test. */ -int rollback_get_secret(uint8_t *secret) -{ - if (rollback_should_fail) - return EC_ERROR_UNKNOWN; - memcpy(secret, fake_rollback_secret, sizeof(fake_rollback_secret)); - return EC_SUCCESS; -} - -static int check_seed_set_result(const int rv, const uint32_t expected, - const struct ec_response_fp_encryption_status *resp) -{ - const uint32_t actual = resp->status & FP_ENC_STATUS_SEED_SET; - - if (rv != EC_RES_SUCCESS || expected != actual) { - ccprintf("%s:%s(): rv = %d, seed is set: %d\n", __FILE__, - __func__, rv, actual); - return -1; - } - - return EC_SUCCESS; -} - -test_static int test_fp_enc_status_valid_flags(void) -{ - /* Putting expected value here because test_static should take void */ - const uint32_t expected = FP_ENC_STATUS_SEED_SET; - int rv; - struct ec_response_fp_encryption_status resp = { 0 }; - - rv = test_send_host_command(EC_CMD_FP_ENC_STATUS, 0, - NULL, 0, - &resp, sizeof(resp)); - if (rv != EC_RES_SUCCESS) { - ccprintf("%s:%s(): failed to get encryption status. rv = %d\n", - __FILE__, __func__, rv); - return -1; - } - - if (resp.valid_flags != expected) { - ccprintf("%s:%s(): expected valid flags 0x%08x, got 0x%08x\n", - __FILE__, __func__, expected, resp.valid_flags); - return -1; - } - - return EC_RES_SUCCESS; -} - -static int test_hkdf_expand_raw(const uint8_t *prk, size_t prk_size, - const uint8_t *info, size_t info_size, - const uint8_t *expected_okm, size_t okm_size) -{ - uint8_t actual_okm[okm_size]; - - TEST_ASSERT(hkdf_expand(actual_okm, okm_size, prk, prk_size, - info, info_size) == EC_SUCCESS); - TEST_ASSERT_ARRAY_EQ(expected_okm, actual_okm, okm_size); - return EC_SUCCESS; -} - -test_static int test_hkdf_expand(void) -{ - /* Test vectors in https://tools.ietf.org/html/rfc5869#appendix-A */ - static const uint8_t prk1[] = { - 0x07, 0x77, 0x09, 0x36, 0x2c, 0x2e, 0x32, 0xdf, - 0x0d, 0xdc, 0x3f, 0x0d, 0xc4, 0x7b, 0xba, 0x63, - 0x90, 0xb6, 0xc7, 0x3b, 0xb5, 0x0f, 0x9c, 0x31, - 0x22, 0xec, 0x84, 0x4a, 0xd7, 0xc2, 0xb3, 0xe5, - }; - static const uint8_t info1[] = { - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, - }; - static const uint8_t expected_okm1[] = { - 0x3c, 0xb2, 0x5f, 0x25, 0xfa, 0xac, 0xd5, 0x7a, - 0x90, 0x43, 0x4f, 0x64, 0xd0, 0x36, 0x2f, 0x2a, - 0x2d, 0x2d, 0x0a, 0x90, 0xcf, 0x1a, 0x5a, 0x4c, - 0x5d, 0xb0, 0x2d, 0x56, 0xec, 0xc4, 0xc5, 0xbf, - 0x34, 0x00, 0x72, 0x08, 0xd5, 0xb8, 0x87, 0x18, - 0x58, 0x65, - }; - static const uint8_t prk2[] = { - 0x06, 0xa6, 0xb8, 0x8c, 0x58, 0x53, 0x36, 0x1a, - 0x06, 0x10, 0x4c, 0x9c, 0xeb, 0x35, 0xb4, 0x5c, - 0xef, 0x76, 0x00, 0x14, 0x90, 0x46, 0x71, 0x01, - 0x4a, 0x19, 0x3f, 0x40, 0xc1, 0x5f, 0xc2, 0x44, - }; - static const uint8_t info2[] = { - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, - 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, - }; - static const uint8_t expected_okm2[] = { - 0xb1, 0x1e, 0x39, 0x8d, 0xc8, 0x03, 0x27, 0xa1, - 0xc8, 0xe7, 0xf7, 0x8c, 0x59, 0x6a, 0x49, 0x34, - 0x4f, 0x01, 0x2e, 0xda, 0x2d, 0x4e, 0xfa, 0xd8, - 0xa0, 0x50, 0xcc, 0x4c, 0x19, 0xaf, 0xa9, 0x7c, - 0x59, 0x04, 0x5a, 0x99, 0xca, 0xc7, 0x82, 0x72, - 0x71, 0xcb, 0x41, 0xc6, 0x5e, 0x59, 0x0e, 0x09, - 0xda, 0x32, 0x75, 0x60, 0x0c, 0x2f, 0x09, 0xb8, - 0x36, 0x77, 0x93, 0xa9, 0xac, 0xa3, 0xdb, 0x71, - 0xcc, 0x30, 0xc5, 0x81, 0x79, 0xec, 0x3e, 0x87, - 0xc1, 0x4c, 0x01, 0xd5, 0xc1, 0xf3, 0x43, 0x4f, - 0x1d, 0x87, - }; - static const uint8_t prk3[] = { - 0x19, 0xef, 0x24, 0xa3, 0x2c, 0x71, 0x7b, 0x16, - 0x7f, 0x33, 0xa9, 0x1d, 0x6f, 0x64, 0x8b, 0xdf, - 0x96, 0x59, 0x67, 0x76, 0xaf, 0xdb, 0x63, 0x77, - 0xac, 0x43, 0x4c, 0x1c, 0x29, 0x3c, 0xcb, 0x04, - }; - static const uint8_t expected_okm3[] = { - 0x8d, 0xa4, 0xe7, 0x75, 0xa5, 0x63, 0xc1, 0x8f, - 0x71, 0x5f, 0x80, 0x2a, 0x06, 0x3c, 0x5a, 0x31, - 0xb8, 0xa1, 0x1f, 0x5c, 0x5e, 0xe1, 0x87, 0x9e, - 0xc3, 0x45, 0x4e, 0x5f, 0x3c, 0x73, 0x8d, 0x2d, - 0x9d, 0x20, 0x13, 0x95, 0xfa, 0xa4, 0xb6, 0x1a, - 0x96, 0xc8, - }; - static uint8_t unused_output[SHA256_DIGEST_SIZE] = { 0 }; - - TEST_ASSERT(test_hkdf_expand_raw(prk1, sizeof(prk1), info1, - sizeof(info1), expected_okm1, - sizeof(expected_okm1)) - == EC_SUCCESS); - TEST_ASSERT(test_hkdf_expand_raw(prk2, sizeof(prk2), info2, - sizeof(info2), expected_okm2, - sizeof(expected_okm2)) - == EC_SUCCESS); - TEST_ASSERT(test_hkdf_expand_raw(prk3, sizeof(prk3), NULL, 0, - expected_okm3, sizeof(expected_okm3)) - == EC_SUCCESS); - - TEST_ASSERT(hkdf_expand(NULL, sizeof(unused_output), prk1, - sizeof(prk1), info1, sizeof(info1)) - == EC_ERROR_INVAL); - TEST_ASSERT(hkdf_expand(unused_output, sizeof(unused_output), - NULL, sizeof(prk1), info1, sizeof(info1)) - == EC_ERROR_INVAL); - TEST_ASSERT(hkdf_expand(unused_output, sizeof(unused_output), - prk1, sizeof(prk1), NULL, sizeof(info1)) - == EC_ERROR_INVAL); - /* Info size too long. */ - TEST_ASSERT(hkdf_expand(unused_output, sizeof(unused_output), - prk1, sizeof(prk1), info1, 1024) - == EC_ERROR_INVAL); - /* OKM size too big. */ - TEST_ASSERT(hkdf_expand(unused_output, 256 * SHA256_DIGEST_SIZE, - prk1, sizeof(prk1), info1, sizeof(info1)) - == EC_ERROR_INVAL); - return EC_SUCCESS; -} - -test_static int test_derive_encryption_key_failure_seed_not_set(void) -{ - static uint8_t unused_key[SBP_ENC_KEY_LEN]; - static const uint8_t unused_salt[FP_CONTEXT_ENCRYPTION_SALT_BYTES]; - - /* GIVEN that the TPM seed is not set. */ - if (fp_tpm_seed_is_set()) { - ccprintf("%s:%s(): this test should be executed before setting" - " TPM seed.\n", __FILE__, __func__); - return -1; - } - - /* THEN derivation will fail. */ - TEST_ASSERT(derive_encryption_key(unused_key, unused_salt) == - EC_ERROR_ACCESS_DENIED); - - return EC_SUCCESS; -} - -static int test_derive_encryption_key_raw(const uint32_t *user_id_, - const uint8_t *salt, - const uint8_t *expected_key) -{ - uint8_t key[SBP_ENC_KEY_LEN]; - int rv; - - /* - * |user_id| is a global variable used as "info" in HKDF expand - * in derive_encryption_key(). - */ - memcpy(user_id, user_id_, sizeof(user_id)); - rv = derive_encryption_key(key, salt); - - TEST_ASSERT(rv == EC_SUCCESS); - TEST_ASSERT_ARRAY_EQ(key, expected_key, sizeof(key)); - - /* Clear state to ensure test independence. */ - memset(user_id, 0, sizeof(user_id)); - - return EC_SUCCESS; -} - -test_static int test_derive_encryption_key(void) -{ - /* - * These vectors are obtained by choosing the salt and the user_id - * (used as "info" in HKDF), and running BoringSSL's HKDF - * (https://boringssl.googlesource.com/boringssl/+/c0b4c72b6d4c6f4828a373ec454bd646390017d4/crypto/hkdf/) - * locally to get the output key. The IKM used in the run is the - * concatenation of |fake_rollback_secret| and |fake_tpm_seed|. - */ - static const uint32_t user_id1[] = { - 0x608b1b0b, 0xe10d3d24, 0x0bbbe4e6, 0x807b36d9, - 0x2a1f8abc, 0xea38104a, 0x562d9431, 0x64d721c5, - }; - - static const uint8_t salt1[] = { - 0xd0, 0x88, 0x34, 0x15, 0xc0, 0xfa, 0x8e, 0x22, - 0x9f, 0xb4, 0xd5, 0xa9, 0xee, 0xd3, 0x15, 0x19, - }; - - static const uint8_t key1[] = { - 0xdb, 0x49, 0x6e, 0x1b, 0x67, 0x8a, 0x35, 0xc6, - 0xa0, 0x9d, 0xb6, 0xa0, 0x13, 0xf4, 0x21, 0xb3, - }; - - static const uint32_t user_id2[] = { - 0x2546a2ca, 0xf1891f7a, 0x44aad8b8, 0x0d6aac74, - 0x6a4ab846, 0x9c279796, 0x5a72eae1, 0x8276d2a3, - }; - - static const uint8_t salt2[] = { - 0x72, 0x6b, 0xc1, 0xe4, 0x64, 0xd4, 0xff, 0xa2, - 0x5a, 0xac, 0x5b, 0x0b, 0x06, 0x67, 0xe1, 0x53, - }; - - static const uint8_t key2[] = { - 0x8d, 0x53, 0xaf, 0x4c, 0x96, 0xa2, 0xee, 0x46, - 0x9c, 0xe2, 0xe2, 0x6f, 0xe6, 0x66, 0x3d, 0x3a, - }; - - /* - * GIVEN that the TPM seed is set, and reading the rollback secret will - * succeed. - */ - TEST_ASSERT(fp_tpm_seed_is_set() && !rollback_should_fail); - - /* THEN the derivation will succeed. */ - TEST_ASSERT(test_derive_encryption_key_raw(user_id1, salt1, key1) == - EC_SUCCESS); - - TEST_ASSERT(test_derive_encryption_key_raw(user_id2, salt2, key2) == - EC_SUCCESS); - - return EC_SUCCESS; -} - -test_static int test_derive_encryption_key_failure_rollback_fail(void) -{ - static uint8_t unused_key[SBP_ENC_KEY_LEN]; - static const uint8_t unused_salt[FP_CONTEXT_ENCRYPTION_SALT_BYTES]; - - /* GIVEN that reading the rollback secret will fail. */ - rollback_should_fail = 1; - /* THEN the derivation will fail. */ - TEST_ASSERT(derive_encryption_key(unused_key, unused_salt) == - EC_ERROR_HW_INTERNAL); - - /* GIVEN that reading the rollback secret will succeed. */ - rollback_should_fail = 0; - /* GIVEN that the TPM seed has been set. */ - TEST_ASSERT(fp_tpm_seed_is_set()); - /* THEN the derivation will succeed. */ - TEST_ASSERT(derive_encryption_key(unused_key, unused_salt) == - EC_SUCCESS); - - return EC_SUCCESS; -} - -test_static int test_derive_new_pos_match_secret(void) -{ - static uint8_t output[FP_POSITIVE_MATCH_SECRET_BYTES]; - /* GIVEN that the encryption salt is not trivial. */ - TEST_ASSERT(!bytes_are_trivial(fake_positive_match_salt, - sizeof(fake_positive_match_salt))); - /* - * GIVEN that the TPM seed is set, and reading the rollback secret will - * succeed. - */ - TEST_ASSERT(fp_tpm_seed_is_set() && !rollback_should_fail); - - /* GIVEN that the salt is not trivial. */ - TEST_ASSERT(!bytes_are_trivial(fake_positive_match_salt, - sizeof(fake_positive_match_salt))); - - /* THEN the derivation will succeed. */ - TEST_ASSERT(derive_positive_match_secret(output, - fake_positive_match_salt) - == EC_SUCCESS); - TEST_ASSERT_ARRAY_EQ( - output, - expected_positive_match_secret_for_empty_user_id, - sizeof(expected_positive_match_secret_for_empty_user_id)); - - /* Now change the user_id to be non-trivial. */ - memcpy(user_id, fake_user_id, sizeof(fake_user_id)); - TEST_ASSERT(derive_positive_match_secret(output, - fake_positive_match_salt) - == EC_SUCCESS); - TEST_ASSERT_ARRAY_EQ( - output, - expected_positive_match_secret_for_fake_user_id, - sizeof(expected_positive_match_secret_for_fake_user_id)); - memset(user_id, 0, sizeof(user_id)); - - return EC_SUCCESS; -} - -test_static int test_derive_positive_match_secret_fail_seed_not_set(void) -{ - static uint8_t output[FP_POSITIVE_MATCH_SECRET_BYTES]; - - /* GIVEN that seed is not set. */ - TEST_ASSERT(!fp_tpm_seed_is_set()); - /* THEN EVEN IF the encryption salt is not trivial. */ - TEST_ASSERT(!bytes_are_trivial(fake_positive_match_salt, - sizeof(fake_positive_match_salt))); - - /* Deriving positive match secret will fail. */ - TEST_ASSERT(derive_positive_match_secret(output, - fake_positive_match_salt) - == EC_ERROR_ACCESS_DENIED); - - return EC_SUCCESS; - -} - -test_static int test_derive_positive_match_secret_fail_rollback_fail(void) -{ - static uint8_t output[FP_POSITIVE_MATCH_SECRET_BYTES]; - - /* GIVEN that reading secret from anti-rollback block will fail. */ - rollback_should_fail = 1; - /* THEN EVEN IF the encryption salt is not trivial. */ - TEST_ASSERT(!bytes_are_trivial(fake_positive_match_salt, - sizeof(fake_positive_match_salt))); - - /* Deriving positive match secret will fail. */ - TEST_ASSERT(derive_positive_match_secret(output, - fake_positive_match_salt) - == EC_ERROR_HW_INTERNAL); - rollback_should_fail = 0; - - return EC_SUCCESS; -} - -test_static int test_derive_positive_match_secret_fail_salt_trivial(void) -{ - static uint8_t output[FP_POSITIVE_MATCH_SECRET_BYTES]; - /* GIVEN that the salt is trivial. */ - static const uint8_t salt[FP_CONTEXT_ENCRYPTION_SALT_BYTES] = { 0 }; - - /* THEN deriving positive match secret will fail. */ - TEST_ASSERT(derive_positive_match_secret(output, salt) - == EC_ERROR_INVAL); - return EC_SUCCESS; -} - -test_static int test_fp_tpm_seed_not_set(void) -{ - int rv; - struct ec_response_fp_encryption_status resp = { 0 }; - - /* Initially the seed should not have been set. */ - rv = test_send_host_command(EC_CMD_FP_ENC_STATUS, 0, - NULL, 0, - &resp, sizeof(resp)); - - return check_seed_set_result(rv, 0, &resp); -} - -test_static int test_set_fp_tpm_seed(void) -{ - int rv; - struct ec_params_fp_seed params; - struct ec_response_fp_encryption_status resp = { 0 }; - - params.struct_version = FP_TEMPLATE_FORMAT_VERSION; - memcpy(params.seed, fake_tpm_seed, sizeof(fake_tpm_seed)); - - rv = test_send_host_command(EC_CMD_FP_SEED, 0, - ¶ms, sizeof(params), - NULL, 0); - if (rv != EC_RES_SUCCESS) { - ccprintf("%s:%s(): rv = %d, set seed failed\n", - __FILE__, __func__, rv); - return -1; - } - - /* Now seed should have been set. */ - rv = test_send_host_command(EC_CMD_FP_ENC_STATUS, 0, - NULL, 0, - &resp, sizeof(resp)); - - return check_seed_set_result(rv, FP_ENC_STATUS_SEED_SET, &resp); -} - -test_static int test_set_fp_tpm_seed_again(void) -{ - int rv; - struct ec_params_fp_seed params; - struct ec_response_fp_encryption_status resp = { 0 }; - - params.struct_version = FP_TEMPLATE_FORMAT_VERSION; - params.seed[0] = 0; - - rv = test_send_host_command(EC_CMD_FP_SEED, 0, - ¶ms, sizeof(params), - NULL, 0); - if (rv != EC_RES_ACCESS_DENIED) { - ccprintf("%s:%s(): rv = %d, setting seed the second time " - "should result in EC_RES_ACCESS_DENIED but did not.\n", - __FILE__, __func__, rv); - return -1; - } - - /* Now seed should still be set. */ - rv = test_send_host_command(EC_CMD_FP_ENC_STATUS, 0, - NULL, 0, - &resp, sizeof(resp)); - - return check_seed_set_result(rv, FP_ENC_STATUS_SEED_SET, &resp); -} - -test_static int test_fp_set_sensor_mode(void) -{ - uint32_t requested_mode = 0; - uint32_t output_mode = 0; - - /* Validate initial conditions */ - TEST_ASSERT(FP_MAX_FINGER_COUNT == 5); - TEST_ASSERT(templ_valid == 0); - TEST_ASSERT(sensor_mode == 0); - - /* GIVEN missing output parameter, THEN get error */ - TEST_ASSERT(fp_set_sensor_mode(0, NULL) == EC_RES_INVALID_PARAM); - /* THEN sensor_mode is unchanged */ - TEST_ASSERT(sensor_mode == 0); - - /* GIVEN requested mode includes FP_MODE_DONT_CHANGE, THEN succeed */ - TEST_ASSERT(sensor_mode == 0); - TEST_ASSERT(output_mode == 0); - requested_mode = FP_MODE_DONT_CHANGE; - TEST_ASSERT(fp_set_sensor_mode(requested_mode, &output_mode) == - EC_RES_SUCCESS); - /* THEN sensor_mode is unchanged */ - TEST_ASSERT(sensor_mode == 0); - /* THEN output_mode matches sensor_mode */ - TEST_ASSERT(output_mode == sensor_mode); - - /* GIVEN request to change to valid sensor mode */ - TEST_ASSERT(sensor_mode == 0); - requested_mode = FP_MODE_ENROLL_SESSION; - /* THEN succeed */ - TEST_ASSERT(fp_set_sensor_mode(requested_mode, &output_mode) == - EC_RES_SUCCESS); - /* THEN requested mode is returned */ - TEST_ASSERT(requested_mode == output_mode); - /* THEN sensor_mode is updated */ - TEST_ASSERT(sensor_mode == requested_mode); - - /* GIVEN max number of fingers already enrolled */ - sensor_mode = 0; - output_mode = 0xdeadbeef; - templ_valid = FP_MAX_FINGER_COUNT; - requested_mode = FP_MODE_ENROLL_SESSION; - /* THEN additional enroll attempt will fail */ - TEST_ASSERT(fp_set_sensor_mode(requested_mode, &output_mode) == - EC_RES_INVALID_PARAM); - /* THEN output parameters is unchanged */ - TEST_ASSERT(output_mode = 0xdeadbeef); - /* THEN sensor_mode is unchanged */ - TEST_ASSERT(sensor_mode == 0); - - /* Clear state to ensure test independence. */ - templ_valid = 0; - - return EC_SUCCESS; -} - -static int test_enable_positive_match_secret_once( - struct positive_match_secret_state *dumb_state) -{ - const int8_t kIndexToEnable = 0; - timestamp_t now = get_time(); - - TEST_ASSERT(fp_enable_positive_match_secret( - kIndexToEnable, dumb_state) == EC_SUCCESS); - TEST_ASSERT(dumb_state->template_matched == kIndexToEnable); - TEST_ASSERT(dumb_state->readable); - TEST_ASSERT(dumb_state->deadline.val == now.val + (5 * SECOND)); - - return EC_SUCCESS; -} - -test_static int test_enable_positive_match_secret(void) -{ - struct positive_match_secret_state dumb_state = { - .template_matched = FP_NO_SUCH_TEMPLATE, - .readable = false, - .deadline.val = 0, - }; - - TEST_ASSERT(test_enable_positive_match_secret_once(&dumb_state) - == EC_SUCCESS); - - /* Trying to enable again before reading secret should fail. */ - TEST_ASSERT(fp_enable_positive_match_secret(0, &dumb_state) == - EC_ERROR_UNKNOWN); - TEST_ASSERT(dumb_state.template_matched == FP_NO_SUCH_TEMPLATE); - TEST_ASSERT(!dumb_state.readable); - TEST_ASSERT(dumb_state.deadline.val == 0); - - return EC_SUCCESS; -} - -test_static int test_disable_positive_match_secret(void) -{ - struct positive_match_secret_state dumb_state = { - .template_matched = FP_NO_SUCH_TEMPLATE, - .readable = false, - .deadline.val = 0, - }; - - TEST_ASSERT(test_enable_positive_match_secret_once(&dumb_state) - == EC_SUCCESS); - - fp_disable_positive_match_secret(&dumb_state); - TEST_ASSERT(dumb_state.template_matched == FP_NO_SUCH_TEMPLATE); - TEST_ASSERT(!dumb_state.readable); - TEST_ASSERT(dumb_state.deadline.val == 0); - - return EC_SUCCESS; -} - -test_static int test_command_read_match_secret(void) -{ - int rv; - struct ec_params_fp_read_match_secret params; - struct ec_response_fp_read_match_secret resp; - timestamp_t now = get_time(); - - /* Invalid finger index should be rejected. */ - params.fgr = FP_NO_SUCH_TEMPLATE; - rv = test_send_host_command(EC_CMD_FP_READ_MATCH_SECRET, 0, ¶ms, - sizeof(params), NULL, 0); - TEST_ASSERT(rv == EC_RES_INVALID_PARAM); - params.fgr = FP_MAX_FINGER_COUNT; - rv = test_send_host_command(EC_CMD_FP_READ_MATCH_SECRET, 0, ¶ms, - sizeof(params), NULL, 0); - TEST_ASSERT(rv == EC_RES_INVALID_PARAM); - - memset(&resp, 0, sizeof(resp)); - /* GIVEN that finger index is valid. */ - params.fgr = 0; - - /* GIVEN that positive match secret is enabled. */ - fp_enable_positive_match_secret(params.fgr, - &positive_match_secret_state); - - /* GIVEN that salt is non-trivial. */ - memcpy(fp_positive_match_salt[0], fake_positive_match_salt, - sizeof(fp_positive_match_salt[0])); - /* THEN reading positive match secret should succeed. */ - rv = test_send_host_command(EC_CMD_FP_READ_MATCH_SECRET, 0, ¶ms, - sizeof(params), &resp, sizeof(resp)); - if (rv != EC_RES_SUCCESS) { - ccprintf("%s:%s(): rv = %d\n", __FILE__, __func__, rv); - return -1; - } - /* AND the readable bit should be cleared after the read. */ - TEST_ASSERT(positive_match_secret_state.readable == false); - - TEST_ASSERT_ARRAY_EQ( - resp.positive_match_secret, - expected_positive_match_secret_for_empty_user_id, - sizeof(expected_positive_match_secret_for_empty_user_id)); - - /* - * Now try reading secret again. - * EVEN IF the deadline has not passed. - */ - positive_match_secret_state.deadline.val = now.val + 1 * SECOND; - rv = test_send_host_command(EC_CMD_FP_READ_MATCH_SECRET, 0, ¶ms, - sizeof(params), NULL, 0); - /* - * This time the command should fail because the - * fp_pos_match_secret_readable bit is cleared when the secret was read - * the first time. - */ - TEST_ASSERT(rv == EC_RES_ACCESS_DENIED); - - return EC_SUCCESS; -} - -test_static int test_command_read_match_secret_wrong_finger(void) -{ - int rv; - struct ec_params_fp_read_match_secret params; - - /* GIVEN that the finger is not the matched or enrolled finger. */ - params.fgr = 0; - /* - * GIVEN that positive match secret is enabled for a different - * finger. - */ - fp_enable_positive_match_secret(params.fgr + 1, - &positive_match_secret_state); - - /* Reading secret will fail. */ - rv = test_send_host_command(EC_CMD_FP_READ_MATCH_SECRET, 0, ¶ms, - sizeof(params), NULL, 0); - TEST_ASSERT(rv == EC_RES_ACCESS_DENIED); - return EC_SUCCESS; -} - -test_static int test_command_read_match_secret_timeout(void) -{ - int rv; - struct ec_params_fp_read_match_secret params; - - params.fgr = 0; - /* GIVEN that the read is too late. */ - fp_enable_positive_match_secret(params.fgr, - &positive_match_secret_state); - set_time(positive_match_secret_state.deadline); - - /* EVEN IF encryption salt is non-trivial. */ - memcpy(fp_positive_match_salt[0], fake_positive_match_salt, - sizeof(fp_positive_match_salt[0])); - /* Reading secret will fail. */ - rv = test_send_host_command(EC_CMD_FP_READ_MATCH_SECRET, 0, ¶ms, - sizeof(params), NULL, 0); - TEST_ASSERT(rv == EC_RES_TIMEOUT); - return EC_SUCCESS; -} - -test_static int test_command_read_match_secret_unreadable(void) -{ - int rv; - struct ec_params_fp_read_match_secret params; - - params.fgr = 0; - /* GIVEN that the readable bit is not set. */ - fp_enable_positive_match_secret(params.fgr, - &positive_match_secret_state); - positive_match_secret_state.readable = false; - - /* EVEN IF the finger is just matched. */ - TEST_ASSERT(positive_match_secret_state.template_matched - == params.fgr); - - /* EVEN IF encryption salt is non-trivial. */ - memcpy(fp_positive_match_salt[0], fake_positive_match_salt, - sizeof(fp_positive_match_salt[0])); - /* Reading secret will fail. */ - rv = test_send_host_command(EC_CMD_FP_READ_MATCH_SECRET, 0, ¶ms, - sizeof(params), NULL, 0); - TEST_ASSERT(rv == EC_RES_ACCESS_DENIED); - return EC_SUCCESS; -} - -void run_test(void) -{ - /* These are independent of global state. */ - RUN_TEST(test_hkdf_expand); - RUN_TEST(test_fp_set_sensor_mode); - - /* These must be run before tpm seed is set. */ - RUN_TEST(test_fp_enc_status_valid_flags); - RUN_TEST(test_fp_tpm_seed_not_set); - RUN_TEST(test_derive_encryption_key_failure_seed_not_set); - RUN_TEST(test_derive_positive_match_secret_fail_seed_not_set); - - RUN_TEST(test_set_fp_tpm_seed); - - /* These must be run after tpm seed is set. */ - RUN_TEST(test_set_fp_tpm_seed_again); - RUN_TEST(test_derive_encryption_key); - RUN_TEST(test_derive_encryption_key_failure_rollback_fail); - RUN_TEST(test_derive_new_pos_match_secret); - RUN_TEST(test_derive_positive_match_secret_fail_rollback_fail); - RUN_TEST(test_derive_positive_match_secret_fail_salt_trivial); - RUN_TEST(test_enable_positive_match_secret); - RUN_TEST(test_disable_positive_match_secret); - RUN_TEST(test_command_read_match_secret); - RUN_TEST(test_command_read_match_secret_wrong_finger); - RUN_TEST(test_command_read_match_secret_timeout); - RUN_TEST(test_command_read_match_secret_unreadable); - - test_print_result(); -} diff --git a/test/fpsensor.mocklist b/test/fpsensor.mocklist deleted file mode 100644 index 3a90debc1f..0000000000 --- a/test/fpsensor.mocklist +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - #define CONFIG_TEST_MOCK_LIST \ - MOCK(FP_SENSOR) \ - MOCK(MKBP_EVENTS) \ - MOCK(TIMER) diff --git a/test/fpsensor.tasklist b/test/fpsensor.tasklist deleted file mode 100644 index bee999ff6b..0000000000 --- a/test/fpsensor.tasklist +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST \ - TASK_TEST(FPSENSOR, fp_task_simulate, NULL, TASK_STACK_SIZE) - diff --git a/test/inductive_charging.c b/test/inductive_charging.c deleted file mode 100644 index f3cc6cf908..0000000000 --- a/test/inductive_charging.c +++ /dev/null @@ -1,170 +0,0 @@ -/* Copyright 2014 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test inductive charging module. - */ - -#include "common.h" -#include "console.h" -#include "gpio.h" -#include "hooks.h" -#include "inductive_charging.h" -#include "lid_switch.h" -#include "test_util.h" -#include "timer.h" -#include "util.h" - -#define START_CHARGE_DELAY 5000 /* ms */ -#define MONITOR_CHARGE_DONE_DELAY 1000 /* ms */ -#define TEST_CHECK_CHARGE_DELAY (START_CHARGE_DELAY + \ - MONITOR_CHARGE_DONE_DELAY + 500) /* ms */ - -static void wait_for_lid_debounce(void) -{ - while (lid_is_open() != gpio_get_level(GPIO_LID_OPEN)) - msleep(20); -} - -static void set_lid_open(int lid_open) -{ - gpio_set_level(GPIO_LID_OPEN, lid_open); - wait_for_lid_debounce(); -} - -static int test_lid(void) -{ - /* Lid is open initially */ - set_lid_open(1); - gpio_set_level(GPIO_CHARGE_DONE, 0); - TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 0); - - /* - * Close the lid. The EC should wait for 5 second before - * enabling transmitter. - */ - set_lid_open(0); - TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 0); - msleep(TEST_CHECK_CHARGE_DELAY); - - /* Transmitter should now be enabled. */ - TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 1); - TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 1); - - /* Open the lid. Charging should stop. */ - set_lid_open(1); - msleep(TEST_CHECK_CHARGE_DELAY); - TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 0); - TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 0); - - return EC_SUCCESS; -} - -static int test_charge_done(void) -{ - /* Close the lid to start charging */ - set_lid_open(0); - msleep(TEST_CHECK_CHARGE_DELAY); - TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 1); - TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 1); - - /* Charging is done. Stop charging, but don't turn off transmitter. */ - gpio_set_level(GPIO_CHARGE_DONE, 1); - TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 1); - TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 0); - - /* Oops, CHARGE_DONE changes again. We should ignore it. */ - gpio_set_level(GPIO_CHARGE_DONE, 0); - TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 1); - TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 0); - - /* Open the lid. Charger should be turned off. */ - set_lid_open(1); - msleep(TEST_CHECK_CHARGE_DELAY); - TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 0); - TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 0); - - return EC_SUCCESS; -} - -static int test_lid_open_during_charging(void) -{ - /* Close the lid. Start charging. */ - set_lid_open(0); - msleep(TEST_CHECK_CHARGE_DELAY); - gpio_set_level(GPIO_CHARGE_DONE, 0); - TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 1); - TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 1); - - /* Open the lid. Transmitter should be turned off. */ - set_lid_open(1); - msleep(TEST_CHECK_CHARGE_DELAY); - TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 0); - TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 0); - - /* Toggle charge done signal. Charging should not start. */ - gpio_set_level(GPIO_CHARGE_DONE, 1); - TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 0); - TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 0); - gpio_set_level(GPIO_CHARGE_DONE, 0); - TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 0); - TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 0); - - return EC_SUCCESS; -} - -static int test_debounce_charge_done(void) -{ - /* Lid is open initially. */ - set_lid_open(1); - gpio_set_level(GPIO_CHARGE_DONE, 0); - msleep(TEST_CHECK_CHARGE_DELAY); - TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 0); - TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 0); - - /* Close the lid. Charging should start. */ - set_lid_open(0); - msleep(START_CHARGE_DELAY + 100); - TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 1); - TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 1); - - /* Within the first second, changes on CHARGE_DONE should be ignore. */ - gpio_set_level(GPIO_CHARGE_DONE, 1); - TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 1); - TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 1); - msleep(100); - TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 1); - TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 1); - gpio_set_level(GPIO_CHARGE_DONE, 0); - TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 1); - TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 1); - msleep(100); - TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 1); - TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 1); - - /* Changes on CHARGE_DONE after take effect. */ - msleep(MONITOR_CHARGE_DONE_DELAY); - gpio_set_level(GPIO_CHARGE_DONE, 1); - TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 1); - TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 0); - - /* Open the lid. Charger should be turned off. */ - set_lid_open(1); - msleep(TEST_CHECK_CHARGE_DELAY); - TEST_ASSERT(gpio_get_level(GPIO_BASE_CHG_VDD_EN) == 0); - TEST_ASSERT(gpio_get_level(GPIO_CHARGE_EN) == 0); - - return EC_SUCCESS; -} - -void run_test(void) -{ - test_reset(); - - RUN_TEST(test_lid); - RUN_TEST(test_charge_done); - RUN_TEST(test_lid_open_during_charging); - RUN_TEST(test_debounce_charge_done); - - test_print_result(); -} diff --git a/test/inductive_charging.tasklist b/test/inductive_charging.tasklist deleted file mode 100644 index f5c894ccaf..0000000000 --- a/test/inductive_charging.tasklist +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2014 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST /* No test task */ diff --git a/test/kb_8042.c b/test/kb_8042.c deleted file mode 100644 index ab28df544c..0000000000 --- a/test/kb_8042.c +++ /dev/null @@ -1,275 +0,0 @@ -/* Copyright 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Tests for keyboard MKBP protocol - */ - -#include "common.h" -#include "console.h" -#include "ec_commands.h" -#include "gpio.h" -#include "i8042_protocol.h" -#include "keyboard_8042.h" -#include "keyboard_protocol.h" -#include "keyboard_scan.h" -#include "lpc.h" -#include "power_button.h" -#include "system.h" -#include "test_util.h" -#include "timer.h" -#include "util.h" - -static const char *action[2] = {"release", "press"}; - -#define BUF_SIZE 16 -static char lpc_char_buf[BUF_SIZE]; -static unsigned int lpc_char_cnt; - -/*****************************************************************************/ -/* Mock functions */ - -int lid_is_open(void) -{ - return 1; -} - -void lpc_keyboard_put_char(uint8_t chr, int send_irq) -{ - lpc_char_buf[lpc_char_cnt++] = chr; -} - -/*****************************************************************************/ -/* Test utilities */ - -static void press_key(int c, int r, int pressed) -{ - ccprintf("Input %s (%d, %d)\n", action[pressed], c, r); - keyboard_state_changed(r, c, pressed); -} - -static void enable_keystroke(int enabled) -{ - uint8_t data = enabled ? I8042_CMD_ENABLE : I8042_CMD_RESET_DIS; - keyboard_host_write(data, 0); - msleep(30); -} - -static void reset_8042(void) -{ - keyboard_host_write(I8042_CMD_RESET_DEF, 0); - msleep(30); -} - -static void set_typematic(uint8_t val) -{ - keyboard_host_write(I8042_CMD_SETREP, 0); - msleep(30); - keyboard_host_write(val, 0); - msleep(30); -} - -static void set_scancode(uint8_t s) -{ - keyboard_host_write(I8042_CMD_SSCANSET, 0); - msleep(30); - keyboard_host_write(s, 0); - msleep(30); -} - -static void write_cmd_byte(uint8_t val) -{ - keyboard_host_write(I8042_WRITE_CMD_BYTE, 1); - msleep(30); - keyboard_host_write(val, 0); - msleep(30); -} - -static uint8_t read_cmd_byte(void) -{ - lpc_char_cnt = 0; - keyboard_host_write(I8042_READ_CMD_BYTE, 1); - msleep(30); - return lpc_char_buf[0]; -} - -static int __verify_lpc_char(char *arr, unsigned int sz, int delay_ms) -{ - int i; - - lpc_char_cnt = 0; - for (i = 0; i < sz; ++i) - lpc_char_buf[i] = 0; - msleep(delay_ms); - TEST_ASSERT_ARRAY_EQ(arr, lpc_char_buf, sz); - return EC_SUCCESS; -} - -#define VERIFY_LPC_CHAR(s) \ - TEST_ASSERT(__verify_lpc_char(s, strlen(s), 30) == EC_SUCCESS) -#define VERIFY_LPC_CHAR_DELAY(s, t) \ - TEST_ASSERT(__verify_lpc_char(s, strlen(s), t) == EC_SUCCESS) - -static int __verify_no_char(void) -{ - lpc_char_cnt = 0; - msleep(30); - TEST_CHECK(lpc_char_cnt == 0); -} - -#define VERIFY_NO_CHAR() TEST_ASSERT(__verify_no_char() == EC_SUCCESS) - -/*****************************************************************************/ -/* Tests */ - -static int test_single_key_press(void) -{ - enable_keystroke(1); - press_key(1, 1, 1); - VERIFY_LPC_CHAR("\x01"); - press_key(1, 1, 0); - VERIFY_LPC_CHAR("\x81"); - - press_key(12, 6, 1); - VERIFY_LPC_CHAR("\xe0\x4d"); - press_key(12, 6, 0); - VERIFY_LPC_CHAR("\xe0\xcd"); - - return EC_SUCCESS; -} - -static int test_disable_keystroke(void) -{ - enable_keystroke(0); - press_key(1, 1, 1); - VERIFY_NO_CHAR(); - press_key(1, 1, 0); - VERIFY_NO_CHAR(); - - return EC_SUCCESS; -} - -static int test_typematic(void) -{ - enable_keystroke(1); - - /* - * 250ms delay, 8 chars / sec. - */ - set_typematic(0xf); - - press_key(1, 1, 1); - VERIFY_LPC_CHAR_DELAY("\x01\x01\x01\x01\x01", 650); - press_key(1, 1, 0); - VERIFY_LPC_CHAR_DELAY("\x81", 300); - - /* - * 500ms delay, 10.9 chars / sec. - */ - reset_8042(); - - press_key(1, 1, 1); - VERIFY_LPC_CHAR_DELAY("\x01\x01\x01", 650); - press_key(1, 1, 0); - VERIFY_LPC_CHAR_DELAY("\x81", 200); - - return EC_SUCCESS; -} - -static int test_scancode_set2(void) -{ - set_scancode(2); - - write_cmd_byte(read_cmd_byte() | I8042_XLATE); - press_key(1, 1, 1); - VERIFY_LPC_CHAR("\x01"); - press_key(1, 1, 0); - VERIFY_LPC_CHAR("\x81"); - - write_cmd_byte(read_cmd_byte() & ~I8042_XLATE); - press_key(1, 1, 1); - VERIFY_LPC_CHAR("\x76"); - press_key(1, 1, 0); - VERIFY_LPC_CHAR("\xf0\x76"); - - return EC_SUCCESS; -} - -static int test_power_button(void) -{ - gpio_set_level(GPIO_POWER_BUTTON_L, 1); - set_scancode(1); - test_chipset_on(); - - gpio_set_level(GPIO_POWER_BUTTON_L, 0); - VERIFY_LPC_CHAR_DELAY("\xe0\x5e", 100); - - gpio_set_level(GPIO_POWER_BUTTON_L, 1); - VERIFY_LPC_CHAR_DELAY("\xe0\xde", 100); - - set_scancode(2); - write_cmd_byte(read_cmd_byte() & ~I8042_XLATE); - - gpio_set_level(GPIO_POWER_BUTTON_L, 0); - VERIFY_LPC_CHAR_DELAY("\xe0\x37", 100); - - gpio_set_level(GPIO_POWER_BUTTON_L, 1); - VERIFY_LPC_CHAR_DELAY("\xe0\xf0\x37", 100); - - test_chipset_off(); - - gpio_set_level(GPIO_POWER_BUTTON_L, 0); - VERIFY_NO_CHAR(); - - gpio_set_level(GPIO_POWER_BUTTON_L, 1); - VERIFY_NO_CHAR(); - - return EC_SUCCESS; -} - -static int test_sysjump(void) -{ - set_scancode(2); - enable_keystroke(1); - - system_run_image_copy(SYSTEM_IMAGE_RW); - - /* Shouldn't reach here */ - return EC_ERROR_UNKNOWN; -} - -static int test_sysjump_cont(void) -{ - write_cmd_byte(read_cmd_byte() | I8042_XLATE); - press_key(1, 1, 1); - VERIFY_LPC_CHAR("\x01"); - press_key(1, 1, 0); - VERIFY_LPC_CHAR("\x81"); - - write_cmd_byte(read_cmd_byte() & ~I8042_XLATE); - press_key(1, 1, 1); - VERIFY_LPC_CHAR("\x76"); - press_key(1, 1, 0); - VERIFY_LPC_CHAR("\xf0\x76"); - - return EC_SUCCESS; -} - -void run_test(void) -{ - test_reset(); - wait_for_task_started(); - - if (system_get_image_copy() == SYSTEM_IMAGE_RO) { - RUN_TEST(test_single_key_press); - RUN_TEST(test_disable_keystroke); - RUN_TEST(test_typematic); - RUN_TEST(test_scancode_set2); - RUN_TEST(test_power_button); - RUN_TEST(test_sysjump); - } else { - RUN_TEST(test_sysjump_cont); - } - - test_print_result(); -} diff --git a/test/kb_8042.tasklist b/test/kb_8042.tasklist deleted file mode 100644 index 8cd35e6145..0000000000 --- a/test/kb_8042.tasklist +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST \ - TASK_TEST(KEYPROTO, keyboard_protocol_task, NULL, TASK_STACK_SIZE) \ - TASK_TEST(KEYSCAN, keyboard_scan_task, NULL, 256) \ - TASK_TEST(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) diff --git a/test/kb_mkbp.c b/test/kb_mkbp.c deleted file mode 100644 index 4624896268..0000000000 --- a/test/kb_mkbp.c +++ /dev/null @@ -1,303 +0,0 @@ -/* Copyright 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Tests for keyboard MKBP protocol - */ - -#include "common.h" -#include "console.h" -#include "ec_commands.h" -#include "gpio.h" -#include "host_command.h" -#include "keyboard_mkbp.h" -#include "keyboard_protocol.h" -#include "keyboard_scan.h" -#include "test_util.h" -#include "util.h" - -static uint8_t state[KEYBOARD_COLS_MAX]; -static int ec_int_level; - -static const char *action[2] = {"release", "press"}; - -/*****************************************************************************/ -/* Mock functions */ - -void host_send_response(struct host_cmd_handler_args *args) -{ - /* Do nothing */ -} - -void gpio_set_level(enum gpio_signal signal, int level) -{ - if (signal == GPIO_EC_INT_L) - ec_int_level = !!level; -} - -int lid_is_open(void) -{ - return 1; -} - -/*****************************************************************************/ -/* Test utilities */ - -#define FIFO_EMPTY() (ec_int_level == 1) -#define FIFO_NOT_EMPTY() (ec_int_level == 0) - -void clear_state(void) -{ - memset(state, 0xff, KEYBOARD_COLS_MAX); -} - -void set_state(int c, int r, int pressed) -{ - uint8_t mask = (1 << r); - - if (pressed) - state[c] &= ~mask; - else - state[c] |= mask; -} - -int press_key(int c, int r, int pressed) -{ - ccprintf("Input %s (%d, %d)\n", action[pressed], c, r); - set_state(c, r, pressed); - return keyboard_fifo_add(state); -} - -int verify_key(int c, int r, int pressed) -{ - struct host_cmd_handler_args args; - struct ec_response_get_next_event event; - int i; - - args.version = 0; - args.command = EC_CMD_GET_NEXT_EVENT; - args.params = NULL; - args.params_size = 0; - args.response = &event; - args.response_max = sizeof(event); - args.response_size = 0; - - if (c >= 0 && r >= 0) { - ccprintf("Verify %s (%d, %d)\n", action[pressed], c, r); - set_state(c, r, pressed); - - if (host_command_process(&args) != EC_RES_SUCCESS) - return 0; - - for (i = 0; i < KEYBOARD_COLS_MAX; ++i) - if (event.data.key_matrix[i] != state[i]) - return 0; - } else { - ccprintf("Verify no events available\n"); - if (host_command_process(&args) != EC_RES_UNAVAILABLE) - return 0; - } - - return 1; -} - -int verify_key_v2(int c, int r, int pressed, int expect_more) -{ - struct host_cmd_handler_args args; - struct ec_response_get_next_event_v1 event; - int i; - - args.version = 2; - args.command = EC_CMD_GET_NEXT_EVENT; - args.params = NULL; - args.params_size = 0; - args.response = &event; - args.response_max = sizeof(event); - args.response_size = 0; - - if (c >= 0 && r >= 0) { - ccprintf("Verify %s (%d, %d). Expect %smore.\n", - action[pressed], c, r, expect_more ? "" : "no "); - set_state(c, r, pressed); - - if (host_command_process(&args) != EC_RES_SUCCESS) - return 0; - - if (!!(event.event_type & EC_MKBP_HAS_MORE_EVENTS) != - expect_more) { - ccprintf("Incorrect more events!\n"); - return 0; - } - - for (i = 0; i < KEYBOARD_COLS_MAX; ++i) - if (event.data.key_matrix[i] != state[i]) - return 0; - } else { - ccprintf("Verify no events available\n"); - if (host_command_process(&args) != EC_RES_UNAVAILABLE) - return 0; - } - - return 1; -} - -int mkbp_config(struct ec_params_mkbp_set_config params) -{ - struct host_cmd_handler_args args; - - args.version = 0; - args.command = EC_CMD_MKBP_SET_CONFIG; - args.params = ¶ms; - args.params_size = sizeof(params); - args.response = NULL; - args.response_max = 0; - args.response_size = 0; - - return host_command_process(&args) == EC_RES_SUCCESS; -} - -int set_fifo_size(int sz) -{ - struct ec_params_mkbp_set_config params; - - params.config.valid_mask = EC_MKBP_VALID_FIFO_MAX_DEPTH; - params.config.valid_flags = 0; - params.config.fifo_max_depth = sz; - - return mkbp_config(params); -} - -int set_kb_scan_enabled(int enabled) -{ - struct ec_params_mkbp_set_config params; - - params.config.valid_mask = 0; - params.config.valid_flags = EC_MKBP_FLAGS_ENABLE; - params.config.flags = (enabled ? EC_MKBP_FLAGS_ENABLE : 0); - - return mkbp_config(params); -} - -void clear_mkbp_events(void) -{ - struct host_cmd_handler_args args; - struct ec_response_get_next_event event; - - args.version = 0; - args.command = EC_CMD_GET_NEXT_EVENT; - args.params = NULL; - args.params_size = 0; - args.response = &event; - args.response_max = sizeof(event); - args.response_size = 0; - - /* - * We should return EC_RES_UNAVAILABLE if there are no MKBP events left. - */ - while (host_command_process(&args) != EC_RES_UNAVAILABLE) - ; -} - -/*****************************************************************************/ -/* Tests */ - -int single_key_press(void) -{ - keyboard_clear_buffer(); - clear_state(); - TEST_ASSERT(press_key(0, 0, 1) == EC_SUCCESS); - TEST_ASSERT(FIFO_NOT_EMPTY()); - TEST_ASSERT(press_key(0, 0, 0) == EC_SUCCESS); - TEST_ASSERT(FIFO_NOT_EMPTY()); - - clear_state(); - TEST_ASSERT(verify_key(0, 0, 1)); - TEST_ASSERT(FIFO_NOT_EMPTY()); - TEST_ASSERT(verify_key(0, 0, 0)); - TEST_ASSERT(FIFO_EMPTY()); - - return EC_SUCCESS; -} - -int single_key_press_v2(void) -{ - keyboard_clear_buffer(); - clear_state(); - TEST_ASSERT(press_key(0, 0, 1) == EC_SUCCESS); - TEST_ASSERT(FIFO_NOT_EMPTY()); - TEST_ASSERT(press_key(0, 0, 0) == EC_SUCCESS); - TEST_ASSERT(FIFO_NOT_EMPTY()); - - clear_state(); - TEST_ASSERT(verify_key_v2(0, 0, 1, 1)); - TEST_ASSERT(FIFO_NOT_EMPTY()); - TEST_ASSERT(verify_key_v2(0, 0, 0, 0)); - TEST_ASSERT(FIFO_EMPTY()); - - return EC_SUCCESS; -} - -int test_fifo_size(void) -{ - keyboard_clear_buffer(); - clear_state(); - TEST_ASSERT(set_fifo_size(1)); - TEST_ASSERT(press_key(0, 0, 1) == EC_SUCCESS); - TEST_ASSERT(press_key(0, 0, 0) == EC_ERROR_OVERFLOW); - - clear_state(); - TEST_ASSERT(verify_key(0, 0, 1)); - TEST_ASSERT(FIFO_EMPTY()); - - /* Restore FIFO size */ - TEST_ASSERT(set_fifo_size(100)); - - return EC_SUCCESS; -} - -int test_enable(void) -{ - keyboard_clear_buffer(); - clear_state(); - TEST_ASSERT(set_kb_scan_enabled(0)); - TEST_ASSERT(press_key(0, 0, 1) == EC_SUCCESS); - TEST_ASSERT(FIFO_EMPTY()); - - TEST_ASSERT(set_kb_scan_enabled(1)); - TEST_ASSERT(press_key(0, 0, 1) == EC_SUCCESS); - TEST_ASSERT(FIFO_NOT_EMPTY()); - TEST_ASSERT(verify_key(0, 0, 1)); - - return EC_SUCCESS; -} - -int fifo_underrun(void) -{ - keyboard_clear_buffer(); - clear_state(); - TEST_ASSERT(press_key(0, 0, 1) == EC_SUCCESS); - - clear_state(); - TEST_ASSERT(verify_key(0, 0, 1)); - - /* When FIFO under run, host command reutns last known state */ - TEST_ASSERT(verify_key(-1, -1, -1)); - - return EC_SUCCESS; -} - -void run_test(void) -{ - ec_int_level = 1; - test_reset(); - - /* Clear any pending events such as lid open. */ - clear_mkbp_events(); - RUN_TEST(single_key_press); - RUN_TEST(single_key_press_v2); - RUN_TEST(test_fifo_size); - RUN_TEST(test_enable); - RUN_TEST(fifo_underrun); - - test_print_result(); -} diff --git a/test/kb_mkbp.tasklist b/test/kb_mkbp.tasklist deleted file mode 100644 index d84996c71c..0000000000 --- a/test/kb_mkbp.tasklist +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST \ - TASK_TEST(KEYSCAN, keyboard_scan_task, NULL, 256) \ - TASK_TEST(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) diff --git a/test/kb_scan.c b/test/kb_scan.c deleted file mode 100644 index 24015758b1..0000000000 --- a/test/kb_scan.c +++ /dev/null @@ -1,490 +0,0 @@ -/* Copyright 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * Copyright 2013 Google Inc. - * - * Tests for keyboard scan deghosting and debouncing. - */ - -#include "common.h" -#include "console.h" -#include "gpio.h" -#include "hooks.h" -#include "host_command.h" -#include "keyboard_raw.h" -#include "keyboard_scan.h" -#include "lid_switch.h" -#include "system.h" -#include "task.h" -#include "test_util.h" -#include "timer.h" -#include "util.h" - -#define KEYDOWN_DELAY_MS 10 -#define KEYDOWN_RETRY 10 -#define NO_KEYDOWN_DELAY_MS 100 - -#define CHECK_KEY_COUNT(old, expected) \ - do { \ - if (verify_key_presses(old, expected) != EC_SUCCESS) \ - return EC_ERROR_UNKNOWN; \ - old = fifo_add_count; \ - } while (0) - -static uint8_t mock_state[KEYBOARD_COLS_MAX]; -static int column_driven; -static int fifo_add_count; -static int lid_open; -#ifdef EMU_BUILD -static int hibernated; -static int reset_called; -#endif - -/* - * Helper method to wake a given task, and provide immediate opportunity to run. - */ -static void task_wake_then_sleep_1ms(int task_id) -{ - task_wake(task_id); - msleep(1); -} - -#ifdef CONFIG_LID_SWITCH -int lid_is_open(void) -{ - return lid_open; -} -#endif - -void keyboard_raw_drive_column(int out) -{ - column_driven = out; -} - -int keyboard_raw_read_rows(void) -{ - int i; - int r = 0; - - if (column_driven == KEYBOARD_COLUMN_NONE) { - return 0; - } else if (column_driven == KEYBOARD_COLUMN_ALL) { - for (i = 0; i < KEYBOARD_COLS_MAX; ++i) - r |= mock_state[i]; - return r; - } else { - return mock_state[column_driven]; - } -} - -int keyboard_fifo_add(const uint8_t *buffp) -{ - fifo_add_count++; - return EC_SUCCESS; -} - -#ifdef EMU_BUILD -void system_hibernate(uint32_t s, uint32_t us) -{ - hibernated = 1; -} - -void chipset_reset(void) -{ - reset_called = 1; -} -#endif - -#define mock_defined_key(k, p) mock_key(KEYBOARD_ROW_ ## k, \ - KEYBOARD_COL_ ## k, \ - p) - -static void mock_key(int r, int c, int keydown) -{ - ccprintf("%s (%d, %d)\n", keydown ? "Pressing" : "Releasing", r, c); - if (keydown) - mock_state[c] |= (1 << r); - else - mock_state[c] &= ~(1 << r); -} - -static int expect_keychange(void) -{ - int old_count = fifo_add_count; - int retry = KEYDOWN_RETRY; - task_wake(TASK_ID_KEYSCAN); - while (retry--) { - msleep(KEYDOWN_DELAY_MS); - if (fifo_add_count > old_count) - return EC_SUCCESS; - } - return EC_ERROR_UNKNOWN; -} - -static int expect_no_keychange(void) -{ - int old_count = fifo_add_count; - task_wake(TASK_ID_KEYSCAN); - msleep(NO_KEYDOWN_DELAY_MS); - return (fifo_add_count == old_count) ? EC_SUCCESS : EC_ERROR_UNKNOWN; -} - -static int host_command_simulate(int r, int c, int keydown) -{ - struct ec_params_mkbp_simulate_key params; - - params.col = c; - params.row = r; - params.pressed = keydown; - - return test_send_host_command(EC_CMD_MKBP_SIMULATE_KEY, 0, ¶ms, - sizeof(params), NULL, 0); -} - -static int verify_key_presses(int old, int expected) -{ - int retry = KEYDOWN_RETRY; - - if (expected == 0) { - msleep(NO_KEYDOWN_DELAY_MS); - return (fifo_add_count == old) ? EC_SUCCESS : EC_ERROR_UNKNOWN; - } else { - while (retry--) { - msleep(KEYDOWN_DELAY_MS); - if (fifo_add_count == old + expected) - return EC_SUCCESS; - } - return EC_ERROR_UNKNOWN; - } -} - -static int deghost_test(void) -{ - /* Test we can detect a keypress */ - mock_key(1, 1, 1); - TEST_ASSERT(expect_keychange() == EC_SUCCESS); - mock_key(1, 1, 0); - TEST_ASSERT(expect_keychange() == EC_SUCCESS); - - /* (1, 1) (1, 2) (2, 1) (2, 2) form ghosting keys */ - mock_key(1, 1, 1); - TEST_ASSERT(expect_keychange() == EC_SUCCESS); - mock_key(2, 2, 1); - TEST_ASSERT(expect_keychange() == EC_SUCCESS); - mock_key(1, 2, 1); - mock_key(2, 1, 1); - TEST_ASSERT(expect_no_keychange() == EC_SUCCESS); - mock_key(2, 1, 0); - mock_key(1, 2, 0); - TEST_ASSERT(expect_no_keychange() == EC_SUCCESS); - mock_key(2, 2, 0); - TEST_ASSERT(expect_keychange() == EC_SUCCESS); - mock_key(1, 1, 0); - TEST_ASSERT(expect_keychange() == EC_SUCCESS); - - /* (1, 1) (2, 0) (2, 1) don't form ghosting keys */ - mock_key(1, 1, 1); - TEST_ASSERT(expect_keychange() == EC_SUCCESS); - mock_key(2, 0, 1); - TEST_ASSERT(expect_keychange() == EC_SUCCESS); - mock_key(1, 0, 1); - mock_key(2, 1, 1); - TEST_ASSERT(expect_keychange() == EC_SUCCESS); - mock_key(1, 0, 0); - mock_key(2, 1, 0); - TEST_ASSERT(expect_keychange() == EC_SUCCESS); - mock_key(2, 0, 0); - TEST_ASSERT(expect_keychange() == EC_SUCCESS); - mock_key(1, 1, 0); - TEST_ASSERT(expect_keychange() == EC_SUCCESS); - - return EC_SUCCESS; -} - -static int debounce_test(void) -{ - int old_count = fifo_add_count; - int i; - - /* One brief keypress is detected. */ - msleep(40); - mock_key(1, 1, 1); - task_wake_then_sleep_1ms(TASK_ID_KEYSCAN); - mock_key(1, 1, 0); - task_wake_then_sleep_1ms(TASK_ID_KEYSCAN); - CHECK_KEY_COUNT(old_count, 2); - - /* Brief bounce, followed by continuous press is detected as one. */ - msleep(40); - mock_key(1, 1, 1); - task_wake_then_sleep_1ms(TASK_ID_KEYSCAN); - mock_key(1, 1, 0); - task_wake_then_sleep_1ms(TASK_ID_KEYSCAN); - mock_key(1, 1, 1); - task_wake_then_sleep_1ms(TASK_ID_KEYSCAN); - CHECK_KEY_COUNT(old_count, 1); - - /* Brief lifting, then re-presseing is detected as new keypress. */ - msleep(40); - mock_key(1, 1, 0); - task_wake_then_sleep_1ms(TASK_ID_KEYSCAN); - mock_key(1, 1, 1); - task_wake_then_sleep_1ms(TASK_ID_KEYSCAN); - CHECK_KEY_COUNT(old_count, 2); - - /* One bouncy re-contact while lifting is ignored. */ - msleep(40); - mock_key(1, 1, 0); - task_wake_then_sleep_1ms(TASK_ID_KEYSCAN); - mock_key(1, 1, 1); - task_wake_then_sleep_1ms(TASK_ID_KEYSCAN); - mock_key(1, 1, 0); - task_wake_then_sleep_1ms(TASK_ID_KEYSCAN); - CHECK_KEY_COUNT(old_count, 1); - - /* - * Debounce interval of first key is not affected by continued - * activity of other keys. - */ - msleep(40); - /* Push the first key */ - mock_key(0, 1, 0); - task_wake_then_sleep_1ms(TASK_ID_KEYSCAN); - /* - * Push down each subsequent key, until all 8 are pressed, each - * time bouncing the former one once. - */ - for (i = 1 ; i < 8; i++) { - mock_key(i, 1, 1); - task_wake(TASK_ID_KEYSCAN); - msleep(3); - mock_key(i - 1, 1, 0); - task_wake(TASK_ID_KEYSCAN); - msleep(1); - mock_key(i - 1, 1, 1); - task_wake(TASK_ID_KEYSCAN); - msleep(1); - } - /* Verify that the bounces were. ignored */ - CHECK_KEY_COUNT(old_count, 8); - /* - * Now briefly lift and re-press the first one, which should now be past - * its debounce interval - */ - mock_key(0, 1, 0); - task_wake_then_sleep_1ms(TASK_ID_KEYSCAN); - CHECK_KEY_COUNT(old_count, 1); - mock_key(0, 1, 1); - task_wake_then_sleep_1ms(TASK_ID_KEYSCAN); - CHECK_KEY_COUNT(old_count, 1); - /* For good measure, release all keys before proceeding. */ - for (i = 0; i < 8; i++) - mock_key(i, 1, 0); - task_wake_then_sleep_1ms(TASK_ID_KEYSCAN); - - return EC_SUCCESS; -} - -static int simulate_key_test(void) -{ - int old_count; - - task_wake(TASK_ID_KEYSCAN); - msleep(40); /* Wait for debouncing to settle */ - - old_count = fifo_add_count; - host_command_simulate(1, 1, 1); - TEST_ASSERT(fifo_add_count > old_count); - msleep(40); - old_count = fifo_add_count; - host_command_simulate(1, 1, 0); - TEST_ASSERT(fifo_add_count > old_count); - msleep(40); - - return EC_SUCCESS; -} - -#ifdef EMU_BUILD -static int wait_variable_set(int *var) -{ - int retry = KEYDOWN_RETRY; - *var = 0; - task_wake(TASK_ID_KEYSCAN); - while (retry--) { - msleep(KEYDOWN_DELAY_MS); - if (*var == 1) - return EC_SUCCESS; - } - return EC_ERROR_UNKNOWN; -} - -static int verify_variable_not_set(int *var) -{ - *var = 0; - task_wake(TASK_ID_KEYSCAN); - msleep(NO_KEYDOWN_DELAY_MS); - return *var ? EC_ERROR_UNKNOWN : EC_SUCCESS; -} - -static int runtime_key_test(void) -{ - /* Alt-VolUp-H triggers system hibernation */ - mock_defined_key(LEFT_ALT, 1); - mock_defined_key(VOL_UP, 1); - mock_defined_key(KEY_H, 1); - TEST_ASSERT(wait_variable_set(&hibernated) == EC_SUCCESS); - mock_defined_key(LEFT_ALT, 0); - mock_defined_key(VOL_UP, 0); - mock_defined_key(KEY_H, 0); - TEST_ASSERT(expect_keychange() == EC_SUCCESS); - - /* Alt-VolUp-R triggers chipset reset */ - mock_defined_key(RIGHT_ALT, 1); - mock_defined_key(VOL_UP, 1); - mock_defined_key(KEY_R, 1); - TEST_ASSERT(wait_variable_set(&reset_called) == EC_SUCCESS); - mock_defined_key(RIGHT_ALT, 0); - mock_defined_key(VOL_UP, 0); - mock_defined_key(KEY_R, 0); - TEST_ASSERT(expect_keychange() == EC_SUCCESS); - - /* Must press exactly 3 keys to trigger runtime keys */ - mock_defined_key(LEFT_ALT, 1); - mock_defined_key(KEY_H, 1); - mock_defined_key(KEY_R, 1); - mock_defined_key(VOL_UP, 1); - TEST_ASSERT(verify_variable_not_set(&hibernated) == EC_SUCCESS); - TEST_ASSERT(verify_variable_not_set(&reset_called) == EC_SUCCESS); - mock_defined_key(VOL_UP, 0); - mock_defined_key(KEY_R, 0); - mock_defined_key(KEY_H, 0); - mock_defined_key(LEFT_ALT, 0); - TEST_ASSERT(expect_keychange() == EC_SUCCESS); - - return EC_SUCCESS; -} -#endif - -#ifdef CONFIG_LID_SWITCH -static int lid_test(void) -{ - msleep(40); /* Allow debounce to settle */ - - lid_open = 0; - hook_notify(HOOK_LID_CHANGE); - msleep(1); /* Allow hooks to run */ - mock_key(1, 1, 1); - TEST_ASSERT(expect_no_keychange() == EC_SUCCESS); - mock_key(1, 1, 0); - TEST_ASSERT(expect_no_keychange() == EC_SUCCESS); - - lid_open = 1; - hook_notify(HOOK_LID_CHANGE); - msleep(1); /* Allow hooks to run */ - mock_key(1, 1, 1); - TEST_ASSERT(expect_keychange() == EC_SUCCESS); - mock_key(1, 1, 0); - TEST_ASSERT(expect_keychange() == EC_SUCCESS); - - return EC_SUCCESS; -} -#endif - -static int test_check_boot_esc(void) -{ - TEST_CHECK(keyboard_scan_get_boot_keys() == BOOT_KEY_ESC); -} - -static int test_check_boot_down(void) -{ - TEST_CHECK(keyboard_scan_get_boot_keys() == BOOT_KEY_DOWN_ARROW); -} - -void test_init(void) -{ - uint32_t state = system_get_scratchpad(); - - if (state & TEST_STATE_MASK(TEST_STATE_STEP_2)) { - /* Power-F3-ESC */ - system_set_reset_flags(system_get_reset_flags() | - EC_RESET_FLAG_RESET_PIN); - mock_key(1, 1, 1); - } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_3)) { - /* Power-F3-Down */ - system_set_reset_flags(system_get_reset_flags() | - EC_RESET_FLAG_RESET_PIN); - mock_key(6, 11, 1); - } -} - -static void run_test_step1(void) -{ - lid_open = 1; - hook_notify(HOOK_LID_CHANGE); - test_reset(); - - RUN_TEST(deghost_test); - RUN_TEST(debounce_test); - RUN_TEST(simulate_key_test); -#ifdef EMU_BUILD - RUN_TEST(runtime_key_test); -#endif -#ifdef CONFIG_LID_SWITCH - RUN_TEST(lid_test); -#endif - - if (test_get_error_count()) - test_reboot_to_next_step(TEST_STATE_FAILED); - else - test_reboot_to_next_step(TEST_STATE_STEP_2); -} - -static void run_test_step2(void) -{ - lid_open = 1; - hook_notify(HOOK_LID_CHANGE); - test_reset(); - - RUN_TEST(test_check_boot_esc); - - if (test_get_error_count()) - test_reboot_to_next_step(TEST_STATE_FAILED); - else - test_reboot_to_next_step(TEST_STATE_STEP_3); -} - -static void run_test_step3(void) -{ - lid_open = 1; - hook_notify(HOOK_LID_CHANGE); - test_reset(); - - RUN_TEST(test_check_boot_down); - - if (test_get_error_count()) - test_reboot_to_next_step(TEST_STATE_FAILED); - else - test_reboot_to_next_step(TEST_STATE_PASSED); -} - -void test_run_step(uint32_t state) -{ - if (state & TEST_STATE_MASK(TEST_STATE_STEP_1)) - run_test_step1(); - else if (state & TEST_STATE_MASK(TEST_STATE_STEP_2)) - run_test_step2(); - else if (state & TEST_STATE_MASK(TEST_STATE_STEP_3)) - run_test_step3(); -} - -int test_task(void *data) -{ - test_run_multistep(); - return EC_SUCCESS; -} - -void run_test(void) -{ - msleep(30); /* Wait for TASK_ID_TEST to initialize */ - task_wake(TASK_ID_TEST); -} diff --git a/test/kb_scan.tasklist b/test/kb_scan.tasklist deleted file mode 100644 index ded03b1112..0000000000 --- a/test/kb_scan.tasklist +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST \ - TASK_TEST(KEYSCAN, keyboard_scan_task, NULL, 256) \ - TASK_TEST(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) \ - TASK_TEST(TEST, test_task, NULL, TASK_STACK_SIZE) diff --git a/test/lid_sw.c b/test/lid_sw.c deleted file mode 100644 index e671f9b9d0..0000000000 --- a/test/lid_sw.c +++ /dev/null @@ -1,94 +0,0 @@ -/* Copyright 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test lid switch. - */ - -#include "common.h" -#include "console.h" -#include "gpio.h" -#include "hooks.h" -#include "host_command.h" -#include "lid_switch.h" -#include "test_util.h" -#include "timer.h" -#include "util.h" - -static int lid_hook_count; - -static void lid_change_hook(void) -{ - lid_hook_count++; -} -DECLARE_HOOK(HOOK_LID_CHANGE, lid_change_hook, HOOK_PRIO_DEFAULT); - -int lid_memmap_state(void) -{ - uint8_t *memmap = host_get_memmap(EC_MEMMAP_SWITCHES); - return *memmap & EC_SWITCH_LID_OPEN; -} - -static int test_hook(void) -{ - /* Close lid for testing */ - gpio_set_level(GPIO_LID_OPEN, 0); - msleep(100); - lid_hook_count = 0; - host_clear_events(0xffffffff); - - gpio_set_level(GPIO_LID_OPEN, 1); - msleep(50); - TEST_ASSERT(lid_hook_count == 1); - TEST_ASSERT(lid_is_open()); - TEST_ASSERT(lid_memmap_state()); - TEST_ASSERT(host_get_events() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN)); - - gpio_set_level(GPIO_LID_OPEN, 0); - msleep(50); - TEST_ASSERT(lid_hook_count == 2); - TEST_ASSERT(!lid_is_open()); - TEST_ASSERT(!lid_memmap_state()); - TEST_ASSERT(host_get_events() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_CLOSED)); - - return EC_SUCCESS; -} - -static int test_debounce(void) -{ - /* Close lid for testing */ - gpio_set_level(GPIO_LID_OPEN, 0); - msleep(100); - lid_hook_count = 0; - host_clear_events(0xffffffff); - - gpio_set_level(GPIO_LID_OPEN, 1); - msleep(20); - TEST_ASSERT(lid_hook_count == 0); - TEST_ASSERT(!lid_is_open()); - TEST_ASSERT(!lid_memmap_state()); - TEST_ASSERT(!(host_get_events() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN))); - - gpio_set_level(GPIO_LID_OPEN, 0); - msleep(50); - TEST_ASSERT(lid_hook_count == 0); - TEST_ASSERT(!lid_is_open()); - TEST_ASSERT(!lid_memmap_state()); - TEST_ASSERT(!(host_get_events() & - EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN))); - - return EC_SUCCESS; -} - -void run_test(void) -{ - test_reset(); - - RUN_TEST(test_hook); - RUN_TEST(test_debounce); - - test_print_result(); -} diff --git a/test/lid_sw.tasklist b/test/lid_sw.tasklist deleted file mode 100644 index da0ab6211a..0000000000 --- a/test/lid_sw.tasklist +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST /* No test task */ diff --git a/test/lightbar.c b/test/lightbar.c deleted file mode 100644 index d0952c92e8..0000000000 --- a/test/lightbar.c +++ /dev/null @@ -1,335 +0,0 @@ -/* Copyright 2014 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "console.h" -#include "ec_commands.h" -#include "lightbar.h" -#include "host_command.h" -#include "test_util.h" -#include "timer.h" -#include "util.h" - -static int get_seq(void) -{ - int rv; - struct ec_params_lightbar params; - struct ec_response_lightbar resp; - - /* Get the state */ - memset(&resp, 0, sizeof(resp)); - params.cmd = LIGHTBAR_CMD_GET_SEQ; - rv = test_send_host_command(EC_CMD_LIGHTBAR_CMD, 0, - ¶ms, sizeof(params), - &resp, sizeof(resp)); - if (rv != EC_RES_SUCCESS) { - ccprintf("%s:%s(): rv = %d\n", __FILE__, __func__, rv); - return -1; - } - - return resp.get_seq.num; -} - -static int set_seq(int s) -{ - int rv; - struct ec_params_lightbar params; - struct ec_response_lightbar resp; - - /* Get the state */ - memset(&resp, 0, sizeof(resp)); - params.cmd = LIGHTBAR_CMD_SEQ; - params.seq.num = s; - rv = test_send_host_command(EC_CMD_LIGHTBAR_CMD, 0, - ¶ms, sizeof(params), - &resp, sizeof(resp)); - if (rv != EC_RES_SUCCESS) { - ccprintf("%s:%s(): rv = %d\n", __FILE__, __func__, rv); - return -1; - } - - return EC_RES_SUCCESS; -} - -test_static int test_double_oneshots(void) -{ - /* Start in S0 */ - TEST_ASSERT(set_seq(LIGHTBAR_S0) == EC_RES_SUCCESS); - usleep(SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_S0); - /* Invoke the oneshot */ - TEST_ASSERT(set_seq(LIGHTBAR_TAP) == EC_RES_SUCCESS); - usleep(SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_TAP); - /* Switch to a different oneshot while that one's running */ - TEST_ASSERT(set_seq(LIGHTBAR_KONAMI) == EC_RES_SUCCESS); - usleep(SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_KONAMI); - /* Afterwards, it should go back to the original normal state */ - usleep(30 * SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_S0); - - /* Same test, but with a bunch more oneshots. */ - TEST_ASSERT(set_seq(LIGHTBAR_S0) == EC_RES_SUCCESS); - usleep(SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_S0); - TEST_ASSERT(set_seq(LIGHTBAR_TAP) == EC_RES_SUCCESS); - usleep(SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_TAP); - TEST_ASSERT(set_seq(LIGHTBAR_KONAMI) == EC_RES_SUCCESS); - usleep(SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_KONAMI); - TEST_ASSERT(set_seq(LIGHTBAR_TAP) == EC_RES_SUCCESS); - usleep(SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_TAP); - TEST_ASSERT(set_seq(LIGHTBAR_KONAMI) == EC_RES_SUCCESS); - usleep(SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_KONAMI); - TEST_ASSERT(set_seq(LIGHTBAR_TAP) == EC_RES_SUCCESS); - usleep(SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_TAP); - /* It should still go back to the original normal state */ - usleep(30 * SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_S0); - - /* But if the interruption is a normal state, that should stick. */ - TEST_ASSERT(set_seq(LIGHTBAR_S0) == EC_RES_SUCCESS); - usleep(SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_S0); - TEST_ASSERT(set_seq(LIGHTBAR_TAP) == EC_RES_SUCCESS); - usleep(SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_TAP); - TEST_ASSERT(set_seq(LIGHTBAR_KONAMI) == EC_RES_SUCCESS); - usleep(SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_KONAMI); - /* Here's a normal sequence */ - TEST_ASSERT(set_seq(LIGHTBAR_S3) == EC_RES_SUCCESS); - usleep(SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_S3); - /* And another one-shot */ - TEST_ASSERT(set_seq(LIGHTBAR_TAP) == EC_RES_SUCCESS); - usleep(SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_TAP); - TEST_ASSERT(set_seq(LIGHTBAR_KONAMI) == EC_RES_SUCCESS); - usleep(SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_KONAMI); - TEST_ASSERT(set_seq(LIGHTBAR_TAP) == EC_RES_SUCCESS); - usleep(SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_TAP); - /* It should go back to the new normal sequence */ - usleep(30 * SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_S3); - - return EC_SUCCESS; -} - -test_static int test_oneshots_norm_msg(void) -{ - /* Revert to the next state when interrupted with a normal message. */ - enum lightbar_sequence seqs[] = { - LIGHTBAR_KONAMI, - LIGHTBAR_TAP, - }; - int i; - - for (i = 0; i < ARRAY_SIZE(seqs); i++) { - /* Start in S0 */ - TEST_ASSERT(set_seq(LIGHTBAR_S0) == EC_RES_SUCCESS); - usleep(SECOND); - /* Invoke the oneshot */ - TEST_ASSERT(set_seq(seqs[i]) == EC_RES_SUCCESS); - usleep(SECOND); - /* Interrupt with S0S3 */ - TEST_ASSERT(set_seq(LIGHTBAR_S0S3) == EC_RES_SUCCESS); - usleep(SECOND); - /* It should be back right away */ - TEST_ASSERT(get_seq() == LIGHTBAR_S0S3); - /* And transition on to the correct value */ - usleep(30 * SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_S3); - } - - return EC_SUCCESS; -} - -test_static int test_stop_timeout(void) -{ - int i; - - for (i = 0; i < LIGHTBAR_NUM_SEQUENCES; i++) { - /* Start in S0 */ - TEST_ASSERT(set_seq(LIGHTBAR_S0) == EC_RES_SUCCESS); - usleep(SECOND); - /* Tell it to stop */ - TEST_ASSERT(set_seq(LIGHTBAR_STOP) == EC_RES_SUCCESS); - usleep(SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_STOP); - /* Try to interrupt it */ - TEST_ASSERT(set_seq(i) == EC_RES_SUCCESS); - usleep(SECOND); - /* What happened? */ - if (i == LIGHTBAR_RUN || - i == LIGHTBAR_S0S3 || i == LIGHTBAR_S3 || - i == LIGHTBAR_S3S5 || i == LIGHTBAR_S5) - /* RUN or shutdown sequences should stop it */ - TEST_ASSERT(get_seq() == LIGHTBAR_S0); - else - /* All other sequences should be ignored */ - TEST_ASSERT(get_seq() == LIGHTBAR_STOP); - - /* Let it RUN again for the next iteration */ - TEST_ASSERT(set_seq(LIGHTBAR_RUN) == EC_RES_SUCCESS); - usleep(SECOND); - } - - TEST_ASSERT(set_seq(LIGHTBAR_S0) == EC_RES_SUCCESS); - return EC_SUCCESS; -} - -test_static int test_oneshots_timeout(void) -{ - /* These should revert to the previous state after running */ - enum lightbar_sequence seqs[] = { - LIGHTBAR_RUN, - LIGHTBAR_KONAMI, - LIGHTBAR_TAP, - }; - int i; - - for (i = 0; i < ARRAY_SIZE(seqs); i++) { - TEST_ASSERT(set_seq(LIGHTBAR_S0) == EC_RES_SUCCESS); - usleep(SECOND); - TEST_ASSERT(set_seq(seqs[i]) == EC_RES_SUCCESS); - /* Assume the oneshot sequence takes at least a second (except - * for LIGHTBAR_RUN, which returns immediately) */ - if (seqs[i] != LIGHTBAR_RUN) { - usleep(SECOND); - TEST_ASSERT(get_seq() == seqs[i]); - } - usleep(30 * SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_S0); - } - - return EC_SUCCESS; -} - -test_static int test_transition_states(void) -{ - /* S5S3 */ - TEST_ASSERT(set_seq(LIGHTBAR_S5S3) == EC_RES_SUCCESS); - usleep(10 * SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_S3); - - /* S3S0 */ - TEST_ASSERT(set_seq(LIGHTBAR_S3S0) == EC_RES_SUCCESS); - usleep(10 * SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_S0); - - /* S0S3 */ - TEST_ASSERT(set_seq(LIGHTBAR_S0S3) == EC_RES_SUCCESS); - usleep(10 * SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_S3); - - /* S3S5 */ - TEST_ASSERT(set_seq(LIGHTBAR_S3S5) == EC_RES_SUCCESS); - usleep(10 * SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_S5); - - return EC_SUCCESS; -} - -test_static int test_stable_states(void) -{ - int i; - - /* Wait for the lightbar task to initialize */ - msleep(500); - - /* It should come up in S5 */ - TEST_ASSERT(get_seq() == LIGHTBAR_S5); - - /* It should stay there */ - for (i = 0; i < 30; i++) { - usleep(SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_S5); - } - - /* S3 is sticky, too */ - TEST_ASSERT(set_seq(LIGHTBAR_S3) == EC_RES_SUCCESS); - for (i = 0; i < 30; i++) { - usleep(SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_S3); - } - - /* And S0 */ - TEST_ASSERT(set_seq(LIGHTBAR_S0) == EC_RES_SUCCESS); - for (i = 0; i < 30; i++) { - usleep(SECOND); - TEST_ASSERT(get_seq() == LIGHTBAR_S0); - } - - return EC_SUCCESS; -} - -const struct lb_brightness_def lb_brightness_levels[] = { - { - /* regular brightness */ - .lux_up = 60, - .lux_down = 40, - }, - { - /* 25 - 50% brightness */ - .lux_up = 40, - .lux_down = 20, - }, - { - /* 0 .. 25% brightness */ - .lux_up = 0, - .lux_down = 0, - }, -}; -const unsigned int lb_brightness_levels_count = - ARRAY_SIZE(lb_brightness_levels); - -int lux_level_to_google_color(const int lux); -extern int google_color_id; - -int lid_is_open(void) -{ - return 1; -} - -test_static int test_als_lightbar(void) -{ - int lux_data[] = { 500, 100, 35, 15, 30, 35, 55, 70, 55, 100 }; - int exp_gcid[] = { 0, 0, 1, 2, 2, 2, 1, 0, 0, 0 }; - int exp_chg[] = { 0, 0, 1, 1, 0, 0, 1, 1, 0, 0 }; - int i; - - BUILD_ASSERT(ARRAY_SIZE(lux_data) == ARRAY_SIZE(exp_gcid)); - BUILD_ASSERT(ARRAY_SIZE(lux_data) == ARRAY_SIZE(exp_chg)); - - google_color_id = 0; - for (i = 0; i < ARRAY_SIZE(lux_data); i++) { - TEST_ASSERT(exp_chg[i] == - lux_level_to_google_color(lux_data[i])); - TEST_ASSERT(exp_gcid[i] == google_color_id); - } - return EC_SUCCESS; -} - -void run_test(void) -{ - /* Ensure tasks are started before running tests */ - usleep(SECOND); - - RUN_TEST(test_stable_states); - RUN_TEST(test_transition_states); - RUN_TEST(test_oneshots_timeout); - RUN_TEST(test_stop_timeout); - RUN_TEST(test_oneshots_norm_msg); - RUN_TEST(test_double_oneshots); - RUN_TEST(test_als_lightbar); - test_print_result(); -} diff --git a/test/lightbar.tasklist b/test/lightbar.tasklist deleted file mode 100644 index b5e714765d..0000000000 --- a/test/lightbar.tasklist +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST \ - TASK_TEST(LIGHTBAR, lightbar_task, NULL, LARGER_TASK_STACK_SIZE) diff --git a/test/motion_angle.c b/test/motion_angle.c deleted file mode 100644 index 37157dc0c0..0000000000 --- a/test/motion_angle.c +++ /dev/null @@ -1,101 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test motion sense code: Check lid angle calculation and tablet mode - * transition. - */ - -#include <math.h> -#include <stdio.h> - -#include "accelgyro.h" -#include "common.h" -#include "gpio.h" -#include "hooks.h" -#include "motion_common.h" -#include "motion_lid.h" -#include "motion_sense.h" -#include "tablet_mode.h" -#include "test_util.h" -#include "util.h" - -/*****************************************************************************/ -/* Test utilities */ - -/* Array units is in m/s^2 - old matrix format. */ -int filler(const struct motion_sensor_t *s, const float v) -{ - return (v * MOTION_SCALING_FACTOR) / s->drv->get_range(s); -} - -static int test_lid_angle_less180(void) -{ - int index = 0, lid_angle; - struct motion_sensor_t *lid = &motion_sensors[ - CONFIG_LID_ANGLE_SENSOR_LID]; - struct motion_sensor_t *base = &motion_sensors[ - CONFIG_LID_ANGLE_SENSOR_BASE]; - - /* We don't have TASK_CHIP so simulate init ourselves */ - hook_notify(HOOK_CHIPSET_SHUTDOWN); - TEST_ASSERT(sensor_active == SENSOR_ACTIVE_S5); - TEST_ASSERT(lid->drv->get_data_rate(lid) == 0); - - /* Go to S0 state */ - hook_notify(HOOK_CHIPSET_SUSPEND); - hook_notify(HOOK_CHIPSET_RESUME); - msleep(1000); - TEST_ASSERT(sensor_active == SENSOR_ACTIVE_S0); - TEST_ASSERT(lid->drv->get_data_rate(lid) == TEST_LID_FREQUENCY); - - /* Open lid, testing close to 180 degree. */ - gpio_set_level(GPIO_LID_OPEN, 1); - msleep(1000); - - cprints(CC_ACCEL, "start loop"); - /* Check we will never enter tablet mode. */ - while (index < kAccelerometerLaptopModeTestDataLength) { - feed_accel_data(kAccelerometerLaptopModeTestData, - &index, filler); - wait_for_valid_sample(); - lid_angle = motion_lid_get_angle(); - cprints(CC_ACCEL, "%d : LID(%d, %d, %d)/BASE(%d, %d, %d): %d", - index / TEST_LID_SAMPLE_SIZE, - lid->xyz[X], lid->xyz[Y], lid->xyz[Z], - base->xyz[X], base->xyz[Y], base->xyz[Z], - lid_angle); - /* We need few sample to debounce and enter laptop mode. */ - TEST_ASSERT(index < TEST_LID_SAMPLE_SIZE * - (TABLET_MODE_DEBOUNCE_COUNT + 2) || - !tablet_get_mode()); - } - - /* Check we will never exit tablet mode. */ - index = 0; - while (index < kAccelerometerFullyOpenTestDataLength) { - feed_accel_data(kAccelerometerFullyOpenTestData, - &index, filler); - wait_for_valid_sample(); - lid_angle = motion_lid_get_angle(); - cprints(CC_ACCEL, "%d : LID(%d, %d, %d)/BASE(%d, %d, %d): %d", - index / TEST_LID_SAMPLE_SIZE, - lid->xyz[X], lid->xyz[Y], lid->xyz[Z], - base->xyz[X], base->xyz[Y], base->xyz[Z], - lid_angle); - TEST_ASSERT(index < TEST_LID_SAMPLE_SIZE * - (TABLET_MODE_DEBOUNCE_COUNT + 2) || - tablet_get_mode()); - } - return EC_SUCCESS; -} - - -void run_test(void) -{ - test_reset(); - - RUN_TEST(test_lid_angle_less180); - - test_print_result(); -} diff --git a/test/motion_angle.tasklist b/test/motion_angle.tasklist deleted file mode 100644 index 0b774ebb4a..0000000000 --- a/test/motion_angle.tasklist +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2014 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST \ - TASK_TEST(MOTIONSENSE, motion_sense_task, NULL, TASK_STACK_SIZE) diff --git a/test/motion_angle_data_literals.c b/test/motion_angle_data_literals.c deleted file mode 100644 index 6c0fcb35c2..0000000000 --- a/test/motion_angle_data_literals.c +++ /dev/null @@ -1,1003 +0,0 @@ -/* Copyright 2018 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include "util.h" - -/* - * Recopied from - * chromium/src/ash/wm/tablet_mode/accelerometer_test_data_literals.cc - * - * The arrays contain actual accelerator readings. - * [ CONFIG_ACCEL_STD_REF_FRAME_OLD must be defined to used this array. ] - */ -const float kAccelerometerLaptopModeTestData[] = { - -0.166016f, -0.00488281f, 0.924805f, -0.770508f, -0.0488281f, - -0.510742f, -0.199219f, -0.0078125f, 0.953125f, -0.782227f, - -0.0244141f, -0.652344f, -0.177734f, -0.0136719f, 0.936523f, - -0.772461f, -0.0527344f, -0.59375f, -0.176758f, -0.00878906f, - 0.9375f, -0.777344f, -0.0419922f, -0.637695f, -0.165039f, - -0.00878906f, 0.942383f, -0.782227f, -0.046875f, -0.613281f, - -0.180664f, -0.00976562f, 0.943359f, -0.777344f, -0.0419922f, - -0.601562f, -0.189453f, -0.00488281f, 0.943359f, -0.776367f, - -0.0263672f, -0.613281f, -0.166992f, -0.00488281f, 0.935547f, - -0.78125f, -0.0380859f, -0.609375f, -0.176758f, -0.00878906f, - 0.947266f, -0.790039f, -0.0576172f, -0.585938f, -0.173828f, - -0.0126953f, 0.93457f, -0.780273f, -0.0654297f, -0.666016f, - -0.169922f, -0.00195312f, 0.928711f, -0.775391f, -0.0351562f, - -0.561523f, -0.193359f, 0.0f, 0.941406f, -0.795898f, - -0.0478516f, -0.640625f, -0.162109f, -0.00585938f, 0.917969f, - -0.768555f, -0.0146484f, -0.685547f, -0.166992f, -0.0136719f, - 0.921875f, -0.755859f, -0.0166016f, -0.425781f, -0.175781f, - -0.0810547f, 1.00098f, -0.802734f, -0.117188f, -0.585938f, - -0.210938f, 0.0214844f, 0.881836f, -0.750977f, -0.0302734f, - -0.677734f, -0.285156f, 0.00976562f, 0.967773f, -0.763672f, - -0.0283203f, -0.850586f, -0.222656f, -0.0136719f, 0.943359f, - -0.763672f, -0.0507812f, -0.640625f, -0.236328f, 0.0859375f, - 0.892578f, -0.742188f, 0.0302734f, -0.484375f, -0.269531f, - 0.0263672f, 0.913086f, -0.714844f, -0.00585938f, -0.745117f, - -0.275391f, 0.0927734f, 0.977539f, -0.776367f, -0.078125f, - -0.750977f, -0.155273f, -0.0341797f, 1.2334f, -1.06445f, - -0.0478516f, -0.823242f, -0.196289f, 0.046875f, 1.19141f, - -1.00391f, -0.140625f, -0.541016f, 0.0917969f, 0.21582f, - 0.717773f, -0.764648f, -0.0341797f, -0.607422f, -0.0351562f, - 0.0888672f, 0.207031f, -0.214844f, -0.18457f, -0.0664062f, - -0.0898438f, 0.0556641f, 0.418945f, -0.232422f, 0.43457f, - 0.0361328f, 0.143555f, 0.376953f, 1.23633f, -1.09082f, - 0.529297f, 0.0507812f, 0.205078f, 0.438477f, 1.66602f, - -1.59668f, 0.325195f, -1.20996f, -0.0791016f, 0.404297f, - 1.50977f, -1.40918f, 0.31543f, -1.30273f, -0.0654297f, - 0.141602f, 0.699219f, -0.589844f, 0.0732422f, -0.27832f, - 0.00488281f, 0.00683594f, 0.0566406f, -0.0410156f, -0.0292969f, - -0.0234375f, -0.0488281f, -0.00195312f, -0.0292969f, 0.0849609f, - -0.139648f, 0.0585938f, 0.677734f, 0.667969f, 1.36523f, - -1.11816f, 0.412109f, 0.844727f, 0.142578f, 0.790039f, - 1.73145f, -1.68066f, 0.464844f, -1.29492f, -0.0800781f, - 0.803711f, 0.879883f, -0.765625f, -0.0400391f, -0.616211f, - -0.170898f, 0.879883f, 0.510742f, 0.158203f, 0.381836f, - -0.270508f, -0.0693359f, 0.651367f, 0.431641f, 0.104492f, - 0.991211f, -0.0634766f, -0.0478516f, 0.750977f, 0.283203f, - -0.0332031f, 1.52051f, -0.00195312f, -0.201172f, 1.08984f, - 0.173828f, 0.0849609f, 1.44141f, -0.214844f, -0.0107422f, - 1.29785f, 0.520508f, 0.00488281f, 1.73047f, -0.523438f, - 0.136719f, 1.42188f, 0.987305f, 0.0527344f, 1.74707f, - -0.525391f, 0.34668f, 0.469727f, 0.428711f, 0.114258f, - -0.788086f, 0.177734f, 0.400391f, -0.106445f, 0.328125f, - -0.566406f, -0.948242f, 0.670898f, 0.467773f, -0.21875f, - 0.55957f, -0.767578f, -0.232422f, 0.195312f, 0.625f, - -0.271484f, 0.865234f, -0.765625f, 0.299805f, 0.0703125f, - 0.378906f, -0.526367f, 0.548828f, -0.231445f, -0.569336f, - 0.455078f, 0.303711f, -0.866211f, -0.485352f, 0.566406f, - -1.60547f, 0.481445f, 0.183594f, -0.782227f, -0.260742f, - 0.243164f, -1.41504f, 0.373047f, 0.172852f, -0.935547f, - -0.412109f, 0.133789f, -1.69727f, 0.178711f, 0.407227f, - -0.952148f, -0.227539f, 0.0751953f, -1.67188f, 0.339844f, - 0.498047f, -0.795898f, 0.209961f, 0.177734f, -1.3916f, - 0.458984f, 0.295898f, 0.0390625f, 0.697266f, 0.258789f, - -0.0703125f, -0.131836f, 0.56543f, 0.250977f, 0.913086f, - -0.353516f, 0.90332f, 0.191406f, 0.708008f, 0.352539f, - 0.853516f, -0.839844f, 0.955078f, 0.636719f, 0.657227f, - 0.389648f, 0.620117f, -0.725586f, 0.43457f, 0.485352f, - 0.424805f, 0.479492f, 0.287109f, -0.505859f, -0.209961f, - 0.0927734f, 0.21582f, 0.709961f, 0.492188f, -0.413086f, - -0.0869141f, 0.0673828f, -0.119141f, 1.20508f, 0.392578f, - 0.229492f, 0.927734f, -0.297852f, 0.142578f, 1.0293f, - 0.430664f, 0.0449219f, 1.71875f, -0.0283203f, 0.0107422f, - 1.18164f, 0.0517578f, 0.0751953f, 1.80273f, -0.0693359f, - -0.19043f, 1.1748f, 0.236328f, 0.0839844f, 1.78711f, - -0.472656f, -0.270508f, 1.10254f, 0.964844f, 0.118164f, - 1.75684f, -0.901367f, -0.211914f, 1.11133f, 0.65625f, - 0.308594f, 0.142578f, 0.396484f, 0.239258f, 0.0800781f, - 0.973633f, -0.824219f, -0.25293f, 0.485352f, 0.351562f, - -0.0771484f, 1.08984f, -0.632812f, 0.240234f, -0.258789f, - 0.436523f, -0.514648f, 0.491211f, 0.0664062f, -0.244141f, - -0.148438f, -0.171875f, -0.477539f, -0.459961f, 1.1084f, - -0.822266f, -0.114258f, -0.192383f, -0.608398f, -0.771484f, - 1.11133f, -1.25488f, 1.01953f, -0.0839844f, -0.620117f, - -0.794922f, 0.660156f, -0.876953f, 0.0957031f, -0.242188f, - -0.711914f, -0.55957f, 0.736328f, -0.649414f, -0.0263672f, - -0.258789f, -0.498047f, -0.973633f, 0.957031f, -0.660156f, - 0.186523f, -0.262695f, -0.595703f, -0.787109f, 0.893555f, - -0.429688f, -0.0234375f, -0.254883f, -0.449219f, -0.783203f, - 0.90918f, 0.106445f, -0.161133f, -0.287109f, -0.0800781f, - -0.729492f, 0.933594f, -0.126953f, -0.0742188f, -0.550781f, - -0.271484f, -0.989258f, 1.00098f, -0.879883f, 0.0234375f, - -0.543945f, -0.50293f, -1.18945f, 1.24023f, -1.33398f, - 0.325195f, -0.262695f, -0.307617f, -0.912109f, 1.39062f, - -1.06055f, 0.0107422f, -0.00292969f, -0.573242f, -0.4375f, - 1.15625f, -0.651367f, -0.310547f, 0.188477f, -0.730469f, - -0.121094f, 0.611328f, -0.779297f, 0.335938f, 0.731445f, - -0.475586f, -0.00390625f, 0.100586f, -0.693359f, 0.254883f, - 0.813477f, -0.345703f, 0.420898f, -0.400391f, -0.539062f, - 0.365234f, 0.720703f, 0.0214844f, 0.673828f, -0.370117f, - 0.0585938f, 0.499023f, 0.523438f, 0.198242f, 0.759766f, - -0.544922f, 0.543945f, 0.226562f, 0.473633f, 0.34082f, - 0.595703f, -0.682617f, 0.292969f, -0.217773f, 0.0742188f, - 0.553711f, 0.762695f, -0.504883f, 0.292969f, 0.0751953f, - 0.0126953f, 0.427734f, 0.769531f, -0.265625f, 0.552734f, - -0.0175781f, -0.30957f, 0.253906f, 0.322266f, 0.117188f, - 0.263672f, -0.706055f, -0.991211f, 0.266602f, 0.501953f, - 0.00585938f, 0.0341797f, -1.24805f, -1.21777f, 0.488281f, - 0.461914f, 0.0986328f, 0.362305f, -1.1709f, -1.17188f, - 0.50293f, 0.458984f, 0.108398f, 0.460938f, -1.52148f, - -1.27051f, 0.379883f, 0.90625f, 0.0400391f, 0.524414f, - -1.77832f, -0.951172f, 0.397461f, 0.589844f, 0.520508f, - 0.439453f, -1.99902f, -0.643555f, 0.313477f, 0.766602f, - 0.450195f, 0.286133f, -1.29883f, -0.375f, 0.225586f, - 0.697266f, 0.299805f, 0.108398f, -0.976562f, 0.09375f, - 0.0361328f, 0.851562f, -0.210938f, 0.0615234f, -0.0898438f, - 0.59082f, 0.313477f, 0.756836f, -0.731445f, 0.296875f, - -0.0927734f, 0.552734f, 0.223633f, 0.558594f, -0.806641f, - 0.00195312f, 0.03125f, 0.728516f, 0.276367f, 0.744141f, - -0.994141f, 0.197266f, -0.425781f, 0.316406f, 0.046875f, - 0.601562f, -0.633789f, -0.0576172f, -0.320312f, 0.786133f, - 0.0986328f, 1.0f, -1.19922f, 0.34668f, -0.546875f, - 0.481445f, 0.00390625f, 0.876953f, -1.04297f, -0.0507812f, - -0.775391f, 0.333984f, -0.0175781f, 1.02539f, -1.07129f, - -0.12207f, -0.212891f, 0.28125f, 0.00488281f, 0.998047f, - -0.97168f, 0.178711f, -0.444336f, 0.178711f, 0.0136719f, - 0.896484f, -0.9375f, 0.0117188f, -0.291992f, 0.132812f, - 0.0234375f, 0.975586f, -0.943359f, -0.0078125f, 0.0546875f, - 0.244141f, -0.0771484f, 1.05469f, -1.02148f, 0.313477f, - -0.349609f, 0.148438f, 0.0839844f, 0.619141f, -0.75f, - -0.589844f, -0.0488281f, 0.0263672f, -0.176758f, 0.697266f, - -0.691406f, -0.625977f, -0.417969f, 0.408203f, 0.265625f, - 1.01953f, -1.09863f, 0.106445f, 0.0117188f, 0.157227f, - 0.424805f, 1.07422f, -0.816406f, 0.498047f, 0.0996094f, - 0.00585938f, 0.53418f, 0.771484f, -0.610352f, 0.744141f, - 0.0195312f, 0.0478516f, 0.552734f, 0.734375f, -0.72168f, - 0.518555f, -0.144531f, -0.0361328f, 0.513672f, 0.822266f, - -0.736328f, 0.65918f, -0.179688f, -0.104492f, 0.425781f, - 1.00098f, -0.885742f, 0.739258f, -0.681641f, -0.443359f, - 0.375977f, 0.884766f, -0.724609f, 0.110352f, -0.289062f, - -0.414062f, 0.494141f, 0.53125f, -0.422852f, 0.216797f, - -0.786133f, -0.569336f, 0.749023f, 0.75293f, -0.529297f, - 0.730469f, -0.911133f, -0.68457f, 0.611328f, 0.959961f, - -0.623047f, 1.06543f, -0.499023f, -0.392578f, 0.761719f, - 0.43457f, -0.357422f, 0.631836f, -0.746094f, -0.370117f, - 0.777344f, 0.379883f, -0.225586f, 0.677734f, -0.478516f, - -0.358398f, 0.788086f, 0.569336f, -0.34082f, 0.939453f, - -0.238281f, -0.230469f, 0.861328f, 0.448242f, -0.219727f, - 0.966797f, -0.310547f, -0.242188f, 0.863281f, 0.369141f, - -0.0859375f, 0.87207f, -0.400391f, -0.385742f, 0.841797f, - 0.401367f, -0.0634766f, 0.912109f, -0.458008f, 0.0107422f, - 0.753906f, 0.758789f, -0.675781f, 0.765625f, -0.342773f, - -0.123047f, 0.855469f, 0.599609f, -0.490234f, 0.963867f, - -0.118164f, -0.0117188f, 0.889648f, 0.637695f, -0.607422f, - 0.803711f, -0.597656f, -0.242188f, 0.855469f, 0.550781f, - -0.607422f, 0.576172f, -0.759766f, -0.220703f, 0.832031f, - 0.477539f, -0.491211f, 0.470703f, -0.575195f, -0.0869141f, - 1.01074f, 0.371094f, -0.25293f, 0.678711f, -0.316406f, - -0.197266f, 1.04785f, 0.386719f, -0.046875f, 0.967773f, - -0.761719f, -0.282227f, 0.956055f, 0.270508f, 0.230469f, - 1.39746f, -0.864258f, -0.417969f, 0.761719f, 0.457031f, - 0.0263672f, 1.38379f, -0.714844f, -0.288086f, 0.535156f, - 0.689453f, -0.507812f, 0.68457f, -0.433594f, -0.0908203f, - 0.210938f, 0.825195f, -0.649414f, 0.326172f, -0.793945f, - 0.0527344f, 0.0546875f, 0.911133f, -0.616211f, -0.0214844f, - -0.00195312f, -0.229492f, -0.0253906f, 0.775391f, -0.611328f, - -0.360352f, 0.0371094f, 0.161133f, 0.0253906f, 0.625f, - -0.624023f, -0.344727f, -0.146484f, 0.371094f, 0.255859f, - 1.41797f, -1.27832f, 0.614258f, 0.764648f, 0.869141f, - 0.426758f, 0.758789f, -1.04395f, 0.401367f, 0.263672f, - 0.563477f, 0.450195f, 0.774414f, -0.908203f, 0.384766f, - -0.262695f, 0.664062f, 0.509766f, 0.798828f, -0.757812f, - 0.770508f, 0.491211f, 0.62207f, 0.487305f, 0.496094f, - -0.530273f, 0.375977f, 1.18652f, 0.736328f, 0.386719f, - 0.470703f, -0.647461f, 0.379883f, 0.47168f, 0.834961f, - 0.289062f, 0.475586f, -0.654297f, 0.448242f, 0.395508f, - 0.930664f, 0.0830078f, 0.157227f, -0.304688f, 0.0634766f, - 1.30078f, 0.905273f, -0.102539f, 0.0576172f, -0.303711f, - -0.334961f, 0.885742f, 0.709961f, -0.143555f, 0.0390625f, - -0.18457f, -0.498047f, 1.1084f, 0.744141f, 0.0283203f, - 0.383789f, -0.371094f, -0.126953f, 1.17285f, 0.506836f, - 0.109375f, 0.680664f, -0.244141f, -0.0830078f, 0.577148f, - 0.12793f, 0.25f, 0.972656f, -0.328125f, 0.34082f, - -0.234375f, -0.327148f, 0.470703f, 0.987305f, -0.535156f, - 0.730469f, -0.957031f, -0.509766f, 0.602539f, 0.938477f, - -0.640625f, 0.836914f, -1.13672f, -0.56543f, 0.450195f, - 0.737305f, -0.449219f, 0.649414f, -1.08105f, -0.364258f, - 0.338867f, 0.667969f, -0.533203f, 0.654297f, -1.0918f, - -0.505859f, 0.422852f, 0.745117f, -0.443359f, 0.319336f, - -0.753906f, -0.563477f, 0.374023f, 0.640625f, -0.435547f, - 0.220703f, -0.868164f, -0.701172f, 0.317383f, 0.702148f, - -0.527344f, 0.138672f, -0.848633f, -0.431641f, 0.220703f, - 0.329102f, -0.25293f, -0.232422f, -0.875977f, -0.442383f, - 0.550781f, 0.783203f, -0.441406f, 0.160156f, -0.107422f, - 0.0683594f, 0.317383f, 1.12012f, -1.02344f, 0.322266f, - -0.469727f, -0.151367f, 0.43457f, 0.65625f, -0.745117f, - 0.216797f, -1.03223f, -0.200195f, 0.240234f, 1.11035f, - -0.90332f, 0.239258f, 0.0429688f, -0.228516f, 0.00390625f, - 0.836914f, -0.770508f, -0.280273f, -0.18457f, 0.0117188f, - 0.214844f, 0.767578f, -0.774414f, -0.0703125f, -0.954102f, - -0.508789f, -0.046875f, 1.00391f, -0.930664f, 0.0292969f, - 0.407227f, -0.519531f, 0.0361328f, 0.753906f, -0.777344f, - -0.0214844f, 0.741211f, -0.27832f, -0.0332031f, 1.15625f, - -0.862305f, -0.115234f, 0.821289f, -0.598633f, 0.00488281f, - 0.929688f, -1.01172f, -0.0996094f, 0.351562f, -0.524414f, - 0.118164f, 1.1709f, -0.938477f, 0.00878906f, 0.948242f, - -0.475586f, 0.443359f, 0.893555f, -0.597656f, 0.0107422f, - 0.558594f, -0.87207f, 0.0810547f, 0.487305f, -0.808594f, - 0.212891f, 0.0878906f, -0.612305f, 0.263672f, 0.400391f, - -0.709961f, 0.380859f, -0.0839844f, -0.566406f, 0.466797f, - 0.445312f, -0.769531f, 0.636719f, -0.273438f, -0.648438f, - 0.34375f, 0.56543f, -0.829102f, 0.417969f, -0.272461f, - -0.746094f, 0.202148f, 0.421875f, -0.445312f, 0.229492f, - 0.178711f, -0.408203f, 0.477539f, 0.693359f, -0.675781f, - 0.145508f, 0.37207f, -0.576172f, 0.0449219f, 0.845703f, - -0.920898f, -0.0185547f, 0.487305f, -0.460938f, 0.0253906f, - 1.04785f, -0.87207f, 0.176758f, 0.356445f, -0.217773f, - 0.0332031f, 0.945312f, -0.556641f, -0.110352f, 0.725586f, - 0.0810547f, -0.0361328f, 1.11426f, -0.396484f, 0.00488281f, - 0.743164f, 0.27832f, 0.0175781f, 0.839844f, -0.0371094f, - -0.00878906f, 0.964844f, 0.547852f, 0.0224609f, 0.518555f, - 0.386719f, -0.0585938f, 1.11816f, 0.712891f, 0.19043f, - 0.523438f, 0.429688f, -0.179688f, 1.18164f, 0.40332f, - 0.241211f, 1.19043f, -0.0234375f, 0.119141f, 0.90918f, - -0.078125f, 0.250977f, 0.973633f, -0.277344f, 0.227539f, - 0.908203f, -0.232422f, 0.269531f, 0.807617f, -0.59668f, - 0.253906f, 0.398438f, -0.506836f, 0.255859f, 0.694336f, - -0.742188f, 0.345703f, 0.412109f, -0.576172f, 0.189453f, - 0.708984f, -0.808594f, 0.230469f, 0.242188f, -0.550781f, - 0.0693359f, 0.695312f, -0.856445f, -0.0253906f, 0.177734f, - -0.6875f, -0.00976562f, 0.731445f, -0.991211f, -0.03125f, - 0.0175781f, -0.805664f, -0.192383f, 0.827148f, -0.947266f, - 0.0820312f, 0.254883f, -0.504883f, -0.259766f, 0.87207f, - -0.693359f, -0.345703f, 0.639648f, -0.162109f, -0.443359f, - 1.05176f, -0.595703f, -0.496094f, 0.485352f, -0.0380859f, - -0.490234f, 0.763672f, -0.382812f, -0.634766f, 0.369141f, - 0.136719f, -0.650391f, 0.536133f, -0.126953f, -0.901367f, - 0.275391f, 0.155273f, -0.75293f, 0.476562f, -0.183594f, - -1.00488f, 0.206055f, -0.0908203f, -1.06836f, 0.3125f, - -0.183594f, -1.30762f, 0.37793f, -0.185547f, -0.885742f, - 0.496094f, -0.250977f, -1.14941f, 0.0517578f, -0.242188f, - -0.753906f, 0.395508f, -0.133789f, -1.10156f, 0.183594f, - -0.398438f, -0.767578f, 0.951172f, -0.359375f, -0.866211f, - 0.373047f, -0.0224609f, -0.0537109f, 0.921875f, -0.263672f, - -0.251953f, 0.455078f, 0.230469f, 0.485352f, 0.84082f, - 0.0351562f, 0.0810547f, 0.554688f, 0.186523f, 0.774414f, - 0.720703f, 0.381836f, 0.71875f, 0.495117f, 0.530273f, - 0.771484f, 0.90332f, 0.34668f, 0.897461f, 0.456055f, - 0.575195f, 0.560547f, 0.133789f, 0.62793f, 0.795898f, - 0.400391f, 0.594727f, 0.577148f, -0.142578f, 0.691406f, - 0.770508f, 0.12793f, 0.679688f, 0.751953f, -0.201172f, - 0.728516f, 0.805664f, -0.0175781f, 0.46875f, 0.655273f, - -0.608398f, 0.750977f, 0.540039f, -0.0166016f, 0.30957f, - 0.755859f, -0.563477f, 0.609375f, 0.763672f, -0.310547f, - 0.0791016f, 0.668945f, -0.575195f, 0.398438f, 0.767578f, - -0.47168f, -0.12793f, 0.631836f, -0.768555f, 0.293945f, - 0.760742f, -0.743164f, -0.311523f, 0.509766f, -0.755859f, - 0.15918f, 0.614258f, -0.832031f, -0.575195f, 0.448242f, - -0.771484f, -0.0605469f, 0.341797f, -0.652344f, -0.8125f, - 0.262695f, -0.205078f, -0.541992f, 0.337891f, -0.8125f, - -1.20996f, 0.179688f, -0.311523f, -0.682617f, 0.0556641f, - -0.944336f, -1.29102f, 0.09375f, 0.503906f, -0.87793f, - -0.0742188f, -0.805664f, -1.53613f, -0.107422f, 0.50293f, - -0.807617f, -0.423828f, 0.0888672f, -0.847656f, -0.342773f, - 0.719727f, -0.87793f, -0.336914f, 0.115234f, -0.500977f, - -0.487305f, 0.395508f, -0.398438f, -0.624023f, 0.3125f, - -0.0693359f, -0.605469f, 0.429688f, -0.283203f, -0.813477f, - 0.246094f, 0.0898438f, -0.764648f, 0.356445f, -0.106445f, - -1.05371f, 0.595703f, 0.251953f, -0.729492f, 0.336914f, - -0.0595703f, -1.06445f, 0.824219f, 0.320312f, -0.50293f, - 0.459961f, -0.161133f, -0.820312f, 0.516602f, 0.410156f, - -0.401367f, 0.407227f, -0.106445f, -0.740234f, 0.546875f, - 0.663086f, -0.170898f, 0.574219f, -0.419922f, -0.271484f, - -0.0273438f, 0.239258f, -0.0361328f, 0.80957f, -0.576172f, - 0.0664062f, 0.0332031f, 0.181641f, 0.245117f, 1.06641f, - -0.826172f, 0.30957f, -0.241211f, 0.03125f, 0.422852f, - 1.14648f, -0.916992f, 0.672852f, -0.242188f, 0.0234375f, - 0.425781f, 1.16895f, -1.08887f, 0.748047f, -0.384766f, - 0.102539f, 0.457031f, 0.992188f, -0.896484f, 0.65625f, - -0.144531f, 0.0332031f, 0.295898f, 0.8125f, -0.706055f, - 0.166016f, -0.237305f, 0.0996094f, 0.130859f, 0.723633f, - -0.769531f, -0.125f, -0.339844f, -0.277344f, -0.00390625f, - 1.2959f, -0.999023f, 0.0185547f, 0.0527344f, 0.270508f, - 0.104492f, 1.05469f, -1.0918f, 0.205078f, 0.00390625f, - 0.141602f, 0.000976562f, 1.15039f, -1.14844f, 0.0664062f, - -0.0566406f, 0.0732422f, 0.0302734f, 1.08398f, -1.04004f, - 0.124023f, -0.114258f, 0.19043f, 0.0263672f, 0.985352f, - -1.00293f, 0.0634766f, -0.0585938f, 0.257812f, -0.0527344f, - 0.96875f, -0.990234f, -0.0361328f, -0.179688f, 0.266602f, - -0.219727f, 0.882812f, -0.879883f, -0.289062f, -0.00292969f, - 0.351562f, -0.313477f, 0.826172f, -0.84668f, -0.322266f, - 0.337891f, 0.478516f, -0.426758f, 0.594727f, -0.621094f, - -0.435547f, 0.676758f, 0.47168f, -0.432617f, 0.333008f, - -0.338867f, -0.767578f, 0.419922f, 0.576172f, -0.673828f, - 0.321289f, -0.53125f, -0.96582f, 0.290039f, 0.426758f, - -0.526367f, 0.230469f, -0.508789f, -1.05859f, 0.195312f, - 0.493164f, -0.479492f, 0.78418f, -0.992188f, -0.453125f, - -0.185547f, 0.375977f, -0.291992f, 0.77832f, -0.884766f, - -0.361328f, 0.438477f, -0.118164f, -0.222656f, 0.923828f, - -0.796875f, 0.0234375f, -0.375f, 0.0332031f, -0.216797f, - 0.908203f, -0.984375f, -0.295898f, -0.384766f, 0.0234375f, - -0.305664f, 1.12695f, -1.04004f, -0.344727f, -0.136719f, - 0.119141f, -0.385742f, 1.06738f, -1.01855f, -0.245117f, - -0.106445f, -0.114258f, -0.365234f, 0.962891f, -0.923828f, - -0.430664f, -0.637695f, -0.347656f, -0.436523f, 0.702148f, - -0.547852f, -0.618164f, -0.447266f, -0.241211f, -0.462891f, - 0.729492f, -0.609375f, -0.578125f, -0.486328f, -0.0556641f, - -0.536133f, 0.50293f, -0.480469f, -0.526367f, -0.210938f, - -0.0585938f, -0.637695f, 0.723633f, -0.319336f, -0.348633f, - -0.00292969f, -0.305664f, -0.629883f, 0.431641f, 0.266602f, - -0.612305f, -0.260742f, 0.0166016f, -0.65332f, -0.272461f, - 0.800781f, -1.09863f, -0.166992f, -0.0859375f, -0.520508f, - -0.473633f, 0.586914f, -0.696289f, -0.682617f, -0.149414f, - 0.198242f, -0.805664f, 1.1377f, 0.444336f, -0.458984f, - -0.577148f, 0.522461f, -0.683594f, 1.25586f, 0.827148f, - -0.249023f, -0.851562f, 0.84668f, -0.448242f, 1.26953f, - 0.855469f, -0.155273f, -0.765625f, 1.0f, -0.337891f, - 0.973633f, 0.660156f, -0.0859375f, -0.476562f, 1.11035f, - -0.00976562f, 0.547852f, 0.958984f, -0.34082f, -0.504883f, - 0.853516f, 0.0664062f, 0.378906f, 0.758789f, -0.749023f, - -0.509766f, 0.739258f, 0.499023f, -0.144531f, 0.84668f, - -0.931641f, -0.329102f, 0.740234f, 0.791992f, -0.168945f, - 0.594727f, -0.435547f, -0.268555f, 0.336914f, 0.817383f, - -0.430664f, -0.0253906f, -0.735352f, -0.0683594f, 0.152344f, - 0.725586f, -0.68457f, -0.294922f, -1.25391f, -0.125f, - 0.0917969f, 0.907227f, -0.633789f, -0.28125f, -0.222656f, - 0.0f, 0.188477f, 1.06445f, -0.929688f, 0.144531f, - -0.139648f, -0.00390625f, -0.21582f, 1.21387f, -0.952148f, - -0.0253906f, -0.389648f, 0.148438f, -0.283203f, 1.14844f, - -0.890625f, -0.204102f, -0.222656f, -0.0332031f, -0.451172f, - 0.625f, -0.486328f, -0.716797f, -0.103516f, 0.265625f, - -0.667969f, 0.231445f, -0.385742f, -0.977539f, 0.111328f, - 0.222656f, -0.766602f, 0.300781f, -0.390625f, -1.07129f, - 0.230469f, 0.318359f, -0.787109f, 0.427734f, -0.512695f, - -0.886719f, 0.240234f, 0.260742f, -0.647461f, 0.566406f, - -0.686523f, -0.723633f, -0.198242f, 0.0722656f, -0.3125f, - 0.771484f, -0.725586f, -0.478516f, -0.176758f, -0.113281f, - -0.262695f, 0.78125f, -0.644531f, -0.210938f, -0.0126953f, - -0.317383f, 0.0673828f, 0.944336f, -0.764648f, 0.1875f, - -0.636719f, -0.401367f, 0.118164f, 0.982422f, -0.826172f, - 0.105469f, -1.0625f, -0.298828f, 0.0537109f, 0.949219f, - -0.788086f, 0.176758f, -0.611328f, -0.0322266f, 0.0439453f, - 0.885742f, -0.730469f, 0.301758f, -0.463867f, -0.144531f, - -0.180664f, 1.08398f, -0.97168f, -0.470703f, 0.128906f, - 0.0146484f, -0.112305f, 0.889648f, -0.946289f, -0.165039f, - -1.34277f, -0.258789f, -0.211914f, 0.962891f, -0.844727f, - -0.588867f, 0.144531f, -0.228516f, -0.207031f, 0.974609f, - -0.848633f, -0.0273438f, -0.570312f, -0.228516f, 0.00195312f, - 1.03125f, -0.977539f, -0.0605469f, -0.733398f, -0.0908203f, - 0.0996094f, 0.856445f, -0.854492f, -0.000976562f, -0.458008f, - -0.135742f, 0.222656f, 1.34082f, -1.13574f, 0.639648f, - 0.015625f, -0.234375f, 0.136719f, 0.835938f, -0.822266f, - -0.114258f, -0.673828f, -0.186523f, 0.169922f, 0.925781f, - -0.839844f, 0.175781f, -0.394531f, 0.224609f, -0.0458984f, - 0.94043f, -0.964844f, -0.0556641f, -0.15332f, 0.163086f, - -0.0175781f, 0.944336f, -0.951172f, -0.0478516f, -0.302734f, - 0.117188f, -0.00683594f, 0.973633f, -0.970703f, -0.0810547f, - -0.301758f, 0.09375f, -0.000976562f, 1.01953f, -0.978516f, - 0.0292969f, -0.293945f, 0.0683594f, -0.00683594f, 1.0127f, - -0.966797f, -0.0175781f, -0.314453f, 0.181641f, 0.0126953f, - 0.982422f, -0.990234f, 0.03125f, -0.194336f, 0.155273f, - -0.00292969f, 0.962891f, -0.932617f, -0.00390625f, -0.0976562f, - 0.144531f, -0.0205078f, 0.913086f, -0.914062f, -0.0908203f, - -0.296875f, 0.166992f, -0.015625f, 0.930664f, -0.950195f, - -0.0888672f, -0.28418f, 0.196289f, -0.0107422f, 0.953125f, - -0.960938f, -0.0273438f, -0.195312f, 0.125f, 0.0126953f, - 0.986328f, -0.951172f, 0.0634766f, -0.231445f, 0.162109f, - -0.0136719f, 0.981445f, -0.974609f, -0.0449219f, -0.0761719f, - 0.186523f, -0.015625f, 0.950195f, -0.962891f, -0.0576172f, - -0.162109f, 0.154297f, -0.0292969f, 0.970703f, -0.973633f, - -0.0136719f, -0.394531f, 0.102539f, -0.00878906f, 0.970703f, - -0.915039f, 0.0546875f, -0.313477f, 0.110352f, -0.0234375f, - 0.947266f, -0.922852f, -0.139648f, -0.181641f, 0.12207f, - 0.0625f, 0.780273f, -0.899414f, -0.84375f, -0.0888672f, - -0.318359f, 1.00781f, 0.888672f, 0.27832f, 0.0195312f, - -1.08594f, 0.137695f, 0.56543f, 1.12891f, -0.235352f, - 1.65039f, -0.0820312f, 0.100586f, 0.987305f, 0.261719f, - -0.0615234f, 1.32227f, 0.669922f, 0.0f, 1.04102f, - 0.231445f, -0.174805f, 1.11426f, -0.261719f, -0.0527344f, - 0.958008f, 0.332031f, -0.28418f, 1.26953f, -0.612305f, - 0.208984f, 0.964844f, 1.15625f, -0.486328f, 2.0f, - -0.760742f, 0.0458984f, 1.44629f, 1.21289f, 0.924805f, - 1.1875f, -0.259766f, 0.114258f, 0.210938f, 0.486328f, - -0.422852f, -0.984375f, 1.08789f, 0.453125f, -0.229492f, - 0.457031f, -0.682617f, -0.500977f, 0.210938f, 0.391602f, - -0.303711f, 0.725586f, -0.80957f, -0.391602f, 0.0976562f, - 0.958984f, 0.0185547f, 1.69922f, -1.36035f, 1.98242f, - -0.392578f, -0.461914f, -0.37793f, -0.0712891f, 0.928711f, - -1.60254f, 0.133789f, -0.0419922f, -1.12109f, -0.201172f, - 0.0732422f, -1.99902f, 0.629883f, -0.174805f, -0.894531f, - 0.0742188f, -0.147461f, -1.23633f, -0.259766f, 0.0410156f, - -1.00879f, -0.0166016f, -0.0205078f, -1.99902f, 0.267578f, - -0.0664062f, -0.164062f, 0.511719f, 0.825195f, -1.21191f, - -0.515625f, 0.46875f, 0.0898438f, 1.09766f, -0.144531f, - 1.59375f, 0.166016f, 0.428711f, 0.294922f, 0.8125f, - -0.770508f, 0.535156f, 0.280273f, 0.231445f, 0.504883f, - 0.864258f, -0.884766f, 0.524414f, -0.183594f, 0.0820312f, - 0.713867f, 0.405273f, -0.520508f, -0.326172f, 0.0126953f, - -0.310547f, 1.38086f, 0.831055f, 0.380859f, 1.3125f, - -1.60645f, 0.151367f, 1.01953f, 0.580078f, -0.0283203f, - 2.0f, 1.03516f, -0.0634766f, 1.03418f, 0.332031f, - -0.0859375f, 1.32129f, -0.234375f, 0.0917969f, 1.49219f, - 0.30957f, -0.118164f, 1.76953f, -0.717773f, 0.174805f, - 1.59863f, 0.0947266f, 1.1875f, 0.429688f, 0.442383f, - 0.00976562f, 0.435547f, 0.345703f, -0.114258f, 0.238281f, - -0.689453f, 0.30957f, 0.0732422f, 0.606445f, -0.650391f, - -0.0947266f, -0.03125f, 0.183594f, -0.144531f, 0.746094f, - -0.793945f, -0.574219f, -0.0742188f, 0.196289f, -0.199219f, - 1.13867f, -1.11816f, -0.227539f, -0.462891f, 0.0517578f, - -0.0341797f, 1.18945f, -1.1084f, -0.0283203f, -0.342773f, - 0.174805f, -0.0078125f, 1.05176f, -1.03906f, 0.0253906f, - -0.375977f, -0.169922f, 0.00292969f, 0.837891f, -0.716797f, - -0.0205078f, -0.373047f, 0.293945f, 0.0175781f, 0.833984f, - -0.916016f, -0.0996094f, -0.149414f, 0.200195f, -0.00195312f, - 0.865234f, -0.916016f, -0.0117188f, -0.390625f, 0.290039f, - 0.0234375f, 0.985352f, -0.987305f, 0.0439453f, -0.214844f, - 0.0917969f, 0.0615234f, 1.02832f, -1.00684f, 0.152344f, - -0.452148f, 0.0615234f, -0.00585938f, 1.02148f, -0.976562f, - -0.0927734f, -0.286133f, 0.189453f, -0.0644531f, 1.02539f, - -1.02246f, 0.0166016f, -0.243164f, 0.109375f, -0.09375f, - 0.981445f, -0.931641f, 0.0458984f, -0.460938f, 0.0537109f, - -0.0429688f, 1.05859f, -0.850586f, 0.0771484f, -0.0507812f, - 0.108398f, -0.177734f, 0.779297f, -0.74707f, -0.378906f, - -0.413086f, -0.205078f, -0.0488281f, 0.946289f, -0.760742f, - -0.180664f, -0.228516f, -0.208008f, -0.0615234f, 1.05371f, - -0.953125f, -0.34668f, -1.16797f, -0.0322266f, -0.276367f, - 1.06641f, -0.863281f, -0.0244141f, -0.290039f, -0.0429688f, - 0.0439453f, 1.28223f, -1.06348f, 0.181641f, -0.514648f, - -0.0214844f, 0.0f, 0.861328f, -0.738281f, -0.0449219f, - 0.0722656f, 0.125f, 0.193359f, 1.15039f, -1.0957f, - 0.225586f, -0.137695f, 0.12207f, -0.0400391f, 0.732422f, - -0.818359f, -0.40918f, -0.672852f, -0.425781f, 0.839844f, - 0.856445f, 0.198242f, -0.363281f, 0.206055f, -0.214844f, - 1.20215f, 0.943359f, 0.0195312f, 2.0f, 0.874023f, - 0.0839844f, 0.827148f, 0.587891f, -0.384766f, 1.57715f, - 0.108398f, -0.116211f, 0.952148f, 0.246094f, -0.336914f, - 0.463867f, -0.740234f, 0.0185547f, 0.950195f, 0.55957f, - -0.442383f, 1.09668f, 0.0585938f, 0.132812f, 1.37695f, - 2.0f, -0.59375f, 2.0f, -0.676758f, -0.199219f, - -0.0205078f, 0.268555f, -0.5f, -1.94629f, 1.2832f, - 0.0078125f, -0.201172f, 0.674805f, -0.708984f, -0.490234f, - -0.515625f, 0.0439453f, -0.0830078f, 1.14355f, -1.01953f, - -0.0224609f, -0.282227f, 0.0214844f, -0.078125f, 1.09668f, - -0.961914f, 0.0253906f, -0.56543f, 0.30957f, 0.964844f, - 1.56836f, -0.272461f, 1.91309f, -0.53418f, -0.695312f, - -0.878906f, -0.0146484f, 0.277344f, -1.6416f, 0.0244141f, - 0.0898438f, -0.785156f, 0.229492f, -0.259766f, -1.06055f, - -0.241211f, 0.0224609f, -0.769531f, 0.748047f, -0.680664f, - -0.629883f, -0.549805f, -0.195312f, -0.796875f, -0.399414f, - 0.0859375f, -1.99902f, 0.24707f, 0.208984f, 0.563477f, - 1.91797f, 0.0585938f, 2.0f, -0.990234f, 0.327148f, - -0.0917969f, 1.16797f, -0.94043f, 0.623047f, -1.1748f, - -0.0205078f, -0.0449219f, 0.883789f, -0.905273f, -0.370117f, - -0.601562f, 0.0332031f, -0.0527344f, 0.928711f, -0.833984f, - -0.180664f, -0.267578f, 0.0351562f, -0.0175781f, 0.998047f, - -0.922852f, -0.000976562f, -0.371094f, 0.0341797f, -0.0166016f, - 0.977539f, -0.900391f, -0.00292969f, -0.37207f, 0.0449219f, - -0.0439453f, 0.989258f, -0.904297f, -0.0576172f, -0.37207f, - 0.270508f, -0.368164f, 0.0576172f, -0.607422f, -1.95508f, - -0.182617f, -0.390625f, 1.62598f, 1.52734f, 1.2793f, - 2.0f, -1.99902f, 0.226562f, 1.01465f, 0.669922f, - -0.373047f, 1.71484f, 1.99707f, -0.0654297f, 1.00391f, - 0.330078f, -0.432617f, 0.704102f, -0.96875f, 0.0800781f, - 0.964844f, 0.702148f, -0.5625f, 1.39746f, -0.203125f, - 0.255859f, 1.74512f, 1.52539f, 0.417969f, 2.0f, - -0.0976562f, -0.482422f, 0.09375f, 0.151367f, -0.328125f, - -1.88867f, -0.0595703f, 0.117188f, 0.0751953f, 0.870117f, - -0.870117f, 0.046875f, -0.280273f, 0.125f, 0.124023f, - 1.0791f, -0.964844f, 0.338867f, -0.0791016f, 0.0751953f, - 0.12207f, 0.920898f, -0.888672f, 0.0273438f, -0.250977f, - 0.00488281f, 0.165039f, 1.01074f, -0.944336f, 0.137695f, - -0.387695f, -0.142578f, 0.238281f, 1.77246f, -1.42285f, - 0.90625f, -0.856445f, 0.0556641f, -0.219727f, -0.785156f, - 1.47266f, -1.99902f, 1.27246f, -0.132812f, -0.746094f, - 0.172852f, -0.0830078f, -1.3584f, 0.638672f, 0.0175781f, - -0.786133f, 0.754883f, -0.729492f, -0.808594f, -0.291992f, - 0.170898f, -0.746094f, 0.623047f, -0.667969f, -0.743164f, - -0.241211f, 0.0693359f, -0.725586f, 0.495117f, -0.545898f, - -0.969727f, -0.131836f, 0.0234375f, -0.52832f, 0.280273f, - -0.327148f, -1.0498f, -0.210938f, -0.253906f, 0.234375f, - 0.661133f, -0.0332031f, -0.708008f, -0.458984f, 0.31543f, - 0.480469f, 1.59082f, -1.22266f, 1.41602f, -0.270508f, - 0.263672f, 0.318359f, 1.21289f, -1.12207f, 0.853516f, - -0.272461f, 0.158203f, 1.84766f, 2.0f, 0.341797f, - 2.0f, -0.788086f, -0.264648f, -0.326172f, -1.25977f, - 0.842773f, -1.99902f, -0.947266f, 0.249023f, -0.642578f, - 0.745117f, -0.744141f, -0.404297f, -0.266602f, 0.0898438f, - -0.568359f, 0.501953f, -0.494141f, -0.858398f, 0.0722656f, - -0.543945f, 1.16895f, 1.12012f, 1.47461f, -1.12988f, - -0.27832f, 0.53125f, 0.875f, 0.845703f, -0.318359f, - 1.68555f, 1.29199f, -0.00195312f, 0.861328f, 0.601562f, - -0.519531f, 1.16211f, -1.05957f, 0.0507812f, 0.904297f, - 0.625977f, -0.525391f, 1.16797f, -0.163086f, 0.125977f, - 1.99902f, 2.0f, 2.0f, 2.0f, -0.00195312f, - -1.11719f, -0.3125f, -0.320312f, 0.585938f, -1.99902f, - 0.647461f, 0.198242f, -0.538086f, 0.993164f, -0.897461f, - -0.227539f, -0.354492f, 0.0976562f, -0.416016f, 0.623047f, - -0.682617f, -0.832031f, -0.223633f, -0.160156f, 0.0751953f, - -0.791992f, 1.13379f, -1.99902f, -0.755859f, 0.669922f, - 1.02637f, 1.26758f, -0.293945f, 2.0f, 1.93457f, - -0.0126953f, 0.773438f, 0.475586f, -0.59375f, 0.329102f, - -0.588867f, 0.113281f, 0.740234f, 0.749023f, -0.716797f, - 0.941406f, -0.0878906f, 0.71875f, 1.8125f, 2.0f, - -0.289062f, 2.0f, -1.01074f, 0.0117188f, -0.183594f, - -0.969727f, 0.893555f, -1.99902f, 0.333008f, 0.188477f, - -0.643555f, 0.504883f, -0.511719f, -0.804688f, -0.957031f, - 0.0546875f, -0.305664f, -0.0449219f, -0.145508f, -1.875f, - 0.0996094f, -0.155273f, 1.59668f, 1.5293f, 1.46973f, - 2.0f, -1.9834f, 0.375f, 1.20508f, 0.736328f, - -0.399414f, 2.0f, 2.0f, 0.123047f, 0.834961f, - 1.04004f, -0.808594f, 1.31934f, -0.634766f, 0.548828f, - 0.129883f, -1.64746f, 2.0f, -1.99902f, 0.819336f, - 0.0273438f, -0.254883f, 0.722656f, -0.691406f, -0.464844f, - -1.05566f, 0.0634766f, -0.206055f, 1.02148f, -0.90332f, - 0.0595703f, -0.03125f, 0.129883f, -0.177734f, 0.697266f, - -0.713867f, -0.351562f, -0.169922f, -0.119141f, -0.172852f, - 1.01855f, -0.989258f, -0.12793f, -0.670898f, -0.146484f, - -0.261719f, 1.16602f, -1.05664f, -0.302734f, -0.25293f, - -0.0458984f, -0.198242f, 0.90625f, -0.876953f, -0.144531f, - -0.424805f, -0.151367f, -0.147461f, 0.926758f, -0.835938f, - -0.191406f, -0.326172f, -0.128906f, -0.216797f, 0.910156f, - -0.851562f, -0.291992f, -0.549805f, -0.0517578f, -0.0869141f, - 1.07715f, -0.977539f, -0.0361328f, -0.418945f, -0.148438f, - -0.133789f, 0.907227f, -0.836914f, -0.213867f, -0.768555f, - -0.0664062f, 0.182617f, 1.0498f, -0.915039f, 0.400391f, - -0.523438f, 0.015625f, 0.0f, 1.13184f, -1.09961f, - -0.244141f, -0.330078f, -0.115234f, 0.0166016f, 0.944336f, - -0.868164f, -0.430664f, -0.246094f, -0.0185547f, -0.00976562f, - 0.819336f, -0.822266f, -0.380859f, -1.1709f, 0.0605469f, - -0.0498047f, 0.777344f, -0.703125f, 0.0800781f, -0.451172f, - 0.304688f, 0.0517578f, 0.825195f, -0.771484f, 0.145508f, - 0.495117f, -0.0888672f, -0.243164f, 1.48145f, -1.22168f, - 0.0615234f, -0.192383f, -0.0537109f, 0.0195312f, 1.21582f, - -1.06836f, 0.175781f, -0.394531f, 0.237305f, -0.0126953f, - 0.800781f, -0.920898f, -0.12207f, -0.391602f, -0.0917969f, - -0.0791016f, 1.08008f, -1.03613f, -0.0654297f, -0.423828f, - 0.0478516f, -0.0253906f, 0.873047f, -0.884766f, -0.0722656f, - -0.579102f, 0.0136719f, -0.0917969f, 0.954102f, -0.922852f, - -0.172852f, -0.244141f, 0.0f, -0.141602f, 0.929688f, - -0.894531f, -0.179688f, -0.291992f, 0.0283203f, -0.0947266f, - 0.961914f, -0.926758f, -0.135742f, -0.329102f, 0.0576172f, - -0.0351562f, 0.999023f, -0.958984f, -0.0498047f, -0.248047f, - 0.0869141f, -0.078125f, 1.01074f, -0.954102f, 0.00976562f, - -0.217773f, 0.0986328f, -0.0556641f, 0.916992f, -0.914062f, - -0.136719f, -0.219727f, 0.0488281f, -0.139648f, 0.985352f, - -0.952148f, -0.152344f, -0.286133f, 0.0166016f, -0.0917969f, - 1.0459f, -0.972656f, -0.0605469f, -0.228516f, 0.0507812f, - -0.0810547f, 0.956055f, -0.9375f, -0.18457f, -0.275391f, - 0.0703125f, -0.0986328f, 0.948242f, -0.928711f, -0.162109f, - -0.333008f}; -const size_t kAccelerometerLaptopModeTestDataLength = - ARRAY_SIZE(kAccelerometerLaptopModeTestData); - -const float kAccelerometerFullyOpenTestData[] = { - 0.892578f, -0.0810547f, 0.0146484f, 0.929688f, -0.0644531f, - -0.0234375f, 0.996094f, -0.0136719f, 0.0185547f, 1.02344f, - -0.0615234f, -0.0449219f, 0.978516f, 0.125977f, 0.0400391f, - 0.996094f, 0.0332031f, -0.0117188f, 0.963867f, 0.107422f, - 0.0214844f, 0.980469f, 0.0185547f, -0.00683594f, 0.952148f, - 0.0361328f, 0.0253906f, 0.976562f, -0.00390625f, -0.0126953f, - 0.97168f, 0.0205078f, 0.0517578f, 1.01074f, 0.015625f, - -0.0234375f, 0.953125f, -0.000976562f, 0.0390625f, 0.977539f, - -0.0224609f, -0.00976562f, 0.954102f, 0.0244141f, 0.0439453f, - 0.986328f, 0.00292969f, -0.000976562f, 0.967773f, 0.0537109f, - 0.046875f, 0.99707f, 0.0175781f, -0.000976562f, 0.951172f, - 0.0390625f, 0.0341797f, 0.974609f, -0.00878906f, -0.000976562f, - 0.948242f, 0.0185547f, 0.0478516f, 0.976562f, -0.000976562f, - -0.00683594f, 0.958984f, 0.0263672f, 0.078125f, 0.982422f, - -0.0205078f, 0.0283203f, 0.930664f, 0.00878906f, 0.0664062f, - 0.970703f, 0.00390625f, -0.0078125f, 0.945312f, 0.0380859f, - -0.00585938f, 0.972656f, 0.0419922f, -0.0478516f, 1.01953f, - 0.240234f, -0.182617f, 1.00977f, 0.18457f, -0.126953f, - 1.05566f, 0.0751953f, -0.0888672f, 1.09766f, 0.0732422f, - -0.0898438f, 1.21484f, 0.119141f, -0.000976562f, 1.23633f, - 0.194336f, -0.447266f, 1.31445f, 0.213867f, -0.118164f, - 1.30762f, 0.0908203f, -0.260742f, 0.860352f, 0.141602f, - -0.166016f, 0.868164f, 0.0429688f, -0.258789f, 0.727539f, - 0.0419922f, -0.21875f, 0.740234f, 0.0126953f, -0.162109f, - 0.652344f, -0.00292969f, -0.185547f, 0.666992f, 0.0800781f, - -0.272461f, 0.852539f, -0.0478516f, -0.228516f, 0.819336f, - -0.0996094f, -0.180664f, 0.959961f, -0.0537109f, -0.240234f, - 0.935547f, -0.0917969f, -0.269531f, 0.988281f, -0.0507812f, - -0.197266f, 0.981445f, -0.0712891f, -0.323242f, 0.964844f, - -0.0683594f, -0.203125f, 0.941406f, -0.0898438f, -0.236328f, - 0.942383f, -0.0429688f, -0.206055f, 0.921875f, -0.0527344f, - -0.239258f, 0.976562f, -0.0742188f, -0.261719f, 0.958008f, - -0.09375f, -0.311523f, 0.949219f, -0.0839844f, -0.242188f, - 0.949219f, -0.0742188f, -0.323242f, 0.973633f, -0.0263672f, - -0.238281f, 0.958984f, -0.0488281f, -0.293945f, 0.931641f, - -0.0214844f, -0.225586f, 0.931641f, 0.0195312f, -0.225586f, - 0.810547f, -0.0947266f, -0.15332f, 0.947266f, 0.241211f, - -0.100586f, 0.326172f, 0.286133f, -0.12207f, 0.855469f, - 0.677734f, -0.228516f, 0.229492f, 1.08398f, 0.0224609f, - 0.822266f, 0.759766f, -0.0722656f, 0.294922f, 1.42676f, - 0.147461f, 0.239258f, 0.755859f, 0.142578f, -0.120117f, - 1.00977f, -0.0722656f, -0.154297f, 0.832031f, -0.0576172f, - -0.15332f, 1.10156f, -0.0273438f, -0.119141f, 1.05078f, - 0.0166016f, -0.0927734f, 1.09961f, -0.0703125f, -0.0751953f, - 1.04688f, -0.00195312f, -0.078125f, 0.897461f, -0.0625f, - -0.078125f, 0.854492f, -0.0947266f, -0.123047f, 0.811523f, - -0.0488281f, -0.113281f, 0.796875f, 0.0f, -0.0488281f, - 0.961914f, -0.177734f, -0.0898438f, 0.859375f, -0.172852f, - 0.0126953f, 1.1084f, -0.158203f, 0.0292969f, 1.0791f, - -0.152344f, 0.154297f, 1.29492f, -0.126953f, 0.134766f, - 1.23145f, -0.0878906f, -0.200195f, 0.667969f, -0.216797f, - -0.0888672f, 0.935547f, -0.143555f, 0.000976562f, 1.13281f, - -0.0498047f, 0.00195312f, 1.05469f, -0.231445f, 0.0927734f, - 0.956055f, -0.292969f, 0.0625f, 0.927734f, -0.112305f, - 0.0585938f, 0.975586f, -0.163086f, 0.0957031f, 1.03418f, - -0.229492f, 0.000976562f, 0.985352f, -0.09375f, -0.00585938f, - 0.945312f, -0.140625f, -0.0302734f, 0.998047f, -0.208008f, - -0.0507812f, 0.916016f, -0.112305f, 0.123047f, 0.981445f, - -0.205078f, 0.129883f, 1.02832f, -0.211914f, 0.105469f, - 1.01367f, -0.142578f, 0.111328f, 1.00098f, -0.110352f, - 0.0986328f, 0.999023f, -0.15918f, 0.0839844f, 0.922852f, - -0.223633f, 0.261719f, 1.06641f, -0.138672f, 0.240234f, - 0.916016f, -0.296875f, 0.00488281f, 1.04199f, -0.128906f, - 0.0341797f, 1.0791f, -0.265625f, 0.015625f, 0.963867f, - -0.161133f, 0.015625f, 0.958008f, -0.0722656f, -0.125f, - 1.03125f, -0.19043f, -0.0722656f, 1.16602f, -0.126953f, - -0.143555f, 1.12793f, -0.197266f, -0.120117f, 1.26465f, - -0.232422f, -0.226562f, 1.125f, -0.0712891f, -0.0927734f, - 1.26465f, -0.145508f, -0.551758f, 0.90918f, -0.163086f, - -0.228516f, 1.2041f, -0.0371094f, -0.493164f, 0.827148f, - 0.0371094f, -0.162109f, 0.568359f, -0.195312f, -0.641602f, - 0.438477f, -0.212891f, -0.513672f, 0.208008f, -0.0488281f, - -0.776367f, 0.0488281f, -0.115234f, -0.84375f, -0.314453f, - 0.106445f, -0.966797f, -0.0078125f, 0.00976562f, -1.01953f, - -0.220703f, -0.0322266f, -0.994141f, 0.0117188f, -0.248047f, - -0.975586f, 0.121094f, -0.0205078f, -0.947266f, 0.00292969f, - -0.160156f, -0.9375f, 0.0175781f, -0.0986328f, -0.916992f, - -0.0195312f, -0.208008f, -0.9375f, -0.0654297f, -0.134766f, - -0.948242f, -0.0185547f, -0.231445f, -0.977539f, -0.0537109f, - -0.198242f, -1.0166f, 0.0439453f, -0.433594f, -0.994141f, - -0.0595703f, -0.389648f, -1.07129f, 0.0859375f, -0.109375f, - -1.01953f, 0.0966797f, -0.12207f, -1.01074f, 0.125977f, - -0.192383f, -1.0f, 0.0820312f, -0.166016f, -1.04688f, - 0.0751953f, -0.265625f, -1.00879f, 0.139648f, -0.135742f, - -1.00977f, 0.0644531f, -0.235352f, -0.989258f, 0.100586f, - -0.144531f, -0.858398f, 0.0273438f, -0.22168f, -0.878906f, - -0.0634766f, -0.1875f, -0.905273f, -0.0195312f, -0.232422f, - -0.926758f, -0.0732422f, -0.319336f, -1.05078f, -0.00878906f, - -0.5625f, -1.05176f, 0.111328f, -0.456055f, -0.942383f, - -0.0146484f, -0.171875f, -0.946289f, -0.0224609f, -0.174805f, - -0.901367f, -0.0283203f, -0.332031f, -0.948242f, -0.0732422f, - -0.262695f, -0.867188f, 0.0351562f, -0.271484f, -0.913086f, - -0.0878906f, -0.259766f, -1.2793f, -0.226562f, -0.382812f, - -1.2334f, 0.0400391f, -0.260742f, -1.22949f, -0.216797f, - -0.432617f, -1.21191f, -0.131836f, -0.368164f, -1.10938f, - -0.323242f, -0.505859f, -1.01953f, -0.197266f, -0.405273f, - -1.25488f, -0.347656f, -0.448242f, -0.803711f, 0.0595703f, - -0.253906f, -0.489258f, -0.00390625f, 0.101562f, 0.15332f, - -0.423828f, -0.0195312f, 0.527344f, -0.350586f, -0.24707f, - 0.363281f, -1.33789f, -0.214844f, 0.322266f, -0.768555f, - -0.279297f, 0.266602f, -0.918945f, -0.320312f, 0.0634766f, - -0.97168f, -0.102539f, 0.114258f, -0.891602f, -0.158203f, - 0.0283203f, -0.998047f, -0.198242f, 0.0634766f, -0.931641f, - -0.239258f, 0.147461f, -0.963867f, -0.219727f, 0.142578f, - -1.02051f, -0.279297f, 0.105469f, -0.955078f, -0.238281f, - 0.104492f, -1.02637f, -0.291992f, -0.0302734f, -1.02637f, - -0.225586f, 0.000976562f, -0.907227f, -0.12793f, 0.03125f, - -0.979492f, -0.100586f, 0.0625f, -0.921875f, -0.155273f, - 0.146484f, -0.929688f, -0.158203f, 0.155273f, -0.981445f, - -0.171875f, 0.212891f, -0.927734f, -0.166992f, 0.198242f, - -1.05371f, -0.197266f, 0.189453f, -0.954102f, -0.113281f, - 0.189453f, -1.00293f, -0.180664f, 0.111328f, -0.967773f, - -0.109375f, 0.125977f, -0.966797f, -0.146484f, 0.0712891f, - -0.982422f, -0.0908203f, 0.112305f, -0.928711f, -0.149414f, - 0.0146484f, -1.00781f, -0.0996094f, 0.102539f, -0.810547f, - -0.157227f, -0.0117188f, -0.820312f, -0.0371094f, 0.28418f, - -0.446289f, -0.166016f, 0.208008f, -0.03125f, -0.0761719f, - 0.755859f, -0.280273f, -0.316406f, 1.42188f, 0.198242f, - -0.49707f, 1.37207f, -0.556641f, -0.382812f, 1.36523f, - 0.110352f, -0.342773f, 1.25391f, -0.225586f, -0.570312f, - 0.958984f, 0.0722656f, -0.237305f, 0.984375f, 0.0957031f, - -0.416992f, 0.853516f, 0.0400391f, -0.416016f, 0.873047f, - 0.0644531f, -0.370117f, 1.04004f, 0.0273438f, -0.408203f, - 0.920898f, -0.0986328f, -0.514648f, 0.956055f, 0.0527344f, - -0.428711f, 0.960938f, 0.109375f, -0.522461f, 0.801758f, - -0.277344f, -0.634766f, 0.882812f, 0.0527344f, -0.34668f, - 0.981445f, -0.09375f, -0.298828f, 0.952148f, -0.213867f, - -0.25293f, 0.90918f, -0.132812f, -0.493164f, 0.885742f, - -0.177734f, -0.525391f, 0.915039f, -0.0605469f, -0.439453f, - 0.87207f, -0.0986328f, -0.506836f, 0.905273f, -0.0732422f, - -0.462891f, 0.870117f, -0.0966797f, -0.511719f, 0.897461f, - -0.0234375f, -0.464844f, 0.868164f, -0.0283203f, -0.474609f, - 0.919922f, 0.0205078f, -0.34375f, 0.889648f, -0.00390625f, - -0.445312f, 0.804688f, -0.0263672f, -0.417969f, 0.806641f, - 0.0410156f, -0.399414f, 0.914062f, -0.0722656f, -0.386719f, - 0.890625f, -0.0615234f, -0.40625f, 0.928711f, 0.0253906f, - -0.118164f, 0.943359f, -0.000976562f, -0.398438f, 0.811523f, - -0.0605469f, -0.234375f, 0.879883f, 0.198242f, -0.509766f, - 0.958008f, 0.0361328f, -0.328125f, 0.938477f, -0.00976562f, - -0.429688f, 0.916016f, -0.0185547f, -0.266602f, 0.898438f, - -0.0380859f, -0.450195f, 0.870117f, 0.162109f, -0.210938f, - 0.899414f, 0.117188f, -0.517578f, 0.756836f, -0.0820312f, - -0.361328f, 0.868164f, -0.0576172f, -1.29883f, 0.515625f, - -0.00195312f, -1.13281f, 0.628906f, 0.00390625f, -0.103516f, - 0.485352f, -0.046875f, -0.922852f, 0.412109f, -0.108398f, - -0.898438f, 0.446289f, -0.111328f, -0.925781f, 0.375977f, - -0.125977f, -0.825195f, 0.446289f, -0.0966797f, -0.958008f, - 0.389648f, -0.0810547f, -1.00781f, 0.532227f, -0.104492f, - -1.0791f, 0.459961f, -0.138672f, -0.941406f, 0.509766f, - -0.107422f, -1.14062f, 0.447266f, -0.195312f, -0.867188f, - 0.474609f, -0.233398f, -0.751953f, 0.612305f, -0.126953f, - -0.661133f, 0.702148f, -0.199219f, -0.260742f, 0.856445f, - -0.0292969f, -0.743164f, 0.921875f, -0.0371094f, -0.293945f, - 0.902344f, -0.103516f, -0.416016f, 0.955078f, -0.00488281f, - -0.232422f, 0.951172f, -0.0498047f, -0.331055f, 0.871094f, - 0.00390625f, -0.186523f, 0.905273f, 0.0566406f, -0.249023f, - 0.677734f, 0.0253906f, 0.145508f, 0.826172f, 0.251953f, - -0.428711f, 0.764648f, 0.488281f, -0.265625f, 0.886719f, - 0.256836f, -0.408203f, 0.744141f, 0.689453f, -0.611328f, - 0.755859f, 0.431641f, -0.525391f, 0.588867f, 0.637695f, - -0.750977f, 0.578125f, 0.568359f, -0.540039f, 0.512695f, - 0.530273f, -0.722656f, 0.498047f, 0.526367f, -0.788086f, - 0.647461f, 0.522461f, -0.862305f, 0.567383f, 0.422852f, - -0.765625f, 0.648438f, 0.405273f, -0.938477f, 0.583008f, - 0.272461f, -1.15137f, 0.481445f, 0.00585938f, -0.788086f, - 0.454102f, -0.0615234f, -0.885742f, 0.306641f, -0.333984f, - -0.678711f, 0.322266f, -0.288086f, -0.615234f, 0.220703f, - -0.476562f, -0.748047f, 0.223633f, -0.396484f, -0.729492f, - 0.235352f, -0.510742f, -0.806641f, 0.227539f, -0.476562f, - -0.665039f, 0.275391f, -0.47168f, -0.938477f, 0.345703f, - -0.369141f, -0.709961f, 0.482422f, -0.393555f, -0.380859f, - 0.759766f, -0.143555f, -0.529297f, 0.956055f, -0.0185547f, - -0.12207f, 1.15527f, 0.0380859f, -0.529297f, 1.04102f, - 0.203125f, -0.0283203f, 1.11719f, 0.0888672f, -0.258789f, - 1.02734f, 0.297852f, -0.0244141f, 1.03223f, 0.211914f, - -0.0859375f, 0.798828f, 0.216797f, 0.19043f, 0.891602f, - 0.256836f, -0.102539f, 0.662109f, 0.263672f, 0.208984f, - 0.810547f, 0.380859f, -0.235352f, 0.707031f, 0.507812f, - -0.0800781f, 0.902344f, 0.470703f, -0.301758f, 0.577148f, - 0.674805f, -0.500977f, 0.748047f, 0.472656f, -0.493164f, - 0.478516f, 0.611328f, -1.04395f, 0.491211f, 0.651367f, - -0.581055f, 0.25293f, 0.325195f, -0.950195f, 0.224609f, - 0.404297f, -1.04883f, 0.116211f, -0.00292969f, -0.980469f, - 0.0566406f, 0.0195312f, -0.821289f, 0.0166016f, -0.141602f, - -0.959961f, -0.0322266f, -0.158203f, -0.837891f, 0.119141f, - -0.224609f, -1.00781f, 0.09375f, -0.151367f, -1.00684f, - 0.248047f, -0.238281f, -0.973633f, 0.271484f, -0.324219f, - -0.942383f, 0.443359f, -0.298828f, -0.845703f, 0.581055f, - -0.291992f, -0.700195f, 0.65918f, -0.319336f, -0.262695f, - 0.818359f, -0.286133f, -0.579102f, 0.827148f, -0.272461f, - -0.0908203f, 0.935547f, -0.233398f, -0.374023f, 0.920898f, - -0.137695f, 0.000976562f, 0.964844f, -0.12793f, -0.285156f, - 0.880859f, -0.0244141f, -0.0830078f, 0.930664f, 0.00976562f, - -0.15332f, 0.731445f, 0.172852f, 0.0380859f, 0.876953f, - 0.264648f, -0.194336f, 0.601562f, 0.613281f, -0.132812f, - 0.803711f, 0.53418f, -0.268555f, 0.933594f, 0.899414f, - -0.332031f, 0.923828f, 0.521484f, -0.425781f, 0.972656f, - 0.959961f, -0.506836f, 0.797852f, 0.506836f, -0.125977f, - 0.740234f, 0.756836f, -0.262695f, 0.783203f, 0.691406f, - -0.422852f, 0.474609f, 0.459961f, 0.00390625f, 0.683594f, - 0.941406f, -0.0625f, 0.0810547f, 1.06934f, 0.0625f, - 0.546875f, 0.967773f, 0.0351562f, 0.202148f, 1.32422f, - -0.148438f, 0.269531f, 0.818359f, -0.3125f, 0.0742188f, - 1.23633f, -0.188477f, -0.0263672f, 0.713867f, -0.139648f, - -0.230469f, 0.8125f, -0.134766f, -0.246094f, 0.734375f, - -0.09375f, -0.22168f, 1.17188f, -0.158203f, -0.209961f, - 1.09766f, -0.141602f, 0.00976562f, 0.991211f, -0.238281f, - 0.0341797f, 0.979492f, -0.207031f, -0.0166016f, 1.00293f, - -0.228516f, 0.0527344f, 1.28711f, -0.167969f, 0.164062f, - 0.925781f, -0.255859f, 0.170898f, 0.956055f, -0.256836f, - 0.191406f, 0.936523f, -0.145508f, 0.205078f, 0.904297f, - -0.257812f, 0.117188f, 0.870117f, -0.188477f, 0.166992f, - 1.02441f, -0.288086f, 0.163086f, 0.938477f, -0.262695f, - 0.138672f, 0.947266f, -0.219727f, 0.0947266f, 0.992188f, - -0.0732422f, 0.116211f, 1.00293f, -0.203125f, 0.0205078f, - 0.933594f, -0.235352f, -0.0126953f, 0.844727f, -0.0693359f, - 0.119141f, 1.00195f, -0.110352f, 0.135742f, 1.00391f, - -0.101562f, 0.0546875f, 1.06543f, -0.18457f, 0.0507812f, - 0.933594f, -0.112305f, 0.00976562f, 0.973633f, -0.193359f, - -0.0185547f, 0.885742f, -0.279297f, -0.0107422f, 1.02344f, - -0.078125f, -0.0107422f, 1.0127f, 0.140625f, -0.142578f, - 0.994141f, -0.132812f, -0.145508f, 0.90918f, -0.000976562f, - -0.22168f, 1.0498f, -0.148438f, -0.185547f, 1.2207f, - -0.172852f, -0.196289f, 1.0957f, -0.183594f, -0.0390625f, - 1.34863f, -0.21875f, -0.745117f, 0.952148f, 0.0126953f, - -0.196289f, 1.29492f, -0.150391f, -0.768555f, 0.853516f, - -0.163086f, -0.25f, 0.358398f, -0.0507812f, -0.80957f, - 0.139648f, 0.125f, -0.790039f, -0.257812f, 0.175781f, - -0.795898f, -0.135742f, 0.00585938f, -0.841797f, -0.279297f, - 0.0419922f, -0.708984f, 0.0175781f, -0.0957031f, -0.75f, - -0.204102f, 0.0419922f, -0.78125f, 0.0322266f, -0.125f, - -0.787109f, -0.0380859f, -0.0683594f, -1.06641f, 0.0947266f, - -0.238281f, -1.02148f, 0.117188f, -0.176758f, -1.77539f, - 0.0117188f, -0.31543f, -1.80566f, -0.0625f, -0.273438f, - -0.764648f, 0.143555f, -0.21875f, -0.746094f, 0.162109f, - -0.0351562f, -0.858398f, 0.186523f, -0.250977f, -0.918945f, - 0.0458984f, 0.135742f, -0.988281f, 0.241211f, -0.192383f, - -0.963867f, 0.277344f, -0.129883f, -0.994141f, 0.22168f, - -0.169922f, -0.96582f, 0.290039f, -0.217773f, -0.990234f, - 0.185547f, -0.152344f, -0.978516f, 0.169922f, -0.0361328f, - -0.912109f, 0.119141f, -0.352539f, -0.838867f, 0.183594f, - -0.0380859f, -0.753906f, 0.274414f, -0.575195f, -0.770508f, - 0.192383f, -0.482422f, -0.904297f, -0.0234375f, -0.498047f, - -0.817383f, 0.0527344f, -0.277344f, -0.428711f, 0.114258f, - -0.634766f, -0.427734f, -0.0429688f, -0.405273f, -0.318359f, - 0.118164f, -0.870117f, -0.193359f, 0.171875f, -0.938477f, - -0.1875f, 0.208008f, -1.04688f, -0.246094f, 0.0849609f, - -1.72461f, -0.353516f, 0.234375f, -1.05859f, -0.304688f, - 0.151367f, -1.38672f, -0.663086f, 0.242188f, -0.939453f, - -0.481445f, 0.189453f, -0.87793f, -0.831055f, 0.358398f, - -0.555664f, -0.621094f, 0.444336f, -0.287109f, -0.802734f, - 0.367188f, -0.25293f, -0.753906f, 0.413086f, 0.0126953f, - -1.0127f, 0.335938f, -0.250977f, -0.942383f, 0.563477f, - 0.000976562f, -1.33691f, 0.138672f, -0.365234f, -0.996094f, - 0.542969f, -0.0400391f, -1.44434f, 0.239258f, -0.655273f, - -0.625977f, 0.313477f, -0.444336f, -0.589844f, -0.106445f, - -0.217773f, 0.00585938f, -0.760742f, -0.219727f, 0.0654297f, - -0.626953f, -0.0439453f, 0.0732422f, -1.22168f, 0.0126953f, - 0.210938f, -0.754883f, -0.0839844f, 0.161133f, -0.980469f, - -0.124023f, 0.141602f, -0.828125f, -0.199219f, 0.152344f, - -0.80957f, -0.230469f, 0.231445f, -0.865234f, -0.259766f, - 0.232422f, -0.892578f, -0.305664f, 0.323242f, -0.87793f, - -0.294922f, 0.274414f, -1.0791f, -0.435547f, 0.222656f, - -0.863281f, -0.375f, 0.219727f, -1.0166f, -0.525391f, - 0.0341797f, -0.834961f, -0.454102f, 0.0371094f, -0.984375f, - -0.486328f, -0.135742f, -0.700195f, -0.339844f, -0.0078125f, - -1.20508f, -0.665039f, -0.791016f, 0.00390625f, -0.277344f, - 0.0136719f, -0.492188f, -0.779297f, -1.49316f, 0.0957031f, - -0.179688f, -0.587891f, 0.665039f, 0.398438f, -0.980469f, - 0.428711f, 0.254883f, -0.828125f, 0.724609f, 0.663086f, - -0.90625f, 0.555664f, 0.0791016f, -0.837891f, 0.591797f, - 0.257812f, -0.806641f, 0.609375f, 0.0458984f, -0.779297f, - 0.529297f, 0.00292969f, -0.829102f, 0.640625f, 0.0371094f, - -0.797852f, 0.583008f, 0.208984f, -0.864258f, 0.583984f, - -0.0615234f, -0.758789f, 0.72168f, 0.0947266f, -0.921875f, - 0.605469f, -0.264648f, -0.75293f, 0.701172f, 0.107422f, - -0.735352f, 0.44043f, -0.527344f, -0.398438f, 0.46875f, - -0.421875f, -0.424805f, 0.0810547f, -0.754883f, -0.241211f, - -0.107422f, -1.13574f, -0.410156f, -0.0400391f, -0.942383f, - -0.454102f, -0.12207f, -1.24902f, -0.509766f, -0.393555f, - -0.959961f, -0.511719f, -0.381836f, -1.04883f, -0.924805f, - -0.756836f, -1.17969f, -0.521484f, -0.105469f, -1.16504f, - -0.767578f, -0.477539f, -0.401367f, -0.0341797f, -0.341797f, - 0.0507812f, 0.389648f, -0.507812f, 0.186523f, 0.438477f, - -1.33594f, 0.625977f, 0.518555f, -0.671875f, 0.182617f, - 0.432617f, -1.18359f, 0.132812f, 0.414062f, -0.782227f, - 0.0615234f, 0.401367f, -1.30176f, -0.0683594f, -0.100586f, - -0.586914f, 0.0302734f, 0.191406f, -0.983398f, -0.0273438f, - -0.735352f, -0.224609f, -0.342773f, -0.241211f, -0.566406f, - 0.015625f, -1.1084f, -0.00976562f, -0.652344f, -0.75293f, - 0.239258f, -0.449219f, -1.08789f, 0.107422f, -0.572266f, - -0.887695f, 0.407227f, -0.423828f, -0.919922f, 0.173828f, - -0.705078f, -0.825195f, 0.411133f, -0.484375f, -0.799805f, - 0.237305f, -0.776367f, -0.745117f, 0.459961f, -0.819336f, - -0.749023f, 0.208008f, -0.788086f, -0.716797f, 0.226562f, - -0.795898f, -0.72168f, 0.123047f, -0.790039f, -0.705078f, - 0.101562f, -0.720703f, -0.745117f, -0.0517578f, -0.771484f, - -0.701172f, -0.0175781f, -0.758789f, -0.765625f, -0.0917969f, - -0.745117f, -0.751953f, -0.149414f, -0.6875f, -0.660156f, - -0.0166016f, -0.782227f, -0.592773f, -0.0205078f, -0.726562f, - -0.376953f, 0.119141f, -0.599609f, -0.371094f, 0.0107422f, - -0.736328f, -0.325195f, 0.0771484f, -0.768555f, -0.388672f, - -0.0273438f, -0.750977f, -0.477539f, 0.107422f, -0.919922f, - -0.514648f, 0.125f, -0.961914f, -0.37793f, 0.0136719f, - -0.981445f, -0.447266f, -0.0107422f, -0.823242f, -0.303711f, - 0.0986328f, -1.00684f, -0.366211f, 0.0986328f, -1.14551f, - -0.239258f, 0.140625f, -0.894531f, -0.297852f, 0.0849609f, - -0.949219f, -0.341797f, 0.131836f, -0.966797f, -0.380859f, - 0.0947266f, -0.75293f, -0.391602f, 0.0839844f, -0.908203f, - -0.40625f, 0.161133f, -0.860352f, -0.452148f, 0.1875f, - -0.950195f, -0.496094f, 0.200195f, -0.828125f, -0.581055f, - 0.0771484f, -0.93457f, -0.607422f, 0.0996094f, -0.863281f, - -0.59375f, 0.0927734f, -0.802734f, -0.604492f, 0.0947266f, - -0.807617f, -0.722656f, 0.101562f, -0.844727f, -0.711914f, - 0.149414f, -1.03125f, -0.77832f, 0.125977f, -0.78418f, - -0.740234f, 0.121094f, -0.891602f, -0.808594f, 0.164062f, - -0.650391f, -0.80957f, 0.0888672f, -0.416992f, -0.866211f, - 0.155273f, -0.382812f, -0.880859f, 0.0849609f, -0.264648f, - -0.775391f, 0.229492f, -0.389648f, -0.814453f, 0.0664062f, - -0.226562f, -0.625f, 0.414062f, -0.274414f, -0.681641f, - 0.0292969f, -0.0478516f, -0.711914f, 0.794922f, -0.388672f, - -0.584961f, 0.368164f, -0.257812f, -0.545898f, 1.09277f, - -0.277344f, -0.125977f, 0.822266f, -0.365234f, -0.467773f, - 0.714844f, -0.413086f, -0.136719f, 1.57227f, -0.0947266f, - -0.223633f, 0.817383f, -0.0556641f, -0.0322266f, 1.18945f, - -0.191406f, -0.498047f, 0.991211f, -0.231445f, -0.246094f, - 0.8125f, -0.239258f, -0.755859f, 0.853516f, -0.228516f, - -0.821289f, 0.503906f, -0.121094f, -0.795898f, 0.523438f, - -0.220703f, -0.773438f, 0.517578f, -0.274414f, -0.757812f, - 0.539062f, -0.222656f, -0.770508f, 0.396484f, -0.115234f, - -1.2334f, 0.485352f, -0.217773f, -0.94043f, 1.01758f, - -0.202148f, -0.605469f, 0.0546875f, 0.0957031f, -0.639648f, - -0.661133f, 0.245117f, -0.750977f, 0.0615234f, -0.726562f, - -0.879883f, -0.432617f, -1.05859f, -1.29688f, 0.00488281f, - 0.193359f, -0.939453f, 0.209961f, -0.209961f, -0.793945f, - 0.251953f, 0.722656f, -0.447266f, 0.0615234f, 0.855469f, - -0.454102f, -0.0126953f, 0.0527344f, -0.342773f, 0.154297f, - 1.3877f, -0.65918f, 0.133789f, 0.0576172f, -0.233398f, - -0.12207f, 0.46582f, -1.09961f, 0.438477f, -0.641602f, - -0.861328f, 0.197266f, -1.99902f, -0.932617f, 0.234375f, - 0.389648f, -0.792969f, -0.0908203f, 1.66797f, -1.0459f, - 0.0107422f, -0.543945f, -0.80957f, 0.206055f, -0.27832f, - -0.915039f, 0.104492f, -0.301758f, -0.891602f, 0.0556641f, - -0.681641f, -0.901367f, 0.0498047f, -0.461914f, -0.927734f, - -0.0390625f, -0.229492f, -1.04004f, 0.0869141f, -0.435547f, - -1.02148f, 0.0947266f, -0.527344f, -0.979492f, 0.0751953f, - 0.266602f, -0.786133f, -0.0224609f, -0.0947266f, -0.702148f, - -0.00683594f, -0.316406f, -0.698242f, -0.317383f, 1.92578f, - -1.0498f, 0.0273438f, -1.14258f, -0.226562f, 0.233398f, - -0.995117f, -0.9375f, 0.0146484f, -0.223633f, -0.49707f, - -0.0078125f, -1.95703f, -0.847656f, 0.157227f, 0.129883f, - -0.459961f, -0.114258f, 2.0f, -1.13574f, -0.0839844f, - -0.0878906f, -0.783203f, 0.131836f, -0.803711f, -0.90332f, - 0.208984f, -0.365234f, -0.97168f, -0.0322266f, 0.186523f, - -0.924805f, 0.00292969f, -0.272461f, -0.890625f, 0.015625f, - -0.333008f, -0.932617f, 0.180664f, -0.459961f, -0.90918f, - 0.240234f, -0.625977f, -1.1582f, 0.0996094f, -0.170898f, - -1.08887f, -0.00976562f, -0.849609f, -0.430664f, 0.139648f, - -0.308594f, -0.572266f, -0.722656f, 1.83496f, -1.00977f, - 0.387695f, 0.487305f, -0.268555f, 0.0712891f, -0.0136719f, - -1.5332f, 0.290039f, -0.0351562f, -0.861328f, 1.98535f, - -1.16602f, -0.602539f, 0.441406f, 0.175781f, -0.605469f, - -0.831055f, 0.686523f, -0.984375f, 0.494141f, -0.489258f, - -0.895508f, 0.371094f, -0.665039f, -1.14258f, -0.214844f, - -0.140625f, -1.06348f, -0.0996094f, 0.255859f, -0.874023f, - 0.193359f, -0.0947266f, -0.959961f, -0.0966797f, 0.00195312f, - -0.996094f, -0.0117188f, -0.174805f, -0.962891f, 0.106445f, - -0.162109f, -1.04297f, -0.0283203f, -0.306641f, -1.06738f, - -0.0224609f, -0.129883f, -1.03223f, 0.129883f, 0.195312f, - -1.08789f, -0.130859f, 0.649414f, -0.572266f, -0.0136719f, - -0.793945f, -0.382812f, 0.0f, -1.08301f, -0.78125f, - -0.0224609f, -0.339844f, -0.629883f, -0.0947266f, -1.83789f, - -1.01562f, 0.046875f, 0.223633f, -0.808594f, 0.0957031f, - 1.09766f, -0.756836f, -0.0488281f, 0.157227f, -0.59082f, - -0.103516f, 0.929688f, -0.816406f, -0.0322266f, -0.426758f, - -0.868164f, -0.209961f, -1.99902f, -0.986328f, -0.00878906f, - -0.365234f, -0.980469f, 0.0439453f, 0.59375f, -0.994141f, - 0.0253906f, 0.0371094f, -0.970703f, -0.0273438f, -0.120117f, - -0.935547f, 0.00195312f, -0.235352f, -0.952148f, -0.0263672f, - -0.194336f, -0.917969f, -0.0195312f, -0.261719f, -0.928711f, - -0.0234375f, -0.219727f, -0.945312f, 0.0107422f, -0.228516f, - -0.938477f, 0.00683594f, -0.178711f, -0.791016f, 0.03125f, - -0.255859f, -0.789062f, 0.0f, -0.141602f, -0.789062f, - 0.232422f, -0.285156f, -0.788086f, 0.228516f, -0.28125f, - -1.0f, 0.258789f, -0.277344f, -0.999023f, 0.28125f, - -0.25293f, -1.06152f, 0.046875f, -0.421875f, -1.07715f, - 0.0390625f, -0.224609f, -0.923828f, -0.0205078f, -0.335938f, - -0.984375f, -0.0966797f, -0.34668f, -0.990234f, -0.191406f, - -0.301758f, -1.03613f, -0.241211f, -0.37207f, -0.975586f, - -0.267578f, -0.460938f, -1.00977f, -0.320312f, -0.382812f, - -0.913086f, -0.257812f, -0.457031f, -0.925781f, -0.256836f, - -0.34668f, -0.889648f, -0.237305f, -0.393555f, -0.897461f, - -0.239258f, -0.429688f, -0.844727f, -0.21875f, -0.428711f, - -0.87207f, -0.203125f, -0.368164f, -0.84668f, -0.101562f, - -0.423828f, -0.875977f, -0.165039f, -0.363281f, -0.884766f, - -0.0625f, -0.473633f, -0.90332f, -0.078125f, -0.138672f, - -0.918945f, -0.198242f, -0.25f, -0.928711f, -0.138672f, - -0.267578f, -1.08203f, 0.00488281f, -0.575195f, -1.125f, - -0.0332031f, -0.4375f, -0.924805f, 0.078125f, -0.305664f, - -0.93457f, -0.0166016f, -0.475586f, -0.94043f, -0.00488281f, - -0.533203f, -0.956055f, 0.00292969f, -0.391602f, -1.00293f, - 0.0361328f, -0.711914f, -1.0166f, 0.0332031f, -0.448242f, - -0.806641f, -0.21582f, -0.556641f, -0.759766f, -0.0214844f, - -0.626953f, -0.700195f, -0.263672f, -0.308594f, -0.608398f, - -0.236328f, -0.253906f, -0.616211f, -0.378906f, 0.224609f, - -0.498047f, -0.399414f, 0.206055f, -0.516602f, -0.228516f, - 0.743164f, -0.174805f, -0.125f, 0.760742f, -0.0214844f, - -0.135742f, 0.966797f, 0.240234f, 0.0332031f, 1.01855f, - 0.105469f, 0.15332f, 0.950195f, 0.240234f, 0.0732422f, - 1.16895f, 0.245117f, 0.206055f, 0.952148f, 0.273438f, - -0.0390625f, 1.2793f, 0.404297f, 0.303711f, 0.720703f, - 0.369141f, 0.0966797f, 0.918945f, 0.329102f, 0.0390625f, - 0.991211f, 0.397461f, -0.124023f, 0.866211f, 0.210938f, - 0.130859f, 1.08789f, 0.317383f, 0.0537109f, 0.858398f, - 0.245117f, 0.0732422f, 0.741211f, 0.419922f, 0.0302734f, - 0.681641f, 0.485352f, -0.0214844f, 0.641602f, 0.520508f, - -0.129883f, 0.839844f, 0.490234f, 0.00390625f, 0.676758f, - 0.581055f, -0.0146484f, 0.692383f, 0.432617f, -0.0371094f, - 0.807617f, 0.664062f, 0.255859f, 0.216797f, 1.22559f, - 0.0195312f, 1.22168f, 1.2793f, -0.405273f, 1.72559f, - 0.708984f, -0.209961f, 0.579102f, 0.821289f, 0.0380859f, - 0.605469f, 0.80957f, 0.147461f, 0.419922f, 0.869141f, - 0.0390625f, 0.5625f, 0.786133f, 0.0654297f, 0.594727f, - 0.879883f, 0.0166016f, 0.480469f, 0.835938f, 0.00195312f, - 0.414062f, 0.899414f, -0.03125f, 0.344727f, 0.889648f, - 0.0185547f, 0.236328f, 0.932617f, -0.00585938f, 0.255859f, - 0.910156f, 0.0898438f, 0.262695f, 0.945312f, 0.0126953f, - 0.279297f, 0.860352f, 0.0507812f, 0.322266f, 0.913086f, - 0.00195312f, 0.296875f, 0.875977f, 0.0078125f, 0.373047f, - 0.922852f, -0.0244141f, 0.267578f, 0.884766f, 0.0117188f, - 0.347656f, 0.926758f, -0.0371094f, 0.266602f, 0.894531f, - -0.00683594f, 0.345703f, 0.926758f, -0.0478516f, 0.269531f, - 0.887695f, 0.0146484f, 0.360352f, 0.927734f, -0.03125f, - 0.272461f}; -const size_t kAccelerometerFullyOpenTestDataLength = - ARRAY_SIZE(kAccelerometerFullyOpenTestData); - diff --git a/test/motion_angle_data_literals_tablet.c b/test/motion_angle_data_literals_tablet.c deleted file mode 100644 index 456779f457..0000000000 --- a/test/motion_angle_data_literals_tablet.c +++ /dev/null @@ -1,1040 +0,0 @@ -/* Copyright 2018 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include "util.h" - -/* - * Recopied from - * chromium/src/ash/wm/tablet_mode/accelerometer_test_data_literals.cc - * - * The arrays contain actual accelerator readings. - */ -const float kAccelerometerVerticalHingeTestData[] = { - -0.0766145f, 6.02381f, 7.85298f, -0.268151f, -8.84897f, - -1.3216f, -0.402226f, 5.11401f, 8.77236f, -1.10133f, - -10.1706f, 1.24498f, -1.18752f, 6.40688f, 8.0924f, - -2.60489f, -8.99262f, 2.58574f, 0.632069f, 9.05008f, - 3.61046f, 1.50356f, -9.67257f, 1.93451f, 0.411803f, - 8.81066f, 0.268151f, -0.00957681f, -8.7532f, 2.15478f, - -0.0191536f, 9.49062f, -0.68953f, 0.0383072f, -8.94474f, - 2.99754f, -0.871489f, 9.80665f, 1.53229f, -0.92895f, - -9.88326f, 0.957681f, 0.507571f, 9.19373f, 1.71425f, - 0.287304f, -9.03093f, 0.651223f, 0.363919f, 9.71088f, - 1.18752f, 1.10133f, -10.0556f, 2.98796f, 0.23942f, - 9.39485f, 1.0343f, 0.842759f, -9.73961f, -1.12049f, - 0.172383f, 9.50977f, 1.18752f, 0.0383072f, -9.9503f, - 0.957681f, -0.373495f, 9.96946f, 1.01514f, 0.794875f, - -10.1897f, -1.38864f, -9.50977f, -1.04387f, 0.325611f, - -9.76834f, 1.05345f, -0.679953f, -9.76834f, -0.641646f, - 0.488417f, -9.2895f, 0.316035f, 0.258574f, -9.29908f, - -0.890643f, 0.469264f, -9.33739f, 0.823605f, -0.45011f, - -9.69173f, -1.02472f, 0.536301f, -9.52892f, 0.90022f, - -0.411803f, -9.34696f, -0.890643f, 0.430956f, -9.48104f, - 0.823605f, -0.603339f, -9.7875f, -0.565032f, 0.574608f, - -9.96946f, 0.536301f, -0.699107f, -9.57681f, -0.823605f, - 0.641646f, -9.43316f, 0.593762f, -0.775721f, -9.35654f, - -1.04387f, 0.440533f, -9.77792f, 1.01514f, -0.881066f, - -9.32781f, -1.10133f, 0.306458f, -9.414f, 0.995988f, - 0.0287304f, -9.26077f, -1.01514f, 0.268151f, -9.29908f, - 0.881066f, 0.00957681f, -9.42358f, -0.679953f, 0.201113f, - -9.49062f, 0.488417f, -0.00957681f, -9.47146f, -0.363919f, - 0.191536f, -9.32781f, 0.124498f, 0.124498f, -9.5385f, - -0.0766145f, 0.268151f, -9.32781f, -0.172383f, 0.0574608f, - -9.69173f, 0.21069f, 0.354342f, -9.50019f, -0.306458f, - 0.0383072f, -9.54808f, 0.507571f, 0.363919f, -9.20331f, - -0.775721f, 0.0574608f, -9.59596f, 0.651223f, 0.679953f, - -9.56723f, -0.794875f, -0.0287304f, -9.49062f, 0.794875f, - 0.612916f, -9.06924f, -1.10133f, -0.201113f, -9.20331f, - 1.90578f, 1.46525f, -9.29908f, -2.17394f, 0.603339f, - -0.995988f, 0.0766145f, 9.58638f, -0.344765f, -0.92895f, - -9.1267f, -2.03986f, -0.497994f, 10.477f, -2.49955f, - -0.0957681f, -10.4866f, -1.5706f, -0.23942f, 9.13627f, - -1.92494f, -0.325611f, -9.05008f, -1.5706f, -0.0383072f, - 10.1323f, -1.87705f, -0.632069f, -9.52892f, -1.20668f, - 0.105345f, 9.14585f, -1.13964f, -0.718261f, -9.02135f, - -1.58975f, 0.296881f, 9.50019f, -1.74298f, -1.00556f, - -9.27993f, -1.09176f, 0.23942f, 9.87369f, -1.04387f, - -0.995988f, -9.35654f, -2.08774f, -0.526724f, 9.89284f, - -1.40779f, -0.459687f, -9.50977f, -2.70066f, -1.47483f, - 8.95431f, -1.92494f, 0.526724f, -8.95431f, -1.05345f, - -0.938527f, 9.14585f, -3.02627f, 1.04387f, -8.78193f, - 1.00556f, -3.56257f, 9.0022f, 1.96325f, 2.36547f, - -9.83538f, 1.02472f, -2.59531f, 9.49062f, 1.0726f, - 1.77171f, -9.06924f, 0.0861913f, -2.17394f, 9.21289f, - -0.823605f, 1.52271f, -10.1323f, 0.316035f, -3.09331f, - 10.0844f, 0.555455f, 2.00155f, -9.75877f, 1.51314f, - -2.24097f, 9.61511f, 0.670376f, 1.35033f, -9.77792f, - 0.986411f, -3.36146f, 9.59596f, 1.77171f, 2.29843f, - -9.48104f, 1.4461f, -2.8922f, 8.88728f, 1.84832f, - 2.38462f, -9.19373f, 1.75256f, -2.6432f, 9.89284f, - 1.38864f, 2.19309f, -9.20331f, 9.98861f, -0.718261f, - -0.746991f, 10.6111f, 0.632069f, 0.948104f, 8.99262f, - -0.258574f, 0.517148f, 9.10754f, 0.21069f, -1.21625f, - 9.90242f, -0.162806f, 0.0287304f, 10.5249f, -0.0861913f, - 0.229843f, 9.83538f, 0.0f, 0.181959f, 10.4291f, - -0.172383f, -0.47884f, 9.43316f, 0.201113f, -0.268151f, - 9.76834f, -0.134075f, -0.354342f, 10.0556f, 1.0726f, - 0.277727f, 9.93115f, -1.05345f, 0.363919f, 9.79707f, - 0.651223f, 0.699107f, 10.0173f, -0.775721f, 0.0670376f, - 9.49062f, 0.296881f, 0.919373f, 10.1801f, -0.68953f, - -0.651223f, 9.70131f, 1.00556f, 0.248997f, 9.42358f, - -0.995988f, 1.45567f, 9.13627f, -1.35033f, 2.36547f, - 9.40442f, 0.976834f, -4.34787f, 8.79151f, -0.90022f, - 1.56102f, 8.92558f, 0.6608f, -2.3942f, 9.59596f, - -0.363919f, 1.40779f, 9.05966f, 0.181959f, -2.1452f, - 9.48104f, -0.612916f, 2.36547f, 9.03093f, 0.21069f, - -2.18351f, 9.74919f, -1.5706f, 2.07817f, 8.85855f, - 1.04387f, -2.30801f, 8.81066f, -1.66636f, 3.4285f, - 8.52336f, 0.440533f, -4.52983f, 9.27993f, -2.19309f, - 2.2697f, 8.83939f, 0.90022f, -2.48039f, 9.1267f, - -2.77727f, 1.4461f, 8.78193f, 0.814029f, -4.24253f, - 8.90643f, -3.39977f, 0.651223f, 8.86812f, 1.08218f, - -2.34632f, 9.42358f, -3.26569f, 0.402226f, 8.94474f, - 0.526724f, -2.65278f, 9.38527f, -3.21781f, 0.0f, - 9.20331f, 0.143652f, -2.71024f, 9.44273f, -2.8922f, - -0.497994f, 9.35654f, 0.105345f, -2.78685f, 9.09797f, - -3.4285f, -1.00556f, 8.81066f, 0.785298f, -3.84988f, - 9.31823f, -3.09331f, -1.4461f, 8.68616f, 0.555455f, - -3.27527f, 9.414f, -2.5187f, -1.79086f, 8.59997f, - 0.766145f, -3.47638f, 9.0022f, -2.67193f, -2.43251f, - 8.77236f, 1.39821f, -2.85389f, 8.25521f, -3.29442f, - -2.46124f, 8.15944f, 1.09176f, -3.51469f, 8.72447f, - -2.69108f, -2.48997f, 8.91601f, 0.881066f, -3.66792f, - 8.92558f, -2.33674f, -2.31759f, 8.84897f, 1.06303f, - -3.055f, 8.92558f, -2.49955f, -2.29843f, 8.81066f, - 0.919373f, -2.56658f, 9.31823f, -2.78685f, -1.81959f, - 9.06924f, 0.411803f, -2.86347f, 9.38527f, -2.78685f, - -1.70467f, 9.25119f, 0.335188f, -4.67348f, 9.165f, - -3.9648f, -0.622492f, 8.65743f, 0.248997f, -3.055f, - 9.414f, -3.67749f, 0.0287304f, 8.82982f, 0.852336f, - -2.50912f, 8.82024f, -3.47638f, 0.201113f, 8.98304f, - 1.06303f, -3.33273f, 8.89685f, -3.64876f, 0.718261f, - 8.91601f, 1.52271f, -2.70066f, 8.95431f, -3.56257f, - 1.35991f, 9.05008f, 1.67594f, -3.16992f, 9.08839f, - -3.16035f, 2.03028f, 9.07881f, 1.64721f, -3.04542f, - 8.91601f, -3.11246f, 2.52828f, 8.88728f, 2.07817f, - -1.99198f, 9.1267f, -2.806f, 0.162806f, 9.1267f, - 2.806f, -2.07817f, 9.14585f, -2.31759f, 2.16436f, - 8.8777f, 2.19309f, -1.88663f, 9.88326f, -2.5187f, - 1.94409f, 9.1267f, 2.46124f, -2.806f, 7.64229f, - -6.0717f, 2.9305f, 8.07325f, 5.64074f, -2.63362f, - 4.29999f, -7.9679f, 0.622492f, 4.71179f, 7.74764f, - -3.41892f, 4.42448f, -8.99262f, 1.13964f, 3.98395f, - 8.47547f, -1.9824f, -0.699107f, -9.46189f, -0.794875f, - -0.593762f, 9.24162f, -2.74854f, 1.88663f, -8.8777f, - -0.153229f, 0.861913f, 8.98304f, -2.48039f, -1.52271f, - -9.32781f, -3.39977f, 0.0574608f, 8.99262f, -5.88974f, - -0.746991f, -3.93607f, -8.01579f, -1.17795f, 8.41801f, - -4.17549f, -2.30801f, -2.61447f, -9.44273f, -2.3942f, - 7.46991f, -5.01825f, -1.0343f, 1.89621f, -8.8777f, - -0.890643f, 8.65743f, -4.31914f, -2.16436f, 1.49398f, - -9.69173f, -1.37906f, 9.05008f, -2.43251f, -1.87705f, - 0.402226f, -8.95431f, -2.01113f, 8.72447f, -3.54342f, - -0.344765f, -2.95923f, -8.42759f, -0.92895f, 8.99262f, - -2.34632f, -0.392649f, -6.70376f, -6.55054f, -0.919373f, - 8.80109f, -2.35589f, -0.0766145f, -8.8777f, -5.89931f, - 0.890643f, 9.7875f, 2.24097f, -0.536301f, -8.08282f, - -4.88417f, -0.191536f, 9.21289f, 1.16837f, -0.440533f, - -7.93917f, -4.81713f, -0.890643f, 9.08839f, 1.75256f, - -1.20668f, -9.414f, -2.57616f, -0.708684f, 9.50977f, - 1.40779f, -1.14922f, -9.8258f, -1.24498f, -0.584185f, - 9.63427f, 0.727837f, -0.181959f, -9.25119f, -2.31759f, - -0.0574608f, 9.64384f, -0.612916f, 1.21625f, -9.50977f, - -1.16837f, 0.756568f, 9.45231f, -0.316035f, 1.21625f, - -10.5441f, -0.45011f, 1.5706f, 9.7875f, -1.22583f, - 9.07881f, 0.0766145f, -2.34632f, 9.26077f, 0.316035f, - 4.28083f, 8.72447f, 0.584185f, -3.27527f, 8.39886f, - 0.47884f, 3.98395f, 9.26077f, 2.35589f, -2.98796f, - 9.52892f, -1.61848f, 3.73495f, 8.91601f, 2.98796f, - -3.36146f, 9.7875f, -2.31759f, 3.60088f, 8.86812f, - 3.32315f, -3.62961f, 9.76834f, -2.46124f, 2.72939f, - 2.31759f, 10.2089f, -2.3942f, 0.995988f, -8.68616f, - 5.5737f, 1.13006f, 9.04051f, -2.09732f, 1.26414f, - -8.51378f, 4.40533f, 0.852336f, 9.91199f, -2.07817f, - 0.622492f, -9.18416f, 4.29999f, 0.229843f, 10.0269f, - -1.08218f, 0.220267f, -9.40442f, 4.40533f, 0.0766145f, - 9.54808f, -1.89621f, 0.967257f, -9.05966f, 3.92649f, - 0.335188f, 9.62469f, -0.497994f, 0.430956f, -9.71088f, - 4.02226f, 0.718261f, 9.63427f, 1.59933f, 0.383072f, - -8.88728f, 3.24654f, 0.42138f, 8.71489f, 2.55701f, - 0.68953f, -9.64384f, 1.67594f, 1.0726f, -7.0198f, - 7.20176f, 0.641646f, -9.17458f, 4.18506f, -0.402226f, - -2.46124f, 8.78193f, -0.0383072f, -8.31267f, 4.03184f, - 0.23942f, 2.27928f, 10.4675f, -0.517148f, -9.47146f, - 4.14676f, -1.37906f, 9.59596f, -4.07972f, 3.45723f, - -9.663f, 1.71425f, -0.134075f, 6.95276f, -5.80354f, - 0.268151f, -5.38217f, 7.03895f, 0.00957681f, 5.20978f, - -7.75721f, -0.047884f, -2.83473f, 8.53294f, -0.306458f, - 1.64721f, -8.64786f, 0.766145f, 0.162806f, 8.84897f, - -0.191536f, -2.58574f, -9.19373f, 0.0f, 4.05099f, - 8.52336f, -0.0383072f, -3.10289f, -9.17458f, 0.45011f, - 4.11803f, 9.19373f, 0.0957681f, -2.47082f, -9.61511f, - 0.804452f, 3.98395f, 8.52336f, 0.114922f, 4.00311f, - -8.76278f, 0.699107f, 4.53941f, 8.28394f, -0.0383072f, - 7.95833f, -6.57927f, -0.124498f, 3.52426f, 10.1035f, - -0.229843f, 6.68461f, -6.2345f, -0.153229f, 3.04542f, - 9.59596f, -0.344765f, 7.47949f, -7.29753f, 0.114922f, - 3.90734f, 9.03093f, -0.383072f, 7.57525f, -7.20176f, - -0.172383f, 3.70622f, 9.8258f, -0.335188f, 7.21134f, - -6.7325f, -0.172383f, 2.71024f, 10.2855f, -0.114922f, - 6.608f, -7.41245f, -0.201113f, 1.87705f, 9.39485f, - 1.37906f, -0.0670376f, -9.47146f, 1.1971f, 1.8579f, - 9.49062f, 0.842759f, -1.63763f, -8.95431f, 0.679953f, - 2.8922f, 9.1267f, 1.43652f, -1.58017f, -9.01178f, - 0.890643f, 3.66792f, 9.22246f, 0.746991f, -1.18752f, - -9.04051f, 2.12605f, 2.72939f, 9.52892f, 3.79242f, - 1.48441f, -9.04051f, 4.57771f, -0.785298f, 9.61511f, - 4.61602f, 1.21625f, -8.4659f, 4.94163f, -0.574608f, - 8.4659f, 4.67348f, 1.48441f, -8.23605f, 4.86502f, - -0.852336f, 9.24162f, 5.12359f, 0.92895f, -9.03093f, - 5.84185f, -0.430956f, 8.92558f, 5.38217f, 0.440533f, - -8.37971f, 6.72292f, -0.220267f, 8.02536f, 6.608f, - 1.6089f, -6.30154f, 6.33985f, 0.277727f, 6.58884f, - 9.85453f, 1.39821f, 0.153229f, 10.0844f, -1.46525f, - 0.45011f, 9.68215f, 1.90578f, -0.0766145f, 9.98861f, - -1.96325f, 0.536301f, 9.90242f, 2.20267f, 0.143652f, - 9.94073f, -2.20267f, 0.191536f, 9.46189f, 1.95367f, - 0.0957681f, 9.74919f, -2.06859f, 0.296881f, 9.30866f, - 1.64721f, 0.153229f, 9.84496f, -1.92494f, 0.574608f, - 7.38372f, 0.488417f, 6.76123f, 8.83939f, -1.37906f, - -3.11246f, 9.2895f, 0.153229f, -0.976834f, 9.86411f, - -0.0574608f, -0.957681f, 9.26077f, 0.833182f, 2.07817f, - 9.26077f, -0.938527f, -0.957681f, 10.0269f, -0.354342f, - 2.43251f, 9.84496f, 0.153229f, -0.957681f, 0.986411f, - -8.74362f, 1.34075f, 2.09732f, 9.165f, -1.84832f, - -1.25456f, -10.228f, 2.19309f, 0.42138f, 9.73004f, - -1.23541f, -1.49398f, -10.1706f, 0.172383f, -1.22583f, - 10.2089f, -0.593762f, -2.2314f, -9.663f, -0.526724f, - -1.6089f, 9.65342f, 0.593762f, -2.38462f, -9.165f, - -1.4461f, -2.46124f, 9.42358f, 0.430956f, -2.38462f, - -9.73004f, 0.0383072f, -2.31759f, 9.57681f, -0.47884f, - -2.44209f, -9.5385f, -0.746991f, -2.32716f, 9.58638f, - 0.612916f, -2.34632f, -10.1418f, -1.0726f, -1.92494f, - 9.90242f, 0.890643f, -2.84431f, 9.38527f, -2.38462f, - -1.69509f, -9.50977f, 2.73897f, -3.88818f, 7.9296f, - -2.40378f, -1.5706f, -8.4659f, 2.62405f, -8.91601f, - -2.98796f, 0.497994f, -8.97347f, 2.79643f, 0.373495f, - -10.3717f, 1.02472f, -0.105345f, -10.0461f, -1.02472f, - 0.679953f, -4.89375f, 8.17859f, 0.0766145f, -6.12916f, - -7.61356f, 0.172383f, -6.4835f, 7.5561f, -0.363919f, - -6.09085f, -7.46991f, 0.699107f, -6.19619f, 7.62314f, - -0.248997f, -5.78439f, -7.52737f, 1.55144f, -6.33985f, - 7.50822f, -0.45011f, -5.6982f, -7.48906f, 1.48441f, - -6.36858f, 7.46991f, -0.373495f, -5.72693f, -7.44118f, - 1.63763f, -6.33027f, 7.8434f, -0.316035f, -6.54096f, - -7.57525f, 1.37906f, -6.69419f, 7.52737f, -0.258574f, - -6.41646f, -7.37414f, 1.21625f, -6.62715f, 7.61356f, - -0.392649f, -6.24408f, -7.48906f, 1.23541f, -6.18662f, - 7.60398f, -0.201113f, -5.9472f, -7.45076f, 1.39821f, - -6.14831f, 7.86256f, -0.584185f, -6.26323f, -7.50822f, - 1.6089f, -5.26724f, 8.74362f, -0.153229f, -4.57771f, - -8.41801f, 0.6608f, -3.56257f, 8.82024f, 0.114922f, - -2.86347f, -8.82982f, 0.948104f, -2.53785f, 9.27035f, - 0.23942f, -2.33674f, -9.29908f, 1.02472f, -2.12605f, - 9.67257f, 0.354342f, -2.1452f, -9.45231f, 0.335188f, - -1.71425f, 9.36612f, 0.287304f, -1.41737f, -9.27035f, - -0.229843f, -2.65278f, 8.94474f, -0.306458f, -0.737414f, - -9.414f, 0.172383f, -8.72447f, 5.46836f, 0.325611f, - -10.2663f, -1.80044f, -0.143652f, -9.35654f, -0.794875f, - -0.756568f, -10.1801f, 1.0343f, 1.20668f, -9.54808f, - -0.986411f, -0.766145f, -9.165f, 0.890643f, 1.13964f, - -8.92558f, -0.555455f, -1.22583f, -9.68215f, 0.976834f, - 0.344765f, -9.14585f, 4.05099f, -1.31202f, -9.57681f, - 0.68953f, 1.51314f, -9.54808f, 0.0957681f, 1.45567f, - -9.18416f, -0.229843f, -0.6608f, -9.71088f, 0.047884f, - 1.35033f, -9.87369f, 0.0383072f, -0.909797f, -8.57124f, - 1.1971f, 3.86903f, -9.76834f, -1.13964f, -2.2697f, - -9.38527f, 0.890643f, 2.74854f, -9.38527f, -1.20668f, - -2.3942f, -8.74362f, 1.4461f, 3.45723f, -8.99262f, - -1.72383f, -2.56658f, -9.48104f, 1.13006f, 2.98796f, - -8.80109f, -1.76213f, -2.52828f, -9.69173f, 1.15879f, - 2.3942f, -8.98304f, -1.68552f, -1.71425f, -8.93516f, - 1.25456f, 3.26569f, -9.61511f, -1.38864f, -2.46124f, - -9.37569f, 1.4461f, 3.40934f, -8.83939f, -2.1069f, - -2.42293f, -9.165f, 1.61848f, 2.9305f, -9.165f, - -2.04944f, -2.50912f, -9.31823f, 0.823605f, 0.0f, - -9.48104f, -0.909797f, 0.497994f, -9.30866f, 1.0343f, - -0.775721f, -9.01178f, -1.15879f, 0.814029f, -9.25119f, - 0.948104f, -0.00957681f, -8.80109f, -1.16837f, 0.737414f, - -9.62469f, 1.39821f, -0.248997f, -9.39485f, -1.45567f, - 0.957681f, -9.57681f, 1.79086f, -0.296881f, -9.50019f, - -1.81002f, 0.842759f, -10.0652f, 1.45567f, -0.248997f, - -9.05966f, -1.61848f, 0.871489f, -9.69173f, 1.56102f, - -0.459687f, -8.91601f, -1.77171f, 0.890643f, -9.48104f, - -0.47884f, -0.497994f, -9.48104f, 0.296881f, 0.632069f, - -10.094f, 0.191536f, -0.248997f, -10.4387f, -0.0670376f, - 0.6608f, -8.08282f, 4.95121f, -1.31202f, -8.17859f, - -4.70221f, 1.80044f, -7.9296f, 5.04698f, -0.536301f, - -8.38928f, -4.80756f, 0.68953f, -8.10198f, 5.23851f, - -0.507571f, -7.97748f, -5.17148f, 1.21625f, -8.37013f, - 5.22894f, -0.497994f, -8.01579f, -5.23851f, 0.976834f, - -8.20732f, 5.20978f, -0.335188f, -7.99663f, -5.19063f, - 0.995988f, -8.26478f, 5.02782f, -0.0957681f, -8.0924f, - -5.0374f, 0.948104f, -8.36055f, 5.02782f, -0.268151f, - -8.02536f, -5.09486f, 0.995988f, -8.28394f, 5.01825f, - -0.191536f, -8.20732f, -5.06613f, 0.861913f, -8.37971f, - 5.06613f, -0.325611f, -8.20732f, -5.00867f, 0.92895f, - -8.3414f, 5.04698f, -0.124498f, -8.13071f, -5.14275f, - 0.852336f, -8.29351f, 5.07571f, -0.0766145f, -8.07325f, - -5.10444f, 0.976834f, -8.47547f, 4.77883f, -0.392649f, - -8.13071f, -4.86502f, 1.05345f, -8.60955f, 2.71981f, - 2.79643f, -9.25119f, 1.31202f, -0.306458f, -9.14585f, - 1.02472f, 1.51314f, -8.64786f, -1.33118f, -1.13964f, - -9.35654f, 1.01514f, 2.31759f, -8.72447f, -1.49398f, - -1.72383f, -9.73004f, 1.58017f, 2.7677f, -9.73004f, - -1.84832f, -1.93451f, -9.15543f, 1.33118f, 2.20267f, - -8.93516f, -1.64721f, -0.995988f, -9.45231f, 0.727837f, - 1.81959f, -9.51935f, -0.909797f, -2.78685f, -9.93115f, - 0.191536f, 0.890643f, -9.84496f, -0.23942f, -0.976834f, - -9.61511f, -0.21069f, 0.517148f, -8.80109f, -0.153229f, - -0.430956f, -9.50019f, 0.373495f, 0.948104f, -9.27035f, - -0.555455f, -0.344765f, -9.57681f, 0.172383f, 0.881066f, - -9.43316f, -0.335188f, -0.756568f, -9.50977f, -0.0191536f, - 0.497994f, -9.42358f, -0.181959f, -0.737414f, -9.92157f, - 0.306458f, 0.545878f, -10.0173f, -0.248997f, -0.134075f, - -9.79707f, 0.0287304f, 0.536301f, -9.71088f, -0.162806f, - -0.181959f, -9.60554f, -0.047884f, 0.804452f, -9.39485f, - -0.181959f, -0.593762f, -9.64384f, -0.047884f, 0.612916f, - -9.58638f, -0.201113f, -0.363919f, -9.56723f, 0.248997f, - 0.411803f, -10.1706f, -0.316035f, -0.526724f, -9.63427f, - 0.459687f, 1.09176f, -9.71088f, -0.603339f, -0.23942f, - -9.62469f, -0.0383072f, 0.68953f, -9.50019f, -0.0861913f, - -1.13006f, -9.80665f, -0.134075f, 0.335188f, -9.40442f, - -0.114922f, -0.354342f, -9.34696f, 0.153229f, 1.54187f, - -9.10754f, -0.526724f, -1.00556f, -9.7875f, 0.0287304f, - 0.775721f, -9.58638f, -0.172383f, -0.641646f, -9.60554f, - 0.258574f, 0.919373f, -9.31823f, -0.402226f, -0.603339f, - -9.5385f, -0.0766145f, 0.92895f, -9.09797f, -0.220267f, - -0.354342f, -9.61511f, -0.335188f, 0.316035f, -9.27993f, - 0.0766145f, -0.47884f, -9.40442f, 0.23942f, 0.6608f, - -9.40442f, -0.335188f, -0.603339f, -9.85453f, -0.0766145f, - 0.459687f, -9.54808f, -0.0670376f, -0.287304f, -9.63427f, - -0.344765f, 0.296881f, -9.32781f, 0.0574608f, -0.220267f, - -9.71088f, 0.181959f, 0.354342f, -9.95988f, -0.248997f, - 0.201113f, -9.8258f, -0.0383072f, 0.833182f, -9.83538f, - -0.047884f, -0.670376f, -9.44273f, 0.0670376f, 0.6608f, - -8.90643f, -0.392649f, -0.354342f, -9.54808f, 0.0957681f, - 0.90022f, -9.05008f, -0.411803f, -0.335188f, -9.52892f, - 0.201113f, 1.12049f, -9.23204f, -0.459687f, -0.842759f, - -9.61511f, -0.162806f, 0.248997f, -9.87369f, 0.124498f, - -1.12049f, -9.70131f, -0.0383072f, 0.670376f, -9.50977f, - -0.162806f, -0.890643f, -9.15543f, 0.488417f, 1.51314f, - -8.94474f, -0.852336f, -0.90022f, -9.60554f, -0.23942f, - 0.622492f, -9.35654f, 0.0f, -0.948104f, -9.64384f, - -0.191536f, 1.21625f, -9.2895f, -0.0766145f, -0.785298f, - -9.55765f, -0.306458f, 0.555455f, -9.73004f, 0.172383f, - -0.603339f, -9.663f, -0.306458f, 0.383072f, -9.63427f, - 0.172383f, -0.354342f, -9.70131f, -0.373495f, 0.68953f, - -9.69173f, 0.181959f, -1.0343f, -9.47146f, -0.526724f, - 0.823605f, -9.23204f, 0.220267f, -1.36948f, -9.36612f, - -0.0670376f, 1.05345f, -8.91601f, -0.316035f, -0.814029f, - -9.93115f, -0.268151f, 1.58017f, -10.0748f, 0.143652f, - -1.26414f, -9.87369f, 0.047884f, 2.09732f, -9.39485f, - -0.344765f, -1.48441f, -9.48104f, 0.967257f, 0.699107f, - -9.34696f, -1.15879f, -0.105345f, -9.414f, 0.852336f, - 0.756568f, -9.62469f, -1.0343f, -0.114922f, -9.80665f, - 0.814029f, 0.737414f, -9.23204f, -1.0726f, -0.23942f, - -9.47146f, 0.890643f, 0.392649f, -9.24162f, -1.08218f, - -0.229843f, -9.42358f, 0.775721f, 0.325611f, -9.21289f, - -0.986411f, -0.201113f, -9.52892f, 1.79086f, 2.04944f, - -9.32781f, -2.15478f, -1.39821f, -8.86812f, 2.07817f, - 2.2697f, -8.91601f, -2.24097f, -1.7334f, -9.34696f, - 1.68552f, 2.29843f, -8.78193f, -2.19309f, -1.58017f, - -9.62469f, 1.7334f, 2.35589f, -9.165f, -2.18351f, - -1.63763f, -9.99819f, 2.28886f, 2.27928f, -10.0365f, - -2.36547f, -1.69509f, -10.726f, -0.488417f, -0.363919f, - -9.25119f, 0.976834f, -3.03585f, -9.31823f, 1.41737f, - 2.09732f, -8.8777f, -1.76213f, 0.651223f, -9.71088f, - 1.00556f, 2.28886f, -9.36612f, -1.13006f, -1.53229f, - -9.87369f, 0.814029f, 1.46525f, -9.92157f, -0.919373f, - -0.957681f, -9.35654f, 0.0191536f, 1.09176f, -9.9503f, - -0.0574608f, -1.0726f, -9.50977f, -0.181959f, 0.603339f, - -8.90643f, -0.172383f, -0.0766145f, -9.85453f, -0.287304f, - 0.833182f, -9.76834f, 0.181959f, -0.402226f, -9.50977f, - -0.0957681f, 0.287304f, -9.7875f, 0.0191536f, -0.47884f, - -9.58638f, 0.047884f, 0.344765f, -9.44273f, -0.181959f, - -0.0861913f, -9.57681f, 0.0287304f, 0.555455f, -9.42358f, - -0.220267f, 0.0f, -9.73004f, -0.229843f, 0.21069f, - -9.51935f, 0.0670376f, -0.21069f, -10.0173f, -0.00957681f, - 0.105345f, -9.68215f, -0.0670376f, -0.124498f, -9.50977f, - 0.114922f, 0.287304f, -9.42358f, -0.229843f, 0.0957681f, - -9.57681f, -0.181959f, 0.181959f, -9.32781f, -0.047884f, - 0.105345f, -10.0078f, -0.258574f, -2.19309f, -9.70131f, - 0.248997f, 1.64721f, -9.55765f, -0.612916f, 0.105345f, - -8.76278f, 0.191536f, 0.919373f, -9.414f, -0.0383072f, - -0.641646f, -9.74919f, 0.0670376f, 0.814029f, -9.80665f, - -0.134075f, -0.804452f, -9.44273f, 0.0957681f, 1.01514f, - -9.71088f, 0.220267f, -0.584185f, -9.32781f, -0.248997f, - 0.957681f, -9.76834f, 0.0766145f, -0.440533f, -9.414f, - -0.21069f, 0.708684f, -9.73004f, 0.0574608f, -0.593762f, - -9.27035f, -0.172383f, 0.756568f, -9.663f, 0.287304f, - 0.172383f, -9.10754f, -0.507571f, 0.718261f, -9.49062f, - 0.229843f, 0.0574608f, -9.50977f, -0.402226f, 0.162806f, - -10.1418f, -0.0670376f, -0.411803f, -9.32781f, -0.0383072f, - 0.804452f, -9.57681f, 0.229843f, -0.21069f, -9.57681f, - -0.296881f, 0.469264f, -9.54808f, 2.03986f, 0.641646f, - -10.0269f, -1.00556f, -0.45011f, -8.77236f, 0.402226f, - 0.718261f, -9.37569f, -0.047884f, -0.344765f, -9.98861f, - -1.48441f, 0.047884f, -9.33739f, 1.33118f, -0.23942f, - -9.30866f, -0.68953f, 0.220267f, -10.0556f, 0.708684f, - 0.201113f, -7.12514f, 6.70376f, 0.105345f, -6.81869f, - -6.33985f, 0.92895f, -8.70532f, 5.46836f, 0.220267f, - -8.41801f, -5.36301f, 0.0574608f, -9.84496f, 3.82115f, - 0.248997f, -9.9503f, -3.5913f, -0.229843f, -10.3238f, - 3.09331f, -0.0574608f, -9.71088f, -2.66235f, 0.6608f, - -8.68616f, 1.53229f, 0.641646f, -9.17458f, -1.22583f, - 0.507571f, -10.0078f, -1.09176f, -0.622492f, -10.0078f, - 1.3216f, -0.497994f, -9.46189f, -1.17795f, 0.0766145f, - -9.23204f, 1.01514f, 0.248997f, -9.38527f, -1.94409f, - 0.296881f, -9.21289f, 1.79086f, -0.21069f, -9.10754f, - -2.12605f, 0.440533f, -9.09797f, 1.82917f, 0.172383f, - -9.02135f, -1.54187f, 0.047884f, -9.35654f, 1.54187f, - 0.047884f, -8.99262f, -1.66636f, -0.0191536f, -9.29908f, - 1.49398f, 0.344765f, -9.663f, -1.65679f, -0.593762f, - -9.29908f, 1.58975f, 0.296881f, -9.69173f, -1.1971f, - -0.153229f, -9.5385f, 1.16837f, 0.114922f, -9.80665f, - -1.22583f, 0.268151f, -9.43316f, 1.08218f, -0.114922f, - -9.74919f, -1.27372f, 0.775721f, -9.38527f, 1.11091f, - -0.440533f, -9.49062f, -1.20668f, 0.574608f, -9.37569f, - 0.995988f, -0.536301f, -9.33739f, -1.06303f, 0.871489f, - -9.5385f, 0.948104f, -0.699107f, -9.44273f, -0.976834f, - 0.871489f, -9.72046f, 0.890643f, -0.746991f, -9.87369f, - -1.33118f, 0.488417f, -9.46189f, 1.13006f, 0.248997f, - -8.92558f, -1.0343f, -0.134075f, -9.07881f, 1.04387f, - 0.737414f, -8.82982f, -0.814029f, -1.46525f, -9.20331f, - 1.06303f, 0.105345f, -9.94073f, -0.957681f, -0.153229f, - -9.35654f, 0.948104f, -0.603339f, -9.31823f, 1.34075f, - 2.03028f, -8.82024f, -1.76213f, -0.861913f, -8.42759f, - -0.440533f, 4.67348f, -8.94474f, 0.201113f, -5.08528f, - -7.51779f, -0.948104f, 5.77481f, -8.15944f, 0.833182f, - -5.63116f, -9.69173f, -0.948104f, 2.36547f, -10.1801f, - 0.679953f, -2.2314f, -9.11712f, 1.72383f, 0.574608f, - -8.83939f, -2.03986f, -0.0287304f, -9.31823f, 1.92494f, - 0.804452f, -9.79707f, -2.03028f, -0.517148f, -8.3414f, - 2.68151f, 1.9824f, -8.24563f, -2.71024f, -2.1069f, - -9.15543f, 2.41336f, 2.28886f, -7.49864f, -3.03585f, - -3.66792f, -8.59997f, 2.00155f, 2.59531f, -9.07881f, - -2.11647f, -2.52828f, -9.64384f, 1.89621f, 2.11647f, - -9.36612f, -2.16436f, -1.83875f, -9.01178f, 1.69509f, - 2.19309f, -9.17458f, -1.94409f, -1.56102f, -9.27993f, - 1.49398f, 2.28886f, -9.51935f, -1.72383f, -2.2697f, - -9.10754f, 1.52271f, 2.43251f, -8.84897f, -2.02071f, - -2.02071f, -9.08839f, 1.51314f, 2.55701f, -9.11712f, - -1.8579f, -2.21224f, -9.09797f, 1.47483f, 2.52828f, - -9.13627f, -1.8579f, -2.09732f, -9.06924f, 1.46525f, - 2.43251f, -8.92558f, -1.90578f, -2.09732f, -9.19373f, - 1.50356f, 2.3942f, -9.21289f, -1.82917f, -2.26013f, - -8.5904f, 2.16436f, 2.33674f, -8.51378f, -2.36547f, - -1.83875f, -8.25521f, 3.62961f, 2.03028f, -7.91044f, - -3.74453f, -1.12049f, -8.61913f, 3.84988f, 1.62806f, - -8.83939f, -3.97437f, -1.26414f, -8.23605f, 4.52025f, - 2.13563f, -8.83939f, -4.35745f, -1.14922f, -7.4316f, - 6.02381f, 2.34632f, -7.33583f, -5.84185f, -1.79086f, - -6.63673f, 6.67503f, 2.37505f, -6.44519f, -6.359f, - -1.62806f, -6.06212f, 7.51779f, 2.38462f, -6.25365f, - -7.23049f, -1.80044f, -5.25767f, 8.64786f, 2.09732f, - -4.32872f, -8.68616f, -2.03986f, -4.39575f, 7.97748f, - 2.00155f, -3.77326f, -8.42759f, -0.775721f, -4.64475f, - 8.32224f, 1.61848f, -4.29999f, -8.60955f, -0.622492f, - -4.7501f, 8.5042f, 1.81959f, -4.79798f, -8.4659f, - -1.08218f, -4.64475f, 8.37013f, 1.92494f, -4.53941f, - -8.5904f, -1.13964f, -4.77883f, 8.73405f, 2.11647f, - -3.33273f, -9.414f, -1.37906f, -9.73004f, -0.92895f, - 0.603339f, -9.67257f, 0.852336f, -1.11091f, -9.87369f, - -0.047884f, 0.153229f, -9.98861f, 0.0670376f, -0.440533f, - -9.61511f, 0.651223f, 0.181959f, -9.5385f, -0.785298f, - 0.612916f, -9.50019f, 0.335188f, -0.23942f, -8.88728f, - -0.536301f, 0.00957681f, -9.95988f, 0.670376f, 0.134075f, - -9.29908f, -0.881066f, 0.0861913f, -9.67257f, 0.488417f, - 0.220267f, -9.62469f, -0.545878f, 0.306458f, -9.58638f, - 0.344765f, 0.306458f, -9.165f, -0.574608f, 0.0287304f, - -9.65342f, 0.143652f, 0.287304f, -10.0844f, -0.191536f, - 0.440533f, -9.40442f, 0.679953f, 0.21069f, -9.37569f, - -0.881066f, 0.402226f, -9.79707f, 1.34075f, 0.785298f, - -10.1801f, -1.13964f, -0.220267f, -9.14585f, 2.29843f, - 0.794875f, -9.36612f, -2.24097f, -0.316035f, -8.83939f, - 3.37104f, 0.727837f, -8.70532f, -3.25611f, 0.0766145f, - -8.24563f, 4.42448f, 0.814029f, -8.14029f, -4.27126f, - -0.392649f, -7.63272f, 5.38217f, 0.957681f, -7.05811f, - -5.5737f, -0.0383072f, -7.57525f, 5.93762f, 1.29287f, - -7.02938f, -6.02381f, -0.651223f, -7.46991f, 6.18662f, - 1.76213f, -7.35499f, -6.21535f, -1.37906f, -7.35499f, - 6.38773f, 1.47483f, -7.40287f, -6.27281f, -0.967257f, - -7.02938f, 6.79953f, 1.30245f, -6.95276f, -6.68461f, - -0.890643f, -6.42604f, 7.32626f, 1.09176f, -6.4835f, - -7.19218f, -0.354342f, -6.41646f, 7.57525f, 0.938527f, - -6.11958f, -7.50822f, -0.229843f, -5.88016f, 7.71891f, - 0.794875f, -5.17148f, -7.70933f, 0.105345f, -5.74608f, - 7.85298f, 0.727837f, -5.09486f, -7.72848f, 0.114922f, - -5.9472f, 7.83383f, 0.727837f, -5.91847f, -7.65187f, - -0.0287304f, -5.97593f, 7.77637f, 0.718261f, -6.01423f, - -7.63272f, 0.191536f, -5.95677f, 7.78594f, 0.526724f, - -5.73651f, -7.6806f, 0.507571f, -5.95677f, 7.89129f, - 0.459687f, -5.66947f, -7.74764f, 0.517148f, -5.93762f, - 7.85298f, 0.430956f, -5.81312f, -7.69018f, 0.459687f, - -5.9855f, 7.78594f, 0.469264f, -5.86101f, -7.65187f, - 0.517148f, -6.03339f, 7.82425f, 0.411803f, -5.75566f, - -7.67102f, 0.526724f, -6.00466f, 7.79552f, 0.402226f, - -5.68862f, -7.67102f, 0.42138f, -6.00466f, 7.79552f, - 0.497994f, -5.60243f, -7.69975f, 0.201113f, -6.13873f, - 7.65187f, 0.42138f, -5.3247f, -7.62314f, 0.172383f, - -6.608f, 7.40287f, 0.258574f, -5.77481f, -7.46991f, - 0.593762f, -7.18261f, 6.82826f, 0.134075f, -6.75165f, - -6.71334f, 0.526724f, -7.88171f, 5.79397f, -0.181959f, - -7.19218f, -5.70778f, 1.54187f, -8.4659f, 4.54898f, - -0.842759f, -7.90087f, -4.30956f, 1.95367f, -10.5728f, - 0.632069f, -1.96325f, -9.84496f, 0.153229f, 1.82917f, - -9.27993f, -0.0861913f, -0.92895f, -9.31823f, 0.047884f, - 1.46525f, -9.93115f, 0.325611f, -1.1971f, -10.2759f, - -0.114922f, 2.3942f, -9.59596f, -0.0766145f, -0.316035f, - -9.97903f, 0.363919f, -1.13964f, -9.04051f, 2.50912f, - 1.31202f, -8.67659f, -2.58574f, -0.603339f, -9.83538f, - 1.00556f, 1.40779f, -9.09797f, -0.92895f, -0.948104f, - -9.165f, 0.699107f, 1.24498f, -8.8777f, -0.517148f, - -0.699107f, -9.57681f, 0.507571f, 0.641646f, -9.65342f, - -0.229843f, -0.565032f, -9.55765f, 0.287304f, 0.47884f, - -8.91601f, -0.201113f, -0.833182f, -9.69173f, 0.134075f, - 0.411803f, -9.47146f, 0.162806f, 0.172383f, -9.5385f, - -0.21069f, 0.143652f, -9.30866f, 0.497994f, -0.105345f, - -9.8258f, 0.507571f, 0.507571f, -9.50977f, -0.248997f, - 0.383072f, -9.60554f, 0.641646f, 0.948104f, -9.27993f, - -0.220267f, -0.0766145f, -10.0844f, 0.430956f, 0.986411f, - -9.52892f, -0.00957681f, 0.517148f, -9.02135f, 0.411803f, - 1.43652f, -9.42358f, -0.00957681f, -0.258574f, -9.27035f, - 1.54187f, 0.45011f, -9.84496f, -0.995988f, 0.316035f, - -9.8258f, -0.402226f, 0.842759f, -8.93516f, 0.967257f, - -0.785298f, -8.94474f, 2.63362f, 0.545878f, -9.25119f, - -2.78685f, 0.0383072f, -7.71891f, 5.74608f, 0.909797f, - -9.34696f, -5.07571f, -0.651223f, -8.63828f, 4.58729f, - 0.430956f, -8.69574f, -4.29041f, -1.16837f, -7.39329f, - 7.83383f, 0.612916f, -7.62314f, -7.28795f, -0.229843f, - -6.17704f, 7.59441f, 1.89621f, -5.58328f, -7.56568f, - 0.153229f, -5.53539f, 8.00621f, 0.967257f, -4.83629f, - -7.9679f, 0.411803f, -4.95121f, 8.04452f, 0.248997f, - -4.46279f, -8.20732f, 0.201113f, -4.99909f, 8.42759f, - 0.105345f, -4.89375f, -8.30309f, -0.0287304f, -4.52983f, - 8.5042f, 0.306458f, -4.72137f, -8.5042f, 0.0f, - -4.36702f, 8.72447f, 0.0f, -4.43406f, -8.68616f, - 0.181959f, -4.15633f, 8.8777f, 0.430956f, -3.98395f, - -9.02135f, 0.584185f, -4.14676f, 8.68616f, 0.0670376f, - -3.9648f, -8.85855f, 1.09176f, -4.18506f, 8.84897f, - -0.114922f, -4.35745f, -8.77236f, 0.248997f, -4.22337f, - 8.07325f, 0.325611f, -3.67749f, -8.5042f, 1.37906f, - -9.15543f, 3.87861f, 2.11647f, -9.27993f, -2.25055f, - -1.5706f, -9.31823f, 0.0670376f, 1.47483f, -10.1897f, - -0.0766145f, -0.354342f, -9.24162f, -0.162806f, 0.0670376f, - -9.81623f, 0.325611f, -1.0343f, -5.88016f, 7.79552f, - 1.65679f, -8.16902f, -5.56412f, -2.83473f, -8.38928f, - 4.31914f, 1.39821f, -8.81066f, -4.41491f, -1.08218f, - -8.82982f, 4.46279f, 0.986411f, -8.61913f, -4.73094f, - -0.727837f, -8.06367f, 3.85945f, 1.38864f, -8.16902f, - -3.98395f, -0.766145f, -8.73405f, 3.92649f, 1.63763f, - -8.71489f, -4.10845f, -1.61848f, -8.91601f, 3.36146f, - 2.04944f, -9.08839f, -3.47638f, -1.97282f, -8.82024f, - 3.40934f, 2.29843f, -8.83939f, -3.66792f, -2.24097f, - -8.88728f, 3.553f, 2.17394f, -8.84897f, -3.78284f, - -2.21224f, -8.73405f, 4.01268f, 2.21224f, -8.74362f, - -4.22337f, -2.07817f, -8.63828f, 3.90734f, 2.20267f, - -8.97347f, -3.77326f, -1.87705f, -8.39886f, 4.48195f, - 2.08774f, -9.06924f, -4.30956f, -1.71425f, -7.44118f, - 6.41646f, 1.83875f, -7.72848f, -6.76123f, -1.05345f, - -6.08127f, 7.51779f, 1.35991f, -4.92248f, -7.63272f, - 0.0766145f, -6.33027f, 7.44118f, 1.49398f, -6.03339f, - -7.42203f, -0.430956f, -6.13873f, 7.53695f, 1.42694f, - -6.27281f, -7.45076f, -0.90022f, -6.17704f, 7.54652f, - 1.37906f, -6.14831f, -7.51779f, -0.42138f, -6.06212f, - 7.56568f, 1.47483f, -6.2345f, -7.46033f, -0.316035f, - -6.02381f, 7.67102f, 1.49398f, -6.22492f, -7.50822f, - -0.497994f, -5.67905f, 7.85298f, 1.71425f, -6.03339f, - -7.57525f, -1.05345f, -5.06613f, 8.05409f, 1.83875f, - -4.82671f, -7.97748f, -0.565032f, -4.54898f, 8.23605f, - 1.99198f, -4.42448f, -8.42759f, -1.06303f, -4.24253f, - 8.7532f, 2.17394f, -4.40533f, -8.81066f, -2.05901f, - -3.44765f, 9.10754f, 1.92494f, -3.01669f, -9.39485f, - -0.68953f, -3.055f, 8.68616f, 2.11647f, -3.4285f, - -8.73405f, -1.3216f, -2.72939f, 8.88728f, 2.11647f, - -2.61447f, -9.02135f, -1.21625f, -2.55701f, 9.38527f, - 2.30801f, -2.15478f, -9.663f, -2.33674f, -2.48039f, - 9.23204f, 2.2314f, -1.53229f, -9.71088f, -1.13964f, - -3.66792f, 8.72447f, 2.24097f, -2.29843f, -8.88728f, - -2.31759f, -8.54251f, 3.89776f, 1.75256f, -9.05966f, - -2.90177f, -2.06859f, -9.29908f, 2.04944f, 1.6089f, - -9.86411f, -1.71425f, -1.16837f, -10.2855f, 1.29287f, - 0.766145f, -10.1993f, -1.1971f, -0.373495f, -9.89284f, - 1.1971f, 0.995988f, -9.14585f, -1.48441f, -0.201113f, - -9.43316f, 0.306458f, 1.45567f, -9.19373f, -0.6608f, - -0.727837f, -9.15543f, -0.0287304f, 0.047884f, -9.40442f, - 0.0287304f, 0.392649f, -9.9503f, -0.948104f, 0.0287304f, - -10.1323f, 1.06303f, -0.47884f, -10.0078f, -0.45011f, - 0.23942f, -9.52892f, 0.287304f, -0.191536f, -9.45231f, - -0.545878f, 0.42138f, -9.52892f, 0.354342f, -0.584185f, - -9.86411f, -0.258574f, 0.699107f, -9.44273f, 0.0f, - -0.42138f, -8.4659f, 3.95522f, 0.354342f, -8.57124f, - -4.1276f, 0.430956f, -8.71489f, 4.04141f, 0.306458f, - -8.95431f, -3.9648f, -0.603339f, -8.89685f, 3.58173f, - 0.354342f, -8.52336f, -3.85945f, 0.258574f, -9.35654f, - 3.54342f, -0.785298f, -9.02135f, -3.69665f, 0.92895f, - -8.76278f, 2.84431f, -1.17795f, -8.56167f, -2.806f, - 2.07817f, -8.89685f, 3.13162f, -1.49398f, -8.5042f, - -3.16035f, 2.03028f, -9.09797f, 4.00311f, -0.995988f, - -9.71088f, -3.79242f, 2.70066f, -9.04051f, 3.58173f, - -1.01514f, -8.04452f, -3.64876f, 1.81002f, -7.86256f, - 4.94163f, -0.201113f, -7.46991f, -5.02782f, 1.81959f, - -7.41245f, 6.46434f, -0.47884f, -7.44118f, -6.31112f, - 0.976834f, -6.57927f, 6.68461f, -0.114922f, -6.36858f, - -6.40688f, 2.35589f, -6.02381f, 7.31668f, -0.469264f, - -5.43005f, -7.24007f, 2.43251f, -6.87615f, 7.48906f, - -0.536301f, -7.03895f, -7.15387f, 0.90022f, -5.9855f, - 7.72848f, -0.201113f, -5.78439f, -7.47949f, 1.13964f, - -6.06212f, 7.9296f, -0.268151f, -5.25767f, -7.76679f, - 1.63763f, -5.70778f, 8.29351f, -0.162806f, -4.72137f, - -8.14029f, 1.20668f, -5.29597f, 8.42759f, 0.143652f, - -4.75967f, -8.42759f, 0.603339f, -5.11401f, 8.44674f, - 0.565032f, -4.85544f, -8.43717f, -0.00957681f, -5.43963f, - 8.23605f, 0.919373f, -5.1619f, -8.05409f, -0.325611f, - -5.60243f, 8.0924f, 0.718261f, -5.48751f, -7.86256f, - -0.047884f, -5.84185f, 7.98706f, 1.11091f, -5.58328f, - -7.91044f, 0.162806f, -5.79397f, 7.8434f, 1.16837f, - -5.47793f, -7.69975f, -0.392649f, -5.78439f, 7.77637f, - 1.36948f, -5.63116f, -7.61356f, -0.651223f, -5.95677f, - 7.73806f, 1.55144f, -5.19063f, -7.69975f, -0.833182f, - -6.22492f, 7.5561f, 1.49398f, -5.46836f, -7.53695f, - -0.833182f, -6.87615f, 6.98149f, 1.25456f, -6.53138f, - -6.82826f, -0.871489f, -7.40287f, 6.03339f, 0.6608f, - -6.67503f, -5.9855f, 0.344765f, -8.00621f, 4.66391f, - 0.574608f, -7.71891f, -4.67348f, 0.641646f, -9.48104f, - 2.24097f, 1.0343f, -9.77792f, -2.03028f, -0.995988f, - -9.76834f, 1.30245f, 1.05345f, -9.72046f, -1.25456f, - -0.593762f, -9.47146f, 0.507571f, 1.1971f, -10.4675f, - -0.459687f, -0.804452f, -9.67257f, 0.201113f, 1.15879f, - -9.60554f, -0.383072f, -1.13006f, -9.42358f, -0.0191536f, - 1.08218f, -10.0844f, -0.0574608f, -0.823605f, -7.12514f, - 6.99107f, -0.488417f, -7.20176f, -6.6463f, 1.63763f, - -7.16345f, 6.86657f, -0.430956f, -7.46991f, -6.47392f, - 0.823605f, -7.09641f, 7.1443f, -0.804452f, -6.6463f, - -7.00065f, 1.76213f, -7.50822f, 6.62715f, -0.277727f, - -5.86101f, -7.06768f, 0.986411f, -7.2688f, 7.23049f, - -0.47884f, -7.28795f, -6.97192f, 1.51314f, -7.37414f, - 6.62715f, -0.287304f, -7.24964f, -6.39731f, 0.995988f, - -7.40287f, 6.56969f, -0.392649f, -7.11557f, -6.44519f, - 1.14922f, -7.3071f, 6.8953f, -0.584185f, -6.56011f, - -6.91445f, 1.78129f, -7.51779f, 6.78038f, -0.612916f, - -5.74608f, -7.02938f, 3.48596f, -7.24007f, 6.33985f, - -0.325611f, -6.8953f, -6.03339f, 0.536301f, -8.99262f, - 5.01825f, -0.258574f, -9.73961f, -4.56814f, 0.632069f, - -9.79707f, 1.66636f, 0.287304f, -9.21289f, -1.87705f, - -0.105345f, -9.77792f, 1.10133f, 0.995988f, -8.88728f, - -1.47483f, -0.335188f, -9.44273f, 1.24498f, 0.497994f, - -9.44273f, -1.34075f, -0.268151f, -9.7875f, 1.0726f, - 0.68953f, -9.39485f, -1.27372f, -0.162806f, -8.86812f, - 2.24097f, 0.545878f, -8.61913f, -2.47082f, 0.632069f, - -9.0022f, 2.02071f, 0.718261f, -9.36612f, -2.12605f, - -0.440533f, -9.22246f, 2.29843f, 1.05345f, -9.10754f, - -2.46124f, -0.402226f, -9.55765f, 2.32716f, 0.842759f, - -9.19373f, -2.50912f, -0.497994f, -8.95431f, 2.62405f, - 1.0726f, -9.15543f, -2.73897f, -0.737414f, -9.54808f, - 2.34632f, 1.11091f, -9.05966f, -2.55701f, -0.440533f, - -10.0556f, -0.746991f, 1.15879f, -8.90643f, 1.48441f, - -1.74298f, -8.53294f, -2.1452f, 2.67193f, -9.15543f, - 2.84431f, -1.62806f, -8.94474f, 1.81959f, 0.42138f, - -9.30866f, -1.75256f, -0.746991f, -9.92157f, 2.12605f, - 0.670376f, -9.35654f, -2.24097f, -0.699107f, -9.49062f, - 2.12605f, 1.25456f, -8.91601f, -2.36547f, -0.411803f, - -8.86812f, 2.40378f, 0.948104f, -8.95431f, -2.47082f, - -0.871489f, -8.90643f, 2.65278f, 1.49398f, -8.95431f, - -2.88262f, -1.18752f, -8.95431f, 3.15077f, 1.25456f, - -9.05966f, -3.34231f, -1.10133f, -9.02135f, 2.9305f, - 1.25456f, -9.03093f, -3.26569f, -1.0726f, -9.32781f, - 2.87304f, 1.0726f, -8.97347f, -3.26569f, -0.794875f, - -9.1267f, 2.94966f, 1.10133f, -9.06924f, -3.20823f, - -0.679953f, -9.06924f, 3.01669f, 1.01514f, -8.98304f, - -3.21781f, -0.507571f, -9.165f, 3.18908f, 0.555455f, - -9.03093f, -3.49553f, -0.354342f, -9.04051f, 3.32315f, - 0.344765f, -9.05966f, -3.48596f, -0.181959f, -8.76278f, - 3.02627f, 0.708684f, -8.90643f, -3.23696f, -0.248997f, - -8.85855f, 2.79643f, 0.641646f, -8.90643f, -2.96881f, - -0.306458f, -8.92558f, 2.7677f, 0.833182f, -8.91601f, - -3.02627f, -0.430956f, -8.94474f, 2.86347f, 1.00556f, - -8.86812f, -3.16035f, -0.565032f, -8.98304f, 2.94966f, - 1.1971f, -9.07881f, -3.20823f, -0.766145f, -8.89685f, - 2.92093f, 1.12049f, -8.89685f, -3.09331f, -0.842759f, - -8.83939f, 2.97839f, 0.967257f, -8.85855f, -3.1795f, - -0.919373f, -8.93516f, 3.15077f, 1.42694f, -8.90643f, - -3.43807f, -0.948104f, -8.99262f, 3.20823f, 1.33118f, - -8.92558f, -3.43807f, -1.0726f, -8.86812f, 3.01669f, - 1.52271f, -8.77236f, -3.33273f, -1.08218f, -8.81066f, - 3.23696f, 1.50356f, -8.82024f, -3.4668f, -1.13964f, - -8.86812f, 3.41892f, 1.40779f, -8.90643f, -3.62961f, - -1.06303f, -8.82982f, 3.38061f, 1.55144f, -8.79151f, - -3.62003f, -1.08218f, -8.82024f, 3.12204f, 1.67594f, - -8.82024f, -3.41892f, -1.15879f, -8.73405f, 3.25611f, - 1.75256f, -8.72447f, -3.4285f, -1.28329f, -8.79151f, - 3.32315f, 1.96325f, -8.78193f, -3.5913f, -1.55144f, - -8.71489f, 3.27527f, 2.02071f, -8.73405f, -3.48596f, - -1.67594f, -8.82024f, 3.16035f, 2.02071f, -8.7532f, - -3.41892f, -1.62806f, -8.73405f, 3.40934f, 1.90578f, - -8.74362f, -3.62003f, -1.38864f, -8.74362f, 3.41892f, - 1.93451f, -8.68616f, -3.66792f, -1.45567f, -8.70532f, - 3.40934f, 1.99198f, -8.68616f, -3.62961f, -1.78129f, - -8.69574f, 3.56257f, 1.93451f, -8.72447f, -3.77326f, - -1.45567f, -8.79151f, 3.45723f, 2.13563f, -8.74362f, - -3.68707f, -1.54187f, -8.79151f, 3.25611f, 2.03986f, - -8.65743f, -3.62003f, -1.6089f, -8.80109f, 3.32315f, - 1.92494f, -8.69574f, -3.5913f, -1.88663f, -8.99262f, - 3.13162f, 1.91536f, -8.63828f, -3.50511f, -1.42694f, - -8.69574f, 3.19865f, 2.22182f, -8.86812f, -3.43807f, - -1.80044f, -8.89685f, 2.61447f, 2.05901f, -8.7532f, - -2.85389f, -1.39821f, -9.32781f, 2.38462f, 2.08774f, - -8.85855f, -2.67193f, -1.5706f, -9.72046f, 1.13006f, - 1.86748f, -9.03093f, -0.756568f, -1.0343f, -10.3334f, - 0.42138f, -1.53229f, -9.57681f, -0.220267f, 1.26414f, - -8.95431f, -0.383072f, 0.201113f, -9.73961f, 0.651223f, - -0.565032f, -10.3334f, -0.651223f, -0.0574608f, -9.68215f, - 0.536301f, 1.02472f, -9.56723f, -0.823605f, -0.296881f, - -9.58638f, 0.890643f, 0.0287304f, -9.50977f, -0.957681f, - -0.0957681f, -9.54808f, 0.890643f, 0.0861913f, -9.72046f, - -1.04387f, -0.248997f, -9.35654f, 1.00556f, 0.335188f, - -9.47146f, -0.948104f, -0.325611f, -9.45231f, 0.90022f, - 0.0383072f, -9.70131f, -0.814029f, -0.191536f, -9.51935f, - 0.756568f, 0.335188f, -9.69173f, -0.861913f, -0.0383072f, - -9.58638f, 0.775721f, 0.306458f, -9.73004f, -0.986411f, - 0.00957681f, -9.47146f, 0.833182f, 0.258574f, -9.64384f, - -0.766145f, -0.287304f, -9.5385f, 0.699107f, 0.335188f, - -9.60554f, -0.842759f, -0.153229f, -9.5385f, 0.785298f, - 0.402226f, -9.73961f, -0.890643f, -0.191536f, -9.43316f, - 0.785298f, 0.411803f, -9.663f, -0.737414f, -0.392649f, - -9.56723f, 0.775721f, 0.335188f, -9.60554f, -0.766145f, - -0.287304f, -9.49062f, 0.679953f, 0.344765f, -9.67257f, - -0.785298f, -0.201113f, -9.44273f, 0.699107f, 0.316035f, - -9.62469f, -0.737414f, -0.220267f, -9.54808f, 0.679953f, - 0.440533f, -9.96946f, -0.497994f, -0.392649f, -9.61511f, - 0.440533f, 0.363919f, -9.46189f, -0.383072f, -0.383072f, - -9.48104f, 0.306458f, 0.565032f, -9.69173f, -1.0726f, - -0.766145f, -9.05008f, 0.909797f, 0.775721f, -9.63427f, - -0.430956f, -0.737414f, -9.54808f, 0.344765f, 0.718261f, - -9.58638f, -0.383072f, -0.229843f, -9.5385f, 0.172383f, - 0.632069f, -9.62469f, -0.335188f, -0.545878f, -9.52892f, - 0.306458f, 0.622492f, -9.48104f, -0.383072f, -0.392649f, - -9.44273f, 0.23942f, 0.68953f, -9.70131f, -0.344765f, - -0.354342f, -9.59596f, 0.229843f, 0.565032f, -9.40442f, - -0.392649f, -0.497994f, -9.43316f, 0.248997f, 0.555455f, - -9.34696f, -0.373495f, -0.220267f, -9.34696f, 0.181959f, - 0.392649f, -10.4579f, 0.0670376f, 0.181959f, -9.5385f, - -0.229843f, 0.296881f, -9.29908f, -0.0287304f, -0.42138f, - -9.45231f, 0.00957681f, 0.565032f, -9.84496f, -0.0766145f, - 0.105345f, -9.64384f, -0.0574608f, 0.277727f, -9.67257f, - -0.21069f, -0.306458f, -9.29908f, 0.047884f, 0.469264f, - -9.64384f, -0.248997f, 0.114922f, -9.52892f, 0.0191536f, - 0.201113f, -9.64384f, -0.411803f, -0.0861913f, -9.67257f, - 0.248997f, 0.0670376f, -9.73004f, -0.383072f, -0.00957681f, - -9.59596f, 0.268151f, -0.047884f, -9.77792f, -0.162806f, - 0.0766145f, -9.68215f, 0.00957681f, 0.153229f, -9.68215f, - -0.0957681f, 0.143652f, -9.50977f, -0.0957681f, 0.23942f, - -9.60554f, -0.316035f, 0.0f, -9.43316f, 0.124498f, - 0.134075f, -9.52892f, -0.47884f, -0.134075f, -9.50019f, - 0.316035f, -0.00957681f, -9.88326f, -0.23942f, -0.0670376f, - -9.5385f, 0.0861913f, 0.316035f, -9.60554f, -0.0766145f, - 0.220267f, -9.62469f, -0.00957681f, -0.172383f, -9.74919f, - -0.00957681f, 0.0766145f, -9.43316f, -0.105345f, 0.0957681f, - -9.69173f, -0.0670376f, 0.00957681f, -9.51935f, -0.0383072f, - -0.0383072f, -9.71088f, 0.0191536f, 0.0766145f, -9.50977f, - -0.0957681f, 0.0766145f, -9.56723f, -0.105345f, 0.0861913f, - -9.2895f, -0.114922f, 0.153229f, -9.71088f, -0.162806f, - 0.0861913f, -9.50019f, 0.0287304f, 0.0861913f, -9.64384f, - -0.0191536f, 0.287304f, -9.50977f, -0.134075f, -0.0383072f, - -9.50019f, 0.143652f, 0.21069f, -9.44273f, -0.23942f, - -0.344765f, -9.64384f, -0.0287304f, 0.172383f, -9.48104f, - -0.0574608f, -0.0957681f, -9.69173f, -0.181959f, 0.201113f, - -9.48104f, 0.114922f, -0.0574608f, -9.75877f, -0.0670376f, - 0.0191536f, -9.55765f, 0.0383072f, 0.172383f, -9.61511f, - -0.0574608f, 0.268151f, -9.24162f, -0.0957681f, -0.0574608f, - -9.56723f, 0.047884f, 0.325611f, -9.51935f, -0.134075f, - -0.459687f, -9.47146f, 0.0f, 0.622492f, -9.49062f, - -0.0670376f, -0.488417f, -9.59596f, 0.0f, 0.823605f, - -9.48104f, -0.0383072f, -0.574608f, -9.5385f, -0.335188f, - 0.641646f, -9.54808f, 0.296881f, -0.536301f, -9.48104f, - -0.363919f, 0.641646f, -9.50977f, 0.287304f, -0.45011f, - -9.46189f, -0.047884f, 1.13964f, -9.57681f, 0.0f, - -0.632069f, -9.57681f, -0.316035f, 0.909797f, -9.63427f, - 0.258574f, -0.517148f, -9.64384f, -0.344765f, 0.545878f, - -9.59596f, 0.296881f, -0.440533f, -9.54808f, -0.0574608f, - 0.746991f, -9.59596f, -0.0383072f, -0.296881f, -9.49062f, - 0.00957681f, 0.852336f, -9.46189f, -0.124498f, -0.21069f, - -9.57681f, 0.0766145f, 0.641646f, -9.37569f, -0.181959f, - -0.42138f, -9.70131f, 0.344765f, 0.737414f, -9.24162f, - -0.469264f, -0.794875f, -9.47146f, 0.0f, 0.699107f, - -9.76834f, 0.0287304f, -0.746991f, -9.48104f, -0.153229f, - 1.33118f, -9.36612f, 0.0957681f, -0.948104f, -9.74919f, - -0.201113f, 1.10133f, -9.35654f, 0.181959f, -0.909797f, - -9.54808f, 0.0957681f, 0.881066f, -9.73961f, 0.153229f, - -1.05345f, -9.49062f, -0.306458f, 1.04387f, -9.51935f, - 0.584185f, -0.766145f, -9.93115f, -0.814029f, 0.727837f, - -9.75877f, 1.0726f, -0.316035f, -9.72046f, -0.296881f, - 0.162806f, -9.47146f, 0.392649f, 0.0766145f, -9.40442f, - 0.21069f, 0.287304f, -9.37569f, -0.248997f, 0.536301f, - -9.5385f, 0.0861913f, 0.114922f, -9.40442f, -0.0287304f, - -0.0383072f, -10.0461f, 0.181959f, -0.00957681f, -9.32781f, - -0.181959f, 0.622492f, -9.46189f, 0.296881f, -0.201113f, - -9.35654f, -0.201113f, 0.201113f, -9.31823f, -0.402226f, - 0.21069f, -9.91199f, 0.517148f, 1.01514f, -9.87369f, - 0.047884f, -0.047884f, -9.56723f, 0.248997f, -0.114922f, - -9.76834f, -0.335188f, 0.0383072f, -9.02135f, 0.316035f, - 0.105345f, -9.5385f, -0.335188f, 0.0287304f, -9.59596f, - 0.344765f, 0.670376f, -9.70131f, 0.0287304f, -0.383072f, - -10.4579f, 0.402226f, 0.411803f, -10.4291f, -0.45011f, - 0.306458f, -9.44273f, 0.545878f, 0.430956f, -9.79707f, - 0.507571f, -0.679953f, -9.26077f, -0.469264f, 1.26414f, - -9.51935f, 0.775721f, -0.114922f, -9.19373f, -0.718261f, - 0.718261f, -9.68215f, 0.881066f, -0.316035f, -9.01178f, - -0.890643f, 0.938527f, -9.25119f, 1.04387f, -0.861913f, - -8.76278f, -0.881066f, -0.823605f, -9.71088f, 0.354342f, - -0.181959f, -9.32781f, -0.248997f, -0.0957681f, -10.4387f, - 0.995988f, -0.268151f, -10.2376f, -0.699107f, 0.536301f, - -9.98861f, 0.555455f, -0.0574608f, -9.49062f, -0.459687f, - 0.823605f, -9.79707f, 0.316035f, 0.268151f, -8.85855f, - -0.488417f, -0.574608f, -9.663f, 0.373495f, -0.287304f, - -9.42358f, 0.0191536f, -1.65679f, -9.42358f, 1.0726f, - 1.80044f, -9.63427f, -0.21069f, -1.66636f, -9.31823f, - 0.306458f, 2.83473f, -9.17458f, 0.814029f, -2.98796f, - -8.67659f, 0.143652f, 1.7334f, -9.31823f, 1.23541f, - -1.15879f, -9.13627f, -1.75256f, 0.785298f, -8.80109f, - 2.54743f, -0.0766145f, -9.91199f, -0.134075f, 1.21625f, - -9.72046f, 0.488417f, 0.363919f, -9.14585f, -0.277727f, - 1.0343f, -9.21289f, 0.718261f, -0.143652f, -9.48104f, - -0.296881f, -0.114922f, -9.2895f, 0.565032f, 0.565032f, - -10.2663f, 0.459687f, -0.143652f, -9.56723f, -0.105345f, - 0.459687f, -10.094f, 0.68953f, -0.306458f, -9.59596f, - -0.172383f, 0.957681f, -10.094f, 0.0861913f, -0.220267f, - -9.34696f, 0.191536f, 0.392649f, -9.79707f, -0.181959f, - -0.488417f, -9.55765f, 0.555455f, 1.0343f, -10.1227f, - 0.0191536f, -0.976834f, -9.40442f, 0.354342f, 0.871489f, - -9.69173f, 0.593762f, -0.296881f, -9.14585f, -0.517148f, - 1.31202f, -9.69173f, 0.861913f, -0.775721f, -9.07881f, - -0.68953f, 0.497994f, -9.90242f, 0.919373f, 0.00957681f, - -9.43316f, -0.68953f, 0.325611f, -9.79707f, 0.507571f, - 0.114922f, -9.40442f, -0.316035f, 0.430956f, -9.8258f, - 0.536301f, -0.0191536f, -9.32781f, -0.258574f, 0.258574f, - -9.93115f, 0.383072f, 0.143652f, -9.48104f, -0.181959f, - 0.6608f, -9.55765f, 0.0861913f, -0.0383072f, -9.37569f, - 0.0287304f, 0.430956f, -9.39485f, 0.325611f, 0.0287304f, - -9.32781f, -0.0861913f, 0.392649f, -9.50019f, 0.651223f, - 0.23942f, -9.40442f, -0.469264f, 0.545878f, -9.75877f, - 0.536301f, 0.0574608f, -9.38527f, -0.411803f, 0.47884f, - -9.87369f, 0.574608f, 0.0383072f, -9.54808f, -0.402226f, - 0.258574f, -9.65342f, 0.325611f, 0.23942f, -9.56723f, - -0.220267f, 0.6608f, -9.50977f, 0.134075f, 0.0766145f, - -9.38527f, -0.047884f, 0.536301f, -9.70131f, 0.0f, - -0.42138f, -9.35654f, 0.181959f, 0.881066f, -9.71088f, - 0.181959f, -0.402226f, -9.50019f, -0.00957681f, 0.727837f, - -9.49062f, 0.306458f, -0.0766145f, -9.27993f, -0.268151f, - 0.766145f, -9.73961f, 0.181959f, -0.517148f, -9.49062f, - -0.0287304f, 0.986411f, -9.86411f, 0.0383072f, -0.383072f, - -9.47146f, 0.0383072f, 0.986411f, -9.50977f, 0.402226f, - -0.383072f, -9.10754f, -0.363919f, 0.823605f, -10.0365f, - 0.90022f, -0.497994f, -9.59596f, -0.651223f, 0.833182f, - -9.73961f, 0.517148f, -0.0957681f, -9.31823f, -0.440533f, - 0.641646f, -9.56723f, 0.0191536f, -0.114922f, -9.33739f, - -0.047884f, 0.593762f, -9.67257f, -0.23942f, -0.459687f, - -9.51935f, 0.258574f, 0.794875f, -9.39485f, 0.0574608f, - -0.172383f, -9.29908f, -0.0574608f, 0.440533f, -10.0078f, - 0.134075f, -0.536301f, -9.45231f, -0.0670376f, 0.766145f, - -10.0748f, -0.0287304f, -0.584185f, -9.55765f, -0.0766145f, - 1.06303f, -9.73961f, 0.392649f, -0.402226f, -9.50019f, - -0.316035f, 1.35991f, -9.75877f, 0.229843f, -0.373495f, - -9.51935f, -0.248997f, 1.39821f, -10.2855f, 0.191536f, - -0.181959f, -10.1514f, -0.124498f, 1.23541f, -10.0461f, - 0.105345f, -0.440533f, -9.88326f, 0.0574608f, -0.0191536f, - -9.60554f, -0.201113f, 0.0957681f, -9.33739f, 0.047884f, - -0.248997f, -9.29908f, -0.23942f, 0.373495f, -9.04051f, - -0.0861913f, -0.00957681f, -9.24162f, -0.114922f, 1.78129f, - -9.414f, -0.124498f, -1.16837f, -9.68215f, -0.181959f, - 1.35033f, -9.60554f, 0.0191536f, -1.4461f, -9.19373f, - -0.220267f, 1.84832f, -9.23204f, -0.00957681f, -1.70467f, - -9.11712f, -0.181959f, 1.50356f, -8.74362f, -0.143652f, - -1.97282f, -8.89685f, 0.143652f, 1.88663f, -8.90643f, - -0.373495f, -1.25456f, -8.81066f, -0.124498f, 1.31202f, - -8.79151f, -0.134075f, -0.92895f, -8.99262f, -0.536301f, - 0.430956f, -9.31823f, 0.373495f, -0.181959f, -10.2855f, - -0.153229f, 0.708684f, -10.5536f, 0.229843f, -0.105345f, - -10.2855f, -0.220267f, -0.105345f, -9.95988f, 0.296881f, - -0.162806f, -9.79707f, -0.0861913f, 0.536301f, -9.39485f, - -0.124498f, -0.392649f, -10.2759f, 0.047884f, 1.09176f, - -9.61511f, -0.191536f, -0.517148f, -10.0461f, 0.229843f, - 1.5706f, -9.56723f, -0.430956f, -0.584185f, -9.5385f, - 0.287304f, 0.938527f, -9.49062f, -0.47884f, -0.287304f, - -9.56723f, -0.248997f, 0.497994f, -9.50977f, 0.0766145f, - -0.957681f, -9.79707f, -0.191536f, 0.296881f, -9.40442f, - 0.00957681f, -0.0383072f, -9.61511f, 0.0191536f, 0.268151f, - -9.31823f, -0.201113f, -0.344765f, -9.48104f, 0.45011f, - 0.555455f, -9.29908f, -0.746991f, 0.0191536f, -9.03093f, - 0.248997f, 0.612916f, -8.97347f, -0.459687f, 0.459687f, - -9.11712f, -0.277727f, -0.402226f, -9.0022f, 0.191536f, - 0.191536f, -10.6207f, -0.0766145f, 0.641646f, -10.1897f, - -0.00957681f, 0.344765f, -10.0844f, 0.0574608f, 0.201113f, - -10.1131f, -0.124498f, 0.191536f, -9.38527f, -0.153229f, - -0.0191536f, -9.43316f, -0.0574608f, -0.134075f, -9.42358f, - -0.47884f, 0.172383f, -9.27035f, 0.143652f, 0.21069f, - -10.343f, -0.0383072f, -0.373495f, -9.8258f, 0.0861913f, - 0.316035f, -10.1706f, -0.181959f, -0.143652f, -9.74919f, - 0.114922f, 0.258574f, -9.50977f, -0.430956f, 0.0670376f, - -9.29908f, 0.172383f, 0.344765f, -9.86411f, -0.68953f, - 0.0191536f, -10.0748f, 0.737414f, 0.440533f, -9.91199f, - -0.622492f, -0.430956f, -9.86411f, 0.708684f, 0.335188f, - -9.88326f, -0.392649f, 0.153229f, -9.77792f, 0.354342f, - -0.191536f, -9.60554f, 0.0670376f, 0.0670376f, -9.31823f, - -0.277727f, -0.0957681f, -9.55765f, 0.593762f, 0.153229f, - -9.23204f, -0.852336f, -0.201113f, -9.63427f, 0.42138f, - 0.507571f, -9.42358f, -0.603339f, -0.641646f, -9.64384f, - 0.42138f, 0.718261f, -9.47146f, -0.507571f, -0.995988f, - -9.83538f, 0.134075f, 0.603339f, -9.32781f, -0.172383f, - -0.861913f, -9.60554f, 0.181959f, 1.05345f, -9.72046f, - -0.0574608f, -1.21625f, -9.57681f, -0.00957681f, 1.1971f, - -9.69173f, 0.363919f, -1.31202f, -9.29908f, -0.306458f, - 1.37906f, -9.33739f, 0.766145f, -1.41737f, -9.05008f, - -0.0574608f, 1.09176f, -9.07881f, 0.727837f, -0.861913f, - -9.42358f, -0.785298f, 0.632069f, -9.48104f, 1.01514f, - 0.047884f, -9.69173f, -1.04387f, -0.124498f, -8.99262f, - 1.11091f, 0.325611f, -9.70131f, -0.363919f, -0.325611f, - -9.50019f, 0.737414f, 1.31202f, -9.76834f, -0.162806f, - -1.10133f, -9.68215f, 0.296881f, 1.04387f, -9.77792f, - 0.603339f, -0.0957681f, -9.83538f, -0.47884f, 0.909797f, - -10.4387f, 0.0766145f, -0.459687f, -9.9503f, 0.047884f, - 1.38864f, -9.60554f, -0.584185f, 0.459687f, -9.75877f, - 0.536301f, -0.124498f, -9.74919f, -0.172383f, 0.651223f, - -10.4483f, 0.229843f, -0.268151f, -9.50019f, -1.58975f, - 0.622492f, -9.64384f, 1.58975f, -0.114922f, -8.96389f, - -1.69509f, 1.16837f, -8.72447f, 1.71425f, -1.04387f, - -8.91601f, -0.90022f, 1.92494f, -8.84897f, 1.04387f, - -0.833182f, -8.86812f, -0.0574608f, 1.17795f, -8.91601f, - 0.47884f, -1.47483f, -9.22246f, 1.25456f, 1.76213f, - -8.88728f, -1.42694f, -2.36547f, -10.1227f, 2.24097f, - 2.09732f, -9.09797f, -2.35589f, -3.11246f, -9.84496f, - 2.75812f, 2.1069f, -9.26077f, -2.98796f, -2.33674f, - -9.01178f, 0.0766145f, 4.2138f, -8.45632f, 1.02472f, - -3.69665f, -8.51378f, -0.344765f, 3.95522f, -8.90643f, - 2.00155f, -3.78284f, -9.05966f, -0.497994f, 3.50511f, - -9.42358f, 1.86748f, -3.62003f, -9.68215f, -0.488417f, - 3.74453f, -9.48104f, 1.69509f, -3.18908f, -9.93115f, - -0.871489f, 3.54342f, -9.68215f, 2.03986f, -2.8922f, - -9.85453f, -0.861913f, 3.16035f, -9.81623f, 2.08774f, - -2.66235f, -9.95988f, -0.852336f, 2.74854f, -9.59596f, - 1.83875f, -2.15478f, -10.0652f, -0.622492f, 2.28886f, - -9.5385f, 1.46525f, -2.18351f, -9.67257f, -0.632069f, - 2.01113f, -9.43316f, 1.3216f, -1.67594f, -9.42358f, - -0.679953f, 1.05345f, -9.45231f, 1.5706f, -1.23541f, - -9.2895f, -0.459687f, 1.39821f, -9.5385f, 1.46525f, - -1.16837f, -9.58638f, -0.316035f, 1.47483f, -9.54808f, - 1.20668f, -1.26414f, -9.60554f, -0.411803f, 1.39821f, - -9.31823f, 1.14922f, -1.14922f, -9.76834f, -0.354342f, - 1.35991f, -9.52892f, 1.11091f, -1.35991f, -9.81623f, - 0.0574608f, 1.46525f, -9.663f, 0.833182f, -1.1971f, - -9.80665f, 0.21069f, 1.62806f, -9.70131f, 0.641646f, - -1.24498f, -9.9503f, 0.497994f, 1.53229f, -9.88326f, - 0.325611f, -1.05345f, -9.86411f, 0.565032f, 1.58017f, - -9.87369f, 0.220267f, -1.24498f, -9.94073f, 0.268151f, - 1.97282f, -9.91199f, 0.584185f, -1.35033f, -9.25119f, - 0.306458f, 1.13006f, -9.46189f, 0.383072f, -1.11091f, - -8.97347f, -0.0670376f, 1.22583f, -8.98304f, 0.459687f, - -0.488417f, -9.30866f, -0.737414f, 1.23541f, -9.13627f, - 1.00556f, -0.526724f, -10.6781f, -0.775721f, 0.373495f, - -10.5919f, 1.13964f, 0.42138f, -9.54808f, -2.07817f, - 0.68953f, -9.26077f, 1.82917f, -0.105345f, -9.03093f, - -0.976834f, 0.430956f, -9.47146f, 0.995988f, -0.181959f, - -9.86411f, -0.23942f, 0.124498f, -9.73004f, 0.153229f, - 0.871489f, -9.97903f, -0.220267f, 0.162806f, -9.59596f, - 0.153229f, 0.430956f, -9.8258f, -0.114922f, 0.0957681f, - -9.76834f, 0.00957681f, -0.0287304f, -10.1801f, -0.268151f, - 0.258574f, -10.0844f, 0.23942f, 0.0766145f, -10.1131f, - 0.794875f, 0.0f, -9.86411f, -0.593762f, 0.909797f, - -9.29908f, -2.09732f, 1.72383f, -9.17458f, 1.89621f, - -1.58975f, -8.91601f, -2.16436f, 1.94409f, -9.1267f, - 2.03986f, -1.96325f, -9.30866f, -2.42293f, 2.02071f, - -9.43316f, 2.26013f, -1.38864f, -9.8258f, -2.2697f, - 1.16837f, -9.44273f, 2.16436f, -1.09176f, -9.14585f, - -2.03986f, 1.26414f, -9.01178f, 1.82917f, -1.28329f, - -8.89685f, -2.09732f, 1.64721f, -8.95431f, 1.93451f, - -1.69509f, -8.8777f, -2.19309f, 1.28329f, -9.03093f, - 2.11647f, -1.40779f, -9.31823f, -2.2697f, 1.09176f, - -9.11712f, 2.06859f, -1.3216f, -9.2895f, -2.21224f, - 1.4461f, -9.165f, 2.00155f, -1.48441f, -8.98304f, - -2.20267f, 1.46525f, -8.83939f, 2.00155f, -1.24498f, - -9.14585f, -2.26013f, 1.43652f, -9.01178f, 2.1069f, - -1.45567f, -9.1267f, -2.29843f, 1.63763f, -9.04051f, - 2.12605f, -1.76213f, -9.18416f, -2.27928f, 1.9824f, - -9.09797f, 2.07817f, -1.79086f, -9.08839f, -2.00155f, - 1.79086f, -9.44273f, 1.87705f, -1.62806f, -9.14585f, - -2.31759f, 1.84832f, -8.86812f, 2.06859f, 1.61848f, - -9.165f, -2.24097f, 2.05901f, -9.0022f, 2.02071f, - -1.7334f, -9.04051f, -2.1452f, 2.04944f, -9.2895f, - 2.06859f, -1.70467f, -9.20331f, -2.22182f, 2.06859f, - -9.33739f, 2.09732f, -1.76213f, -9.34696f, -2.13563f, - 1.99198f, -9.1267f, 1.9824f, -1.84832f, -8.88728f, - -1.79086f, 1.55144f, -9.03093f, 1.62806f, -1.61848f, - -9.1267f, -1.58975f, 1.47483f, -9.19373f, 1.49398f, - -1.47483f, -8.92558f, -1.48441f, 1.76213f, -8.69574f, - 1.18752f, -1.76213f, -9.24162f, -1.35991f, 1.49398f, - -9.48104f, 1.23541f, -1.61848f, -9.51935f, 1.86748f, - 2.00155f, -8.71489f, -1.24498f, -2.11647f, -5.6982f, - 8.15944f, 1.27372f, -4.52983f, -7.99663f, -0.775721f, - -4.00311f, 8.31267f, 0.632069f, -3.68707f, -8.03494f, - 0.344765f, -2.16436f, 7.79552f, 3.7158f, -1.7334f, - -7.74764f, -4.22337f, -1.56102f, 8.78193f, 4.39575f, - -1.58017f, -8.76278f, -4.5011f, -1.72383f, 9.05008f, - 5.25767f, -1.93451f, -9.11712f, -3.9648f, -0.995988f, - 7.97748f, 5.34386f, -1.33118f, -7.92002f, -4.03184f, - -0.670376f, 9.17458f, 4.3766f, 0.220267f, -9.60554f, - -4.13718f, -0.746991f, 7.33583f, 5.34386f, -1.1971f, - -7.28795f, -5.14275f, 0.871489f, 7.90087f, 5.80354f, - 0.584185f, -8.33182f, -3.04542f, 0.986411f, 7.59441f, - 6.49307f, -0.0670376f, -7.85298f, -5.92804f, 2.07817f, - 8.83939f, 5.4109f, 0.325611f, -9.59596f, -3.83072f, - 0.718261f, 7.38372f, 5.99508f, 0.248997f, -8.29351f, - -5.10444f, 1.72383f, 7.83383f, 5.85143f, 2.12605f, - -9.15543f, -4.03184f, 2.05901f, 7.37414f, 5.79397f, - 2.19309f, -8.49463f, -4.95121f, 2.13563f, 7.91044f, - 4.29999f, 2.1452f, -8.76278f, -2.24097f, 1.31202f, - 8.59997f, 5.72693f, 0.746991f, -9.55765f, -3.54342f, - 1.36948f, 8.5042f, 5.09486f, 1.17795f, -9.62469f, - -4.1276f, 1.77171f, 8.69574f, 5.46836f, 1.63763f, - -9.40442f, -2.32716f, 1.91536f, 7.75721f, 5.25767f, - 2.04944f, -8.81066f, -2.40378f, 0.392649f, 7.73806f, - 5.63116f, 1.45567f, -9.24162f, -1.49398f, -0.258574f, - 6.82826f, 7.34541f, -0.42138f, -9.07881f, -1.30245f, - -0.517148f, 6.97192f, 7.6806f, -0.890643f, -9.58638f, - -4.81713f, -0.21069f, 3.13162f, 9.20331f, -0.967257f, - -10.0748f, 0.181959f, -0.948104f, -5.9855f, 7.4316f, - -1.00556f, -9.5385f, 0.497994f, 0.162806f, -8.47547f, - 4.32872f, 0.248997f, -9.165f, -2.27928f, 0.143652f, - -8.6287f, 4.47237f, 0.354342f, -9.51935f, 0.986411f, -}; - -const size_t kAccelerometerVerticalHingeTestDataLength = - ARRAY_SIZE(kAccelerometerVerticalHingeTestData); - -const float kAccelerometerVerticalHingeUnstableTestData[] = { - 8.5904f, -1.36948f, -3.74453f, 8.72447f, 1.1971f, 4.00311f, - 8.80109f, -3.08373f, 2.27928f, 8.95431f, -1.90578f, -1.10133f, - 8.93516f, -2.03986f, 0.248997f, 9.05008f, 1.53229f, -0.708684f, - -8.78193f, 1.43652f, -2.63362f, -8.66701f, 0.220267f, 2.79643f, - -8.66701f, -2.06859f, 2.42293f, -8.79151f, -2.88262f, -1.16837f, - 8.74362f, -1.9824f, 3.53384f, 9.04051f, 0.0574608f, -1.36948f, - 8.78193f, -4.1276f, 2.58574f, 8.8777f, 0.201113f, -1.80044f, - 8.70532f, -0.296881f, 1.52271f, 9.02135f, -0.871489f, -2.43251f, - -9.09797f, -1.3216f, -3.60088f, -8.97347f, 2.52828f, 2.6432f, - -8.82024f, 1.87705f, 0.354342f, -7.93917f, -4.38618f, 0.258574f, - -8.81066f, 1.91536f, -2.92093f, -8.04452f, -5.4492f, 3.28484f, - -8.86812f, 2.05901f, 0.890643f, -8.01579f, -5.65989f, -2.20267f, - -9.0022f, 2.18351f, -2.9305f, -8.80109f, -4.01268f, 3.055f, - -9.37569f, -1.04387f, 0.277727f, -6.80911f, 2.806f, -6.0717f, - -8.79151f, -8.79151f, -2.11647f, -8.6287f, -1.53229f, 3.58173f, - -8.97347f, -0.335188f, 1.26414f, 8.5042f, 1.51314f, -2.20267f, - -9.19373f, -1.37906f, 1.41737f, -7.67102f, 2.8922f, -5.09486f, - -8.81066f, 0.986411f, 2.30801f, -8.53294f, 3.26569f, -3.11246f, - -9.03093f, 1.06303f, 1.39821f, -8.8777f, -4.47237f, -0.632069f, - -8.74362f, -1.83875f, -0.0957681f, -7.92002f, 1.0343f, -3.84988f, - -8.92558f, 0.440533f, 1.26414f, -8.71489f, -0.153229f, -3.64876f, -}; - -const size_t kAccelerometerVerticalHingeUnstableTestDataLength = - ARRAY_SIZE(kAccelerometerVerticalHingeUnstableTestData); diff --git a/test/motion_angle_tablet.c b/test/motion_angle_tablet.c deleted file mode 100644 index 5f096b1603..0000000000 --- a/test/motion_angle_tablet.c +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright 2018 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test motion sense code, when in tablet mode. - */ - -#include <math.h> -#include <stdio.h> - -#include "accelgyro.h" -#include "common.h" -#include "gpio.h" -#include "hooks.h" -#include "motion_common.h" -#include "motion_lid.h" -#include "motion_sense.h" -#include "tablet_mode.h" -#include "test_util.h" -#include "util.h" - - -/*****************************************************************************/ -/* Test utilities */ - -/* convert array value from g to m.s^2. */ -int filler(const struct motion_sensor_t *s, const float v) -{ - return FP_TO_INT( fp_div( - FLOAT_TO_FP(v) * MOTION_SCALING_FACTOR, - fp_mul(INT_TO_FP(s->drv->get_range(s)), MOTION_ONE_G))); -} - -static int test_lid_angle_less180(void) -{ - int index = 0, lid_angle; - struct motion_sensor_t *lid = &motion_sensors[ - CONFIG_LID_ANGLE_SENSOR_LID]; - struct motion_sensor_t *base = &motion_sensors[ - CONFIG_LID_ANGLE_SENSOR_BASE]; - - /* We don't have TASK_CHIP so simulate init ourselves */ - hook_notify(HOOK_CHIPSET_SHUTDOWN); - TEST_ASSERT(sensor_active == SENSOR_ACTIVE_S5); - TEST_ASSERT(lid->drv->get_data_rate(lid) == 0); - - /* Go to S0 state */ - hook_notify(HOOK_CHIPSET_SUSPEND); - hook_notify(HOOK_CHIPSET_RESUME); - msleep(1000); - TEST_ASSERT(sensor_active == SENSOR_ACTIVE_S0); - TEST_ASSERT(lid->drv->get_data_rate(lid) == TEST_LID_FREQUENCY); - - /* Open lid, testing close to 180 degree. */ - gpio_set_level(GPIO_LID_OPEN, 1); - msleep(1000); - - cprints(CC_ACCEL, "start loop"); - /* Force clamshell mode, to be sure we go in tablet mode ASAP. */ - tablet_set_mode(0); - - /* Check we stay in tablet mode, even when hinge is vertical. */ - while (index < kAccelerometerVerticalHingeTestDataLength) { - feed_accel_data(kAccelerometerVerticalHingeTestData, - &index, filler); - wait_for_valid_sample(); - lid_angle = motion_lid_get_angle(); - cprints(CC_ACCEL, "%d : LID(%d, %d, %d)/BASE(%d, %d, %d): %d", - index / TEST_LID_SAMPLE_SIZE, - lid->xyz[X], lid->xyz[Y], lid->xyz[Z], - base->xyz[X], base->xyz[Y], base->xyz[Z], - lid_angle); - /* We need few sample to debounce and enter laptop mode. */ - TEST_ASSERT(index < 2 * TEST_LID_SAMPLE_SIZE * \ - (TABLET_MODE_DEBOUNCE_COUNT + 2) || - tablet_get_mode()); - } - /* - * Check we stay in tablet mode, even when hinge is vertical and - * shaked. - */ - tablet_set_mode(0); - while (index < kAccelerometerVerticalHingeUnstableTestDataLength) { - feed_accel_data(kAccelerometerVerticalHingeUnstableTestData, - &index, filler); - wait_for_valid_sample(); - lid_angle = motion_lid_get_angle(); - cprints(CC_ACCEL, "%d : LID(%d, %d, %d)/BASE(%d, %d, %d): %d", - index / TEST_LID_SAMPLE_SIZE, - lid->xyz[X], lid->xyz[Y], lid->xyz[Z], - base->xyz[X], base->xyz[Y], base->xyz[Z], - lid_angle); - /* We need few sample to debounce and enter laptop mode. */ - TEST_ASSERT(index < TEST_LID_SAMPLE_SIZE * - (TABLET_MODE_DEBOUNCE_COUNT + 2) || - tablet_get_mode()); - } - return EC_SUCCESS; -} - - -void run_test(void) -{ - test_reset(); - - RUN_TEST(test_lid_angle_less180); - - test_print_result(); -} diff --git a/test/motion_angle_tablet.tasklist b/test/motion_angle_tablet.tasklist deleted file mode 100644 index 0b774ebb4a..0000000000 --- a/test/motion_angle_tablet.tasklist +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2014 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST \ - TASK_TEST(MOTIONSENSE, motion_sense_task, NULL, TASK_STACK_SIZE) diff --git a/test/motion_common.c b/test/motion_common.c deleted file mode 100644 index 36f9d003a0..0000000000 --- a/test/motion_common.c +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright 2018 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Common test code to test lid angle calculation. - */ - -#include "accelgyro.h" -#include "host_command.h" -#include "motion_common.h" -#include "motion_sense.h" -#include "task.h" -#include "timer.h" - -/*****************************************************************************/ -/* Mock functions */ -static int accel_init(const struct motion_sensor_t *s) -{ - return EC_SUCCESS; -} - -static int accel_read(const struct motion_sensor_t *s, intv3_t v) -{ - rotate(s->xyz, *s->rot_standard_ref, v); - return EC_SUCCESS; -} - -static int accel_get_range(const struct motion_sensor_t *s) -{ - return s->default_range; -} - -static int accel_get_resolution(const struct motion_sensor_t *s) -{ - return 0; -} - -int test_data_rate[2] = { 0 }; - -static int accel_set_data_rate(const struct motion_sensor_t *s, - const int rate, - const int rnd) -{ - test_data_rate[s - motion_sensors] = rate | (rnd ? ROUND_UP_FLAG : 0); - return EC_SUCCESS; -} - -static int accel_get_data_rate(const struct motion_sensor_t *s) -{ - return test_data_rate[s - motion_sensors]; -} - -const struct accelgyro_drv test_motion_sense = { - .init = accel_init, - .read = accel_read, - .get_range = accel_get_range, - .get_resolution = accel_get_resolution, - .set_data_rate = accel_set_data_rate, - .get_data_rate = accel_get_data_rate, -}; - -struct motion_sensor_t motion_sensors[] = { - [BASE] = { - .name = "base", - .active_mask = SENSOR_ACTIVE_S0_S3_S5, - .chip = MOTIONSENSE_CHIP_LSM6DS0, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_BASE, - .drv = &test_motion_sense, - .rot_standard_ref = NULL, - .default_range = 2, /* g, enough for laptop. */ - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = TEST_LID_FREQUENCY, - }, - }, - }, - [LID] = { - .name = "lid", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_KXCJ9, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_LID, - .drv = &test_motion_sense, - .rot_standard_ref = NULL, - .default_range = 2, /* g, enough for laptop. */ - .config = { - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = TEST_LID_FREQUENCY, - }, - }, - }, -}; -const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); - -/* Read 6 samples from array to sensor vectors, convert units if necessary. */ -void feed_accel_data(const float *array, int *idx, - int (filler)(const struct motion_sensor_t*, const float)) -{ - int i, j; - - for (i = 0; i < motion_sensor_count; i++) { - struct motion_sensor_t *s = &motion_sensors[i]; - - for (j = X; j <= Z; j++) - s->xyz[j] = filler(s, array[*idx + i * 3 + j]); - } - *idx += 6; -} - -void wait_for_valid_sample(void) -{ - uint8_t sample; - uint8_t *lpc_status = host_get_memmap(EC_MEMMAP_ACC_STATUS); - - sample = *lpc_status & EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK; - usleep(TEST_LID_EC_RATE); - task_wake(TASK_ID_MOTIONSENSE); - while ((*lpc_status & EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK) == sample) - usleep(TEST_LID_SLEEP_RATE); -} - - diff --git a/test/motion_common.h b/test/motion_common.h deleted file mode 100644 index 45d856d9ef..0000000000 --- a/test/motion_common.h +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright 2018 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Common test code to test lid angle calculation. - */ -#ifndef __CROS_EC_MOTION_COMMON_H -#define __CROS_EC_MOTION_COMMON_H - -#include "motion_sense.h" -/* - * Period in us for the motion task period. - * The task will read the vectors at that interval - */ -#define TEST_LID_EC_RATE (1 * MSEC) -#define TEST_LID_FREQUENCY (1e9 / TEST_LID_EC_RATE) /* mHz */ - -/* - * Time in ms to wait for the task to read the vectors. - */ -#define TEST_LID_SLEEP_RATE (TEST_LID_EC_RATE / 5) - -/* We gather 6 elements [2 vectors of 3 axis] per sample. */ -#define TEST_LID_SAMPLE_SIZE (2 * 3) - -extern enum chipset_state_mask sensor_active; - -extern struct motion_sensor_t motion_sensors[]; -extern const unsigned int motion_sensor_count; - -void wait_for_valid_sample(void); -void feed_accel_data(const float *array, int *idx, - int (filler)(const struct motion_sensor_t *s, const float f)); - -/* - * External data - from - * chromium/src/ash/wm/tablet_mode/tablet_mode_controller_unittest.cc - * - * Test accelerometer data taken with the lid at less than 180 degrees while - * shaking the device around. The data is to be interpreted in groups of 6 where - * each 6 values corresponds to the base accelerometer (-y / g, -x / g, -z / g) - * followed by the lid accelerometer (-y / g , x / g, z / g). - * [ CONFIG_ACCEL_STD_REF_FRAME_OLD must be defined to used this array. ] - */ -extern const float kAccelerometerLaptopModeTestData[]; -extern const size_t kAccelerometerLaptopModeTestDataLength; - -/* - * Test accelerometer data taken with the lid open 360 degrees while - * shaking the device around. The data is to be interpreted in groups of 6 where - * each 6 values corresponds to the base accelerometer (-y / g, -x / g, -z / g) - * followed by the lid accelerometer (-y / g , x / g, z / g). - * [ CONFIG_ACCEL_STD_REF_FRAME_OLD must be defined to used this array. ] - */ -extern const float kAccelerometerFullyOpenTestData[]; -extern const size_t kAccelerometerFullyOpenTestDataLength; - -/* - * Test accelerometer data taken with the lid open 360 degrees while the device - * hinge was nearly vertical, while shaking the device around. The data is to be - * interpreted in groups of 6 where each 6 values corresponds to the X, Y, and Z - * readings from the base and lid accelerometers in this order. - */ -extern const float kAccelerometerVerticalHingeTestData[]; -extern const size_t kAccelerometerVerticalHingeTestDataLength; -extern const float kAccelerometerVerticalHingeUnstableTestData[]; -extern const size_t kAccelerometerVerticalHingeUnstableTestDataLength; -#endif /* __CROS_EC_MOTION_COMMON_H */ diff --git a/test/motion_lid.c b/test/motion_lid.c deleted file mode 100644 index d25de9e3fe..0000000000 --- a/test/motion_lid.c +++ /dev/null @@ -1,342 +0,0 @@ -/* Copyright 2014 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test motion sense code. - */ - -#include <math.h> -#include <stdio.h> - -#include "accelgyro.h" -#include "common.h" -#include "gpio.h" -#include "hooks.h" -#include "host_command.h" -#include "motion_lid.h" -#include "motion_sense.h" -#include "task.h" -#include "test_util.h" -#include "timer.h" -#include "util.h" - -extern enum chipset_state_mask sensor_active; - -/* - * Period in us for the motion task period. - * The task will read the vectors at that interval - */ -#define TEST_LID_EC_RATE (10 * MSEC) - -/* - * Time in ms to wait for the task to read the vectors. - */ -#define TEST_LID_SLEEP_RATE (TEST_LID_EC_RATE / 5) -#define ONE_G_MEASURED (1 << 14) - -/*****************************************************************************/ -/* Mock functions */ -static int accel_init(const struct motion_sensor_t *s) -{ - return EC_SUCCESS; -} - -static int accel_read(const struct motion_sensor_t *s, intv3_t v) -{ - rotate(s->xyz, *s->rot_standard_ref, v); - return EC_SUCCESS; -} - -static int accel_set_range(const struct motion_sensor_t *s, - const int range, - const int rnd) -{ - return EC_SUCCESS; -} - -static int accel_get_range(const struct motion_sensor_t *s) -{ - return s->default_range; -} - -static int accel_get_resolution(const struct motion_sensor_t *s) -{ - return 0; -} - -int test_data_rate[2] = { 0 }; - -static int accel_set_data_rate(const struct motion_sensor_t *s, - const int rate, - const int rnd) -{ - test_data_rate[s - motion_sensors] = rate; - return EC_SUCCESS; -} - -static int accel_get_data_rate(const struct motion_sensor_t *s) -{ - return test_data_rate[s - motion_sensors]; -} - -const struct accelgyro_drv test_motion_sense = { - .init = accel_init, - .read = accel_read, - .set_range = accel_set_range, - .get_range = accel_get_range, - .get_resolution = accel_get_resolution, - .set_data_rate = accel_set_data_rate, - .get_data_rate = accel_get_data_rate, -}; - -struct motion_sensor_t motion_sensors[] = { - [BASE] = { - .name = "base", - .active_mask = SENSOR_ACTIVE_S0_S3_S5, - .chip = MOTIONSENSE_CHIP_LSM6DS0, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_BASE, - .drv = &test_motion_sense, - .rot_standard_ref = NULL, - .default_range = MOTION_SCALING_FACTOR / ONE_G_MEASURED, - .config = { - /* AP: by default shutdown all sensors */ - [SENSOR_CONFIG_AP] = { - .odr = 0, - .ec_rate = 0, - }, - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 119000 | ROUND_UP_FLAG, - .ec_rate = TEST_LID_EC_RATE - }, - /* Used for double tap */ - [SENSOR_CONFIG_EC_S3] = { - .odr = 119000 | ROUND_UP_FLAG, - .ec_rate = TEST_LID_EC_RATE * 100, - }, - [SENSOR_CONFIG_EC_S5] = { - .odr = 0, - .ec_rate = 0, - }, - }, - }, - [LID] = { - .name = "lid", - .active_mask = SENSOR_ACTIVE_S0, - .chip = MOTIONSENSE_CHIP_KXCJ9, - .type = MOTIONSENSE_TYPE_ACCEL, - .location = MOTIONSENSE_LOC_LID, - .drv = &test_motion_sense, - .rot_standard_ref = NULL, - .default_range = MOTION_SCALING_FACTOR / ONE_G_MEASURED, - .config = { - /* AP: by default shutdown all sensors */ - [SENSOR_CONFIG_AP] = { - .odr = 0, - .ec_rate = 0, - }, - /* EC use accel for angle detection */ - [SENSOR_CONFIG_EC_S0] = { - .odr = 119000 | ROUND_UP_FLAG, - .ec_rate = TEST_LID_EC_RATE, - }, - /* Used for double tap */ - [SENSOR_CONFIG_EC_S3] = { - .odr = 200000 | ROUND_UP_FLAG, - .ec_rate = TEST_LID_EC_RATE * 100, - }, - [SENSOR_CONFIG_EC_S5] = { - .odr = 0, - .ec_rate = 0, - }, - }, - }, -}; -const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); - -/*****************************************************************************/ -/* Test utilities */ -static void wait_for_valid_sample(void) -{ - uint8_t sample; - uint8_t *lpc_status = host_get_memmap(EC_MEMMAP_ACC_STATUS); - - sample = *lpc_status & EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK; - usleep(TEST_LID_EC_RATE); - task_wake(TASK_ID_MOTIONSENSE); - while ((*lpc_status & EC_MEMMAP_ACC_STATUS_SAMPLE_ID_MASK) == sample) - usleep(TEST_LID_SLEEP_RATE); -} - -static int test_lid_angle(void) -{ - - struct motion_sensor_t *base = &motion_sensors[ - CONFIG_LID_ANGLE_SENSOR_BASE]; - struct motion_sensor_t *lid = &motion_sensors[ - CONFIG_LID_ANGLE_SENSOR_LID]; - int lid_angle; - - /* We don't have TASK_CHIP so simulate init ourselves */ - hook_notify(HOOK_CHIPSET_SHUTDOWN); - TEST_ASSERT(sensor_active == SENSOR_ACTIVE_S5); - TEST_ASSERT(accel_get_data_rate(lid) == 0); - - /* Go to S0 state */ - hook_notify(HOOK_CHIPSET_SUSPEND); - hook_notify(HOOK_CHIPSET_RESUME); - msleep(1000); - TEST_ASSERT(sensor_active == SENSOR_ACTIVE_S0); - TEST_ASSERT(accel_get_data_rate(lid) == 119000); - - /* - * Set the base accelerometer as if it were sitting flat on a desk - * and set the lid to closed. - */ - base->xyz[X] = 0; - base->xyz[Y] = 0; - base->xyz[Z] = ONE_G_MEASURED; - lid->xyz[X] = 0; - lid->xyz[Y] = 0; - lid->xyz[Z] = -ONE_G_MEASURED; - gpio_set_level(GPIO_LID_OPEN, 0); - /* Initial wake up, like init does */ - task_wake(TASK_ID_MOTIONSENSE); - - /* wait for the EC sampling period to expire */ - msleep(TEST_LID_EC_RATE); - task_wake(TASK_ID_MOTIONSENSE); - - wait_for_valid_sample(); - lid_angle = motion_lid_get_angle(); - cprints(CC_ACCEL, "LID(%d, %d, %d)/BASE(%d, %d, %d): %d", - lid->xyz[X], lid->xyz[Y], lid->xyz[Z], - base->xyz[X], base->xyz[Y], base->xyz[Z], - lid_angle); - TEST_ASSERT(lid_angle == 0); - - /* Set lid open to 90 degrees. */ - lid->xyz[X] = 0; - lid->xyz[Y] = ONE_G_MEASURED; - lid->xyz[Z] = 0; - gpio_set_level(GPIO_LID_OPEN, 1); - msleep(100); - wait_for_valid_sample(); - - TEST_ASSERT(motion_lid_get_angle() == 90); - - /* Set lid open to 225. */ - lid->xyz[X] = 0; - lid->xyz[Y] = -1 * ONE_G_MEASURED * 0.707106; - lid->xyz[Z] = ONE_G_MEASURED * 0.707106; - wait_for_valid_sample(); - TEST_ASSERT(motion_lid_get_angle() == 225); - - /* Set lid open to 350 */ - lid->xyz[X] = 0; - lid->xyz[Y] = -1 * ONE_G_MEASURED * 0.1736; - lid->xyz[Z] = -1 * ONE_G_MEASURED * 0.9848; - wait_for_valid_sample(); - TEST_ASSERT(motion_lid_get_angle() == 350); - - /* - * Set lid open to 10. Since the lid switch still indicates that it's - * open, we should be getting an unreliable reading. - */ - lid->xyz[X] = 0; - lid->xyz[Y] = ONE_G_MEASURED * 0.1736; - lid->xyz[Z] = -1 * ONE_G_MEASURED * 0.9848; - wait_for_valid_sample(); - TEST_ASSERT(motion_lid_get_angle() == LID_ANGLE_UNRELIABLE); - - /* Rotate back to 180 and then 10 */ - lid->xyz[X] = 0; - lid->xyz[Y] = 0; - lid->xyz[Z] = ONE_G_MEASURED; - wait_for_valid_sample(); - TEST_ASSERT(motion_lid_get_angle() == 180); - - /* - * Again, since the lid isn't closed, the angle should be unreliable. - * See SMALL_LID_ANGLE_RANGE. - */ - lid->xyz[X] = 0; - lid->xyz[Y] = ONE_G_MEASURED * 0.1736; - lid->xyz[Z] = -1 * ONE_G_MEASURED * 0.9848; - wait_for_valid_sample(); - TEST_ASSERT(motion_lid_get_angle() == LID_ANGLE_UNRELIABLE); - - /* - * Align base with hinge and make sure it returns unreliable for angle. - * In this test it doesn't matter what the lid acceleration vector is. - */ - base->xyz[X] = ONE_G_MEASURED; - base->xyz[Y] = 0; - base->xyz[Z] = 0; - wait_for_valid_sample(); - TEST_ASSERT(motion_lid_get_angle() == LID_ANGLE_UNRELIABLE); - - /* - * Use all three axes and set lid to negative base and make sure - * angle is 180. - */ - base->xyz[X] = 5296; - base->xyz[Y] = 7856; - base->xyz[Z] = 13712; - lid->xyz[X] = 5296; - lid->xyz[Y] = 7856; - lid->xyz[Z] = 13712; - wait_for_valid_sample(); - TEST_ASSERT(motion_lid_get_angle() == 180); - - /* - * Close the lid and set the angle to 0. - */ - base->xyz[X] = 0; - base->xyz[Y] = 0; - base->xyz[Z] = ONE_G_MEASURED; - lid->xyz[X] = 0; - lid->xyz[Y] = 0; - lid->xyz[Z] = -1 * ONE_G_MEASURED; - gpio_set_level(GPIO_LID_OPEN, 0); - msleep(100); - wait_for_valid_sample(); - TEST_ASSERT(motion_lid_get_angle() == 0); - - /* - * Make the angle large, but since the lid is closed, the angle should - * be regarded as unreliable. - */ - lid->xyz[X] = 0; - lid->xyz[Y] = -1 * ONE_G_MEASURED * 0.1736; - lid->xyz[Z] = -1 * ONE_G_MEASURED * 0.9848; - wait_for_valid_sample(); - TEST_ASSERT(motion_lid_get_angle() == LID_ANGLE_UNRELIABLE); - - /* - * Open the lid to 350, and then close the lid and set the angle - * to 10. The reading of small angle shouldn't be corrected. - */ - gpio_set_level(GPIO_LID_OPEN, 1); - msleep(100); - gpio_set_level(GPIO_LID_OPEN, 0); - msleep(100); - lid->xyz[X] = 0; - lid->xyz[Y] = ONE_G_MEASURED * 0.1736; - lid->xyz[Z] = -1 * ONE_G_MEASURED * 0.9848; - wait_for_valid_sample(); - TEST_ASSERT(motion_lid_get_angle() == 10); - - return EC_SUCCESS; -} - - -void run_test(void) -{ - test_reset(); - - RUN_TEST(test_lid_angle); - - test_print_result(); -} diff --git a/test/motion_lid.tasklist b/test/motion_lid.tasklist deleted file mode 100644 index 0b774ebb4a..0000000000 --- a/test/motion_lid.tasklist +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2014 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST \ - TASK_TEST(MOTIONSENSE, motion_sense_task, NULL, TASK_STACK_SIZE) diff --git a/test/motion_sense_fifo.c b/test/motion_sense_fifo.c deleted file mode 100644 index f18ef1de72..0000000000 --- a/test/motion_sense_fifo.c +++ /dev/null @@ -1,362 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test motion_sense_fifo. - */ - -#include "stdio.h" -#include "motion_sense_fifo.h" -#include "test_util.h" -#include "util.h" -#include "hwtimer.h" - -struct motion_sensor_t motion_sensors[] = { - [BASE] = {}, - [LID] = {}, -}; - -const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors); - -uint32_t mkbp_last_event_time; - -static struct ec_response_motion_sensor_data data[CONFIG_ACCEL_FIFO_SIZE]; -static uint16_t data_bytes_read; - -static int test_insert_async_event(void) -{ - int read_count; - - motion_sense_fifo_insert_async_event(motion_sensors, ASYNC_EVENT_FLUSH); - motion_sense_fifo_insert_async_event(motion_sensors + 1, - ASYNC_EVENT_ODR); - - read_count = motion_sense_fifo_read( - sizeof(data), CONFIG_ACCEL_FIFO_SIZE, - data, &data_bytes_read); - TEST_EQ(read_count, 2, "%d"); - TEST_EQ(data_bytes_read, - (int) (2 * sizeof(struct ec_response_motion_sensor_data)), - "%d"); - - TEST_BITS_SET(data[0].flags, ASYNC_EVENT_FLUSH); - TEST_BITS_CLEARED(data[0].flags, MOTIONSENSE_SENSOR_FLAG_ODR); - TEST_EQ(data[0].sensor_num, 0, "%d"); - - TEST_BITS_SET(data[1].flags, ASYNC_EVENT_ODR); - TEST_BITS_CLEARED(data[1].flags, MOTIONSENSE_SENSOR_FLAG_FLUSH); - TEST_EQ(data[1].sensor_num, 1, "%d"); - - return EC_SUCCESS; -} - -static int test_wake_up_needed(void) -{ - data[0].flags = MOTIONSENSE_SENSOR_FLAG_WAKEUP; - - motion_sense_fifo_stage_data(data, motion_sensors, 0, 100); - TEST_EQ(motion_sense_fifo_wake_up_needed(), 0, "%d"); - - motion_sense_fifo_commit_data(); - TEST_EQ(motion_sense_fifo_wake_up_needed(), 1, "%d"); - - return EC_SUCCESS; -} - -static int test_wake_up_needed_overflow(void) -{ - int i; - - data[0].flags = MOTIONSENSE_SENSOR_FLAG_WAKEUP; - motion_sense_fifo_stage_data(data, motion_sensors, 0, 100); - - data[0].flags = 0; - /* - * Using CONFIG_ACCEL_FIFO_SIZE / 2 since 2 entries are inserted per - * 'data': - * - a timestamp - * - the data - */ - for (i = 0; i < (CONFIG_ACCEL_FIFO_SIZE / 2); i++) - motion_sense_fifo_stage_data(data, motion_sensors, 0, 101 + i); - - TEST_EQ(motion_sense_fifo_wake_up_needed(), 1, "%d"); - return EC_SUCCESS; -} - -static int test_adding_timestamp(void) -{ - int read_count; - - motion_sense_fifo_add_timestamp(100); - read_count = motion_sense_fifo_read( - sizeof(data), CONFIG_ACCEL_FIFO_SIZE, - data, &data_bytes_read); - - TEST_EQ(read_count, 1, "%d"); - TEST_BITS_SET(data[0].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[0].timestamp, 100, "%u"); - return EC_SUCCESS; -} - -static int test_stage_data_sets_xyz(void) -{ - motion_sensors->oversampling_ratio = 1; - motion_sensors->oversampling = 0; - data->data[0] = 1; - data->data[1] = 2; - data->data[2] = 3; - motion_sense_fifo_stage_data(data, motion_sensors, 3, 100); - - TEST_EQ(motion_sensors->xyz[0], 1, "%d"); - TEST_EQ(motion_sensors->xyz[1], 2, "%d"); - TEST_EQ(motion_sensors->xyz[2], 3, "%d"); - - return EC_SUCCESS; -} - -static int test_stage_data_removed_oversample(void) -{ - int read_count; - - motion_sensors->oversampling_ratio = 2; - motion_sensors->oversampling = 0; - data->data[0] = 1; - data->data[1] = 2; - data->data[2] = 3; - motion_sense_fifo_stage_data(data, motion_sensors, 3, 100); - - data->data[0] = 4; - data->data[1] = 5; - data->data[2] = 6; - motion_sense_fifo_stage_data(data, motion_sensors, 3, 110); - motion_sense_fifo_commit_data(); - - read_count = motion_sense_fifo_read( - sizeof(data), CONFIG_ACCEL_FIFO_SIZE, - data, &data_bytes_read); - TEST_EQ(read_count, 3, "%d"); - TEST_BITS_SET(data[0].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[0].timestamp, 100, "%u"); - TEST_BITS_CLEARED(data[1].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[1].data[0], 1, "%d"); - TEST_EQ(data[1].data[1], 2, "%d"); - TEST_EQ(data[1].data[2], 3, "%d"); - TEST_BITS_SET(data[2].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[2].timestamp, 110, "%u"); - - return EC_SUCCESS; -} - -static int test_stage_data_remove_all_oversampling(void) -{ - int read_count; - - motion_sensors->oversampling_ratio = 0; - motion_sensors->oversampling = 0; - data->data[0] = 1; - data->data[1] = 2; - data->data[2] = 3; - motion_sense_fifo_stage_data(data, motion_sensors, 3, 100); - - data->data[0] = 4; - data->data[1] = 5; - data->data[2] = 6; - motion_sense_fifo_stage_data(data, motion_sensors, 3, 110); - motion_sense_fifo_commit_data(); - - read_count = motion_sense_fifo_read( - sizeof(data), CONFIG_ACCEL_FIFO_SIZE, - data, &data_bytes_read); - TEST_EQ(read_count, 2, "%d"); - TEST_BITS_SET(data[0].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[0].timestamp, 100, "%u"); - TEST_BITS_SET(data[1].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[1].timestamp, 110, "%u"); - - return EC_SUCCESS; -} - -static int test_stage_data_evicts_data_with_timestamp(void) -{ - int i, read_count; - - /* Fill the fifo */ - motion_sensors->oversampling_ratio = 1; - for (i = 0; i < CONFIG_ACCEL_FIFO_SIZE / 2; i++) - motion_sense_fifo_stage_data(data, motion_sensors, - 3, i * 100); - - /* Add a single entry (should evict 2) */ - motion_sense_fifo_add_timestamp(CONFIG_ACCEL_FIFO_SIZE * 100); - read_count = motion_sense_fifo_read( - sizeof(data), CONFIG_ACCEL_FIFO_SIZE, - data, &data_bytes_read); - TEST_EQ(read_count, CONFIG_ACCEL_FIFO_SIZE - 1, "%d"); - TEST_BITS_SET(data->flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data->timestamp, 100, "%u"); - TEST_BITS_SET(data[CONFIG_ACCEL_FIFO_SIZE - 2].flags, - MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[CONFIG_ACCEL_FIFO_SIZE - 2].timestamp, - CONFIG_ACCEL_FIFO_SIZE * 100, "%u"); - - return EC_SUCCESS; -} - -static int test_add_data_no_spreading_when_different_sensors(void) -{ - int read_count; - uint32_t now = __hw_clock_source_read(); - - motion_sensors[0].oversampling_ratio = 1; - motion_sensors[1].oversampling_ratio = 1; - - motion_sense_fifo_stage_data(data, motion_sensors, 3, now); - motion_sense_fifo_stage_data(data, motion_sensors + 1, 3, now); - motion_sense_fifo_commit_data(); - - read_count = motion_sense_fifo_read( - sizeof(data), CONFIG_ACCEL_FIFO_SIZE, - data, &data_bytes_read); - TEST_EQ(read_count, 4, "%d"); - TEST_BITS_SET(data[0].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[0].timestamp, now, "%u"); - TEST_BITS_SET(data[2].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[2].timestamp, now, "%u"); - - return EC_SUCCESS; -} - -static int test_add_data_no_spreading_different_timestamps(void) -{ - int read_count; - - motion_sensors[0].oversampling_ratio = 1; - - motion_sense_fifo_stage_data(data, motion_sensors, 3, 100); - motion_sense_fifo_stage_data(data, motion_sensors, 3, 120); - motion_sense_fifo_commit_data(); - - read_count = motion_sense_fifo_read( - sizeof(data), CONFIG_ACCEL_FIFO_SIZE, - data, &data_bytes_read); - TEST_EQ(read_count, 4, "%d"); - TEST_BITS_SET(data[0].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[0].timestamp, 100, "%u"); - TEST_BITS_SET(data[2].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[2].timestamp, 120, "%u"); - - return EC_SUCCESS; -} - -static int test_spread_data_in_window(void) -{ - uint32_t now; - int read_count; - - motion_sensors[0].oversampling_ratio = 1; - motion_sensors[0].collection_rate = 20000; /* ns */ - now = __hw_clock_source_read(); - - motion_sense_fifo_stage_data(data, motion_sensors, 3, - now - 18000); - motion_sense_fifo_stage_data(data, motion_sensors, 3, - now - 18000); - motion_sense_fifo_commit_data(); - read_count = motion_sense_fifo_read( - sizeof(data), CONFIG_ACCEL_FIFO_SIZE, - data, &data_bytes_read); - TEST_EQ(read_count, 4, "%d"); - TEST_BITS_SET(data[0].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[0].timestamp, now - 18000, "%u"); - TEST_BITS_SET(data[2].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - /* TODO(b/142892004): mock __hw_clock_source_read so we can check for - * exact TS. - */ - TEST_NEAR(data[2].timestamp, now, 2, "%u"); - - return EC_SUCCESS; -} - -static int test_spread_data_by_collection_rate(void) -{ - const uint32_t now = __hw_clock_source_read(); - int read_count; - - motion_sensors[0].oversampling_ratio = 1; - motion_sensors[0].collection_rate = 20000; /* ns */ - motion_sense_fifo_stage_data(data, motion_sensors, 3, - now - 20500); - motion_sense_fifo_stage_data(data, motion_sensors, 3, - now - 20500); - motion_sense_fifo_commit_data(); - read_count = motion_sense_fifo_read( - sizeof(data), CONFIG_ACCEL_FIFO_SIZE, - data, &data_bytes_read); - TEST_EQ(read_count, 4, "%d"); - TEST_BITS_SET(data[0].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[0].timestamp, now - 20500, "%u"); - TEST_BITS_SET(data[2].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[2].timestamp, now - 500, "%u"); - - return EC_SUCCESS; -} - -static int test_spread_double_commit_same_timestamp(void) -{ - const uint32_t now = __hw_clock_source_read(); - int read_count; - - motion_sensors[0].oversampling_ratio = 1; - motion_sensors[0].collection_rate = 20000; /* ns */ - motion_sense_fifo_stage_data(data, motion_sensors, 3, - now - 20500); - motion_sense_fifo_commit_data(); - motion_sense_fifo_stage_data(data, motion_sensors, 3, - now - 20500); - motion_sense_fifo_commit_data(); - - read_count = motion_sense_fifo_read( - sizeof(data), CONFIG_ACCEL_FIFO_SIZE, - data, &data_bytes_read); - TEST_EQ(read_count, 4, "%d"); - TEST_BITS_SET(data[0].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_EQ(data[0].timestamp, now - 20500, "%u"); - TEST_BITS_SET(data[2].flags, MOTIONSENSE_SENSOR_FLAG_TIMESTAMP); - TEST_GT(time_until(now - 20500, data[2].timestamp), 10000, "%u"); - TEST_LE(time_until(now - 20500, data[2].timestamp), 20000, "%u"); - - return EC_SUCCESS; -} - -void before_test(void) -{ - motion_sense_fifo_commit_data(); - motion_sense_fifo_read(sizeof(data), CONFIG_ACCEL_FIFO_SIZE, &data, - &data_bytes_read); - motion_sense_fifo_reset_wake_up_needed(); - memset(data, 0, sizeof(data)); - motion_sense_fifo_reset(); -} - -void run_test(void) -{ - test_reset(); - - RUN_TEST(test_insert_async_event); - RUN_TEST(test_wake_up_needed); - RUN_TEST(test_wake_up_needed_overflow); - RUN_TEST(test_adding_timestamp); - RUN_TEST(test_stage_data_sets_xyz); - RUN_TEST(test_stage_data_removed_oversample); - RUN_TEST(test_stage_data_remove_all_oversampling); - RUN_TEST(test_stage_data_evicts_data_with_timestamp); - RUN_TEST(test_add_data_no_spreading_when_different_sensors); - RUN_TEST(test_add_data_no_spreading_different_timestamps); - RUN_TEST(test_spread_data_in_window); - RUN_TEST(test_spread_data_by_collection_rate); - RUN_TEST(test_spread_double_commit_same_timestamp); - - test_print_result(); -} - diff --git a/test/motion_sense_fifo.tasklist b/test/motion_sense_fifo.tasklist deleted file mode 100644 index 0e3696c3f0..0000000000 --- a/test/motion_sense_fifo.tasklist +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST \ - TASK_TEST(MOTIONSENSE, motion_sense_task, NULL, TASK_STACK_SIZE) diff --git a/test/sbs_charging_v2.c b/test/sbs_charging_v2.c deleted file mode 100644 index 2e69beaf6e..0000000000 --- a/test/sbs_charging_v2.c +++ /dev/null @@ -1,697 +0,0 @@ -/* Copyright 2014 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test lid switch. - */ - -#include "battery_smart.h" -#include "charge_state.h" -#include "chipset.h" -#include "common.h" -#include "gpio.h" -#include "hooks.h" -#include "host_command.h" -#include "task.h" -#include "test_util.h" -#include "util.h" - -#define WAIT_CHARGER_TASK 600 -#define BATTERY_DETACH_DELAY 35000 - -static int mock_chipset_state = CHIPSET_STATE_ON; -static int is_shutdown; -static int is_force_discharge; -static int is_hibernated; -static int override_voltage, override_current, override_usec; - -/* The simulation doesn't really hibernate, so we must reset this ourselves */ -extern timestamp_t shutdown_target_time; - -static void reset_mocks(void) -{ - mock_chipset_state = CHIPSET_STATE_ON; - is_shutdown = is_force_discharge = is_hibernated = 0; - override_voltage = override_current = override_usec = 0; - shutdown_target_time.val = 0ULL; -} - -int board_cut_off_battery(void) -{ - return EC_SUCCESS; -} - -void chipset_force_shutdown(enum chipset_shutdown_reason reason) -{ - is_shutdown = 1; - mock_chipset_state = CHIPSET_STATE_HARD_OFF; -} - -int chipset_in_state(int state_mask) -{ - return state_mask & mock_chipset_state; -} - -int board_discharge_on_ac(int enabled) -{ - is_force_discharge = enabled; - return EC_SUCCESS; -} - -void system_hibernate(int sec, int usec) -{ - is_hibernated = 1; -} - -int charger_profile_override(struct charge_state_data *curr) -{ - if (override_voltage) - curr->requested_voltage = override_voltage; - if (override_current) - curr->requested_current = override_current; - - if (override_usec) - return override_usec; - - /* Don't let it sleep a whole minute when the AP is off */ - if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) - return CHARGE_POLL_PERIOD_LONG; - - return 0; -} - -static uint32_t meh; -enum ec_status charger_profile_override_get_param(uint32_t param, - uint32_t *value) -{ - if (param == CS_PARAM_CUSTOM_PROFILE_MIN) { - *value = meh; - return EC_RES_SUCCESS; - } - return EC_RES_INVALID_PARAM; -} -enum ec_status charger_profile_override_set_param(uint32_t param, - uint32_t value) -{ - if (param == CS_PARAM_CUSTOM_PROFILE_MIN) { - meh = value; - return EC_RES_SUCCESS; - } - return EC_RES_INVALID_PARAM; -} - -static int wait_charging_state(void) -{ - enum charge_state state; - task_wake(TASK_ID_CHARGER); - msleep(WAIT_CHARGER_TASK); - state = charge_get_state(); - ccprintf("[CHARGING TEST] state = %d\n", state); - return state; -} - -static int charge_control(enum ec_charge_control_mode mode) -{ - struct ec_params_charge_control params; - params.mode = mode; - return test_send_host_command(EC_CMD_CHARGE_CONTROL, 1, ¶ms, - sizeof(params), NULL, 0); -} - -/* Setup init condition */ -static void test_setup(int on_ac) -{ - const struct battery_info *bat_info = battery_get_info(); - - reset_mocks(); - - /* 50% of charge */ - sb_write(SB_RELATIVE_STATE_OF_CHARGE, 50); - sb_write(SB_ABSOLUTE_STATE_OF_CHARGE, 50); - /* full charge capacity in mAh */ - sb_write(SB_FULL_CHARGE_CAPACITY, 0xf000); - /* 25 degree Celsius */ - sb_write(SB_TEMPERATURE, CELSIUS_TO_DECI_KELVIN(25)); - /* battery pack voltage */ - sb_write(SB_VOLTAGE, bat_info->voltage_normal); - /* desired charging voltage/current */ - sb_write(SB_CHARGING_VOLTAGE, bat_info->voltage_max); - sb_write(SB_CHARGING_CURRENT, 4000); - - /* battery pack current is positive when charging */ - if (on_ac) { - sb_write(SB_CURRENT, 1000); - gpio_set_level(GPIO_AC_PRESENT, 1); - } else { - sb_write(SB_CURRENT, -100); - gpio_set_level(GPIO_AC_PRESENT, 0); - } - - /* Reset the charger state to initial state */ - charge_control(CHARGE_CONTROL_NORMAL); - - /* Let things stabilize */ - wait_charging_state(); -} - -/* Host Event helpers */ -static int ev_is_set(int event) -{ - return host_get_events() & EC_HOST_EVENT_MASK(event); -} -static int ev_is_clear(int event) -{ - return !ev_is_set(event); -} -static void ev_clear(int event) -{ - host_clear_events(EC_HOST_EVENT_MASK(event)); -} - -static int test_charge_state(void) -{ - enum charge_state state; - uint32_t flags; - - /* On AC */ - test_setup(1); - - ccprintf("[CHARGING TEST] AC on\n"); - - /* Detach battery, charging error */ - ccprintf("[CHARGING TEST] Detach battery\n"); - TEST_ASSERT(test_detach_i2c(I2C_PORT_BATTERY, BATTERY_ADDR_FLAGS) == - EC_SUCCESS); - msleep(BATTERY_DETACH_DELAY); - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_ERROR); - - /* Attach battery again, charging */ - ccprintf("[CHARGING TEST] Attach battery\n"); - test_attach_i2c(I2C_PORT_BATTERY, BATTERY_ADDR_FLAGS); - /* And changing full capacity should trigger a host event */ - ev_clear(EC_HOST_EVENT_BATTERY); - sb_write(SB_FULL_CHARGE_CAPACITY, 0xeff0); - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_CHARGE); - TEST_ASSERT(ev_is_set(EC_HOST_EVENT_BATTERY)); - - /* Unplug AC, discharging at 1000mAh */ - ccprintf("[CHARGING TEST] AC off\n"); - gpio_set_level(GPIO_AC_PRESENT, 0); - sb_write(SB_CURRENT, -1000); - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_DISCHARGE); - flags = charge_get_flags(); - TEST_ASSERT(!(flags & CHARGE_FLAG_EXTERNAL_POWER)); - TEST_ASSERT(!(flags & CHARGE_FLAG_FORCE_IDLE)); - - /* Discharging waaaay overtemp is ignored */ - ccprintf("[CHARGING TEST] AC off, batt temp = 0xffff\n"); - gpio_set_level(GPIO_AC_PRESENT, 0); - sb_write(SB_CURRENT, -1000); - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_DISCHARGE); - sb_write(SB_TEMPERATURE, 0xffff); - state = wait_charging_state(); - TEST_ASSERT(!is_shutdown); - TEST_ASSERT(state == PWR_STATE_DISCHARGE); - sb_write(SB_TEMPERATURE, CELSIUS_TO_DECI_KELVIN(40)); - - /* Discharging overtemp */ - ccprintf("[CHARGING TEST] AC off, batt temp = 90 C\n"); - gpio_set_level(GPIO_AC_PRESENT, 0); - sb_write(SB_CURRENT, -1000); - - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_DISCHARGE); - sb_write(SB_TEMPERATURE, CELSIUS_TO_DECI_KELVIN(90)); - state = wait_charging_state(); - sleep(CONFIG_BATTERY_CRITICAL_SHUTDOWN_TIMEOUT); - TEST_ASSERT(is_shutdown); - TEST_ASSERT(state == PWR_STATE_DISCHARGE); - sb_write(SB_TEMPERATURE, CELSIUS_TO_DECI_KELVIN(40)); - - /* Force idle */ - ccprintf("[CHARGING TEST] AC on, force idle\n"); - gpio_set_level(GPIO_AC_PRESENT, 1); - sb_write(SB_CURRENT, 1000); - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_CHARGE); - flags = charge_get_flags(); - TEST_ASSERT(flags & CHARGE_FLAG_EXTERNAL_POWER); - TEST_ASSERT(!(flags & CHARGE_FLAG_FORCE_IDLE)); - charge_control(CHARGE_CONTROL_IDLE); - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_IDLE); - flags = charge_get_flags(); - TEST_ASSERT(flags & CHARGE_FLAG_EXTERNAL_POWER); - TEST_ASSERT(flags & CHARGE_FLAG_FORCE_IDLE); - charge_control(CHARGE_CONTROL_NORMAL); - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_CHARGE); - - /* Force discharge */ - ccprintf("[CHARGING TEST] AC on, force discharge\n"); - gpio_set_level(GPIO_AC_PRESENT, 1); - sb_write(SB_CURRENT, 1000); - charge_control(CHARGE_CONTROL_DISCHARGE); - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_IDLE); - TEST_ASSERT(is_force_discharge); - charge_control(CHARGE_CONTROL_NORMAL); - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_CHARGE); - TEST_ASSERT(!is_force_discharge); - - return EC_SUCCESS; -} - -static int test_low_battery(void) -{ - test_setup(1); - - ccprintf("[CHARGING TEST] Low battery with AC and positive current\n"); - sb_write(SB_RELATIVE_STATE_OF_CHARGE, 2); - sb_write(SB_CURRENT, 1000); - wait_charging_state(); - mock_chipset_state = CHIPSET_STATE_SOFT_OFF; - hook_notify(HOOK_CHIPSET_SHUTDOWN); - TEST_ASSERT(!is_hibernated); - - ccprintf("[CHARGING TEST] Low battery with AC and negative current\n"); - sb_write(SB_CURRENT, -1000); - wait_charging_state(); - sleep(CONFIG_BATTERY_CRITICAL_SHUTDOWN_TIMEOUT); - TEST_ASSERT(is_hibernated); - - ccprintf("[CHARGING TEST] Low battery shutdown S0->S5\n"); - mock_chipset_state = CHIPSET_STATE_ON; - hook_notify(HOOK_CHIPSET_PRE_INIT); - hook_notify(HOOK_CHIPSET_STARTUP); - gpio_set_level(GPIO_AC_PRESENT, 0); - is_hibernated = 0; - sb_write(SB_CURRENT, -1000); - sb_write(SB_RELATIVE_STATE_OF_CHARGE, 2); - wait_charging_state(); - mock_chipset_state = CHIPSET_STATE_SOFT_OFF; - hook_notify(HOOK_CHIPSET_SHUTDOWN); - wait_charging_state(); - /* after a while, the EC should hibernate */ - sleep(CONFIG_BATTERY_CRITICAL_SHUTDOWN_TIMEOUT); - TEST_ASSERT(is_hibernated); - - ccprintf("[CHARGING TEST] Low battery shutdown S5\n"); - is_hibernated = 0; - sb_write(SB_RELATIVE_STATE_OF_CHARGE, 10); - wait_charging_state(); - sb_write(SB_RELATIVE_STATE_OF_CHARGE, 2); - wait_charging_state(); - /* after a while, the EC should hibernate */ - sleep(CONFIG_BATTERY_CRITICAL_SHUTDOWN_TIMEOUT); - TEST_ASSERT(is_hibernated); - - ccprintf("[CHARGING TEST] Low battery AP shutdown\n"); - is_shutdown = 0; - mock_chipset_state = CHIPSET_STATE_ON; - sb_write(SB_RELATIVE_STATE_OF_CHARGE, 10); - gpio_set_level(GPIO_AC_PRESENT, 1); - sb_write(SB_CURRENT, 1000); - wait_charging_state(); - gpio_set_level(GPIO_AC_PRESENT, 0); - sb_write(SB_CURRENT, -1000); - sb_write(SB_RELATIVE_STATE_OF_CHARGE, 2); - wait_charging_state(); - usleep(32 * SECOND); - wait_charging_state(); - TEST_ASSERT(is_shutdown); - - return EC_SUCCESS; -} - -static int test_high_temp_battery(void) -{ - test_setup(1); - - ccprintf("[CHARGING TEST] High battery temperature shutdown\n"); - ev_clear(EC_HOST_EVENT_BATTERY_SHUTDOWN); - sb_write(SB_TEMPERATURE, CELSIUS_TO_DECI_KELVIN(90)); - wait_charging_state(); - TEST_ASSERT(ev_is_set(EC_HOST_EVENT_BATTERY_SHUTDOWN)); - TEST_ASSERT(!is_shutdown); - sleep(CONFIG_BATTERY_CRITICAL_SHUTDOWN_TIMEOUT); - TEST_ASSERT(is_shutdown); - - ccprintf("[CHARGING TEST] High battery temp S0->S5 hibernate\n"); - mock_chipset_state = CHIPSET_STATE_SOFT_OFF; - wait_charging_state(); - TEST_ASSERT(is_hibernated); - - return EC_SUCCESS; -} - -static int test_external_funcs(void) -{ - int rv, temp; - uint32_t flags; - int state; - - /* Connect the AC */ - test_setup(1); - - flags = charge_get_flags(); - TEST_ASSERT(flags & CHARGE_FLAG_EXTERNAL_POWER); - TEST_ASSERT(!(flags & CHARGE_FLAG_FORCE_IDLE)); - - /* Invalid or do-nothing commands first */ - UART_INJECT("chg\n"); - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_CHARGE); - flags = charge_get_flags(); - TEST_ASSERT(flags & CHARGE_FLAG_EXTERNAL_POWER); - TEST_ASSERT(!(flags & CHARGE_FLAG_FORCE_IDLE)); - - UART_INJECT("chg blahblah\n"); - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_CHARGE); - flags = charge_get_flags(); - TEST_ASSERT(flags & CHARGE_FLAG_EXTERNAL_POWER); - TEST_ASSERT(!(flags & CHARGE_FLAG_FORCE_IDLE)); - - UART_INJECT("chg idle\n"); - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_CHARGE); - flags = charge_get_flags(); - TEST_ASSERT(flags & CHARGE_FLAG_EXTERNAL_POWER); - TEST_ASSERT(!(flags & CHARGE_FLAG_FORCE_IDLE)); - - UART_INJECT("chg idle blargh\n"); - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_CHARGE); - flags = charge_get_flags(); - TEST_ASSERT(flags & CHARGE_FLAG_EXTERNAL_POWER); - TEST_ASSERT(!(flags & CHARGE_FLAG_FORCE_IDLE)); - - /* Now let's force idle on and off */ - UART_INJECT("chg idle on\n"); - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_IDLE); - flags = charge_get_flags(); - TEST_ASSERT(flags & CHARGE_FLAG_EXTERNAL_POWER); - TEST_ASSERT(flags & CHARGE_FLAG_FORCE_IDLE); - - UART_INJECT("chg idle off\n"); - wait_charging_state(); - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_CHARGE); - flags = charge_get_flags(); - TEST_ASSERT(flags & CHARGE_FLAG_EXTERNAL_POWER); - TEST_ASSERT(!(flags & CHARGE_FLAG_FORCE_IDLE)); - - /* and the rest */ - TEST_ASSERT(charge_get_state() == PWR_STATE_CHARGE); - TEST_ASSERT(!charge_want_shutdown()); - TEST_ASSERT(charge_get_percent() == 50); - temp = 0; - rv = charge_get_battery_temp(0, &temp); - TEST_ASSERT(rv == EC_SUCCESS); - TEST_ASSERT(K_TO_C(temp) == 25); - - return EC_SUCCESS; -} - -#define CHG_OPT1 0x2000 -#define CHG_OPT2 0x4000 -static int test_hc_charge_state(void) -{ - enum charge_state state; - int i, rv, tmp; - struct ec_params_charge_state params; - struct ec_response_charge_state resp; - - /* Let's connect the AC again. */ - test_setup(1); - - /* Initialize the charger options with some nonzero value */ - TEST_ASSERT(charger_set_option(CHG_OPT1) == EC_SUCCESS); - - /* Get the state */ - memset(&resp, 0, sizeof(resp)); - params.cmd = CHARGE_STATE_CMD_GET_STATE; - rv = test_send_host_command(EC_CMD_CHARGE_STATE, 0, - ¶ms, sizeof(params), - &resp, sizeof(resp)); - TEST_ASSERT(rv == EC_RES_SUCCESS); - TEST_ASSERT(resp.get_state.ac); - TEST_ASSERT(resp.get_state.chg_voltage); - TEST_ASSERT(resp.get_state.chg_current); - TEST_ASSERT(resp.get_state.chg_input_current); - TEST_ASSERT(resp.get_state.batt_state_of_charge); - - /* Check all the params */ - for (i = 0; i < CS_NUM_BASE_PARAMS; i++) { - - /* Read it */ - memset(&resp, 0, sizeof(resp)); - params.cmd = CHARGE_STATE_CMD_GET_PARAM; - params.get_param.param = i; - rv = test_send_host_command(EC_CMD_CHARGE_STATE, 0, - ¶ms, sizeof(params), - &resp, sizeof(resp)); - TEST_ASSERT(rv == EC_RES_SUCCESS); - if (i != CS_PARAM_LIMIT_POWER) - TEST_ASSERT(resp.get_param.value); - else - TEST_ASSERT(!resp.get_param.value); - - /* Bump it up a bit */ - tmp = resp.get_param.value; - switch (i) { - case CS_PARAM_CHG_VOLTAGE: - case CS_PARAM_CHG_CURRENT: - case CS_PARAM_CHG_INPUT_CURRENT: - tmp -= 128; /* Should be valid delta */ - break; - case CS_PARAM_CHG_STATUS: - case CS_PARAM_LIMIT_POWER: - /* These ones can't be set */ - break; - case CS_PARAM_CHG_OPTION: - tmp = CHG_OPT2; - break; - } - params.cmd = CHARGE_STATE_CMD_SET_PARAM; - params.set_param.param = i; - params.set_param.value = tmp; - rv = test_send_host_command(EC_CMD_CHARGE_STATE, 0, - ¶ms, sizeof(params), - &resp, sizeof(resp)); - if (i == CS_PARAM_CHG_STATUS || i == CS_PARAM_LIMIT_POWER) - TEST_ASSERT(rv == EC_RES_ACCESS_DENIED); - else - TEST_ASSERT(rv == EC_RES_SUCCESS); - /* Allow the change to take effect */ - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_CHARGE); - - /* Read it back again*/ - memset(&resp, 0, sizeof(resp)); - params.cmd = CHARGE_STATE_CMD_GET_PARAM; - params.get_param.param = i; - rv = test_send_host_command(EC_CMD_CHARGE_STATE, 0, - ¶ms, sizeof(params), - &resp, sizeof(resp)); - TEST_ASSERT(rv == EC_RES_SUCCESS); - TEST_ASSERT(resp.get_param.value == tmp); - } - - /* And a custom profile param */ - meh = 0xdeadbeef; - memset(&resp, 0, sizeof(resp)); - params.cmd = CHARGE_STATE_CMD_GET_PARAM; - params.get_param.param = CS_PARAM_CUSTOM_PROFILE_MIN; - rv = test_send_host_command(EC_CMD_CHARGE_STATE, 0, - ¶ms, sizeof(params), - &resp, sizeof(resp)); - TEST_ASSERT(rv == EC_RES_SUCCESS); - TEST_ASSERT(resp.get_param.value == meh); - params.cmd = CHARGE_STATE_CMD_SET_PARAM; - params.set_param.param = CS_PARAM_CUSTOM_PROFILE_MIN; - params.set_param.value = 0xc0def00d; - rv = test_send_host_command(EC_CMD_CHARGE_STATE, 0, - ¶ms, sizeof(params), - &resp, sizeof(resp)); - TEST_ASSERT(rv == EC_RES_SUCCESS); - /* Allow the change to take effect */ - state = wait_charging_state(); - TEST_ASSERT(meh == params.set_param.value); - - /* param out of range */ - params.cmd = CHARGE_STATE_CMD_GET_PARAM; - params.get_param.param = CS_NUM_BASE_PARAMS; - rv = test_send_host_command(EC_CMD_CHARGE_STATE, 0, - ¶ms, sizeof(params), - &resp, sizeof(resp)); - TEST_ASSERT(rv == EC_RES_INVALID_PARAM); - params.cmd = CHARGE_STATE_CMD_SET_PARAM; - params.set_param.param = CS_NUM_BASE_PARAMS; - params.set_param.value = 0x1000; /* random value */ - rv = test_send_host_command(EC_CMD_CHARGE_STATE, 0, - ¶ms, sizeof(params), - &resp, sizeof(resp)); - TEST_ASSERT(rv == EC_RES_INVALID_PARAM); - - /* command out of range */ - params.cmd = CHARGE_STATE_NUM_CMDS; - rv = test_send_host_command(EC_CMD_CHARGE_STATE, 0, - ¶ms, sizeof(params), - &resp, sizeof(resp)); - TEST_ASSERT(rv == EC_RES_INVALID_PARAM); - - /* - * We've screwed with the charger settings, so let the state machine - * reset itself before we stop. - */ - test_setup(0); - test_setup(1); - - return EC_SUCCESS; -} - -static int test_hc_current_limit(void) -{ - int rv, norm_current, lower_current; - struct ec_params_charge_state cs_params; - struct ec_response_charge_state cs_resp; - struct ec_params_current_limit cl_params; - - /* On AC */ - test_setup(1); - - /* See what current the charger is delivering */ - cs_params.cmd = CHARGE_STATE_CMD_GET_STATE; - rv = test_send_host_command(EC_CMD_CHARGE_STATE, 0, - &cs_params, sizeof(cs_params), - &cs_resp, sizeof(cs_resp)); - TEST_ASSERT(rv == EC_RES_SUCCESS); - norm_current = cs_resp.get_state.chg_current; - - /* Lower it a bit */ - lower_current = norm_current - 256; - cl_params.limit = lower_current; - rv = test_send_host_command(EC_CMD_CHARGE_CURRENT_LIMIT, 0, - &cl_params, sizeof(cl_params), - 0, 0); - TEST_ASSERT(rv == EC_RES_SUCCESS); - wait_charging_state(); - - /* See that it's changed */ - rv = test_send_host_command(EC_CMD_CHARGE_STATE, 0, - &cs_params, sizeof(cs_params), - &cs_resp, sizeof(cs_resp)); - TEST_ASSERT(rv == EC_RES_SUCCESS); - TEST_ASSERT(lower_current == cs_resp.get_state.chg_current); - - /* Remove the limit */ - cl_params.limit = -1U; - rv = test_send_host_command(EC_CMD_CHARGE_CURRENT_LIMIT, 0, - &cl_params, sizeof(cl_params), - 0, 0); - TEST_ASSERT(rv == EC_RES_SUCCESS); - wait_charging_state(); - - /* See that it's back */ - rv = test_send_host_command(EC_CMD_CHARGE_STATE, 0, - &cs_params, sizeof(cs_params), - &cs_resp, sizeof(cs_resp)); - TEST_ASSERT(rv == EC_RES_SUCCESS); - TEST_ASSERT(norm_current == cs_resp.get_state.chg_current); - - return EC_SUCCESS; -} - -static int test_low_battery_hostevents(void) -{ - int state; - - test_setup(0); - - ccprintf("[CHARGING TEST] Low battery host events\n"); - - /* You know you make me wanna */ - sb_write(SB_RELATIVE_STATE_OF_CHARGE, BATTERY_LEVEL_LOW + 1); - ev_clear(EC_HOST_EVENT_BATTERY_LOW); - ev_clear(EC_HOST_EVENT_BATTERY_CRITICAL); - ev_clear(EC_HOST_EVENT_BATTERY_SHUTDOWN); - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_DISCHARGE); - TEST_ASSERT(ev_is_clear(EC_HOST_EVENT_BATTERY_LOW)); - TEST_ASSERT(ev_is_clear(EC_HOST_EVENT_BATTERY_CRITICAL)); - TEST_ASSERT(ev_is_clear(EC_HOST_EVENT_BATTERY_SHUTDOWN)); - - /* (Shout) a little bit louder now */ - sb_write(SB_RELATIVE_STATE_OF_CHARGE, BATTERY_LEVEL_LOW - 1); - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_DISCHARGE); - TEST_ASSERT(ev_is_set(EC_HOST_EVENT_BATTERY_LOW)); - TEST_ASSERT(ev_is_clear(EC_HOST_EVENT_BATTERY_CRITICAL)); - TEST_ASSERT(ev_is_clear(EC_HOST_EVENT_BATTERY_SHUTDOWN)); - TEST_ASSERT(!is_shutdown); - - /* (Shout) a little bit louder now */ - sb_write(SB_RELATIVE_STATE_OF_CHARGE, BATTERY_LEVEL_CRITICAL + 1); - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_DISCHARGE); - TEST_ASSERT(ev_is_set(EC_HOST_EVENT_BATTERY_LOW)); - TEST_ASSERT(ev_is_clear(EC_HOST_EVENT_BATTERY_CRITICAL)); - TEST_ASSERT(ev_is_clear(EC_HOST_EVENT_BATTERY_SHUTDOWN)); - TEST_ASSERT(!is_shutdown); - - /* (Shout) a little bit louder now */ - sb_write(SB_RELATIVE_STATE_OF_CHARGE, BATTERY_LEVEL_CRITICAL - 1); - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_DISCHARGE); - TEST_ASSERT(ev_is_set(EC_HOST_EVENT_BATTERY_LOW)); - TEST_ASSERT(ev_is_set(EC_HOST_EVENT_BATTERY_CRITICAL)); - TEST_ASSERT(ev_is_clear(EC_HOST_EVENT_BATTERY_SHUTDOWN)); - TEST_ASSERT(!is_shutdown); - - /* (Shout) a little bit louder now */ - sb_write(SB_RELATIVE_STATE_OF_CHARGE, BATTERY_LEVEL_SHUTDOWN + 1); - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_DISCHARGE); - TEST_ASSERT(ev_is_set(EC_HOST_EVENT_BATTERY_LOW)); - TEST_ASSERT(ev_is_set(EC_HOST_EVENT_BATTERY_CRITICAL)); - TEST_ASSERT(ev_is_clear(EC_HOST_EVENT_BATTERY_SHUTDOWN)); - TEST_ASSERT(!is_shutdown); - - /* (Shout) a little bit louder now */ - sb_write(SB_RELATIVE_STATE_OF_CHARGE, BATTERY_LEVEL_SHUTDOWN - 1); - state = wait_charging_state(); - TEST_ASSERT(state == PWR_STATE_DISCHARGE); - TEST_ASSERT(ev_is_set(EC_HOST_EVENT_BATTERY_LOW)); - TEST_ASSERT(ev_is_set(EC_HOST_EVENT_BATTERY_CRITICAL)); - /* hey-hey-HEY-hey. Doesn't immediately shut down */ - TEST_ASSERT(ev_is_set(EC_HOST_EVENT_BATTERY_SHUTDOWN)); - TEST_ASSERT(!is_shutdown); - /* after a while, the AP should shut down */ - sleep(CONFIG_BATTERY_CRITICAL_SHUTDOWN_TIMEOUT); - TEST_ASSERT(is_shutdown); - - return EC_SUCCESS; -} - - - -void run_test(void) -{ - RUN_TEST(test_charge_state); - RUN_TEST(test_low_battery); - RUN_TEST(test_high_temp_battery); - RUN_TEST(test_external_funcs); - RUN_TEST(test_hc_charge_state); - RUN_TEST(test_hc_current_limit); - RUN_TEST(test_low_battery_hostevents); - - test_print_result(); -} diff --git a/test/sbs_charging_v2.tasklist b/test/sbs_charging_v2.tasklist deleted file mode 100644 index 3895762986..0000000000 --- a/test/sbs_charging_v2.tasklist +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2014 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST \ - TASK_TEST(CHARGER, charger_task, NULL, TASK_STACK_SIZE) \ - TASK_TEST(CHIPSET, chipset_task, NULL, TASK_STACK_SIZE) diff --git a/test/test_config.h b/test/test_config.h index e5d19f0bf8..6afb8f6417 100644 --- a/test/test_config.h +++ b/test/test_config.h @@ -27,15 +27,6 @@ #define CONFIG_BASE32 #endif -#ifdef TEST_BKLIGHT_LID -#define CONFIG_BACKLIGHT_LID -#endif - -#ifdef TEST_BKLIGHT_PASSTHRU -#define CONFIG_BACKLIGHT_LID -#define CONFIG_BACKLIGHT_REQ_GPIO GPIO_PCH_BKLTEN -#endif - #ifdef TEST_FLASH_LOG #define CONFIG_CRC8 #define CONFIG_FLASH_ERASED_VALUE32 (-1U) @@ -45,22 +36,6 @@ #define CONFIG_MALLOC #endif -#ifdef TEST_KB_8042 -#define CONFIG_KEYBOARD_PROTOCOL_8042 -#endif - -#ifdef TEST_KB_MKBP -#define CONFIG_KEYBOARD_PROTOCOL_MKBP -#define CONFIG_MKBP_EVENT -#define CONFIG_MKBP_USE_GPIO -#endif - -#ifdef TEST_KB_SCAN -#define CONFIG_KEYBOARD_PROTOCOL_MKBP -#define CONFIG_MKBP_EVENT -#define CONFIG_MKBP_USE_GPIO -#endif - #ifdef TEST_MATH_UTIL #define CONFIG_MATH_UTIL #endif @@ -75,48 +50,6 @@ #define CONFIG_MAG_CALIBRATE #endif -#ifdef TEST_FPSENSOR -#define CONFIG_AES -#define CONFIG_AES_GCM -#define CONFIG_ROLLBACK_SECRET_SIZE 32 -#define CONFIG_SHA256 -#endif - -#ifdef TEST_MOTION_SENSE_FIFO -#define CONFIG_ACCEL_FIFO -#define CONFIG_ACCEL_FIFO_SIZE 256 -#define CONFIG_ACCEL_FIFO_THRES 10 -#endif - -#if defined(TEST_MOTION_LID) || defined(TEST_MOTION_ANGLE) || \ - defined(TEST_MOTION_ANGLE_TABLET) || defined(TEST_MOTION_SENSE_FIFO) -enum sensor_id { - BASE, - LID, - SENSOR_COUNT, -}; - -#define CONFIG_LID_ANGLE -#define CONFIG_LID_ANGLE_SENSOR_BASE BASE -#define CONFIG_LID_ANGLE_SENSOR_LID LID -#define CONFIG_TABLET_MODE -#define CONFIG_MOTION_FILL_LPC_SENSE_DATA - -#endif - -#if defined(TEST_MOTION_ANGLE) -#define CONFIG_ACCEL_FORCE_MODE_MASK \ - ((1 << CONFIG_LID_ANGLE_SENSOR_BASE) | \ - (1 << CONFIG_LID_ANGLE_SENSOR_LID)) -#define CONFIG_ACCEL_STD_REF_FRAME_OLD -#endif - -#if defined(TEST_MOTION_ANGLE_TABLET) -#define CONFIG_ACCEL_FORCE_MODE_MASK \ - ((1 << CONFIG_LID_ANGLE_SENSOR_BASE) | \ - (1 << CONFIG_LID_ANGLE_SENSOR_LID)) -#endif - #ifdef TEST_RMA_AUTH /* Test server public and private keys */ @@ -175,23 +108,6 @@ enum sensor_id { #define CONFIG_MALLOC #endif -#ifdef TEST_SBS_CHARGING_V2 -#define CONFIG_BATTERY -#define CONFIG_BATTERY_MOCK -#define CONFIG_BATTERY_SMART -#define CONFIG_CHARGER -#define CONFIG_CHARGER_PROFILE_OVERRIDE -#define CONFIG_CHARGER_INPUT_CURRENT 4032 -#define CONFIG_CHARGER_DISCHARGE_ON_AC -#define CONFIG_CHARGER_DISCHARGE_ON_AC_CUSTOM -#define CONFIG_I2C -#define CONFIG_I2C_MASTER -int board_discharge_on_ac(int enabled); -#define I2C_PORT_MASTER 0 -#define I2C_PORT_BATTERY 0 -#define I2C_PORT_CHARGER 0 -#endif - #ifdef TEST_THERMAL #define CONFIG_CHIPSET_CAN_THROTTLE #define CONFIG_FANS 1 @@ -214,202 +130,10 @@ int ncp15wb_calculate_temp(uint16_t adc); #define CONFIG_VOLUME_BUTTONS #endif -#ifdef TEST_BATTERY_GET_PARAMS_SMART -#define CONFIG_BATTERY_MOCK -#define CONFIG_BATTERY_SMART -#define CONFIG_CHARGER_INPUT_CURRENT 4032 -#define CONFIG_I2C -#define CONFIG_I2C_MASTER -#define I2C_PORT_MASTER 0 -#define I2C_PORT_BATTERY 0 -#define I2C_PORT_CHARGER 0 -#endif - #ifdef TEST_CEC #define CONFIG_CEC #endif -#ifdef TEST_LIGHTBAR -#define CONFIG_I2C -#define CONFIG_I2C_MASTER -#define I2C_PORT_LIGHTBAR 0 -#define CONFIG_ALS_LIGHTBAR_DIMMING 0 -#endif - -#ifdef TEST_USB_COMMON -#define CONFIG_USB_POWER_DELIVERY -#define CONFIG_USB_PD_PORT_MAX_COUNT 1 -#define CONFIG_USB_PD_TCPC -#define CONFIG_USB_PD_TCPM_STUB -#define CONFIG_SHA256 -#define CONFIG_SW_CRC -#endif - -#if defined(TEST_USB_SM_FRAMEWORK_H3) -#define CONFIG_USB_PD_PORT_MAX_COUNT 1 -#undef CONFIG_USB_PRL_SM -#undef CONFIG_USB_PE_SM -#undef CONFIG_USB_TYPEC_SM -#define CONFIG_USB_SM_FRAMEWORK -#endif - -#if defined(TEST_USB_SM_FRAMEWORK_H2) -#define CONFIG_USB_PD_PORT_MAX_COUNT 1 -#undef CONFIG_USB_PRL_SM -#undef CONFIG_USB_PE_SM -#undef CONFIG_USB_TYPEC_SM -#define CONFIG_USB_SM_FRAMEWORK -#endif - -#if defined(TEST_USB_SM_FRAMEWORK_H1) -#define CONFIG_USB_PD_PORT_MAX_COUNT 1 -#undef CONFIG_USB_PRL_SM -#undef CONFIG_USB_PE_SM -#undef CONFIG_USB_TYPEC_SM -#define CONFIG_USB_SM_FRAMEWORK -#endif - -#if defined(TEST_USB_SM_FRAMEWORK_H0) -#define CONFIG_USB_PD_PORT_MAX_COUNT 1 -#undef CONFIG_USB_PRL_SM -#undef CONFIG_USB_PE_SM -#undef CONFIG_USB_TYPEC_SM -#define CONFIG_USB_SM_FRAMEWORK -#endif - -#if defined(TEST_USB_PRL) -#define CONFIG_USB_PD_PORT_MAX_COUNT 2 -#define CONFIG_USB_SM_FRAMEWORK -#undef CONFIG_USB_PE_SM -#undef CONFIG_USB_TYPEC_SM -#define CONFIG_USB_PRL_SM -#define CONFIG_USB_PD_TCPC -#define CONFIG_USB_PD_TCPM_STUB -#define CONFIG_USB_POWER_DELIVERY -#define CONFIG_SHA256 -#define CONFIG_SW_CRC -#endif - -#if defined(TEST_USB_PE_DRP) -#define CONFIG_TEST_USB_PE_SM -#define CONFIG_USB_PD_PORT_MAX_COUNT 1 -#define CONFIG_USB_PE_SM -#define CONFIG_USB_PID 0x5036 -#define CONFIG_USB_POWER_DELIVERY -#undef CONFIG_USB_PRL_SM -#define CONFIG_USB_SM_FRAMEWORK -#undef CONFIG_USB_TYPEC_SM -#define CONFIG_USBC_VCONN -#define PD_VCONN_SWAP_DELAY 5000 /* us */ -#define CONFIG_USB_PD_DISCHARGE_GPIO -#endif - -/* Common TypeC tests defines */ -#if defined(TEST_USB_TYPEC_VPD) || \ - defined(TEST_USB_TYPEC_CTVPD) -#define CONFIG_USB_PID 0x5036 -#define VPD_HW_VERSION 0x0001 -#define VPD_FW_VERSION 0x0001 -#define USB_BCD_DEVICE 0 - -/* Vbus impedance in milliohms */ -#define VPD_VBUS_IMPEDANCE 65 - -/* GND impedance in milliohms */ -#define VPD_GND_IMPEDANCE 33 - -#define CONFIG_USB_PD_PORT_MAX_COUNT 1 -#define CONFIG_USB_SM_FRAMEWORK -#define CONFIG_USB_PE_SM -#define CONFIG_USB_PRL_SM -#define CONFIG_USB_TYPEC_SM -#define CONFIG_USB_PD_TCPC -#define CONFIG_USB_PD_TCPM_STUB -#define CONFIG_USB_POWER_DELIVERY -#define CONFIG_SW_CRC -#endif /* Common TypeC test defines */ - -#ifdef TEST_USB_TYPEC_VPD -#define CONFIG_USB_TYPEC_VPD -#endif - -#ifdef TEST_USB_TYPEC_CTVPD -#define CONFIG_USB_TYPEC_CTVPD -#endif - -#ifdef TEST_USB_TYPEC_DRP_ACC_TRYSRC -#define CONFIG_USB_TYPEC_DRP_ACC_TRYSRC -#define CONFIG_USB_PD_DUAL_ROLE -#define CONFIG_USB_PD_TRY_SRC -#define CONFIG_USB_TYPEC_SM -#define CONFIG_USB_SM_FRAMEWORK -#define CONFIG_USB_PD_PORT_MAX_COUNT 1 -#define CONFIG_USBC_SS_MUX -#define CONFIG_USB_PD_VBUS_DETECT_TCPC -#define CONFIG_USB_POWER_DELIVERY -#undef CONFIG_USB_PRL_SM -#undef CONFIG_USB_PE_SM -#endif - -#ifdef TEST_USB_PD_INT -#define CONFIG_USB_POWER_DELIVERY -#define CONFIG_USB_PD_DUAL_ROLE -#define CONFIG_USB_PD_PORT_MAX_COUNT 1 -#define CONFIG_USB_PD_TCPC -#define CONFIG_USB_PD_TCPM_STUB -#define CONFIG_SHA256 -#define CONFIG_SW_CRC -#endif - -#if defined(TEST_USB_PD) || defined(TEST_USB_PD_GIVEBACK) || \ - defined(TEST_USB_PD_REV30) -#define CONFIG_USB_POWER_DELIVERY -#define CONFIG_USB_PD_DUAL_ROLE -#define CONFIG_USB_PD_PORT_MAX_COUNT 2 -#define CONFIG_USB_PD_TCPC -#define CONFIG_USB_PD_TCPM_STUB -#define CONFIG_SHA256 -#define CONFIG_SW_CRC -#ifdef TEST_USB_PD_REV30 -#define CONFIG_USB_PD_REV30 -#define CONFIG_USB_PID 0x5000 -#endif -#ifdef TEST_USB_PD_GIVEBACK -#define CONFIG_USB_PD_GIVE_BACK -#endif -#endif /* TEST_USB_PD || TEST_USB_PD_GIVEBACK || TEST_USB_PD_REV30 */ - -#ifdef TEST_USB_PPC -#define CONFIG_USB_PD_PORT_MAX_COUNT 1 -#define CONFIG_USB_PD_VBUS_DETECT_PPC -#define CONFIG_USBC_PPC -#define CONFIG_USBC_PPC_POLARITY -#define CONFIG_USBC_PPC_SBU -#define CONFIG_USBC_PPC_VCONN -#endif - -#if defined(TEST_CHARGE_MANAGER) || defined(TEST_CHARGE_MANAGER_DRP_CHARGING) -#define CONFIG_CHARGE_MANAGER -#define CONFIG_USB_PD_DUAL_ROLE -#define CONFIG_USB_PD_PORT_MAX_COUNT 2 -#define CONFIG_BATTERY -#define CONFIG_BATTERY_SMART -#define CONFIG_I2C -#define CONFIG_I2C_MASTER -#define I2C_PORT_BATTERY 0 -#endif /* TEST_CHARGE_MANAGER_* */ - -#ifdef TEST_CHARGE_MANAGER_DRP_CHARGING -#define CONFIG_CHARGE_MANAGER_DRP_CHARGING -#else -#undef CONFIG_CHARGE_MANAGER_DRP_CHARGING -#endif /* TEST_CHARGE_MANAGER_DRP_CHARGING */ - -#ifdef TEST_CHARGE_RAMP -#define CONFIG_CHARGE_RAMP_SW -#define CONFIG_USB_PD_PORT_MAX_COUNT 2 -#endif - #ifdef TEST_EC_COMM #define CONFIG_CRC8 #define CONFIG_EC_EFS_SUPPORT diff --git a/test/usb_common.tasklist b/test/usb_common.tasklist deleted file mode 100644 index 9bf1c80c20..0000000000 --- a/test/usb_common.tasklist +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST - diff --git a/test/usb_common_test.c b/test/usb_common_test.c deleted file mode 100644 index d054f4ead2..0000000000 --- a/test/usb_common_test.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test USB common module. - */ -#include "test_util.h" -#include "usb_common.h" - -int test_pd_get_cc_state(void) -{ - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_RP_3_0, TYPEC_CC_VOLT_RP_3_0), - PD_CC_DFP_DEBUG_ACC, "%d"); - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_RP_3_0, TYPEC_CC_VOLT_RP_1_5), - PD_CC_DFP_DEBUG_ACC, "%d"); - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_RP_3_0, TYPEC_CC_VOLT_RP_DEF), - PD_CC_DFP_DEBUG_ACC, "%d"); - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_RP_1_5, TYPEC_CC_VOLT_RP_3_0), - PD_CC_DFP_DEBUG_ACC, "%d"); - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_RP_1_5, TYPEC_CC_VOLT_RP_1_5), - PD_CC_DFP_DEBUG_ACC, "%d"); - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_RP_1_5, TYPEC_CC_VOLT_RP_DEF), - PD_CC_DFP_DEBUG_ACC, "%d"); - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_RP_DEF, TYPEC_CC_VOLT_RP_3_0), - PD_CC_DFP_DEBUG_ACC, "%d"); - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_RP_DEF, TYPEC_CC_VOLT_RP_1_5), - PD_CC_DFP_DEBUG_ACC, "%d"); - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_RP_DEF, TYPEC_CC_VOLT_RP_DEF), - PD_CC_DFP_DEBUG_ACC, "%d"); - - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_RP_3_0, TYPEC_CC_VOLT_OPEN), - PD_CC_DFP_ATTACHED, "%d"); - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_RP_1_5, TYPEC_CC_VOLT_OPEN), - PD_CC_DFP_ATTACHED, "%d"); - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_RP_DEF, TYPEC_CC_VOLT_OPEN), - PD_CC_DFP_ATTACHED, "%d"); - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_RP_3_0), - PD_CC_DFP_ATTACHED, "%d"); - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_RP_1_5), - PD_CC_DFP_ATTACHED, "%d"); - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_RP_DEF), - PD_CC_DFP_ATTACHED, "%d"); - - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_RD, TYPEC_CC_VOLT_RD), - PD_CC_UFP_DEBUG_ACC, "%d"); - - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_RD, TYPEC_CC_VOLT_RA), - PD_CC_UFP_ATTACHED, "%d"); - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_RD, TYPEC_CC_VOLT_OPEN), - PD_CC_UFP_ATTACHED, "%d"); - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_RA, TYPEC_CC_VOLT_RD), - PD_CC_UFP_ATTACHED, "%d"); - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_RD), - PD_CC_UFP_ATTACHED, "%d"); - - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_RA, TYPEC_CC_VOLT_RA), - PD_CC_UFP_AUDIO_ACC, "%d"); - - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_OPEN), - PD_CC_NONE, "%d"); - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_RA), - PD_CC_NONE, "%d"); - TEST_EQ(pd_get_cc_state(TYPEC_CC_VOLT_RA, TYPEC_CC_VOLT_OPEN), - PD_CC_NONE, "%d"); - - return EC_SUCCESS; -} - -void run_test(void) -{ - RUN_TEST(test_pd_get_cc_state); - - test_print_result(); -} diff --git a/test/usb_pd.c b/test/usb_pd.c deleted file mode 100644 index 6ec9b3ffda..0000000000 --- a/test/usb_pd.c +++ /dev/null @@ -1,923 +0,0 @@ -/* Copyright 2014 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test USB PD module. - */ -#include "battery.h" -#include "common.h" -#include "crc.h" -#include "task.h" -#include "test_util.h" -#include "timer.h" -#include "usb_pd.h" -#include "usb_pd_test_util.h" -#include "util.h" - -#define PORT0 0 -#define PORT1 1 - -#define BATTERY_DESIGN_VOLTAGE 7600 -#define BATTERY_DESIGN_CAPACITY 5131 -#define BATTERY_FULL_CHARGE_CAPACITY 5131 -#define BATTERY_REMAINING_CAPACITY 2566 - -struct pd_port_t { - int host_mode; - int has_vbus; - int msg_tx_id; - int msg_rx_id; - int polarity; - int partner_role; /* -1 for none */ - int partner_polarity; - int rev; -} pd_port[CONFIG_USB_PD_PORT_MAX_COUNT]; - -static int give_back_called; - -/* Mock functions */ -#ifdef CONFIG_USB_PD_REV30 - -uint16_t pd_get_identity_vid(int port) -{ - return 0; -} - -uint16_t pd_get_identity_pid(int port) -{ - return 0; -} - -enum battery_present battery_is_present(void) -{ - return BP_YES; -} - -int battery_status(int *status) -{ - *status = 1; - return 0; -} - -int battery_remaining_capacity(int *capacity) -{ - *capacity = BATTERY_REMAINING_CAPACITY; - return 0; -} - -int battery_full_charge_capacity(int *capacity) -{ - *capacity = BATTERY_FULL_CHARGE_CAPACITY; - return 0; -} - -int battery_design_capacity(int *capacity) -{ - *capacity = BATTERY_DESIGN_CAPACITY; - return 0; -} - -int battery_design_voltage(int *voltage) -{ - *voltage = BATTERY_DESIGN_VOLTAGE; - return 0; -} - -#endif - -int pd_adc_read(int port, int cc) -{ - if (pd_port[port].host_mode && - pd_port[port].partner_role == PD_ROLE_SINK) - /* we are source connected to sink, return Rd/Open */ - return (pd_port[port].partner_polarity == cc) ? 400 : 3000; - else if (!pd_port[port].host_mode && - pd_port[port].partner_role == PD_ROLE_SOURCE) - /* we are sink connected to source, return Rp/Open */ - return (pd_port[port].partner_polarity == cc) ? 1700 : 0; - else if (pd_port[port].host_mode) - /* no sink on the other side, both CC are opened */ - return 3000; - else if (!pd_port[port].host_mode) - /* no source on the other side, both CC are opened */ - return 0; - - /* should never get here */ - return 0; -} - -int pd_snk_is_vbus_provided(int port) -{ - return pd_port[port].has_vbus; -} - -void pd_set_host_mode(int port, int enable) -{ - pd_port[port].host_mode = enable; -} - -void pd_select_polarity(int port, int polarity) -{ - pd_port[port].polarity = polarity; -} - -int pd_vdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload) -{ - return 0; -} - -int board_select_rp_value(int port, int rp) -{ - return 0; -} - -/* Tests */ - -void inc_tx_id(int port) -{ - pd_port[port].msg_tx_id = (pd_port[port].msg_tx_id + 1) % 7; -} - -void inc_rx_id(int port) -{ - pd_port[port].msg_rx_id = (pd_port[port].msg_rx_id + 1) % 7; -} - -static void init_ports(void) -{ - int i; - - for (i = 0; i < board_get_usb_pd_port_count(); ++i) { - pd_port[i].host_mode = 0; - pd_port[i].partner_role = -1; - pd_port[i].has_vbus = 0; -#ifdef CONFIG_USB_PD_REV30 - pd_port[i].rev = PD_REV30; -#else - pd_port[i].rev = PD_REV20; -#endif - } -} - -static void simulate_rx_msg(int port, uint16_t header, int cnt, - const uint32_t *data) -{ - int i; - - pd_test_rx_set_preamble(port, 1); - pd_test_rx_msg_append_sop(port); - pd_test_rx_msg_append_short(port, header); - - crc32_init(); - crc32_hash16(header); - for (i = 0; i < cnt; ++i) { - pd_test_rx_msg_append_word(port, data[i]); - crc32_hash32(data[i]); - } - pd_test_rx_msg_append_word(port, crc32_result()); - - pd_test_rx_msg_append_eop(port); - pd_test_rx_msg_append_last_edge(port); - - pd_simulate_rx(port); -} - -static void simulate_wait(int port) -{ - uint16_t header = PD_HEADER(PD_CTRL_WAIT, PD_ROLE_SOURCE, - PD_ROLE_DFP, pd_port[port].msg_rx_id, - 0, pd_port[port].rev, 0); - - simulate_rx_msg(port, header, 0, NULL); -} - -static void simulate_accept(int port) -{ - uint16_t header = PD_HEADER(PD_CTRL_ACCEPT, PD_ROLE_SOURCE, - PD_ROLE_DFP, pd_port[port].msg_rx_id, - 0, pd_port[port].rev, 0); - - simulate_rx_msg(port, header, 0, NULL); -} - -static void simulate_reject(int port) -{ - uint16_t header = PD_HEADER(PD_CTRL_REJECT, PD_ROLE_SOURCE, - PD_ROLE_DFP, pd_port[port].msg_rx_id, - 0, pd_port[port].rev, 0); - - simulate_rx_msg(port, header, 0, NULL); -} - - -#ifdef CONFIG_USB_PD_REV30 -static void simulate_get_bat_cap(int port) -{ - uint16_t msg[2]; - uint16_t header = PD_HEADER(PD_EXT_GET_BATTERY_CAP, PD_ROLE_SOURCE, - PD_ROLE_DFP, pd_port[port].msg_rx_id, - 1, pd_port[port].rev, 1); - - /* set extended header */ - msg[0] = PD_EXT_HEADER(0, 0, 1); - - /* set battery status ref */ - msg[1] = 0; - - simulate_rx_msg(port, header, 1, (const uint32_t *)msg); -} - -static void simulate_get_bat_status(int port) -{ - uint16_t msg[2]; - uint16_t header = PD_HEADER(PD_EXT_GET_BATTERY_STATUS, PD_ROLE_SOURCE, - PD_ROLE_DFP, pd_port[port].msg_rx_id, - 1, pd_port[port].rev, 1); - - /* set extended header */ - msg[0] = PD_EXT_HEADER(0, 0, 1); - - /* set battery status ref */ - msg[1] = 0; - - simulate_rx_msg(port, header, 1, (const uint32_t *)msg); -} -#endif - -static void simulate_source_cap(int port, uint32_t cnt) -{ - uint32_t src_pdo_cnt = (cnt == 0) ? 1 : pd_src_pdo_cnt; - - uint16_t header = PD_HEADER(PD_DATA_SOURCE_CAP, PD_ROLE_SOURCE, - PD_ROLE_DFP, pd_port[port].msg_rx_id, - src_pdo_cnt, pd_port[port].rev, 0); - - simulate_rx_msg(port, header, src_pdo_cnt, pd_src_pdo); -} - -static void simulate_goodcrc(int port, int role, int id) -{ - simulate_rx_msg(port, PD_HEADER(PD_CTRL_GOOD_CRC, role, role, id, 0, - pd_port[port].rev, 0), 0, NULL); -} - -static int verify_goodcrc(int port, int role, int id) -{ - - return pd_test_tx_msg_verify_sop(port) && - pd_test_tx_msg_verify_short(port, PD_HEADER(PD_CTRL_GOOD_CRC, - role, role, id, 0, 0, 0)) && - pd_test_tx_msg_verify_crc(port) && - pd_test_tx_msg_verify_eop(port); -} - -static void plug_in_source(int port, int polarity) -{ - pd_port[port].has_vbus = 1; - pd_port[port].partner_role = PD_ROLE_SOURCE; - pd_port[port].partner_polarity = polarity; - /* Indicate that the CC lines have changed. */ - task_set_event(PD_PORT_TO_TASK_ID(port), PD_EVENT_CC, 0); -} - -static void plug_in_sink(int port, int polarity) -{ - pd_port[port].has_vbus = 0; - pd_port[port].partner_role = PD_ROLE_SINK; - pd_port[port].partner_polarity = polarity; - /* Indicate that the CC lines have changed. */ - task_set_event(PD_PORT_TO_TASK_ID(port), PD_EVENT_CC, 0); -} - -static void unplug(int port) -{ - pd_port[port].msg_tx_id = 0; - pd_port[port].msg_rx_id = 0; - pd_port[port].has_vbus = 0; - pd_port[port].partner_role = -1; - /* Indicate that the CC lines have changed. */ - task_set_event(PD_PORT_TO_TASK_ID(port), PD_EVENT_CC, 0); - task_wake(PD_PORT_TO_TASK_ID(port)); - usleep(30 * MSEC); -} - -void pd_snk_give_back(int port, uint32_t * const ma, uint32_t * const mv) -{ - if (*ma == 3000) - give_back_called = 1; -} - -static void simulate_ps_rdy(int port) -{ - uint16_t header = PD_HEADER(PD_CTRL_PS_RDY, PD_ROLE_SOURCE, - PD_ROLE_DFP, pd_port[port].msg_rx_id, - 0, pd_port[port].rev, 0); - - simulate_rx_msg(port, header, 0, NULL); -} - -static void simulate_goto_min(int port) -{ - uint16_t header = PD_HEADER(PD_CTRL_GOTO_MIN, PD_ROLE_SOURCE, - PD_ROLE_DFP, pd_port[port].msg_rx_id, 0, pd_port[port].rev, 0); - - simulate_rx_msg(port, header, 0, NULL); -} - -static int test_request_with_wait_and_contract(void) -{ -#ifdef CONFIG_USB_PD_REV30 - uint32_t expected_status_bsdo = - BSDO_CAP(DIV_ROUND_NEAREST(BATTERY_REMAINING_CAPACITY * - BATTERY_DESIGN_VOLTAGE, 100000)) | - BSDO_PRESENT; - uint16_t expected_cap_hdr = PD_EXT_HEADER(0, 0, 9); - uint16_t expected_cap_vid = USB_VID_GOOGLE; -#ifdef CONFIG_USB_PID - uint16_t expected_cap_pid = CONFIG_USB_PID; -#else - uint16_t expected_cap_pid = 0; -#endif - uint16_t expected_cap_des = - DIV_ROUND_NEAREST(BATTERY_DESIGN_CAPACITY * - BATTERY_DESIGN_VOLTAGE, 100000); - uint16_t expected_cap_ful = - DIV_ROUND_NEAREST(BATTERY_FULL_CHARGE_CAPACITY * - BATTERY_DESIGN_VOLTAGE, 100000); - uint16_t expected_cap_type = 0; -#endif - -#ifdef CONFIG_USB_PD_GIVE_BACK - uint32_t expected_rdo = - RDO_FIXED(2, 3000, PD_MIN_CURRENT_MA, RDO_GIVE_BACK); -#else - uint32_t expected_rdo = RDO_FIXED(2, 3000, 3000, 0); -#endif - uint8_t port = PORT0; - - plug_in_source(port, 0); - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(2 * PD_T_CC_DEBOUNCE + 100 * MSEC); - TEST_ASSERT(pd_port[port].polarity == 0); - - /* We're in SNK_DISCOVERY now. Let's send the source cap. */ - simulate_source_cap(port, 1); - task_wait_event(30 * MSEC); - TEST_ASSERT(verify_goodcrc(port, PD_ROLE_SINK, - pd_port[port].msg_rx_id)); - - /* Wait for the power request */ - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(35 * MSEC); /* tSenderResponse: 24~30 ms */ - inc_rx_id(port); - - /* Process the request */ - TEST_ASSERT(pd_test_tx_msg_verify_sop(port)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, - PD_HEADER(PD_DATA_REQUEST, PD_ROLE_SINK, PD_ROLE_UFP, - pd_port[port].msg_tx_id, 1, pd_port[port].rev, 0))); - TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_rdo)); - TEST_ASSERT(pd_test_tx_msg_verify_crc(port)); - TEST_ASSERT(pd_test_tx_msg_verify_eop(port)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - - /* Request was good. Send GoodCRC */ - simulate_goodcrc(port, PD_ROLE_SOURCE, pd_port[port].msg_tx_id); - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - inc_tx_id(port); - - /* We're in SNK_REQUESTED. Send accept */ - simulate_accept(port); - task_wait_event(30 * MSEC); - TEST_ASSERT(verify_goodcrc(0, PD_ROLE_SINK, pd_port[port].msg_rx_id)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - inc_rx_id(port); - - /* - * We're in SNK_TRANSITION. - * And we have an explicit power contract. - */ - simulate_source_cap(port, 1); - task_wait_event(30 * MSEC); - TEST_ASSERT(verify_goodcrc(port, PD_ROLE_SINK, - pd_port[port].msg_rx_id)); - - /* Wait for the power request */ - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(35 * MSEC); /* tSenderResponse: 24~30 ms */ - inc_rx_id(port); - - /* Process the request */ - TEST_ASSERT(pd_test_tx_msg_verify_sop(port)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, - PD_HEADER(PD_DATA_REQUEST, PD_ROLE_SINK, PD_ROLE_UFP, - pd_port[port].msg_tx_id, 1, pd_port[port].rev, 0))); - TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_rdo)); - TEST_ASSERT(pd_test_tx_msg_verify_crc(port)); - TEST_ASSERT(pd_test_tx_msg_verify_eop(port)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - - /* Request was good. Send GoodCRC */ - simulate_goodcrc(port, PD_ROLE_SOURCE, pd_port[port].msg_tx_id); - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - inc_tx_id(port); - - /* We're in SNK_REQUESTED. Send wait */ - simulate_wait(port); - task_wait_event(30 * MSEC); - TEST_ASSERT(verify_goodcrc(0, PD_ROLE_SINK, pd_port[port].msg_rx_id)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - /* PD_T_SINK_REQUEST. Request is sent again after 100 ms */ - task_wait_event(100 * MSEC); - inc_rx_id(port); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - - /* We had an explicit contract. So request should have been resent. */ - /* Process the request */ - TEST_ASSERT(pd_test_tx_msg_verify_sop(port)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, - PD_HEADER(PD_DATA_REQUEST, PD_ROLE_SINK, PD_ROLE_UFP, - pd_port[port].msg_tx_id, 1, - pd_port[port].rev, 0 - ))); - TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_rdo)); - TEST_ASSERT(pd_test_tx_msg_verify_crc(port)); - TEST_ASSERT(pd_test_tx_msg_verify_eop(port)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - - /* Request was good. Send GoodCRC */ - simulate_goodcrc(port, PD_ROLE_SOURCE, pd_port[port].msg_tx_id); - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - inc_tx_id(port); - - /* We're in SNK_REQUESTED. Send accept */ - simulate_accept(port); - task_wait_event(30 * MSEC); - TEST_ASSERT(verify_goodcrc(0, PD_ROLE_SINK, pd_port[port].msg_rx_id)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - inc_rx_id(port); - - /* We're in SNK_TRANSITION. Send ps_rdy */ - simulate_ps_rdy(port); - task_wait_event(30 * MSEC); - TEST_ASSERT(verify_goodcrc(0, PD_ROLE_SINK, pd_port[port].msg_rx_id)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - inc_rx_id(port); - - /* - * Test Extended Get_Battery_Cap and Get_Battery_Status messages. - */ -#ifdef CONFIG_USB_PD_REV30 - /* We're in SNK_READY. Send get battery cap. */ - simulate_get_bat_cap(port); - task_wait_event(30 * MSEC); - TEST_ASSERT(verify_goodcrc(0, PD_ROLE_SINK, pd_port[port].msg_rx_id)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - inc_rx_id(port); - - /* Process the request */ - TEST_ASSERT(pd_test_tx_msg_verify_sop(port)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, - PD_HEADER(PD_EXT_BATTERY_CAP, PD_ROLE_SINK, PD_ROLE_UFP, - pd_port[port].msg_tx_id, 3, pd_port[port].rev, 1))); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, expected_cap_hdr)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, expected_cap_vid)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, expected_cap_pid)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, expected_cap_des)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, expected_cap_ful)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, expected_cap_type)); - TEST_ASSERT(pd_test_tx_msg_verify_crc(port)); - TEST_ASSERT(pd_test_tx_msg_verify_eop(port)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - - /* Request was good. Send GoodCRC */ - simulate_goodcrc(port, PD_ROLE_SOURCE, pd_port[port].msg_tx_id); - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - inc_tx_id(port); - - /* Send get battery status. */ - simulate_get_bat_status(port); - task_wait_event(30 * MSEC); - TEST_ASSERT(verify_goodcrc(0, PD_ROLE_SINK, pd_port[port].msg_rx_id)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - inc_rx_id(port); - - /* Process the request */ - TEST_ASSERT(pd_test_tx_msg_verify_sop(port)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, - PD_HEADER(PD_DATA_BATTERY_STATUS, PD_ROLE_SINK, PD_ROLE_UFP, - pd_port[port].msg_tx_id, 1, pd_port[port].rev, 0))); - TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_status_bsdo)); - TEST_ASSERT(pd_test_tx_msg_verify_crc(port)); - TEST_ASSERT(pd_test_tx_msg_verify_eop(port)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - - /* Request was good. Send GoodCRC */ - simulate_goodcrc(port, PD_ROLE_SOURCE, pd_port[port].msg_tx_id); - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - inc_tx_id(port); -#endif - /* We're in SNK_READY. Send goto_min */ - simulate_goto_min(port); - task_wait_event(30 * MSEC); - TEST_ASSERT(verify_goodcrc(0, PD_ROLE_SINK, pd_port[port].msg_rx_id)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - inc_rx_id(port); - -#ifdef CONFIG_USB_PD_GIVE_BACK - TEST_ASSERT(give_back_called); -#else - TEST_ASSERT(!give_back_called); -#endif - /* We're done */ - unplug(port); - - return EC_SUCCESS; -} - -static int test_request_with_wait(void) -{ -#ifdef CONFIG_USB_PD_GIVE_BACK - uint32_t expected_rdo = RDO_FIXED(1, 900, PD_MIN_CURRENT_MA, - RDO_CAP_MISMATCH | RDO_GIVE_BACK); -#else - uint32_t expected_rdo = RDO_FIXED(1, 900, 900, RDO_CAP_MISMATCH); -#endif - uint8_t port = PORT0; - - plug_in_source(port, 0); - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(2 * PD_T_CC_DEBOUNCE + 100 * MSEC); - TEST_ASSERT(pd_port[port].polarity == 0); - - /* We're in SNK_DISCOVERY now. Let's send the source cap. */ - simulate_source_cap(port, 0); - task_wait_event(30 * MSEC); - TEST_ASSERT(verify_goodcrc(port, - PD_ROLE_SINK, pd_port[port].msg_rx_id)); - - /* Wait for the power request */ - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(35 * MSEC); /* tSenderResponse: 24~30 ms */ - inc_rx_id(port); - - /* Process the request */ - TEST_ASSERT(pd_test_tx_msg_verify_sop(port)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, - PD_HEADER(PD_DATA_REQUEST, PD_ROLE_SINK, PD_ROLE_UFP, - pd_port[port].msg_tx_id, 1, pd_port[port].rev, 0))); - TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_rdo)); - TEST_ASSERT(pd_test_tx_msg_verify_crc(port)); - TEST_ASSERT(pd_test_tx_msg_verify_eop(port)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - - /* Request is good. Send GoodCRC */ - simulate_goodcrc(port, PD_ROLE_SOURCE, pd_port[port].msg_tx_id); - task_wake(PD_PORT_TO_TASK_ID(0)); - task_wait_event(30 * MSEC); - inc_tx_id(port); - - /* We're in SNK_REQUESTED. Send wait */ - simulate_wait(port); - task_wait_event(30 * MSEC); - TEST_ASSERT(verify_goodcrc(0, PD_ROLE_SINK, pd_port[port].msg_rx_id)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - inc_rx_id(port); - - /* We didn't have an explicit contract. So we're in SNK_DISCOVERY. */ - /* Resend Source Cap. */ - simulate_source_cap(port, 0); - task_wait_event(30 * MSEC); - TEST_ASSERT(verify_goodcrc(port, - PD_ROLE_SINK, pd_port[port].msg_rx_id)); - - /* Wait for the power request */ - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(35 * MSEC); /* tSenderResponse: 24~30 ms */ - inc_rx_id(port); - - /* Process the request */ - TEST_ASSERT(pd_test_tx_msg_verify_sop(port)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, - PD_HEADER(PD_DATA_REQUEST, PD_ROLE_SINK, PD_ROLE_UFP, - pd_port[port].msg_tx_id, 1, pd_port[port].rev, 0))); - TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_rdo)); - TEST_ASSERT(pd_test_tx_msg_verify_crc(port)); - TEST_ASSERT(pd_test_tx_msg_verify_eop(port)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - - /* Request was good. Send GoodCRC */ - simulate_goodcrc(port, PD_ROLE_SOURCE, pd_port[port].msg_tx_id); - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - inc_tx_id(port); - - /* We're done */ - unplug(port); - return EC_SUCCESS; -} - -static int test_request_with_wait_no_src_cap(void) -{ -#ifdef CONFIG_USB_PD_GIVE_BACK - uint32_t expected_rdo = RDO_FIXED(1, 900, PD_MIN_CURRENT_MA, - RDO_CAP_MISMATCH | RDO_GIVE_BACK); -#else - uint32_t expected_rdo = RDO_FIXED(1, 900, 900, RDO_CAP_MISMATCH); -#endif - uint8_t port = PORT0; - - plug_in_source(port, 0); - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(2 * PD_T_CC_DEBOUNCE + 100 * MSEC); - TEST_ASSERT(pd_port[port].polarity == 0); - - /* We're in SNK_DISCOVERY now. Let's send the source cap. */ - simulate_source_cap(port, 0); - task_wait_event(30 * MSEC); - TEST_ASSERT(verify_goodcrc(port, - PD_ROLE_SINK, pd_port[port].msg_rx_id)); - - /* Wait for the power request */ - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(35 * MSEC); /* tSenderResponse: 24~30 ms */ - inc_rx_id(port); - - /* Process the request */ - TEST_ASSERT(pd_test_tx_msg_verify_sop(port)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, - PD_HEADER(PD_DATA_REQUEST, PD_ROLE_SINK, PD_ROLE_UFP, - pd_port[port].msg_tx_id, 1, pd_port[port].rev, 0))); - TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_rdo)); - TEST_ASSERT(pd_test_tx_msg_verify_crc(port)); - TEST_ASSERT(pd_test_tx_msg_verify_eop(port)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - - /* Request is good. Send GoodCRC */ - simulate_goodcrc(port, PD_ROLE_SOURCE, pd_port[port].msg_tx_id); - task_wake(PD_PORT_TO_TASK_ID(0)); - task_wait_event(30 * MSEC); - inc_tx_id(port); - - /* We're in SNK_REQUESTED. Send wait */ - simulate_wait(port); - task_wait_event(30 * MSEC); - TEST_ASSERT(verify_goodcrc(0, PD_ROLE_SINK, pd_port[port].msg_rx_id)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - inc_rx_id(port); - - /* - * Some port partners do not send another SRC_CAP and expect us to send - * another REQUEST 100ms after the WAIT. - */ - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(100 * MSEC); /* tSinkRequest: 100 ms */ - inc_rx_id(port); - - /* Process the request */ - TEST_ASSERT(pd_test_tx_msg_verify_sop(port)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, - PD_HEADER(PD_DATA_REQUEST, PD_ROLE_SINK, PD_ROLE_UFP, - pd_port[port].msg_tx_id, 1, pd_port[port].rev, 0))); - TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_rdo)); - TEST_ASSERT(pd_test_tx_msg_verify_crc(port)); - TEST_ASSERT(pd_test_tx_msg_verify_eop(port)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - - /* Request was good. Send GoodCRC */ - simulate_goodcrc(port, PD_ROLE_SOURCE, pd_port[port].msg_tx_id); - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - inc_tx_id(port); - - /* We're done */ - unplug(port); - return EC_SUCCESS; -} - -static int test_request_with_reject(void) -{ -#ifdef CONFIG_USB_PD_GIVE_BACK - uint32_t expected_rdo = RDO_FIXED(1, 900, PD_MIN_CURRENT_MA, - RDO_CAP_MISMATCH | RDO_GIVE_BACK); -#else - uint32_t expected_rdo = RDO_FIXED(1, 900, 900, RDO_CAP_MISMATCH); -#endif - uint8_t port = PORT0; - - plug_in_source(port, 0); - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(2 * PD_T_CC_DEBOUNCE + 100 * MSEC); - TEST_ASSERT(pd_port[port].polarity == 0); - - /* We're in SNK_DISCOVERY now. Let's send the source cap. */ - simulate_source_cap(port, 0); - task_wait_event(30 * MSEC); - TEST_ASSERT(verify_goodcrc(port, - PD_ROLE_SINK, pd_port[port].msg_rx_id)); - - /* Wait for the power request */ - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(35 * MSEC); /* tSenderResponse: 24~30 ms */ - inc_rx_id(port); - - /* Process the request */ - TEST_ASSERT(pd_test_tx_msg_verify_sop(port)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, - PD_HEADER(PD_DATA_REQUEST, PD_ROLE_SINK, PD_ROLE_UFP, - pd_port[port].msg_tx_id, 1, pd_port[port].rev, 0))); - TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_rdo)); - TEST_ASSERT(pd_test_tx_msg_verify_crc(port)); - TEST_ASSERT(pd_test_tx_msg_verify_eop(port)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - - /* Request is good. Send GoodCRC */ - simulate_goodcrc(port, PD_ROLE_SOURCE, pd_port[port].msg_tx_id); - task_wake(PD_PORT_TO_TASK_ID(0)); - task_wait_event(30 * MSEC); - inc_tx_id(port); - - /* We're in SNK_REQUESTED. Send reject */ - simulate_reject(port); - task_wait_event(30 * MSEC); - TEST_ASSERT(verify_goodcrc(0, PD_ROLE_SINK, pd_port[port].msg_rx_id)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - inc_rx_id(port); - - /* We're in SNK_READY. Send source cap. again. */ - simulate_source_cap(port, 0); - task_wait_event(30 * MSEC); - TEST_ASSERT(verify_goodcrc(port, - PD_ROLE_SINK, pd_port[port].msg_rx_id)); - - /* Wait for the power request */ - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(35 * MSEC); /* tSenderResponse: 24~30 ms */ - inc_rx_id(port); - - /* Process the request */ - TEST_ASSERT(pd_test_tx_msg_verify_sop(port)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, - PD_HEADER(PD_DATA_REQUEST, PD_ROLE_SINK, PD_ROLE_UFP, - pd_port[port].msg_tx_id, 1, pd_port[port].rev, 0))); - TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_rdo)); - TEST_ASSERT(pd_test_tx_msg_verify_crc(port)); - TEST_ASSERT(pd_test_tx_msg_verify_eop(port)); - - /* We're done */ - unplug(port); - return EC_SUCCESS; -} - -static int test_request(void) -{ -#ifdef CONFIG_USB_PD_GIVE_BACK - uint32_t expected_rdo = RDO_FIXED(1, 900, PD_MIN_CURRENT_MA, - RDO_CAP_MISMATCH | RDO_GIVE_BACK); -#else - uint32_t expected_rdo = RDO_FIXED(1, 900, 900, RDO_CAP_MISMATCH); -#endif - uint8_t port = PORT0; - - plug_in_source(port, 0); - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(2 * PD_T_CC_DEBOUNCE + 100 * MSEC); - TEST_ASSERT(pd_port[port].polarity == 0); - - /* We're in SNK_DISCOVERY now. Let's send the source cap. */ - simulate_source_cap(port, 0); - task_wait_event(30 * MSEC); - TEST_ASSERT(verify_goodcrc(port, - PD_ROLE_SINK, pd_port[port].msg_rx_id)); - - /* Wait for the power request */ - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(35 * MSEC); /* tSenderResponse: 24~30 ms */ - inc_rx_id(port); - - /* Process the request */ - TEST_ASSERT(pd_test_tx_msg_verify_sop(port)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, - PD_HEADER(PD_DATA_REQUEST, PD_ROLE_SINK, PD_ROLE_UFP, - pd_port[port].msg_tx_id, 1, pd_port[port].rev, 0))); - TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_rdo)); - TEST_ASSERT(pd_test_tx_msg_verify_crc(port)); - TEST_ASSERT(pd_test_tx_msg_verify_eop(port)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - - /* Request was good. Send GoodCRC */ - simulate_goodcrc(port, PD_ROLE_SOURCE, pd_port[port].msg_tx_id); - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - inc_tx_id(port); - - /* We're done */ - unplug(port); - - return EC_SUCCESS; -} - -static int test_sink(void) -{ - int i; - uint8_t port = PORT1; - - plug_in_sink(port, 1); - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(250 * MSEC); /* tTypeCSinkWaitCap: 210~250 ms */ - TEST_ASSERT(pd_port[port].polarity == 1); - - /* The source cap should be sent */ - TEST_ASSERT(pd_test_tx_msg_verify_sop(port)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, - PD_HEADER(PD_DATA_SOURCE_CAP, PD_ROLE_SOURCE, - PD_ROLE_DFP, pd_port[port].msg_tx_id, - pd_src_pdo_cnt, pd_port[port].rev, 0))); - - for (i = 0; i < pd_src_pdo_cnt; ++i) - TEST_ASSERT(pd_test_tx_msg_verify_word(port, pd_src_pdo[i])); - - TEST_ASSERT(pd_test_tx_msg_verify_crc(port)); - TEST_ASSERT(pd_test_tx_msg_verify_eop(port)); - - /* Wake from pd_start_tx */ - task_wake(PD_PORT_TO_TASK_ID(port)); - usleep(30 * MSEC); - - /* Looks good. Ack the source cap. */ - simulate_goodcrc(port, PD_ROLE_SINK, pd_port[port].msg_tx_id); - - /* Wake from pd_rx_start */ - task_wake(PD_PORT_TO_TASK_ID(port)); - usleep(30 * MSEC); - inc_tx_id(port); - - /* We're done */ - unplug(port); - return EC_SUCCESS; -} - -void run_test(void) -{ - test_reset(); - init_ports(); - pd_set_dual_role(PORT0, PD_DRP_TOGGLE_ON); - pd_set_dual_role(PORT1, PD_DRP_TOGGLE_ON); - - RUN_TEST(test_request); - RUN_TEST(test_sink); - RUN_TEST(test_request_with_wait); - RUN_TEST(test_request_with_wait_no_src_cap); - RUN_TEST(test_request_with_wait_and_contract); - RUN_TEST(test_request_with_reject); - - test_print_result(); -} diff --git a/test/usb_pd.tasklist b/test/usb_pd.tasklist deleted file mode 100644 index fbd319148e..0000000000 --- a/test/usb_pd.tasklist +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2013 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST \ - TASK_TEST(PD_C0, pd_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_TEST(PD_C1, pd_task, NULL, LARGER_TASK_STACK_SIZE) diff --git a/test/usb_pd_giveback.tasklist b/test/usb_pd_giveback.tasklist deleted file mode 120000 index 45cc6c8aa2..0000000000 --- a/test/usb_pd_giveback.tasklist +++ /dev/null @@ -1 +0,0 @@ -usb_pd.tasklist
\ No newline at end of file diff --git a/test/usb_pd_int.c b/test/usb_pd_int.c deleted file mode 100644 index b1701c5f96..0000000000 --- a/test/usb_pd_int.c +++ /dev/null @@ -1,105 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test USB-PD interrupt task. - */ -#include "task.h" -#include "test_util.h" -#include "mock/tcpc_mock.h" -#include "mock/timer_mock.h" -#include "mock/usb_mux_mock.h" - -#define PORT0 0 - -/* Install Mock TCPC and MUX drivers */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .drv = &mock_tcpc_driver, - }, -}; - -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .driver = &mock_usb_mux_driver, - } -}; - -static int deferred_resume_called; -void pd_deferred_resume(int port) -{ - deferred_resume_called = 1; -} - -static int num_events; -uint16_t tcpc_get_alert_status(void) -{ - if (--num_events > 0) - return PD_STATUS_TCPC_ALERT_0; - else - return 0; -} - -test_static int test_storm_not_triggered(void) -{ - num_events = 100; - deferred_resume_called = 0; - schedule_deferred_pd_interrupt(PORT0); - task_wait_event(SECOND); - TEST_EQ(deferred_resume_called, 0, "%d"); - - return EC_SUCCESS; -} - -test_static int test_storm_triggered(void) -{ - num_events = 1000; - deferred_resume_called = 0; - schedule_deferred_pd_interrupt(PORT0); - task_wait_event(SECOND); - TEST_EQ(deferred_resume_called, 1, "%d"); - - return EC_SUCCESS; -} - -test_static int test_storm_not_triggered_for_32bit_overflow(void) -{ - int i; - timestamp_t time; - - /* Ensure the MSB is 1 for overflow comparison tests */ - time.val = 0xff000000; - force_time(time); - - /* - * 100 events every second for 10 seconds should never trigger - * a shutdown call. - */ - for (i = 0; i < 10; ++i) { - num_events = 100; - deferred_resume_called = 0; - schedule_deferred_pd_interrupt(PORT0); - task_wait_event(SECOND); - - TEST_EQ(deferred_resume_called, 0, "%d"); - } - - return EC_SUCCESS; -} - -void before_test(void) -{ - pd_set_suspend(PORT0, 0); -} - -void run_test(void) -{ - /* Let tasks settle down */ - task_wait_event(MINUTE); - - RUN_TEST(test_storm_not_triggered); - RUN_TEST(test_storm_triggered); - RUN_TEST(test_storm_not_triggered_for_32bit_overflow); - - test_print_result(); -} diff --git a/test/usb_pd_int.mocklist b/test/usb_pd_int.mocklist deleted file mode 100644 index 71c2e2cee9..0000000000 --- a/test/usb_pd_int.mocklist +++ /dev/null @@ -1,8 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - #define CONFIG_TEST_MOCK_LIST \ - MOCK(USB_MUX) \ - MOCK(TCPC) diff --git a/test/usb_pd_int.tasklist b/test/usb_pd_int.tasklist deleted file mode 100644 index 3487d55dc7..0000000000 --- a/test/usb_pd_int.tasklist +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST \ - TASK_TEST(PD_C0, pd_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_TEST(PD_INT_C0, pd_interrupt_handler_task, 0, LARGER_TASK_STACK_SIZE) diff --git a/test/usb_pd_rev30.tasklist b/test/usb_pd_rev30.tasklist deleted file mode 120000 index 45cc6c8aa2..0000000000 --- a/test/usb_pd_rev30.tasklist +++ /dev/null @@ -1 +0,0 @@ -usb_pd.tasklist
\ No newline at end of file diff --git a/test/usb_pd_test_util.h b/test/usb_pd_test_util.h deleted file mode 100644 index 02fae22b41..0000000000 --- a/test/usb_pd_test_util.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright 2014 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test utilities for USB PD unit test. - */ - -#ifndef __TEST_USB_PD_TEST_UTIL_H -#define __TEST_USB_PD_TEST_UTIL_H - -/* Simulate Rx message */ -void pd_test_rx_set_preamble(int port, int has_preamble); -void pd_test_rx_msg_append_bits(int port, uint32_t bits, int nb); -void pd_test_rx_msg_append_kcode(int port, uint8_t kcode); -void pd_test_rx_msg_append_sop(int port); -void pd_test_rx_msg_append_sop_prime(int port); -void pd_test_rx_msg_append_eop(int port); -void pd_test_rx_msg_append_last_edge(int port); -void pd_test_rx_msg_append_4b(int port, uint8_t val); -void pd_test_rx_msg_append_short(int port, uint16_t val); -void pd_test_rx_msg_append_word(int port, uint32_t val); -void pd_simulate_rx(int port); - -/* Verify Tx message */ -int pd_test_tx_msg_verify_kcode(int port, uint8_t kcode); -int pd_test_tx_msg_verify_sop(int port); -int pd_test_tx_msg_verify_sop_prime(int port); -int pd_test_tx_msg_verify_eop(int port); -int pd_test_tx_msg_verify_4b5b(int port, uint8_t b4); -int pd_test_tx_msg_verify_short(int port, uint16_t val); -int pd_test_tx_msg_verify_word(int port, uint32_t val); -int pd_test_tx_msg_verify_crc(int port); - -#endif /* __TEST_USB_PD_TEST_UTIL_H */ diff --git a/test/usb_pe.h b/test/usb_pe.h deleted file mode 100644 index e9dc58925c..0000000000 --- a/test/usb_pe.h +++ /dev/null @@ -1,157 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test USB PE module. - */ -#ifndef __CROS_TEST_USB_PE_H -#define __CROS_TEST_USB_PE_H - -#include "common.h" - -/* - * Test references to port - */ -#define PORT0 0 - -/* - * Parameters for pe_run - * - * pe_run(port, evt, enable) - * evt - currently ignored in the implementation - * enable - 0 Disable/1 Enable - */ -#define EVT_IGNORED 0 - -#define ENABLED 1 -#define DISABLED 0 - -/** - * usb_pe_drp_sm.c locally defined. If it changes there, it must - * be changed here as well. - */ - -/* - * Policy Engine Layer Flags - */ - -/* At least one successful PD communication packet received from port partner */ -#define PE_FLAGS_PD_CONNECTION BIT(0) -/* Accept message received from port partner */ -#define PE_FLAGS_ACCEPT BIT(1) -/* Power Supply Ready message received from port partner */ -#define PE_FLAGS_PS_READY BIT(2) -/* Protocol Error was determined based on error recovery current state */ -#define PE_FLAGS_PROTOCOL_ERROR BIT(3) -/* Set if we are in Modal Operation */ -#define PE_FLAGS_MODAL_OPERATION BIT(4) -/* A message we requested to be sent has been transmitted */ -#define PE_FLAGS_TX_COMPLETE BIT(5) -/* A message sent by a port partner has been received */ -#define PE_FLAGS_MSG_RECEIVED BIT(6) -/* A hard reset has been requested but has not been sent, not currently used */ -#define PE_FLAGS_HARD_RESET_PENDING BIT(7) -/* Port partner sent a Wait message. Wait before we resend our message */ -#define PE_FLAGS_WAIT BIT(8) -/* An explicit contract is in place with our port partner */ -#define PE_FLAGS_EXPLICIT_CONTRACT BIT(9) -/* Waiting for Sink Capabailities timed out. Used for retry error handling */ -#define PE_FLAGS_SNK_WAIT_CAP_TIMEOUT BIT(10) -/* Power Supply voltage/current transition timed out */ -#define PE_FLAGS_PS_TRANSITION_TIMEOUT BIT(11) -/* Flag to note current Atomic Message Sequence is interruptible */ -#define PE_FLAGS_INTERRUPTIBLE_AMS BIT(12) -/* Flag to note Power Supply reset has completed */ -#define PE_FLAGS_PS_RESET_COMPLETE BIT(13) -/* Flag to note a Structured Vendor Defined Message should be sent */ -#define PE_FLAGS_SEND_SVDM BIT(14) -/* VCONN swap operation has completed */ -#define PE_FLAGS_VCONN_SWAP_COMPLETE BIT(15) -/* Flag to note no more discover identity messages are sent to port partner */ -#define PE_FLAGS_DISCOVER_PORT_IDENTITY_DONE BIT(16) -/* Flag to note Swap Source Start timer should be set at PE_SRC_Startup entry */ -#define PE_FLAGS_RUN_SOURCE_START_TIMER BIT(17) -/* Flag to note Port Discovery port partner replied with BUSY */ -#define PE_FLAGS_VDM_REQUEST_BUSY BIT(18) -/* Flag to note Port Discovery port partner replied with NAK */ -#define PE_FLAGS_VDM_REQUEST_NAKED BIT(19) -/* Flag to note FRS/PRS context in shared state machine path */ -#define PE_FLAGS_FAST_ROLE_SWAP_PATH BIT(20) -/* Flag to note if FRS listening is enabled */ -#define PE_FLAGS_FAST_ROLE_SWAP_ENABLED BIT(21) -/* Flag to note TCPC passed on FRS signal from port partner */ -#define PE_FLAGS_FAST_ROLE_SWAP_SIGNALED BIT(22) - -/* List of all Policy Engine level states */ -enum usb_pe_state { - /* Normal States */ - PE_SRC_STARTUP, - PE_SRC_DISCOVERY, - PE_SRC_SEND_CAPABILITIES, - PE_SRC_NEGOTIATE_CAPABILITY, - PE_SRC_TRANSITION_SUPPLY, - PE_SRC_READY, - PE_SRC_DISABLED, - PE_SRC_CAPABILITY_RESPONSE, - PE_SRC_HARD_RESET, - PE_SRC_HARD_RESET_RECEIVED, - PE_SRC_TRANSITION_TO_DEFAULT, - PE_SNK_STARTUP, - PE_SNK_DISCOVERY, - PE_SNK_WAIT_FOR_CAPABILITIES, - PE_SNK_EVALUATE_CAPABILITY, - PE_SNK_SELECT_CAPABILITY, - PE_SNK_READY, - PE_SNK_HARD_RESET, - PE_SNK_TRANSITION_TO_DEFAULT, - PE_SNK_GIVE_SINK_CAP, - PE_SNK_GET_SOURCE_CAP, - PE_SNK_TRANSITION_SINK, - PE_SEND_SOFT_RESET, - PE_SOFT_RESET, - PE_SEND_NOT_SUPPORTED, - PE_SRC_PING, - PE_GIVE_BATTERY_CAP, - PE_GIVE_BATTERY_STATUS, - PE_DRS_EVALUATE_SWAP, - PE_DRS_CHANGE, - PE_DRS_SEND_SWAP, - PE_PRS_SRC_SNK_EVALUATE_SWAP, - PE_PRS_SRC_SNK_TRANSITION_TO_OFF, - PE_PRS_SRC_SNK_WAIT_SOURCE_ON, - PE_PRS_SRC_SNK_SEND_SWAP, - PE_PRS_SNK_SRC_EVALUATE_SWAP, - PE_PRS_SNK_SRC_TRANSITION_TO_OFF, - PE_PRS_SNK_SRC_ASSERT_RP, - PE_PRS_SNK_SRC_SOURCE_ON, - PE_PRS_SNK_SRC_SEND_SWAP, - PE_FRS_SNK_SRC_START_AMS, - PE_VCS_EVALUATE_SWAP, - PE_VCS_SEND_SWAP, - PE_VCS_WAIT_FOR_VCONN_SWAP, - PE_VCS_TURN_ON_VCONN_SWAP, - PE_VCS_TURN_OFF_VCONN_SWAP, - PE_VCS_SEND_PS_RDY_SWAP, - PE_DO_PORT_DISCOVERY, - PE_VDM_REQUEST, - PE_VDM_ACKED, - PE_VDM_RESPONSE, - PE_HANDLE_CUSTOM_VDM_REQUEST, - PE_WAIT_FOR_ERROR_RECOVERY, - PE_BIST, - PE_DR_SNK_GET_SINK_CAP, - - /* Super States */ - PE_PRS_FRS_SHARED, -}; - -void set_state_pe(const int port, const enum usb_pe_state new_state); -enum usb_pe_state get_state_pe(const int port); - -void pe_set_flag(int port, int flag); -void pe_clr_flag(int port, int flag); -int pe_chk_flag(int port, int flag); -int pe_get_all_flags(int port); -void pe_set_all_flags(int port, int flags); - -#endif /* __CROS_TEST_USB_PE_H */ diff --git a/test/usb_pe_drp.c b/test/usb_pe_drp.c deleted file mode 100644 index c6a1dc0af7..0000000000 --- a/test/usb_pe_drp.c +++ /dev/null @@ -1,151 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test USB PE module. - */ -#include "battery.h" -#include "common.h" -#include "task.h" -#include "test_util.h" -#include "timer.h" -#include "usb_emsg.h" -#include "usb_pe.h" -#include "usb_pe_sm.h" -#include "usb_prl_sm.h" -#include "usb_sm_checks.h" -#include "usb_tc_sm.h" - -/** - * STUB Section - */ -const struct svdm_response svdm_rsp = { - .identity = NULL, - .svids = NULL, - .modes = NULL, -}; - -int board_vbus_source_enabled(int port) -{ - return 0; -} - -/** - * Test section - */ -/* PE Fast Role Swap */ -static int test_pe_frs(void) -{ - pe_run(PORT0, EVT_IGNORED, ENABLED); - TEST_ASSERT(pe_is_running(PORT0)); - - /* - * FRS will only trigger when we are SNK, with an Explicit - * contract. So set this state up manually - */ - tc_prs_src_snk_assert_rd(PORT0); - pe_set_flag(PORT0, PE_FLAGS_EXPLICIT_CONTRACT); - set_state_pe(PORT0, PE_SNK_READY); - pe_run(PORT0, EVT_IGNORED, ENABLED); - TEST_ASSERT(get_state_pe(PORT0) == PE_SNK_READY); - - /* - * Trigger the Fast Role Switch from simulated ISR - */ - pe_got_frs_signal(PORT0); - TEST_ASSERT(pe_chk_flag(PORT0, PE_FLAGS_FAST_ROLE_SWAP_SIGNALED)); - - /* - * Verify we detected FRS and ready to start swap - */ - pe_run(PORT0, EVT_IGNORED, ENABLED); - TEST_ASSERT(get_state_pe(PORT0) == PE_PRS_SNK_SRC_SEND_SWAP); - TEST_ASSERT(pe_chk_flag(PORT0, PE_FLAGS_FAST_ROLE_SWAP_PATH)); - TEST_ASSERT(!pe_chk_flag(PORT0, PE_FLAGS_EXPLICIT_CONTRACT)); - - /* - * Make sure that we sent FR_Swap - */ - pe_run(PORT0, EVT_IGNORED, ENABLED); - TEST_ASSERT(fake_prl_get_last_sent_ctrl_msg(PORT0) == PD_CTRL_FR_SWAP); - TEST_ASSERT(get_state_pe(PORT0) == PE_PRS_SNK_SRC_SEND_SWAP); - TEST_ASSERT(pe_chk_flag(PORT0, PE_FLAGS_FAST_ROLE_SWAP_PATH)); - - /* - * Accept the partners PS_RDY control message - */ - emsg[PORT0].header = PD_HEADER(PD_CTRL_ACCEPT, 0, 0, 0, 0, 0, 0); - pe_set_flag(PORT0, PE_FLAGS_MSG_RECEIVED); - pe_run(PORT0, EVT_IGNORED, ENABLED); - TEST_ASSERT(!pe_chk_flag(PORT0, PE_FLAGS_MSG_RECEIVED)); - TEST_ASSERT(get_state_pe(PORT0) == PE_PRS_SNK_SRC_TRANSITION_TO_OFF); - TEST_ASSERT(pe_chk_flag(PORT0, PE_FLAGS_FAST_ROLE_SWAP_PATH)); - - /* - * Send back our PS_RDY - */ - emsg[PORT0].header = PD_HEADER(PD_CTRL_PS_RDY, 0, 0, 0, 0, 0, 0); - pe_set_flag(PORT0, PE_FLAGS_MSG_RECEIVED); - TEST_ASSERT(!tc_is_attached_src(PORT0)); - pe_run(PORT0, EVT_IGNORED, ENABLED); - TEST_ASSERT(!pe_chk_flag(PORT0, PE_FLAGS_MSG_RECEIVED)); - TEST_ASSERT(tc_is_attached_src(PORT0)); - TEST_ASSERT(get_state_pe(PORT0) == PE_PRS_SNK_SRC_ASSERT_RP); - TEST_ASSERT(pe_chk_flag(PORT0, PE_FLAGS_FAST_ROLE_SWAP_PATH)); - - /* - * We are now attached source, so move to next state - */ - pe_run(PORT0, EVT_IGNORED, ENABLED); - TEST_ASSERT(get_state_pe(PORT0) == PE_PRS_SNK_SRC_SOURCE_ON); - TEST_ASSERT(pe_chk_flag(PORT0, PE_FLAGS_FAST_ROLE_SWAP_PATH)); - - /* - * Move the time to be after our wait time. - */ - force_time((timestamp_t)(get_time().val + - PD_POWER_SUPPLY_TURN_ON_DELAY)); - - /* - * After delay we are ready to send our PS_RDY - */ - pe_run(PORT0, EVT_IGNORED, ENABLED); - TEST_ASSERT(get_state_pe(PORT0) == PE_PRS_SNK_SRC_SOURCE_ON); - TEST_ASSERT(pe_chk_flag(PORT0, PE_FLAGS_FAST_ROLE_SWAP_PATH)); - TEST_ASSERT(fake_prl_get_last_sent_ctrl_msg(PORT0) == PD_CTRL_PS_RDY); - - /* - * Fake the Transmit complete and this will bring us to Source Startup - */ - pe_set_flag(PORT0, PE_FLAGS_TX_COMPLETE); - pe_run(PORT0, EVT_IGNORED, ENABLED); - TEST_ASSERT(get_state_pe(PORT0) == PE_SRC_STARTUP); - TEST_ASSERT(!pe_chk_flag(PORT0, PE_FLAGS_FAST_ROLE_SWAP_PATH)); - - return EC_SUCCESS; -} - -static int test_vbus_gpio_discharge(void) -{ - pd_set_vbus_discharge(PORT0, 1); - TEST_EQ(gpio_get_level(GPIO_USB_C0_DISCHARGE), 1, "%d"); - - pd_set_vbus_discharge(PORT0, 0); - TEST_EQ(gpio_get_level(GPIO_USB_C0_DISCHARGE), 0, "%d"); - - return EC_SUCCESS; -} - -void run_test(void) -{ - test_reset(); - - RUN_TEST(test_pe_frs); - RUN_TEST(test_vbus_gpio_discharge); - - /* Do basic state machine sanity checks last. */ - RUN_TEST(test_pe_no_parent_cycles); - RUN_TEST(test_pe_no_empty_state); - - test_print_result(); -} diff --git a/test/usb_pe_drp.tasklist b/test/usb_pe_drp.tasklist deleted file mode 100644 index 80b3135e56..0000000000 --- a/test/usb_pe_drp.tasklist +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TEST_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST diff --git a/test/usb_ppc.c b/test/usb_ppc.c deleted file mode 100644 index cf2a971a87..0000000000 --- a/test/usb_ppc.c +++ /dev/null @@ -1,193 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test USB PD module. - */ -#include "common.h" -#include "console.h" -#include "crc.h" -#include "task.h" -#include "test_util.h" -#include "timer.h" -#include "usbc_ppc.h" -#include "util.h" - -const struct ppc_drv null_drv = { - .init = NULL, - .is_sourcing_vbus = NULL, - .vbus_sink_enable = NULL, - .vbus_source_enable = NULL, - .set_polarity = NULL, - .set_vbus_source_current_limit = NULL, - .discharge_vbus = NULL, - .set_sbu = NULL, - .set_vconn = NULL, - .is_vbus_present = NULL, - .enter_low_power_mode = NULL, -}; - -struct ppc_config_t ppc_chips[] = { - [0] = { - .drv = &null_drv - }, -}; -unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips); - -const struct tcpc_config_t tcpc_config[] = { - [0] = { - }, -}; - -static int test_ppc_init(void) -{ - int rv; - - rv = ppc_init(1); - TEST_ASSERT(rv == EC_ERROR_INVAL); - rv = ppc_init(0); - TEST_ASSERT(rv == EC_ERROR_UNIMPLEMENTED); - - return EC_SUCCESS; -} - -static int test_ppc_is_sourcing_vbus(void) -{ - int rv; - - rv = ppc_is_sourcing_vbus(1); - TEST_ASSERT(rv == EC_ERROR_INVAL); - rv = ppc_is_sourcing_vbus(0); - TEST_ASSERT(rv == EC_ERROR_UNIMPLEMENTED); - - return EC_SUCCESS; -} - -static int test_ppc_set_polarity(void) -{ - int rv; - - rv = ppc_set_polarity(1, 0); - TEST_ASSERT(rv == EC_ERROR_INVAL); - rv = ppc_set_polarity(0, 0); - TEST_ASSERT(rv == EC_ERROR_UNIMPLEMENTED); - - return EC_SUCCESS; -} - -static int test_ppc_set_vbus_source_current_limit(void) -{ - int rv; - - rv = ppc_set_vbus_source_current_limit(1, 0); - TEST_ASSERT(rv == EC_ERROR_INVAL); - rv = ppc_set_vbus_source_current_limit(0, 0); - TEST_ASSERT(rv == EC_ERROR_UNIMPLEMENTED); - - return EC_SUCCESS; -} - -static int test_ppc_set_sbu(void) -{ - int rv; - - rv = ppc_set_sbu(1, 0); - TEST_ASSERT(rv == EC_ERROR_INVAL); - rv = ppc_set_sbu(0, 0); - TEST_ASSERT(rv == EC_ERROR_UNIMPLEMENTED); - - return EC_SUCCESS; -} - -static int test_ppc_set_vconn(void) -{ - int rv; - - rv = ppc_set_vconn(1, 0); - TEST_ASSERT(rv == EC_ERROR_INVAL); - rv = ppc_set_vconn(0, 0); - TEST_ASSERT(rv == EC_ERROR_UNIMPLEMENTED); - - return EC_SUCCESS; -} - -static int test_ppc_discharge_vbus(void) -{ - int rv; - - rv = ppc_discharge_vbus(1, 0); - TEST_ASSERT(rv == EC_ERROR_INVAL); - rv = ppc_discharge_vbus(0, 0); - TEST_ASSERT(rv == EC_ERROR_UNIMPLEMENTED); - - return EC_SUCCESS; -} - -static int test_ppc_vbus_sink_enable(void) -{ - int rv; - - rv = ppc_vbus_sink_enable(1, 0); - TEST_ASSERT(rv == EC_ERROR_INVAL); - rv = ppc_vbus_sink_enable(0, 0); - TEST_ASSERT(rv == EC_ERROR_UNIMPLEMENTED); - - return EC_SUCCESS; -} - -static int test_ppc_enter_low_power_mode(void) -{ - int rv; - - rv = ppc_enter_low_power_mode(1); - TEST_ASSERT(rv == EC_ERROR_INVAL); - rv = ppc_enter_low_power_mode(0); - TEST_ASSERT(rv == EC_ERROR_UNIMPLEMENTED); - - return EC_SUCCESS; -} - -static int test_ppc_vbus_source_enable(void) -{ - int rv; - - rv = ppc_vbus_source_enable(1, 0); - TEST_ASSERT(rv == EC_ERROR_INVAL); - rv = ppc_vbus_source_enable(0, 0); - TEST_ASSERT(rv == EC_ERROR_UNIMPLEMENTED); - - return EC_SUCCESS; -} - -static int test_ppc_is_vbus_present(void) -{ - int rv; - - rv = ppc_is_vbus_present(1); - TEST_ASSERT(rv == EC_ERROR_INVAL); - rv = ppc_is_vbus_present(0); - TEST_ASSERT(rv == EC_ERROR_UNIMPLEMENTED); - - return EC_SUCCESS; -} - - - -void run_test(void) -{ - test_reset(); - - RUN_TEST(test_ppc_init); - RUN_TEST(test_ppc_is_sourcing_vbus); - RUN_TEST(test_ppc_set_polarity); - RUN_TEST(test_ppc_set_vbus_source_current_limit); - RUN_TEST(test_ppc_set_sbu); - RUN_TEST(test_ppc_set_vconn); - RUN_TEST(test_ppc_discharge_vbus); - RUN_TEST(test_ppc_vbus_sink_enable); - RUN_TEST(test_ppc_enter_low_power_mode); - RUN_TEST(test_ppc_vbus_source_enable); - RUN_TEST(test_ppc_is_vbus_present); - - test_print_result(); -} diff --git a/test/usb_ppc.tasklist b/test/usb_ppc.tasklist deleted file mode 100644 index 9fc1a80f4d..0000000000 --- a/test/usb_ppc.tasklist +++ /dev/null @@ -1,9 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST diff --git a/test/usb_prl.c b/test/usb_prl.c deleted file mode 100644 index 425ba8ceca..0000000000 --- a/test/usb_prl.c +++ /dev/null @@ -1,1414 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test USB Protocol Layer module. - */ -#include "common.h" -#include "crc.h" -#include "task.h" -#include "test_util.h" -#include "timer.h" -#include "tcpm.h" -#include "usb_emsg.h" -#include "usb_pe_sm.h" -#include "usb_pd.h" -#include "usb_pd_test_util.h" -#include "usb_prl_sm.h" -#include "usb_sm_checks.h" -#include "util.h" - -#define PORT0 0 -#define PORT1 1 - -/* - * These enum definitions are declared in usb_prl_sm and are private to that - * file. If those definitions are re-ordered, then we need to update these - * definitions (should be very rare). - */ -enum usb_prl_tx_state { - PRL_TX_PHY_LAYER_RESET, - PRL_TX_WAIT_FOR_MESSAGE_REQUEST, - PRL_TX_LAYER_RESET_FOR_TRANSMIT, - PRL_TX_WAIT_FOR_PHY_RESPONSE, - PRL_TX_SRC_SOURCE_TX, - PRL_TX_SNK_START_AMS, - PRL_TX_SRC_PENDING, - PRL_TX_SNK_PENDING, - PRL_TX_DISCARD_MESSAGE, -}; - -enum usb_prl_hr_state { - PRL_HR_WAIT_FOR_REQUEST, - PRL_HR_RESET_LAYER, - PRL_HR_WAIT_FOR_PHY_HARD_RESET_COMPLETE, - PRL_HR_WAIT_FOR_PE_HARD_RESET_COMPLETE, -}; - -enum usb_rch_state { - RCH_WAIT_FOR_MESSAGE_FROM_PROTOCOL_LAYER, - RCH_PASS_UP_MESSAGE, - RCH_PROCESSING_EXTENDED_MESSAGE, - RCH_REQUESTING_CHUNK, - RCH_WAITING_CHUNK, - RCH_REPORT_ERROR, -}; - -enum usb_tch_state { - TCH_WAIT_FOR_MESSAGE_REQUEST_FROM_PE, - TCH_WAIT_FOR_TRANSMISSION_COMPLETE, - TCH_CONSTRUCT_CHUNKED_MESSAGE, - TCH_SENDING_CHUNKED_MESSAGE, - TCH_WAIT_CHUNK_REQUEST, - TCH_MESSAGE_RECEIVED, - TCH_MESSAGE_SENT, - TCH_REPORT_ERROR, -}; - -/* Defined in implementation */ -enum usb_prl_tx_state prl_tx_get_state(const int port); -enum usb_prl_hr_state prl_hr_get_state(const int port); -enum usb_rch_state rch_get_state(const int port); -enum usb_tch_state tch_get_state(const int port); - - -static uint32_t test_data[] = { - 0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f, - 0x10111213, 0x14151617, 0x1819a0b0, 0xc0d0e0f0, - 0x20212223, 0x24252627, 0x28292a2b, 0x2c2d2e2f, - 0x30313233, 0x34353637, 0x38393a3b, 0x3c3d3e3f, - 0x40414243, 0x44454647, 0x48494a4b, 0x4c4d4e4f, - 0x50515253, 0x54555657, 0x58595a5b, 0x5c5d5e5f, - 0x60616263, 0x64656667, 0x68696a6b, 0x6c6d6e6f, - 0x70717273, 0x74757677, 0x78797a7b, 0x7c7d7e7f, - 0x80818283, 0x84858687, 0x88898a8b, 0x8c8d8e8f, - 0x90919293, 0x94959697, 0x98999a9b, 0x9c9d9e9f, - 0xa0a1a2a3, 0xa4a5a6a7, 0xa8a9aaab, 0xacadaeaf, - 0xb0b1b2b3, 0xb4b5b6b7, 0xb8b9babb, 0xbcbdbebf, - 0xc0c1c2c3, 0xc4c5c6c7, 0xc8c9cacb, 0xcccdcecf, - 0xd0d1d2d3, 0xd4d5d6d7, 0xd8d9dadb, 0xdcdddedf, - 0xe0e1e2e3, 0xe4e5e6e7, 0xe8e9eaeb, 0xecedeeef, - 0xf0f1f2f3, 0xf4f5f6f7, 0xf8f9fafb, 0xfcfdfeff, - 0x11223344 -}; - -static struct pd_prl { - int rev; - int pd_enable; - enum pd_power_role power_role; - enum pd_data_role data_role; - int msg_tx_id; - int msg_rx_id; - - int mock_pe_message_sent; - int mock_pe_error; - int mock_pe_hard_reset_sent; - int mock_pe_got_hard_reset; - int mock_pe_message_received; - int mock_got_soft_reset; -} pd_port[CONFIG_USB_PD_PORT_MAX_COUNT]; - -static void init_port(int port, int rev) -{ - pd_port[port].rev = rev; - pd_port[port].pd_enable = 0; - pd_port[port].power_role = PD_ROLE_SINK; - pd_port[port].data_role = PD_ROLE_UFP; - pd_port[port].msg_tx_id = 0; - pd_port[port].msg_rx_id = 0; - - tcpm_init(port); - tcpm_set_polarity(port, 0); - tcpm_set_rx_enable(port, 0); -} - -static inline uint32_t pending_pd_task_events(int port) -{ - return *task_get_event_bitmap(PD_PORT_TO_TASK_ID(port)); -} - -void inc_tx_id(int port) -{ - pd_port[port].msg_tx_id = (pd_port[port].msg_tx_id + 1) & 7; -} - -void inc_rx_id(int port) -{ - pd_port[port].msg_rx_id = (pd_port[port].msg_rx_id + 1) % 7; -} - -static int verify_goodcrc(int port, int role, int id) -{ - return pd_test_tx_msg_verify_sop(port) && - pd_test_tx_msg_verify_short(port, PD_HEADER(PD_CTRL_GOOD_CRC, - role, role, id, 0, 0, 0)) && - pd_test_tx_msg_verify_crc(port) && - pd_test_tx_msg_verify_eop(port); -} - -static void simulate_rx_msg(int port, uint16_t header, int cnt, - const uint32_t *data) -{ - int i; - - pd_test_rx_set_preamble(port, 1); - pd_test_rx_msg_append_sop(port); - pd_test_rx_msg_append_short(port, header); - - crc32_init(); - crc32_hash16(header); - - for (i = 0; i < cnt; ++i) { - pd_test_rx_msg_append_word(port, data[i]); - crc32_hash32(data[i]); - } - - pd_test_rx_msg_append_word(port, crc32_result()); - - pd_test_rx_msg_append_eop(port); - pd_test_rx_msg_append_last_edge(port); - - pd_simulate_rx(port); -} - -static void simulate_goodcrc(int port, int role, int id) -{ - simulate_rx_msg(port, PD_HEADER(PD_CTRL_GOOD_CRC, role, role, id, 0, - pd_port[port].rev, 0), 0, NULL); -} - -static void cycle_through_state_machine(int port, uint32_t num, uint32_t time) -{ - int i; - - for (i = 0; i < num; i++) { - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(time); - } -} - -static int simulate_request_chunk(int port, enum pd_data_msg_type msg_type, - int chunk_num, int len) -{ - uint16_t header = PD_HEADER(msg_type, pd_port[port].power_role, - pd_port[port].data_role, - pd_port[port].msg_rx_id, - 1, pd_port[port].rev, 1); - uint32_t msg = PD_EXT_HEADER(chunk_num, 1, len); - - simulate_rx_msg(port, header, 1, (const uint32_t *)&msg); - task_wait_event(30 * MSEC); - - if (!verify_goodcrc(port, pd_port[port].data_role, - pd_port[port].msg_rx_id)) - return 0; - - return 1; -} - -static int simulate_receive_ctrl_msg(int port, enum pd_ctrl_msg_type msg_type) -{ - uint16_t header = PD_HEADER(msg_type, pd_port[port].power_role, - pd_port[port].data_role, pd_port[port].msg_rx_id, - 0, pd_port[port].rev, 0); - - simulate_rx_msg(port, header, 0, NULL); - task_wait_event(30 * MSEC); - - if (!verify_goodcrc(port, pd_port[port].data_role, - pd_port[port].msg_rx_id)) - return 0; - - return 1; -} - -static int verify_data_reception(int port, uint16_t header, int len) -{ - int i; - int cnt = (len + 3) & ~3; - - cycle_through_state_machine(port, 3, 10 * MSEC); - - if (pd_port[port].mock_pe_error >= 0) - return 0; - - if (!pd_port[port].mock_pe_message_received) - return 0; - - if (emsg[port].header != header) - return 0; - - if (emsg[port].len != cnt) - return 0; - - for (i = 0; i < cnt; i++) { - if (i < len) { - if (emsg[port].buf[i] != - *((unsigned char *)test_data + i)) - return 0; - } else { - if (emsg[port].buf[i] != 0) - return 0; - } - } - - return 1; -} - -static int verify_chunk_data_reception(int port, uint16_t header, int len) -{ - int i; - uint8_t *td = (uint8_t *)test_data; - - if (pd_port[port].mock_got_soft_reset) { - ccprintf("Got mock soft reset\n"); - return 0; - } - - if (!pd_port[port].mock_pe_message_received) { - ccprintf("No mock pe msg received\n"); - return 0; - } - - if (pd_port[port].mock_pe_error >= 0) { - ccprintf("Mock pe error (%d)\n", pd_port[port].mock_pe_error); - return 0; - } - - if (emsg[port].len != len) { - ccprintf("emsg len (%d) != 0\n", emsg[port].len); - return 0; - } - - for (i = 0; i < len; i++) { - if (emsg[port].buf[i] != td[i]) { - ccprintf("emsg buf[%d] != td\n", i); - return 0; - } - } - - return 1; -} - -static int simulate_receive_data(int port, enum pd_data_msg_type msg_type, - int len) -{ - int i; - int nw = (len + 3) >> 2; - uint8_t td[28]; - uint16_t header = PD_HEADER(msg_type, pd_port[port].power_role, - pd_port[port].data_role, pd_port[port].msg_rx_id, - nw, pd_port[port].rev, 0); - - pd_port[port].mock_pe_error = -1; - pd_port[port].mock_pe_message_received = 0; - emsg[port].header = 0; - emsg[port].len = 0; - memset(emsg[port].buf, 0, 260); - - for (i = 0; i < 28; i++) { - if (i < len) - td[i] = *((uint8_t *)test_data + i); - else - td[i] = 0; - } - - simulate_rx_msg(port, header, nw, (uint32_t *)td); - task_wait_event(30 * MSEC); - - if (!verify_goodcrc(port, pd_port[port].data_role, - pd_port[port].msg_rx_id)) - return 0; - - inc_rx_id(port); - - return verify_data_reception(port, header, len); -} - -static int simulate_receive_extended_data(int port, - enum pd_data_msg_type msg_type, int len) -{ - int i; - int j; - int byte_len; - int nw; - int dsize; - uint8_t td[28]; - int chunk_num = 0; - int data_offset = 0; - uint8_t *expected_data = (uint8_t *)test_data; - uint16_t header; - - pd_port[port].mock_pe_error = -1; - pd_port[port].mock_pe_message_received = 0; - emsg[port].header = 0; - emsg[port].len = 0; - memset(emsg[port].buf, 0, 260); - - dsize = len; - for (j = 0; j < 10; j++) { - /* Let state machine settle before starting another round */ - cycle_through_state_machine(port, 10, MSEC); - - byte_len = len; - if (byte_len > 26) - byte_len = 26; - - len -= 26; - - memset(td, 0, 28); - *(uint16_t *)td = PD_EXT_HEADER(chunk_num, 0, dsize); - - for (i = 0; i < byte_len; i++) - td[i + 2] = *(expected_data + data_offset++); - - nw = (byte_len + 2 + 3) >> 2; - header = PD_HEADER(msg_type, pd_port[port].power_role, - pd_port[port].data_role, pd_port[port].msg_rx_id, - nw, pd_port[port].rev, 1); - - if (pd_port[port].mock_pe_error >= 0) { - ccprintf("Mock pe error (%d) iteration (%d)\n", - pd_port[port].mock_pe_error, j); - return 0; - } - - if (pd_port[port].mock_pe_message_received) { - ccprintf("Mock pe msg received iteration (%d)\n", j); - return 0; - } - - if (emsg[port].len != 0) { - ccprintf("emsg len (%d) != 0 iteration (%d)\n", - emsg[port].len, j); - return 0; - } - - simulate_rx_msg(port, header, nw, (uint32_t *)td); - cycle_through_state_machine(port, 1, MSEC); - - if (!verify_goodcrc(port, pd_port[port].data_role, - pd_port[port].msg_rx_id)) { - ccprintf("Verify goodcrc bad iteration (%d)\n", j); - return 0; - } - - cycle_through_state_machine(port, 1, MSEC); - inc_rx_id(port); - - /* - * If no more data, do expected to get a chunk request - */ - if (len <= 0) - break; - - /* - * We need to ensure that the TX event has been set, which may - * require an extra cycle through the state machine - */ - if (!(PD_EVENT_TX & pending_pd_task_events(port))) - cycle_through_state_machine(port, 1, MSEC); - - chunk_num++; - - /* Test Request next chunk packet */ - if (!pd_test_tx_msg_verify_sop(port)) { - ccprintf("Verify sop bad iteration (%d)\n", j); - return 0; - } - - if (!pd_test_tx_msg_verify_short(port, - PD_HEADER(msg_type, - pd_port[port].power_role, - pd_port[port].data_role, - pd_port[port].msg_tx_id, - 1, pd_port[port].rev, 1))) { - ccprintf("Verify msg short bad iteration (%d)\n", j); - return 0; - } - - if (!pd_test_tx_msg_verify_word(port, - PD_EXT_HEADER(chunk_num, 1, 0))) { - ccprintf("Verify msg word bad iteration (%d)\n", j); - return 0; - } - - if (!pd_test_tx_msg_verify_crc(port)) { - ccprintf("Verify msg crc bad iteration (%d)\n", j); - return 0; - } - - if (!pd_test_tx_msg_verify_eop(port)) { - ccprintf("Verify msg eop bad iteration (%d)\n", j); - return 0; - } - - cycle_through_state_machine(port, 1, MSEC); - - /* Request next chunk packet was good. Send GoodCRC */ - simulate_goodcrc(port, pd_port[port].power_role, - pd_port[port].msg_tx_id); - - cycle_through_state_machine(port, 1, MSEC); - - inc_tx_id(port); - } - - cycle_through_state_machine(port, 1, MSEC); - - return verify_chunk_data_reception(port, header, dsize); -} - -static int verify_ctrl_msg_transmission(int port, - enum pd_ctrl_msg_type msg_type) -{ - if (!pd_test_tx_msg_verify_sop(port)) - return 0; - - if (!pd_test_tx_msg_verify_short(port, - PD_HEADER(msg_type, pd_port[port].power_role, - pd_port[port].data_role, pd_port[port].msg_tx_id, 0, - pd_port[port].rev, 0))) - return 0; - - if (!pd_test_tx_msg_verify_crc(port)) - return 0; - - if (!pd_test_tx_msg_verify_eop(port)) - return 0; - - return 1; -} - -static int simulate_send_ctrl_msg_request_from_pe(int port, - enum tcpm_transmit_type type, enum pd_ctrl_msg_type msg_type) -{ - pd_port[port].mock_got_soft_reset = 0; - pd_port[port].mock_pe_error = -1; - pd_port[port].mock_pe_message_sent = 0; - prl_send_ctrl_msg(port, type, msg_type); - cycle_through_state_machine(port, 1, MSEC); - - /* Soft reset takes another iteration through the state machine */ - if (msg_type == PD_CTRL_SOFT_RESET) - cycle_through_state_machine(port, 1, MSEC); - - return verify_ctrl_msg_transmission(port, msg_type); -} - -static int verify_data_msg_transmission(int port, - enum pd_data_msg_type msg_type, int len) -{ - int i; - int num_words = (len + 3) >> 2; - int data_obj_in_bytes; - uint32_t td; - - if (!pd_test_tx_msg_verify_sop(port)) - return 0; - - if (!pd_test_tx_msg_verify_short(port, - PD_HEADER(msg_type, pd_port[port].power_role, - pd_port[port].data_role, pd_port[port].msg_tx_id, - num_words, pd_port[port].rev, 0))) - return 0; - - for (i = 0; i < num_words; i++) { - td = test_data[i]; - data_obj_in_bytes = (i + 1) * 4; - if (data_obj_in_bytes > len) { - switch (data_obj_in_bytes - len) { - case 1: - td &= 0x00ffffff; - break; - case 2: - td &= 0x0000ffff; - break; - case 3: - td &= 0x000000ff; - break; - } - } - - if (!pd_test_tx_msg_verify_word(port, td)) - return 0; - } - - if (!pd_test_tx_msg_verify_crc(port)) - return 0; - - if (!pd_test_tx_msg_verify_eop(port)) - return 0; - - return 1; -} - -static int simulate_send_data_msg_request_from_pe(int port, - enum tcpm_transmit_type type, enum pd_ctrl_msg_type msg_type, int len) -{ - int i; - uint8_t *buf = emsg[port].buf; - uint8_t *td = (uint8_t *)test_data; - - pd_port[port].mock_got_soft_reset = 0; - pd_port[port].mock_pe_error = -1; - pd_port[port].mock_pe_message_sent = 0; - - for (i = 0; i < len; i++) - buf[i] = td[i]; - - emsg[port].len = len; - - prl_send_data_msg(port, type, msg_type); - cycle_through_state_machine(port, 1, MSEC); - - return verify_data_msg_transmission(port, msg_type, len); -} - -static int verify_extended_data_msg_transmission(int port, - enum pd_data_msg_type msg_type, int len) -{ - int i; - int j; - int nw; - int byte_len; - int dsize; - uint32_t td; - uint8_t *expected_data = (uint8_t *)&test_data; - int data_offset = 0; - int chunk_number_to_send = 0; - - dsize = len; - - for (j = 0; j < 10; j++) { - byte_len = len; - if (byte_len > 26) - byte_len = 26; - - nw = (byte_len + 2 + 3) >> 2; - - if (!pd_test_tx_msg_verify_sop(port)) { - ccprintf("failed tx sop; iteration (%d)\n", j); - return 0; - } - - if (!pd_test_tx_msg_verify_short(port, - PD_HEADER(msg_type, pd_port[port].power_role, - pd_port[port].data_role, - pd_port[port].msg_tx_id, - nw, pd_port[port].rev, 1))) { - ccprintf("failed tx short\n"); - return 0; - } - td = PD_EXT_HEADER(chunk_number_to_send, 0, dsize); - td |= *(expected_data + data_offset++) << 16; - td |= *(expected_data + data_offset++) << 24; - - if (byte_len == 1) - td &= 0x00ffffff; - - if (!pd_test_tx_msg_verify_word(port, td)) { - ccprintf("failed tx word\n"); - return 0; - } - - byte_len -= 2; - - if (byte_len > 0) { - nw = (byte_len + 3) >> 2; - for (i = 0; i < nw; i++) { - td = *(expected_data + data_offset++) << 0; - td |= *(expected_data + data_offset++) << 8; - td |= *(expected_data + data_offset++) << 16; - td |= *(expected_data + data_offset++) << 24; - - switch (byte_len) { - case 3: - td &= 0x00ffffff; - break; - case 2: - td &= 0x0000ffff; - break; - case 1: - td &= 0x000000ff; - break; - } - - if (!pd_test_tx_msg_verify_word(port, td)) - return 0; - byte_len -= 4; - } - } - - if (!pd_test_tx_msg_verify_crc(port)) { - ccprintf("failed tx crc\n"); - return 0; - } - - if (!pd_test_tx_msg_verify_eop(port)) { - ccprintf("failed tx eop\n"); - return 0; - } - - cycle_through_state_machine(port, 1, MSEC); - - /* Send GoodCRC */ - simulate_goodcrc(port, pd_port[port].power_role, - pd_port[port].msg_tx_id); - cycle_through_state_machine(port, 1, MSEC); - inc_tx_id(port); - - len -= 26; - if (len <= 0) - break; - - chunk_number_to_send++; - /* Let state machine settle */ - cycle_through_state_machine(port, 10, MSEC); - if (!simulate_request_chunk(port, msg_type, - chunk_number_to_send, dsize)) { - ccprintf("failed request chunk\n"); - return 0; - } - - cycle_through_state_machine(port, 1, MSEC); - inc_rx_id(port); - } - - return 1; -} - -static int simulate_send_extended_data_msg(int port, - enum tcpm_transmit_type type, enum pd_ctrl_msg_type msg_type, - int len) -{ - int i; - uint8_t *buf = emsg[port].buf; - uint8_t *td = (uint8_t *)test_data; - - memset(buf, 0, 260); - emsg[port].len = len; - - /* don't overflow buffer */ - if (len > 260) - len = 260; - - for (i = 0; i < len; i++) - buf[i] = td[i]; - - prl_send_ext_data_msg(port, type, msg_type); - cycle_through_state_machine(port, 1, MSEC); - - return verify_extended_data_msg_transmission(port, msg_type, - len); -} - -static void enable_prl(int port, int en) -{ - tcpm_set_rx_enable(port, en); - - pd_port[port].pd_enable = en; - pd_port[port].msg_tx_id = 0; - pd_port[port].msg_rx_id = 0; - - /* Init PRL */ - cycle_through_state_machine(port, 10, MSEC); - - prl_set_rev(port, TCPC_TX_SOP, pd_port[port].rev); -} - -enum pd_power_role tc_get_power_role(int port) -{ - return pd_port[port].power_role; -} - -enum pd_data_role tc_get_data_role(int port) -{ - return pd_port[port].data_role; -} - -enum pd_cable_plug tc_get_cable_plug(int port) -{ - return PD_PLUG_FROM_DFP_UFP; -} - -void pe_report_error(int port, enum pe_error e) -{ - pd_port[port].mock_pe_error = e; -} - -void pe_got_hard_reset(int port) -{ - pd_port[port].mock_pe_got_hard_reset = 1; -} - -void pe_message_received(int port) -{ - pd_port[port].mock_pe_message_received = 1; -} - -void pe_message_sent(int port) -{ - pd_port[port].mock_pe_message_sent = 1; -} - -void pe_hard_reset_sent(int port) -{ - pd_port[port].mock_pe_hard_reset_sent = 1; -} - -void pe_got_soft_reset(int port) -{ - pd_port[port].mock_got_soft_reset = 1; -} - -static int test_prl_reset(void) -{ - int port = PORT0; - - enable_prl(port, 1); - - prl_reset(port); - - TEST_ASSERT(prl_tx_get_state(port) == - PRL_TX_WAIT_FOR_MESSAGE_REQUEST); - TEST_ASSERT(rch_get_state(port) == - RCH_WAIT_FOR_MESSAGE_FROM_PROTOCOL_LAYER); - TEST_ASSERT(tch_get_state(port) == - TCH_WAIT_FOR_MESSAGE_REQUEST_FROM_PE); - TEST_ASSERT(prl_hr_get_state(port) == - PRL_HR_WAIT_FOR_REQUEST); - enable_prl(port, 0); - - return EC_SUCCESS; -} - -static int test_send_ctrl_msg(void) -{ - int i; - int port = PORT0; - - enable_prl(port, 1); - - /* - * TEST: Control message transmission and tx_id increment - */ - for (i = 0; i < 10; i++) { - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - TEST_ASSERT(prl_tx_get_state(port) == - PRL_TX_WAIT_FOR_MESSAGE_REQUEST); - - TEST_ASSERT(simulate_send_ctrl_msg_request_from_pe(port, - TCPC_TX_SOP, PD_CTRL_ACCEPT)); - - cycle_through_state_machine(port, 1, MSEC); - - simulate_goodcrc(port, pd_port[port].power_role, - pd_port[port].msg_tx_id); - inc_tx_id(port); - - /* Let statemachine settle */ - cycle_through_state_machine(port, 10, MSEC); - - TEST_ASSERT(!pd_port[port].mock_got_soft_reset); - TEST_ASSERT(pd_port[port].mock_pe_message_sent); - TEST_ASSERT(pd_port[port].mock_pe_error < 0); - } - - enable_prl(port, 0); - - return EC_SUCCESS; -} - -static int test_send_ctrl_msg_with_retry_and_fail(void) -{ - int i; - int port = PORT0; - - enable_prl(port, 1); - - /* - * TEST: Control message transmission fail with retry - */ - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(MSEC); - - TEST_ASSERT(prl_tx_get_state(port) == - PRL_TX_WAIT_FOR_MESSAGE_REQUEST); - - TEST_ASSERT(simulate_send_ctrl_msg_request_from_pe(port, - TCPC_TX_SOP, PD_CTRL_ACCEPT)); - - cycle_through_state_machine(port, 1, MSEC); - - simulate_goodcrc(port, pd_port[port].power_role, - pd_port[port].msg_tx_id); - - /* Do not increment tx_id so phy layer will not transmit message */ - - /* Let statemachine settle */ - cycle_through_state_machine(port, 10, MSEC); - - TEST_ASSERT(!pd_port[port].mock_got_soft_reset); - TEST_ASSERT(pd_port[port].mock_pe_message_sent); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(MSEC); - - TEST_ASSERT(prl_tx_get_state(port) == - PRL_TX_WAIT_FOR_MESSAGE_REQUEST); - - pd_port[port].mock_pe_message_sent = 0; - prl_send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_ACCEPT); - cycle_through_state_machine(port, 1, MSEC); - - for (i = 0; i < N_RETRY_COUNT + 1; i++) { - /* Ensure that we have timed out */ - cycle_through_state_machine(port, 10, 100 * MSEC); - - TEST_ASSERT(!pd_port[port].mock_got_soft_reset); - TEST_ASSERT(pd_port[port].mock_pe_message_sent == 0); - if (i == N_RETRY_COUNT) - TEST_ASSERT(pd_port[port].mock_pe_error == - ERR_TCH_XMIT); - else - TEST_ASSERT(pd_port[port].mock_pe_error < 0); - } - - enable_prl(port, 0); - - return EC_SUCCESS; -} - -static int test_send_ctrl_msg_with_retry_and_success(void) -{ - int i; - int port = PORT0; - - enable_prl(port, 1); - - /* - * TEST: Control message transmission fail with retry - */ - - TEST_ASSERT(prl_tx_get_state(port) == - PRL_TX_WAIT_FOR_MESSAGE_REQUEST); - - pd_port[port].mock_got_soft_reset = 0; - pd_port[port].mock_pe_error = -1; - pd_port[port].mock_pe_message_sent = 0; - - prl_send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_ACCEPT); - task_wait_event(40 * MSEC); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - simulate_goodcrc(port, pd_port[port].power_role, - pd_port[port].msg_tx_id); - - /* Do not increment tx_id. */ - - cycle_through_state_machine(port, 3, 10 * MSEC); - - TEST_ASSERT(!pd_port[port].mock_got_soft_reset); - TEST_ASSERT(pd_port[port].mock_pe_message_sent); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - TEST_ASSERT(prl_tx_get_state(port) == - PRL_TX_WAIT_FOR_MESSAGE_REQUEST); - - pd_port[port].mock_pe_message_sent = 0; - prl_send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_ACCEPT); - task_wait_event(30 * MSEC); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - - for (i = 0; i < N_RETRY_COUNT + 1; i++) { - if (i == N_RETRY_COUNT) - inc_tx_id(port); - - simulate_goodcrc(port, pd_port[port].power_role, - pd_port[port].msg_tx_id); - - cycle_through_state_machine(port, 8, 10 * MSEC); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(PD_T_TCPC_TX_TIMEOUT); - - TEST_ASSERT(!pd_port[port].mock_got_soft_reset); - if (i == N_RETRY_COUNT) - TEST_ASSERT(pd_port[port].mock_pe_message_sent); - else - TEST_ASSERT(pd_port[port].mock_pe_message_sent == 0); - TEST_ASSERT(pd_port[port].mock_pe_error < 0); - } - - enable_prl(port, 0); - - return EC_SUCCESS; -} - -static int test_send_data_msg(void) -{ - int i; - int port = PORT0; - - enable_prl(port, 1); - - /* - * TEST: Sending data message with 1 to 28 bytes - */ - for (i = 1; i <= 28; i++) { - cycle_through_state_machine(port, 1, MSEC); - - TEST_ASSERT(prl_tx_get_state(port) == - PRL_TX_WAIT_FOR_MESSAGE_REQUEST); - - TEST_ASSERT(simulate_send_data_msg_request_from_pe(port, - TCPC_TX_SOP, PD_DATA_SOURCE_CAP, i)); - - cycle_through_state_machine(port, 1, MSEC); - - simulate_goodcrc(port, pd_port[port].power_role, - pd_port[port].msg_tx_id); - inc_tx_id(port); - - cycle_through_state_machine(port, 10, MSEC); - - TEST_ASSERT(!pd_port[port].mock_got_soft_reset); - TEST_ASSERT(pd_port[port].mock_pe_message_sent); - TEST_ASSERT(pd_port[port].mock_pe_error < 0); - } - - enable_prl(port, 0); - - return EC_SUCCESS; -} - -static int test_send_data_msg_to_much_data(void) -{ - int port = PORT0; - - enable_prl(port, 1); - - /* - * TEST: Send data message with more than 28-bytes, should fail - */ - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - TEST_ASSERT(prl_tx_get_state(port) == - PRL_TX_WAIT_FOR_MESSAGE_REQUEST); - - /* Try to send 29-bytes */ - TEST_ASSERT(!simulate_send_data_msg_request_from_pe(port, - TCPC_TX_SOP, PD_DATA_SOURCE_CAP, 29)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - - cycle_through_state_machine(port, 10, MSEC); - - TEST_ASSERT(!pd_port[port].mock_got_soft_reset); - TEST_ASSERT(!pd_port[port].mock_pe_message_sent); - TEST_ASSERT(pd_port[port].mock_pe_error = ERR_TCH_XMIT); - - enable_prl(port, 0); - - return EC_SUCCESS; -} - -static int test_send_extended_data_msg(void) -{ - int i; - int port = PORT0; - - enable_prl(port, 1); - - /* - * TEST: Sending extended data message with 29 to 260 bytes - */ - - pd_port[port].mock_got_soft_reset = 0; - pd_port[port].mock_pe_error = -1; - - ccprintf("Iteration "); - for (i = 29; i <= 260; i++) { - ccprintf(".%d", i); - pd_port[port].mock_pe_message_sent = 0; - - cycle_through_state_machine(port, 10, MSEC); - - TEST_ASSERT(prl_tx_get_state(port) == - PRL_TX_WAIT_FOR_MESSAGE_REQUEST); - - TEST_ASSERT(simulate_send_extended_data_msg( - port, TCPC_TX_SOP, PD_EXT_MANUFACTURER_INFO, i)); - - cycle_through_state_machine(port, 10, MSEC); - - TEST_ASSERT(!pd_port[port].mock_got_soft_reset); - TEST_ASSERT(pd_port[port].mock_pe_message_sent); - TEST_ASSERT(pd_port[port].mock_pe_error < 0); - } - enable_prl(port, 0); - - return EC_SUCCESS; -} - -static int test_receive_soft_reset_msg(void) -{ - int port = PORT0; - int expected_header = PD_HEADER(PD_CTRL_SOFT_RESET, - pd_port[port].power_role, - pd_port[port].data_role, - pd_port[port].msg_rx_id, - 0, pd_port[port].rev, 0); - - enable_prl(port, 1); - - /* - * TEST: Receiving Soft Reset - */ - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - TEST_ASSERT(rch_get_state(port) == - RCH_WAIT_FOR_MESSAGE_FROM_PROTOCOL_LAYER); - - pd_port[port].mock_got_soft_reset = 0; - pd_port[port].mock_pe_error = -1; - pd_port[port].mock_pe_message_received = 0; - - TEST_ASSERT(simulate_receive_ctrl_msg(port, PD_CTRL_SOFT_RESET)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - - cycle_through_state_machine(port, 10, MSEC); - - TEST_ASSERT(pd_port[port].mock_got_soft_reset); - TEST_ASSERT(pd_port[port].mock_pe_error < 0); - TEST_ASSERT(pd_port[port].mock_pe_message_received); - TEST_ASSERT(expected_header == emsg[port].header); - TEST_ASSERT(emsg[port].len == 0); - - enable_prl(port, 0); - - return EC_SUCCESS; -} - -static int test_receive_control_msg(void) -{ - int port = PORT0; - int expected_header = PD_HEADER(PD_CTRL_DR_SWAP, - pd_port[port].power_role, - pd_port[port].data_role, - pd_port[port].msg_rx_id, - 0, pd_port[port].rev, 0); - - enable_prl(port, 1); - - /* - * TEST: Receiving a control message - */ - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - TEST_ASSERT(rch_get_state(port) == - RCH_WAIT_FOR_MESSAGE_FROM_PROTOCOL_LAYER); - - pd_port[port].mock_got_soft_reset = 0; - pd_port[port].mock_pe_error = -1; - pd_port[port].mock_pe_message_received = 0; - - TEST_ASSERT(simulate_receive_ctrl_msg(port, PD_CTRL_DR_SWAP)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - - cycle_through_state_machine(port, 3, 10 * MSEC); - - TEST_ASSERT(!pd_port[port].mock_got_soft_reset); - TEST_ASSERT(pd_port[port].mock_pe_error < 0); - TEST_ASSERT(pd_port[port].mock_pe_message_received); - TEST_ASSERT(expected_header == emsg[port].header); - TEST_ASSERT(emsg[port].len == 0); - - enable_prl(port, 0); - - return EC_SUCCESS; -} - -static int test_receive_data_msg(void) -{ - int port = PORT0; - int i; - - enable_prl(port, 1); - - /* - * TEST: Receiving data message with 1 to 28 bytes - */ - - for (i = 1; i <= 28; i++) { - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - TEST_ASSERT(rch_get_state(port) == - RCH_WAIT_FOR_MESSAGE_FROM_PROTOCOL_LAYER); - TEST_ASSERT(simulate_receive_data(port, - PD_DATA_BATTERY_STATUS, i)); - } - - enable_prl(port, 0); - - return EC_SUCCESS; -} - -static int test_receive_extended_data_msg(void) -{ - int len; - int port = PORT0; - - enable_prl(port, 1); - - /* - * TEST: Receiving extended data message with 29 to 260 bytes - */ - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - TEST_ASSERT(rch_get_state(port) == - RCH_WAIT_FOR_MESSAGE_FROM_PROTOCOL_LAYER); - - for (len = 29; len <= 260; len++) - TEST_ASSERT(simulate_receive_extended_data(port, - PD_DATA_BATTERY_STATUS, len)); - - enable_prl(port, 0); - - return EC_SUCCESS; -} - -static int test_send_soft_reset_msg(void) -{ - int port = PORT0; - - enable_prl(port, 1); - - /* - * TEST: Send soft reset - */ - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - TEST_ASSERT(prl_tx_get_state(port) == - PRL_TX_WAIT_FOR_MESSAGE_REQUEST); - - TEST_ASSERT(simulate_send_ctrl_msg_request_from_pe(port, - TCPC_TX_SOP, PD_CTRL_SOFT_RESET)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - - simulate_goodcrc(port, pd_port[port].power_role, - pd_port[port].msg_tx_id); - inc_tx_id(port); - - TEST_ASSERT(prl_tx_get_state(port) == - PRL_TX_LAYER_RESET_FOR_TRANSMIT); - - cycle_through_state_machine(port, 3, 10 * MSEC); - - TEST_ASSERT(!pd_port[port].mock_got_soft_reset); - TEST_ASSERT(pd_port[port].mock_pe_message_sent); - TEST_ASSERT(pd_port[port].mock_pe_error < 0); - - enable_prl(port, 0); - - return EC_SUCCESS; -} - -static int test_pe_execute_hard_reset_msg(void) -{ - int port = PORT0; - - enable_prl(port, 1); - - pd_port[port].mock_pe_hard_reset_sent = 0; - - /* - * TEST: Policy Engine initiated hard reset - */ - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - TEST_ASSERT(prl_hr_get_state(port) == PRL_HR_WAIT_FOR_REQUEST); - - /* Simulate receiving hard reset from policy engine */ - prl_execute_hard_reset(port); - - TEST_ASSERT(prl_hr_get_state(port) == PRL_HR_RESET_LAYER); - TEST_ASSERT(prl_tx_get_state(port) == - PRL_TX_WAIT_FOR_MESSAGE_REQUEST); - - cycle_through_state_machine(port, 1, 10 * MSEC); - - TEST_ASSERT(prl_hr_get_state(port) == - PRL_HR_WAIT_FOR_PHY_HARD_RESET_COMPLETE); - - cycle_through_state_machine(port, 2, PD_T_PS_HARD_RESET); - TEST_ASSERT(pd_port[port].mock_pe_hard_reset_sent); - - TEST_ASSERT(prl_hr_get_state(port) == - PRL_HR_WAIT_FOR_PE_HARD_RESET_COMPLETE); - - /* Simulate policy engine indicating that it is done hard reset */ - prl_hard_reset_complete(port); - - cycle_through_state_machine(port, 1, 10 * MSEC); - - TEST_ASSERT(prl_hr_get_state(port) == PRL_HR_WAIT_FOR_REQUEST); - - enable_prl(port, 0); - - return EC_SUCCESS; -} - -static int test_phy_execute_hard_reset_msg(void) -{ - int port = PORT0; - - enable_prl(port, 1); - - /* - * TEST: Port partner initiated hard reset - */ - - pd_port[port].mock_pe_got_hard_reset = 0; - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - TEST_ASSERT(prl_hr_get_state(port) == PRL_HR_WAIT_FOR_REQUEST); - - /* Simulate receiving hard reset from port partner */ - pd_execute_hard_reset(port); - - TEST_ASSERT(prl_hr_get_state(port) == PRL_HR_RESET_LAYER); - TEST_ASSERT(prl_tx_get_state(port) == - PRL_TX_WAIT_FOR_MESSAGE_REQUEST); - - cycle_through_state_machine(port, 1, 10 * MSEC); - - TEST_ASSERT(prl_hr_get_state(port) == - PRL_HR_WAIT_FOR_PE_HARD_RESET_COMPLETE); - - cycle_through_state_machine(port, 2, PD_T_PS_HARD_RESET); - TEST_ASSERT(pd_port[port].mock_pe_got_hard_reset); - - TEST_ASSERT(prl_hr_get_state(port) == - PRL_HR_WAIT_FOR_PE_HARD_RESET_COMPLETE); - - /* Simulate policy engine indicating that it is done hard reset */ - prl_hard_reset_complete(port); - - cycle_through_state_machine(port, 1, 10 * MSEC); - - TEST_ASSERT(prl_hr_get_state(port) == PRL_HR_WAIT_FOR_REQUEST); - - enable_prl(port, 0); - - return EC_SUCCESS; -} - -int pd_task(void *u) -{ - int port = PORT0; - int evt; - - while (1) { - evt = task_wait_event(-1); - - tcpc_run(port, evt); - prl_run(port, evt, pd_port[port].pd_enable); - } - - return EC_SUCCESS; -} - -/* Reset the state machine between each test */ -void before_test(void) -{ - pd_port[PORT0].mock_pe_message_sent = 0; - pd_port[PORT0].mock_pe_error = -1; - pd_port[PORT0].mock_pe_hard_reset_sent = 0; - pd_port[PORT0].mock_pe_got_hard_reset = 0; - pd_port[PORT0].mock_pe_message_received = 0; - pd_port[PORT0].mock_got_soft_reset = 0; - pd_port[PORT0].pd_enable = false; - cycle_through_state_machine(PORT0, 10, MSEC); - pd_port[PORT0].pd_enable = true; - cycle_through_state_machine(PORT0, 10, MSEC); -} - -void run_test(void) -{ - test_reset(); - - /* Test PD 2.0 Protocol */ - init_port(PORT0, PD_REV20); - RUN_TEST(test_prl_reset); - RUN_TEST(test_send_ctrl_msg); - RUN_TEST(test_send_ctrl_msg_with_retry_and_fail); - RUN_TEST(test_send_ctrl_msg_with_retry_and_success); - RUN_TEST(test_send_data_msg); - RUN_TEST(test_send_data_msg_to_much_data); - RUN_TEST(test_receive_control_msg); - RUN_TEST(test_receive_data_msg); - RUN_TEST(test_receive_soft_reset_msg); - RUN_TEST(test_send_soft_reset_msg); - RUN_TEST(test_pe_execute_hard_reset_msg); - RUN_TEST(test_phy_execute_hard_reset_msg); - - /* TODO(shurst): More PD 2.0 Tests */ - - /* Test PD 3.0 Protocol */ - init_port(PORT0, PD_REV30); - RUN_TEST(test_prl_reset); - RUN_TEST(test_send_ctrl_msg); - RUN_TEST(test_send_ctrl_msg_with_retry_and_fail); - RUN_TEST(test_send_ctrl_msg_with_retry_and_success); - RUN_TEST(test_send_data_msg); - RUN_TEST(test_send_data_msg_to_much_data); - RUN_TEST(test_send_extended_data_msg); - RUN_TEST(test_receive_control_msg); - RUN_TEST(test_receive_data_msg); - RUN_TEST(test_receive_extended_data_msg); - RUN_TEST(test_receive_soft_reset_msg); - RUN_TEST(test_send_soft_reset_msg); - RUN_TEST(test_pe_execute_hard_reset_msg); - RUN_TEST(test_phy_execute_hard_reset_msg); - - /* TODO(shurst): More PD 3.0 Tests */ - - /* Do basic state machine sanity checks last. */ - RUN_TEST(test_prl_no_parent_cycles); - RUN_TEST(test_prl_no_empty_state); - RUN_TEST(test_prl_all_states_named); - - test_print_result(); -} - diff --git a/test/usb_prl.tasklist b/test/usb_prl.tasklist deleted file mode 100644 index 9c583f7906..0000000000 --- a/test/usb_prl.tasklist +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TEST_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST \ - TASK_TEST(PD_C0, pd_task, NULL, LARGER_TASK_STACK_SIZE) \ - TASK_TEST(PD_C1, pd_task, NULL, LARGER_TASK_STACK_SIZE) diff --git a/test/usb_sm_checks.c b/test/usb_sm_checks.c deleted file mode 100644 index 498d56e323..0000000000 --- a/test/usb_sm_checks.c +++ /dev/null @@ -1,254 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test USB Type-C VPD and CTVPD module. - */ -#include "common.h" -#include "task.h" -#include "test_util.h" -#include "timer.h" -#include "usb_pd.h" -#include "usb_sm.h" -#include "usb_tc_sm.h" -#include "util.h" -#include "usb_pd_test_util.h" -#include "vpd_api.h" - -#ifdef CONFIG_USB_TYPEC_SM -extern const struct test_sm_data test_tc_sm_data[]; -extern const int test_tc_sm_data_size; -#else -const struct test_sm_data test_tc_sm_data[] = {}; -const int test_tc_sm_data_size; -#endif - -#ifdef CONFIG_USB_PRL_SM -extern const struct test_sm_data test_prl_sm_data[]; -extern const int test_prl_sm_data_size; -#else -const struct test_sm_data test_prl_sm_data[] = {}; -const int test_prl_sm_data_size; -#endif - -#ifdef CONFIG_USB_PE_SM -extern const struct test_sm_data test_pe_sm_data[]; -extern const int test_pe_sm_data_size; -#else -const struct test_sm_data test_pe_sm_data[] = {}; -const int test_pe_sm_data_size; -#endif - -test_static int test_no_parent_cycles(const struct test_sm_data * const sm_data) -{ - int i; - - for (i = 0; i < sm_data->size; ++i) { - int depth = 0; - usb_state_ptr current = &sm_data->base[i]; - - while (current != NULL && ++depth <= sm_data->size) - current = current->parent; - - if (depth > sm_data->size) - break; - } - - /* Ensure all states end, otherwise the ith state has a cycle. */ - TEST_EQ(i, sm_data->size, "%d"); - - return EC_SUCCESS; -} - -int test_tc_no_parent_cycles(void) -{ - int i; - - for (i = 0; i < test_tc_sm_data_size; ++i) { - const int rv = test_no_parent_cycles(&test_tc_sm_data[i]); - - if (rv) { - ccprintf("TC State machine %d has a cycle!\n", i); - TEST_ASSERT(0); - } - } - - return EC_SUCCESS; -} - -int test_prl_no_parent_cycles(void) -{ - int i; - - for (i = 0; i < test_prl_sm_data_size; ++i) { - const int rv = test_no_parent_cycles(&test_prl_sm_data[i]); - - if (rv) { - ccprintf("PRL State machine %d has a cycle!\n", i); - TEST_ASSERT(0); - } - } - - return EC_SUCCESS; -} - -int test_pe_no_parent_cycles(void) -{ - int i; - - for (i = 0; i < test_pe_sm_data_size; ++i) { - const int rv = test_no_parent_cycles(&test_pe_sm_data[i]); - - if (rv) { - ccprintf("PE State machine %d has a cycle!\n", i); - TEST_ASSERT(0); - } - } - - return EC_SUCCESS; -} - -static int test_no_empty_state(const struct test_sm_data * const sm_data) -{ - int i; - const struct usb_state empty = { 0 }; - - for (i = 0; i < sm_data->size; ++i) { - if (memcmp(&sm_data->base[i], &empty, sizeof(empty)) == 0) - break; - } - - /* Ensure all states had data, otherwise the ith state is empty. */ - TEST_EQ(i, sm_data->size, "%d"); - - return EC_SUCCESS; -} - -int test_tc_no_empty_state(void) -{ - int i; - - for (i = 0; i < test_tc_sm_data_size; ++i) { - const int rv = test_no_empty_state(&test_tc_sm_data[i]); - - if (rv) { - ccprintf("TC State machine %d has empty state!\n", i); - TEST_ASSERT(0); - } - } - - return EC_SUCCESS; -} - -int test_prl_no_empty_state(void) -{ - int i; - - for (i = 0; i < test_prl_sm_data_size; ++i) { - const int rv = test_no_empty_state(&test_prl_sm_data[i]); - - if (rv) { - ccprintf("PRL State machine %d has empty state!\n", i); - TEST_ASSERT(0); - } - } - - return EC_SUCCESS; -} - -int test_pe_no_empty_state(void) -{ - int i; - - for (i = 0; i < test_pe_sm_data_size; ++i) { - const int rv = test_no_empty_state(&test_pe_sm_data[i]); - - if (rv) { - ccprintf("PE State machine %d has empty state!\n", i); - TEST_ASSERT(0); - } - } - - return EC_SUCCESS; -} - -static volatile int state_printed; - -/* Override the implement version of print */ -__override void print_current_state(const int port) -{ - state_printed = 1; -} - -static int test_all_states_named(const struct test_sm_data * const sm_data) -{ - int i; - - for (i = 0; i < sm_data->size; ++i) { - usb_state_ptr current = &sm_data->base[i]; - - state_printed = 0; - - if (current->entry) - current->entry(0); - - if (state_printed) { - if (i >= sm_data->names_size || - sm_data->names[i] == NULL) { - ccprintf("State %d does not have a name!\n", i); - TEST_ASSERT(0); - } - } - } - - return EC_SUCCESS; -} - -int test_tc_all_states_named(void) -{ - int i; - - for (i = 0; i < test_tc_sm_data_size; ++i) { - const int rv = test_all_states_named(&test_tc_sm_data[i]); - - if (rv) { - ccprintf("TC State machine %d has empty name!\n", i); - TEST_ASSERT(0); - } - } - - return EC_SUCCESS; -} - -int test_prl_all_states_named(void) -{ - int i; - - for (i = 0; i < test_prl_sm_data_size; ++i) { - const int rv = test_all_states_named(&test_prl_sm_data[i]); - - if (rv) { - ccprintf("PRL State machine %d has empty name!\n", i); - TEST_ASSERT(0); - } - } - - return EC_SUCCESS; -} - -int test_pe_all_states_named(void) -{ - int i; - - for (i = 0; i < test_pe_sm_data_size; ++i) { - const int rv = test_all_states_named(&test_pe_sm_data[i]); - - if (rv) { - ccprintf("PE State machine %d has empty name!\n", i); - TEST_ASSERT(0); - } - } - - return EC_SUCCESS; -} - diff --git a/test/usb_sm_checks.h b/test/usb_sm_checks.h deleted file mode 100644 index 0a556518a4..0000000000 --- a/test/usb_sm_checks.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Sanity tests for a state machine definition */ - -#ifndef __CROS_EC_USB_SM_CHECKS_H -#define __CROS_EC_USB_SM_CHECKS_H - -int test_tc_no_parent_cycles(void); -int test_tc_no_empty_state(void); -int test_tc_all_states_named(void); - - -int test_prl_no_parent_cycles(void); -int test_prl_no_empty_state(void); -int test_prl_all_states_named(void); - - -int test_pe_no_parent_cycles(void); -int test_pe_no_empty_state(void); -int test_pe_all_states_named(void); - -#endif /* __CROS_EC_USB_SM_CHECKS_H */
\ No newline at end of file diff --git a/test/usb_sm_framework_h0.tasklist b/test/usb_sm_framework_h0.tasklist deleted file mode 120000 index b55922b1ee..0000000000 --- a/test/usb_sm_framework_h0.tasklist +++ /dev/null @@ -1 +0,0 @@ -usb_sm_framework_h3.tasklist
\ No newline at end of file diff --git a/test/usb_sm_framework_h1.tasklist b/test/usb_sm_framework_h1.tasklist deleted file mode 120000 index b55922b1ee..0000000000 --- a/test/usb_sm_framework_h1.tasklist +++ /dev/null @@ -1 +0,0 @@ -usb_sm_framework_h3.tasklist
\ No newline at end of file diff --git a/test/usb_sm_framework_h2.tasklist b/test/usb_sm_framework_h2.tasklist deleted file mode 120000 index b55922b1ee..0000000000 --- a/test/usb_sm_framework_h2.tasklist +++ /dev/null @@ -1 +0,0 @@ -usb_sm_framework_h3.tasklist
\ No newline at end of file diff --git a/test/usb_sm_framework_h3.c b/test/usb_sm_framework_h3.c deleted file mode 100644 index a87002bedf..0000000000 --- a/test/usb_sm_framework_h3.c +++ /dev/null @@ -1,1002 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test USB Type-C VPD and CTVPD module. - */ -#include "common.h" -#include "task.h" -#include "test_util.h" -#include "timer.h" -#include "usb_pd.h" -#include "usb_sm.h" -#include "usb_tc_sm.h" -#include "util.h" -#include "usb_pd_test_util.h" -#include "vpd_api.h" - -/* - * Test State Hierarchy - * SM_TEST_A4 transitions to SM_TEST_B4 - * SM_TEST_B4 transitions to SM_TEST_B5 - * SM_TEST_B5 transitions to SM_TEST_B6 - * SM_TEST_B6 transitions to SM_TEST_C - * SM_TEST_C transitions to SM_TEST_A7 - * SM_TEST_A7 transitions to SM_TEST_A6 - * SM_TEST_A6 transitions to SM_TEST_A5 - * SM_TEST_A5 transitions to SM_TEST_A4 - * - * --------------------------- --------------------------- - * | SM_TEST_SUPER_A1 | | SM_TEST_SUPER_B1 | - * | ----------------------- | | ----------------------- | - * | | SM_TEST_SUPER_A2 | | | | SM_TEST_SUPER_B2 | | - * | | ------------------- | | | | ------------------- | | - * | | |SM_TEST_SUPER_A3 | | | | | |SM_TEST_SUPER_B3 | | | - * | | | | | | | | | | | | - * | | | ------------- | | | | | | ------------- | | | - * | | | | SM_TEST_A4|------------------>| SM_TEST_B4| | | | - * | | | ------------- | | | | | | ------------- | | | - * | | | ^ | | | | | |--------|--------| | | - * | | | | | | | | | | | | - * | | | -------------- | | | | | \/ | | - * | | | | SM_TEST_A5 | | | | | | -------------- | | - * | | | -------------- | | | | | | SM_TEST_B5 | | | - * | | |--------^--------| | | | | -------------- | | - * | | | | | | | | | | - * | | -------------- | | | -----------|----------- | - * | | | SM_TEST_A6 | | | | \/ | - * | | -------------- | | | -------------- | - * | |----------^----------| | | | SM_TEST_B6 | | - * | | | | -------------- | - * | -------------- | |--------/----------------| - * | | SM_TEST_A7 | | / - * | -------------- | / - * |------------------^------| / - * \ / - * \ \/ - * ------------- - * | SM_TEST_C | - * ------------- - * - * test_hierarchy_0: Tests a flat state machine without super states - * test_hierarchy_1: Tests a hierarchical state machine with 1 super state - * test_hierarchy_2: Tests a hierarchical state machine with 2 super states - * test_hierarchy_3: Tests a hierarchical state machine with 3 super states - * - */ - -#define SEQUENCE_SIZE 55 - -enum state_id { - ENTER_A1 = 1, - RUN_A1, - EXIT_A1, - ENTER_A2, - RUN_A2, - EXIT_A2, - ENTER_A3, - RUN_A3, - EXIT_A3, - ENTER_A4, - RUN_A4, - EXIT_A4, - ENTER_A5, - RUN_A5, - EXIT_A5, - ENTER_A6, - RUN_A6, - EXIT_A6, - ENTER_A7, - RUN_A7, - EXIT_A7, - ENTER_B1, - RUN_B1, - EXIT_B1, - ENTER_B2, - RUN_B2, - EXIT_B2, - ENTER_B3, - RUN_B3, - EXIT_B3, - ENTER_B4, - RUN_B4, - EXIT_B4, - ENTER_B5, - RUN_B5, - EXIT_B5, - ENTER_B6, - RUN_B6, - EXIT_B6, - ENTER_C, - RUN_C, - EXIT_C, -}; - -#define PORT0 0 - -struct sm_ { - /* struct sm_obj must be first */ - struct sm_ctx ctx; - int sv_tmp; - int idx; - int seq[SEQUENCE_SIZE]; -} sm[1]; - -enum state { - SM_TEST_SUPER_A1, - SM_TEST_SUPER_A2, - SM_TEST_SUPER_A3, - SM_TEST_SUPER_B1, - SM_TEST_SUPER_B2, - SM_TEST_SUPER_B3, - SM_TEST_A4, - SM_TEST_A5, - SM_TEST_A6, - SM_TEST_A7, - SM_TEST_B4, - SM_TEST_B5, - SM_TEST_B6, - SM_TEST_C, -}; -static const struct usb_state states[]; - -static struct control { - usb_state_ptr a3_entry_to; - usb_state_ptr b3_run_to; - usb_state_ptr b6_entry_to; - usb_state_ptr c_entry_to; - usb_state_ptr c_exit_to; -} test_control; - -static void set_state_sm(const int port, const enum state new_state) -{ - set_state(port, &sm[port].ctx, &states[new_state]); -} - -static void sm_test_super_A1_entry(const int port) -{ - sm[port].seq[sm[port].idx++] = ENTER_A1; -} - -static void sm_test_super_A1_run(const int port) -{ - sm[port].seq[sm[port].idx++] = RUN_A1; -} - -static void sm_test_super_A1_exit(const int port) -{ - sm[port].seq[sm[port].idx++] = EXIT_A1; -} - -static void sm_test_super_B1_entry(const int port) -{ - sm[port].seq[sm[port].idx++] = ENTER_B1; -} - -static void sm_test_super_B1_run(const int port) -{ - sm[port].seq[sm[port].idx++] = RUN_B1; -} - -static void sm_test_super_B1_exit(const int port) -{ - sm[port].seq[sm[port].idx++] = EXIT_B1; -} - -static void sm_test_super_A2_entry(const int port) -{ - sm[port].seq[sm[port].idx++] = ENTER_A2; -} - -static void sm_test_super_A2_run(const int port) -{ - sm[port].seq[sm[port].idx++] = RUN_A2; -} - -static void sm_test_super_A2_exit(const int port) -{ - sm[port].seq[sm[port].idx++] = EXIT_A2; -} - - -static void sm_test_super_B2_entry(const int port) -{ - sm[port].seq[sm[port].idx++] = ENTER_B2; -} - -static void sm_test_super_B2_run(const int port) -{ - sm[port].seq[sm[port].idx++] = RUN_B2; -} - -static void sm_test_super_B2_exit(const int port) -{ - sm[port].seq[sm[port].idx++] = EXIT_B2; -} - -static void sm_test_super_A3_entry(const int port) -{ - sm[port].seq[sm[port].idx++] = ENTER_A3; - if (test_control.a3_entry_to) - set_state(port, &sm[port].ctx, test_control.a3_entry_to); -} - -static void sm_test_super_A3_run(const int port) -{ - sm[port].seq[sm[port].idx++] = RUN_A3; -} - -static void sm_test_super_A3_exit(const int port) -{ - sm[port].seq[sm[port].idx++] = EXIT_A3; -} - -static void sm_test_super_B3_entry(const int port) -{ - sm[port].seq[sm[port].idx++] = ENTER_B3; -} - -static void sm_test_super_B3_run(const int port) -{ - sm[port].seq[sm[port].idx++] = RUN_B3; - if (test_control.b3_run_to) - set_state(port, &sm[port].ctx, test_control.b3_run_to); -} - -static void sm_test_super_B3_exit(const int port) -{ - sm[port].seq[sm[port].idx++] = EXIT_B3; -} - -static void sm_test_A4_entry(const int port) -{ - sm[port].sv_tmp = 0; - sm[port].seq[sm[port].idx++] = ENTER_A4; -} - -static void sm_test_A4_run(const int port) -{ - if (sm[port].sv_tmp == 0) { - sm[port].sv_tmp = 1; - sm[port].seq[sm[port].idx++] = RUN_A4; - } else { - set_state_sm(port, SM_TEST_B4); - } -} - -static void sm_test_A4_exit(const int port) -{ - sm[port].seq[sm[port].idx++] = EXIT_A4; -} - - -static void sm_test_A5_entry(const int port) -{ - sm[port].sv_tmp = 0; - sm[port].seq[sm[port].idx++] = ENTER_A5; -} - -static void sm_test_A5_run(const int port) -{ - if (sm[port].sv_tmp == 0) { - sm[port].sv_tmp = 1; - sm[port].seq[sm[port].idx++] = RUN_A5; - } else { - set_state_sm(port, SM_TEST_A4); - } -} - -static void sm_test_A5_exit(const int port) -{ - sm[port].seq[sm[port].idx++] = EXIT_A5; -} - - -static void sm_test_A6_entry(const int port) -{ - sm[port].sv_tmp = 0; - sm[port].seq[sm[port].idx++] = ENTER_A6; -} - -static void sm_test_A6_run(const int port) -{ - if (sm[port].sv_tmp == 0) { - sm[port].sv_tmp = 1; - sm[port].seq[sm[port].idx++] = RUN_A6; - } else { - set_state_sm(port, SM_TEST_A5); - } -} - -static void sm_test_A6_exit(const int port) -{ - sm[port].seq[sm[port].idx++] = EXIT_A6; -} - -static void sm_test_A7_entry(const int port) -{ - sm[port].sv_tmp = 0; - sm[port].seq[sm[port].idx++] = ENTER_A7; -} - -static void sm_test_A7_run(const int port) -{ - if (sm[port].sv_tmp == 0) { - sm[port].sv_tmp = 1; - sm[port].seq[sm[port].idx++] = RUN_A7; - } else { - set_state_sm(port, SM_TEST_A6); - } -} - -static void sm_test_A7_exit(const int port) -{ - sm[port].seq[sm[port].idx++] = EXIT_A7; -} - -static void sm_test_B4_entry(const int port) -{ - sm[port].sv_tmp = 0; - sm[port].seq[sm[port].idx++] = ENTER_B4; -} - -static void sm_test_B4_run(const int port) -{ - if (sm[port].sv_tmp == 0) { - sm[port].seq[sm[port].idx++] = RUN_B4; - sm[port].sv_tmp = 1; - } else { - set_state_sm(port, SM_TEST_B5); - } -} - -static void sm_test_B4_exit(const int port) -{ - sm[port].seq[sm[port].idx++] = EXIT_B4; -} - - -static void sm_test_B5_entry(const int port) -{ - sm[port].sv_tmp = 0; - sm[port].seq[sm[port].idx++] = ENTER_B5; -} - -static void sm_test_B5_run(const int port) -{ - if (sm[port].sv_tmp == 0) { - sm[port].sv_tmp = 1; - sm[port].seq[sm[port].idx++] = RUN_B5; - } else { - set_state_sm(port, SM_TEST_B6); - } -} - -static void sm_test_B5_exit(const int port) -{ - sm[port].seq[sm[port].idx++] = EXIT_B5; -} - - -static void sm_test_B6_entry(const int port) -{ - sm[port].sv_tmp = 0; - sm[port].seq[sm[port].idx++] = ENTER_B6; - if (test_control.b6_entry_to) - set_state(port, &sm[port].ctx, test_control.b6_entry_to); -} - -static void sm_test_B6_run(const int port) -{ - if (sm[port].sv_tmp == 0) { - sm[port].sv_tmp = 1; - sm[port].seq[sm[port].idx++] = RUN_B6; - } else { - set_state_sm(port, SM_TEST_C); - } -} - -static void sm_test_B6_exit(const int port) -{ - sm[port].seq[sm[port].idx++] = EXIT_B6; -} - -static void sm_test_C_entry(const int port) -{ - sm[port].sv_tmp = 0; - sm[port].seq[sm[port].idx++] = ENTER_C; - if (test_control.c_entry_to) - set_state(port, &sm[port].ctx, test_control.c_entry_to); -} - -static void sm_test_C_run(const int port) -{ - if (sm[port].sv_tmp == 0) { - sm[port].seq[sm[port].idx++] = RUN_C; - sm[port].sv_tmp = 1; - } else { - set_state_sm(port, SM_TEST_A7); - } -} - -static void sm_test_C_exit(const int port) -{ - sm[port].seq[sm[port].idx++] = EXIT_C; - if (test_control.c_exit_to) - set_state(port, &sm[port].ctx, test_control.c_exit_to); -} - -static void run_sm(void) -{ - task_wake(TASK_ID_TEST); - task_wait_event(5 * MSEC); -} - -test_static int test_hierarchy_0(void) -{ - int port = PORT0; - int i = 0; - - set_state_sm(port, SM_TEST_A4); - - run_sm(); - TEST_EQ(sm[port].seq[i], ENTER_A4, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_A4, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_A4, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B4, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_B4, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_B4, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B5, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_B5, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_B5, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B6, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_B6, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_B6, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_C, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_C, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_C, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A7, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_A7, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_A7, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A6, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_A6, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_A6, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A5, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_A5, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_A5, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A4, "%d"); ++i; - - for (; i < SEQUENCE_SIZE; i++) - TEST_EQ(sm[port].seq[i], 0, "%d"); - - return EC_SUCCESS; -} - -test_static int test_hierarchy_1(void) -{ - int port = PORT0; - int i = 0; - - set_state_sm(port, SM_TEST_A4); - - run_sm(); - TEST_EQ(sm[port].seq[i], ENTER_A3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A4, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_A4, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_A3, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_A4, "%d"); ++i; - TEST_EQ(sm[port].seq[i], EXIT_A3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B4, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_B4, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_B3, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_B4, "%d"); ++i; - TEST_EQ(sm[port].seq[i], EXIT_B3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B5, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_B5, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_B5, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B6, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_B6, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_B6, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_C, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_C, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_C, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A7, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_A7, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_A7, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A6, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_A6, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_A6, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A5, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_A5, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_A3, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_A5, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A4, "%d"); ++i; - - for (i = 33; i < SEQUENCE_SIZE; i++) - TEST_EQ(sm[port].seq[i], 0, "%d"); - - return EC_SUCCESS; -} - -test_static int test_hierarchy_2(void) -{ - - int port = PORT0; - int i = 0; - - set_state_sm(port, SM_TEST_A4); - - run_sm(); - TEST_EQ(sm[port].seq[i], ENTER_A2, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A4, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_A4, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_A3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_A2, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_A4, "%d"); ++i; - TEST_EQ(sm[port].seq[i], EXIT_A3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], EXIT_A2, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B2, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B4, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_B4, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_B3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_B2, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_B4, "%d"); ++i; - TEST_EQ(sm[port].seq[i], EXIT_B3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B5, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_B5, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_B2, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_B5, "%d"); ++i; - TEST_EQ(sm[port].seq[i], EXIT_B2, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B6, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_B6, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_B6, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_C, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_C, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_C, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A7, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_A7, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_A7, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A2, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A6, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_A6, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_A2, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_A6, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A5, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_A5, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_A3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_A2, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_A5, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A4, "%d"); ++i; - - for (; i < SEQUENCE_SIZE; i++) - TEST_EQ(sm[port].seq[i], 0, "%d"); - - return EC_SUCCESS; -} - -test_static int test_hierarchy_3(void) -{ - - int port = PORT0; - int i = 0; - - set_state_sm(port, SM_TEST_A4); - - run_sm(); - TEST_EQ(sm[port].seq[i], ENTER_A1, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A2, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A4, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_A4, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_A3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_A2, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_A1, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_A4, "%d"); ++i; - TEST_EQ(sm[port].seq[i], EXIT_A3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], EXIT_A2, "%d"); ++i; - TEST_EQ(sm[port].seq[i], EXIT_A1, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B1, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B2, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B4, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_B4, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_B3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_B2, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_B1, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_B4, "%d"); ++i; - TEST_EQ(sm[port].seq[i], EXIT_B3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B5, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_B5, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_B2, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_B1, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_B5, "%d"); ++i; - TEST_EQ(sm[port].seq[i], EXIT_B2, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B6, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_B6, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_B1, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_B6, "%d"); ++i; - TEST_EQ(sm[port].seq[i], EXIT_B1, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_C, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_C, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_C, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A1, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A7, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_A7, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_A1, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_A7, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A2, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A6, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_A6, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_A2, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_A1, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_A6, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A5, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_A5, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_A3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_A2, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_A1, "%d"); ++i; - - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_A5, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A4, "%d"); ++i; - - for (; i < SEQUENCE_SIZE; i++) - TEST_EQ(sm[port].seq[i], 0, "%d"); - - return EC_SUCCESS; -} - -test_static int test_set_state_from_parents(void) -{ - int port = PORT0; - int i = 0; - - /* Start state machine */ - test_control.a3_entry_to = &states[SM_TEST_B4]; - run_sm(); - set_state_sm(port, SM_TEST_A4); - TEST_EQ(sm[port].seq[i], ENTER_A1, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A2, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A3, "%d"); ++i; - /* Does not enter or exit A4 */ - TEST_EQ(sm[port].seq[i], EXIT_A3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], EXIT_A2, "%d"); ++i; - TEST_EQ(sm[port].seq[i], EXIT_A1, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B1, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B2, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B4, "%d"); ++i; - /* Ensure we didn't go further than above statements */ - TEST_EQ(sm[port].seq[i], 0, "%d"); - - test_control.b3_run_to = &states[SM_TEST_B5]; - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_B4, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_B3, "%d"); ++i; - /* Does not run b2 or b1 */ - TEST_EQ(sm[port].seq[i], EXIT_B4, "%d"); ++i; - TEST_EQ(sm[port].seq[i], EXIT_B3, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B5, "%d"); ++i; - /* Ensure we didn't go further than above statements */ - TEST_EQ(sm[port].seq[i], 0, "%d"); - - run_sm(); - TEST_EQ(sm[port].seq[i], RUN_B5, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_B2, "%d"); ++i; - TEST_EQ(sm[port].seq[i], RUN_B1, "%d"); ++i; - /* Ensure we didn't go further than above statements */ - TEST_EQ(sm[port].seq[i], 0, "%d"); - - /* - * Ensure that multiple chains of parent entry works. Also ensure - * that set states in exit are ignored. - */ - test_control.b6_entry_to = &states[SM_TEST_C]; - test_control.c_entry_to = &states[SM_TEST_A7]; - test_control.c_exit_to = &states[SM_TEST_A4]; - run_sm(); - TEST_EQ(sm[port].seq[i], EXIT_B5, "%d"); ++i; - TEST_EQ(sm[port].seq[i], EXIT_B2, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_B6, "%d"); ++i; - TEST_EQ(sm[port].seq[i], EXIT_B6, "%d"); ++i; - TEST_EQ(sm[port].seq[i], EXIT_B1, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_C, "%d"); ++i; - TEST_EQ(sm[port].seq[i], EXIT_C, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A1, "%d"); ++i; - TEST_EQ(sm[port].seq[i], ENTER_A7, "%d"); ++i; - /* Ensure we didn't go further than above statements */ - TEST_EQ(sm[port].seq[i], 0, "%d"); - - for (; i < SEQUENCE_SIZE; i++) - TEST_EQ(sm[port].seq[i], 0, "%d"); - - return EC_SUCCESS; -} - -#ifdef TEST_USB_SM_FRAMEWORK_H3 -#define TEST_AT_LEAST_3 -#endif - -#if defined(TEST_AT_LEAST_3) || defined(TEST_USB_SM_FRAMEWORK_H2) -#define TEST_AT_LEAST_2 -#endif - -#if defined(TEST_AT_LEAST_2) || defined(TEST_USB_SM_FRAMEWORK_H1) -#define TEST_AT_LEAST_1 -#endif - -static const struct usb_state states[] = { - [SM_TEST_SUPER_A1] = { - .entry = sm_test_super_A1_entry, - .run = sm_test_super_A1_run, - .exit = sm_test_super_A1_exit, - }, - [SM_TEST_SUPER_A2] = { - .entry = sm_test_super_A2_entry, - .run = sm_test_super_A2_run, - .exit = sm_test_super_A2_exit, -#ifdef TEST_AT_LEAST_3 - .parent = &states[SM_TEST_SUPER_A1], -#endif - }, - [SM_TEST_SUPER_A3] = { - .entry = sm_test_super_A3_entry, - .run = sm_test_super_A3_run, - .exit = sm_test_super_A3_exit, -#ifdef TEST_AT_LEAST_2 - .parent = &states[SM_TEST_SUPER_A2], -#endif - }, - [SM_TEST_SUPER_B1] = { - .entry = sm_test_super_B1_entry, - .run = sm_test_super_B1_run, - .exit = sm_test_super_B1_exit, - }, - [SM_TEST_SUPER_B2] = { - .entry = sm_test_super_B2_entry, - .run = sm_test_super_B2_run, - .exit = sm_test_super_B2_exit, -#ifdef TEST_AT_LEAST_3 - .parent = &states[SM_TEST_SUPER_B1], -#endif - }, - [SM_TEST_SUPER_B3] = { - .entry = sm_test_super_B3_entry, - .run = sm_test_super_B3_run, - .exit = sm_test_super_B3_exit, -#ifdef TEST_AT_LEAST_2 - .parent = &states[SM_TEST_SUPER_B2], -#endif - }, - [SM_TEST_A4] = { - .entry = sm_test_A4_entry, - .run = sm_test_A4_run, - .exit = sm_test_A4_exit, -#ifdef TEST_AT_LEAST_1 - .parent = &states[SM_TEST_SUPER_A3], -#endif - }, - [SM_TEST_A5] = { - .entry = sm_test_A5_entry, - .run = sm_test_A5_run, - .exit = sm_test_A5_exit, -#ifdef TEST_AT_LEAST_1 - .parent = &states[SM_TEST_SUPER_A3], -#endif - }, - [SM_TEST_A6] = { - .entry = sm_test_A6_entry, - .run = sm_test_A6_run, - .exit = sm_test_A6_exit, -#ifdef TEST_AT_LEAST_2 - .parent = &states[SM_TEST_SUPER_A2], -#endif - }, - [SM_TEST_A7] = { - .entry = sm_test_A7_entry, - .run = sm_test_A7_run, - .exit = sm_test_A7_exit, -#ifdef TEST_AT_LEAST_3 - .parent = &states[SM_TEST_SUPER_A1], -#endif - }, - [SM_TEST_B4] = { - .entry = sm_test_B4_entry, - .run = sm_test_B4_run, - .exit = sm_test_B4_exit, -#ifdef TEST_AT_LEAST_1 - .parent = &states[SM_TEST_SUPER_B3], -#endif - }, - [SM_TEST_B5] = { - .entry = sm_test_B5_entry, - .run = sm_test_B5_run, - .exit = sm_test_B5_exit, -#ifdef TEST_AT_LEAST_2 - .parent = &states[SM_TEST_SUPER_B2], -#endif - }, - [SM_TEST_B6] = { - .entry = sm_test_B6_entry, - .run = sm_test_B6_run, - .exit = sm_test_B6_exit, -#ifdef TEST_AT_LEAST_3 - .parent = &states[SM_TEST_SUPER_B1], -#endif - }, - [SM_TEST_C] = { - .entry = sm_test_C_entry, - .run = sm_test_C_run, - .exit = sm_test_C_exit, - }, -}; - -/* Run before each RUN_TEST line */ -void before_test(void) -{ - /* Rest test variables */ - memset(&sm[PORT0], 0, sizeof(struct sm_)); - memset(&test_control, 0, sizeof(struct control)); -} - -int test_task(void *u) -{ - int port = PORT0; - - while (1) { - /* wait for next event/packet or timeout expiration */ - task_wait_event(-1); - /* run state machine */ - run_state(port, &sm[port].ctx); - } - - return EC_SUCCESS; -} - -void run_test(void) -{ - test_reset(); -#if defined(TEST_USB_SM_FRAMEWORK_H3) - RUN_TEST(test_hierarchy_3); - RUN_TEST(test_set_state_from_parents); -#elif defined(TEST_USB_SM_FRAMEWORK_H2) - RUN_TEST(test_hierarchy_2); -#elif defined(TEST_USB_SM_FRAMEWORK_H1) - RUN_TEST(test_hierarchy_1); -#else - RUN_TEST(test_hierarchy_0); -#endif - test_print_result(); -} diff --git a/test/usb_sm_framework_h3.tasklist b/test/usb_sm_framework_h3.tasklist deleted file mode 100644 index 998998fd6c..0000000000 --- a/test/usb_sm_framework_h3.tasklist +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TEST_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST \ - TASK_TEST(TEST, test_task, NULL, LARGER_TASK_STACK_SIZE) diff --git a/test/usb_test/Makefile b/test/usb_test/Makefile deleted file mode 100644 index e18e4a7c3b..0000000000 --- a/test/usb_test/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright 2015 The Chromium OS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -PROGRAM := device_configuration -SOURCE := $(PROGRAM).c -LIBS := -LFLAGS := -CFLAGS := -std=gnu99 \ - -g3 \ - -O3 \ - -Wall \ - -Werror \ - -Wpointer-arith \ - -Wcast-align \ - -Wcast-qual \ - -Wundef \ - -Wsign-compare \ - -Wredundant-decls \ - -Wmissing-declarations - -# -# Add libusb-1.0 required flags -# -LIBS += $(shell pkg-config --libs libusb-1.0) -CFLAGS += $(shell pkg-config --cflags libusb-1.0) - -$(PROGRAM): $(SOURCE) Makefile - gcc $(CFLAGS) $(SOURCE) $(LFLAGS) $(LIBS) -o $@ - -.PHONY: clean - -clean: - rm -rf $(PROGRAM) *~ diff --git a/test/usb_test/README b/test/usb_test/README deleted file mode 100644 index 5d7af93f7e..0000000000 --- a/test/usb_test/README +++ /dev/null @@ -1,2 +0,0 @@ -These tests need to be built and run by hand, unless/until we set up a lab -with known devices attached to a test host. diff --git a/test/usb_test/device_configuration.c b/test/usb_test/device_configuration.c deleted file mode 100644 index 69f889c2d3..0000000000 --- a/test/usb_test/device_configuration.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright 2016 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include <errno.h> -#include <getopt.h> -#include <libusb.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -/* Options */ -static uint16_t vid = 0x18d1; /* Google */ -static uint16_t pid = 0x5014; /* Cr50 */ - -static char *progname; - -static void usage(int errs) -{ - printf("\nUsage: %s [vid:pid] [value]\n" - "\n" - "Set/Get the USB Device Configuration value\n" - "\n" - "The default vid:pid is %04x:%04x\n" - "\n", progname, vid, pid); - - exit(!!errs); -} - -/* Globals */ -struct libusb_device_handle *devh = 0; - -static void stupid_usb(const char *format, ...) -{ - va_list ap; - - va_start(ap, format); - vfprintf(stderr, format, ap); - va_end(ap); - - if (devh) - libusb_close(devh); - - libusb_exit(NULL); - - exit(1); -} - - -int main(int argc, char *argv[]) -{ - int r = 1; - int errorcnt = 0; - int do_set = 0; - uint16_t setval = 0; - uint8_t buf[80]; /* Arbitrary size */ - int i; - - progname = strrchr(argv[0], '/'); - if (progname) - progname++; - else - progname = argv[0]; - - opterr = 0; /* quiet, you */ - while ((i = getopt(argc, argv, "")) != -1) { - switch (i) { - case 'h': - usage(errorcnt); - break; - case 0: /* auto-handled option */ - break; - case '?': - if (optopt) - printf("Unrecognized option: -%c\n", optopt); - else - printf("Unrecognized option: %s\n", - argv[optind - 1]); - errorcnt++; - break; - case ':': - printf("Missing argument to %s\n", argv[optind - 1]); - errorcnt++; - break; - default: - printf("Internal error at %s:%d\n", __FILE__, __LINE__); - exit(1); - } - } - - if (errorcnt) - usage(errorcnt); - - if (optind < argc) { - uint16_t v, p; - - if (2 == sscanf(argv[optind], "%hx:%hx", &v, &p)) { - vid = v; - pid = p; - optind++; - } - } - - if (optind < argc) { - do_set = 1; - setval = atoi(argv[optind]); - } - - r = libusb_init(NULL); - if (r) { - printf("libusb_init() returned 0x%x: %s\n", - r, libusb_error_name(r)); - return 1; - } - - devh = libusb_open_device_with_vid_pid(NULL, vid, pid); - if (!devh) { - perror(progname); - stupid_usb("Can't open device %04x:%04x\n", vid, pid); - } - - - /* Set config*/ - if (do_set) { - printf("SetCfg %d\n", setval); - r = libusb_control_transfer( - devh, - 0x00, /* bmRequestType */ - 0x09, /* bRequest */ - setval, /* wValue */ - 0x0000, /* wIndex */ - NULL, /* data */ - 0x0000, /* wLength */ - 1000); /* timeout (ms) */ - - if (r < 0) - printf("transfer returned 0x%x %s\n", - r, libusb_error_name(r)); - } - - /* Get config */ - memset(buf, 0, sizeof(buf)); - - r = libusb_control_transfer( - devh, - 0x80, /* bmRequestType */ - 0x08, /* bRequest */ - 0x0000, /* wValue */ - 0x0000, /* wIndex */ - buf, /* data */ - 0x0001, /* wLength */ - 1000); /* timeout (ms) */ - - if (r <= 0) - stupid_usb("GetCfg transfer() returned 0x%x %s\n", - r, libusb_error_name(r)); - - printf("GetCfg returned %d bytes:", r); - for (i = 0; i < r; i++) - printf(" 0x%02x", buf[i]); - printf("\n"); - - /* done */ - if (devh) - libusb_close(devh); - libusb_exit(NULL); - - return 0; -} diff --git a/test/usb_typec_ctvpd.c b/test/usb_typec_ctvpd.c deleted file mode 100644 index 0253bd75d1..0000000000 --- a/test/usb_typec_ctvpd.c +++ /dev/null @@ -1,1540 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test USB Type-C VPD and CTVPD module. - */ -#include "common.h" -#include "crc.h" -#include "task.h" -#include "test_util.h" -#include "timer.h" -#include "usb_pd.h" -#include "usb_sm.h" -#include "usb_tc_sm.h" -#include "util.h" -#include "usb_pd_tcpm.h" -#include "usb_pd_test_util.h" -#include "usb_sm_checks.h" -#include "vpd_api.h" - -#define PORT0 0 - -enum cc_type {CC1, CC2}; -enum vbus_type {VBUS_0 = 0, VBUS_5 = 5000}; -enum vconn_type {VCONN_0 = 0, VCONN_3 = 3000, VCONN_5 = 5000}; -enum snk_con_voltage_type {SRC_CON_DEF, SRC_CON_1_5, SRC_CON_3_0}; - -/* - * These enum definitions are declared in usb_tc_*_sm and are private to that - * file. If those definitions are re-ordered, then we need to update these - * definitions (should be very rare). - */ -enum usb_tc_state { - /* Normal States */ - TC_DISABLED, - TC_UNATTACHED_SNK, - TC_ATTACH_WAIT_SNK, - TC_ATTACHED_SNK, - TC_ERROR_RECOVERY, - TC_TRY_SNK, - TC_UNATTACHED_SRC, - TC_ATTACH_WAIT_SRC, - TC_TRY_WAIT_SRC, - TC_ATTACHED_SRC, - TC_CT_TRY_SNK, - TC_CT_ATTACH_WAIT_UNSUPPORTED, - TC_CT_ATTACHED_UNSUPPORTED, - TC_CT_UNATTACHED_UNSUPPORTED, - TC_CT_UNATTACHED_VPD, - TC_CT_DISABLED_VPD, - TC_CT_ATTACHED_VPD, - TC_CT_ATTACH_WAIT_VPD, -}; - -/* Defined in implementation */ -enum usb_tc_state get_state_tc(const int port); - -struct pd_port_t { - int host_mode; - int has_vbus; - int msg_tx_id; - int msg_rx_id; - int polarity; - int partner_role; /* -1 for none */ - int partner_polarity; - int rev; -} pd_port[CONFIG_USB_PD_PORT_MAX_COUNT]; - -uint64_t wait_for_state_change(int port, uint64_t timeout) -{ - uint64_t start; - uint64_t wait; - enum usb_tc_state state = get_state_tc(port); - - task_wake(PD_PORT_TO_TASK_ID(port)); - - wait = get_time().val + timeout; - start = get_time().val; - while (get_state_tc(port) == state && get_time().val < wait) { - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(1 * MSEC); - } - - return get_time().val - start; -} - -#if defined(TEST_USB_TYPEC_CTVPD) -static int ct_connect_sink(enum cc_type cc, enum snk_con_voltage_type v) -{ - int ret; - - switch (v) { - case SRC_CON_DEF: - ret = (cc) ? mock_set_cc2_rp3a0_rd_l(PD_SRC_DEF_RD_THRESH_MV) : - mock_set_cc1_rp3a0_rd_l(PD_SRC_DEF_RD_THRESH_MV); - break; - case SRC_CON_1_5: - ret = (cc) ? mock_set_cc2_rp3a0_rd_l(PD_SRC_1_5_RD_THRESH_MV) : - mock_set_cc1_rp3a0_rd_l(PD_SRC_1_5_RD_THRESH_MV); - break; - case SRC_CON_3_0: - ret = (cc) ? mock_set_cc2_rp3a0_rd_l(PD_SRC_3_0_RD_THRESH_MV) : - mock_set_cc1_rp3a0_rd_l(PD_SRC_3_0_RD_THRESH_MV); - break; - default: - ret = 0; - } - - return ret; -} - -static int ct_disconnect_sink(void) -{ - int r1; - int r2; - - r1 = mock_set_cc1_rp3a0_rd_l(PD_SRC_DEF_VNC_MV); - r2 = mock_set_cc2_rp3a0_rd_l(PD_SRC_DEF_VNC_MV); - - return r1 & r2; -} - -static int ct_connect_source(enum cc_type cc, enum vbus_type vbus) -{ - mock_set_ct_vbus(vbus); - return (cc) ? mock_set_cc2_rpusb_odh(PD_SNK_VA_MV) : - mock_set_cc1_rpusb_odh(PD_SNK_VA_MV); -} - -static int ct_disconnect_source(void) -{ - int r1; - int r2; - - mock_set_ct_vbus(VBUS_0); - r1 = mock_set_cc1_rpusb_odh(0); - r2 = mock_set_cc2_rpusb_odh(0); - - return r1 & r2; -} -#endif - -static void host_disconnect_source(void) -{ - mock_set_host_vbus(VBUS_0); - mock_set_host_cc_source_voltage(0); - mock_set_host_cc_sink_voltage(0); -} - -static void host_connect_source(enum vbus_type vbus) -{ - mock_set_host_vbus(vbus); - mock_set_host_cc_source_voltage(PD_SNK_VA_MV); -} - -#if defined(TEST_USB_TYPEC_CTVPD) -static void host_connect_sink(enum snk_con_voltage_type v) -{ - switch (v) { - case SRC_CON_DEF: - mock_set_host_cc_sink_voltage(PD_SRC_DEF_RD_THRESH_MV); - break; - case SRC_CON_1_5: - mock_set_host_cc_sink_voltage(PD_SRC_1_5_RD_THRESH_MV); - break; - case SRC_CON_3_0: - mock_set_host_cc_sink_voltage(PD_SRC_3_0_RD_THRESH_MV); - break; - } -} -#endif - -static void init_port(int port) -{ - pd_port[port].polarity = 0; - pd_port[port].rev = PD_REV30; - pd_port[port].msg_tx_id = 0; - pd_port[port].msg_rx_id = 0; -} - -static int check_host_ra_rd(void) -{ - /* Make sure CC_RP3A0_RD_L is configured as GPO */ - if (mock_get_cfg_cc_rp3a0_rd_l() != PIN_GPO) - return 0; - - /* Make sure CC_RP3A0_RD_L is asserted low */ - if (mock_get_cc_rp3a0_rd_l() != 0) - return 0; - - /* Make sure VPDMCU_CC_EN is enabled */ - if (mock_get_mcu_cc_en() != 1) - return 0; - - /* Make sure CC_VPDMCU is configured as ADC */ - if (mock_get_cfg_cc_vpdmcu() != PIN_ADC) - return 0; - - /* Make sure CC_DB_EN_OD is HZ */ - if (mock_get_cc_db_en_od() != GPO_HZ) - return 0; - - return 1; -} - -static int check_host_rd(void) -{ - /* Make sure CC_RP3A0_RD_L is configured as GPO */ - if (mock_get_cfg_cc_rp3a0_rd_l() != PIN_GPO) - return 0; - - /* Make sure CC_RP3A0_RD_L is asserted low */ - if (mock_get_cc_rp3a0_rd_l() != 0) - return 0; - - /* Make sure VPDMCU_CC_EN is enabled */ - if (mock_get_mcu_cc_en() != 1) - return 0; - - /* Make sure CC_VPDMCU is configured as ADC */ - if (mock_get_cfg_cc_vpdmcu() != PIN_ADC) - return 0; - - /* Make sure CC_DB_EN_OD is LOW */ - if (mock_get_cc_db_en_od() != GPO_LOW) - return 0; - - return 1; -} - -#if defined(TEST_USB_TYPEC_CTVPD) -static int check_host_rp3a0(void) -{ - /* Make sure CC_RP3A0_RD_L is asserted high */ - if (mock_get_cc_rp3a0_rd_l() != 1) - return 0; - - return 1; -} - -static int check_host_rpusb(void) -{ - /* Make sure CC_RPUSB_ODH is asserted high */ - if (mock_get_cc_rpusb_odh() != 1) - return 0; - - /* Make sure CC_RP3A0_RD_L is configured as comparator */ - if (mock_get_cfg_cc_rp3a0_rd_l() != PIN_CMP) - return 0; - - return 1; -} - -static int check_host_cc_open(void) -{ - /* Make sure CC_RPUSB_ODH is hi-z */ - if (mock_get_cc_rpusb_odh() != GPO_HZ) - return 0; - - /* Make sure CC_RP3A0_RD_L is set to comparitor */ - if (mock_get_cfg_cc_rp3a0_rd_l() != PIN_CMP) - return 0; - - /* Make sure cc_db_en_od is set low */ - if (mock_get_cc_db_en_od() != GPO_LOW) - return 0; - - return 1; -} - -static int check_ct_ccs_hz(void) -{ - return (mock_get_ct_rd() == GPO_HIGH); -} - -static int check_ct_ccs_rd(void) -{ - return (mock_get_ct_rd() == GPO_LOW); -} - -static int check_ct_ccs_cc1_rpusb(void) -{ - return (mock_get_ct_cc1_rpusb() == 1); -} -#endif - -void inc_tx_id(int port) -{ - pd_port[port].msg_tx_id = (pd_port[port].msg_tx_id + 1) % 7; -} - -void inc_rx_id(int port) -{ - pd_port[port].msg_rx_id = (pd_port[port].msg_rx_id + 1) % 7; -} - -static int verify_goodcrc(int port, int role, int id) -{ - return pd_test_tx_msg_verify_sop_prime(port) && - pd_test_tx_msg_verify_short(port, PD_HEADER(PD_CTRL_GOOD_CRC, - role, role, id, 0, 0, 0)) && - pd_test_tx_msg_verify_crc(port) && - pd_test_tx_msg_verify_eop(port); -} - -static void simulate_rx_msg(int port, uint16_t header, int cnt, - const uint32_t *data) -{ - int i; - - pd_test_rx_set_preamble(port, 1); - pd_test_rx_msg_append_sop_prime(port); - pd_test_rx_msg_append_short(port, header); - - crc32_init(); - crc32_hash16(header); - - for (i = 0; i < cnt; ++i) { - pd_test_rx_msg_append_word(port, data[i]); - crc32_hash32(data[i]); - } - - pd_test_rx_msg_append_word(port, crc32_result()); - - pd_test_rx_msg_append_eop(port); - pd_test_rx_msg_append_last_edge(port); - - pd_simulate_rx(port); -} - -static void simulate_goodcrc(int port, int role, int id) -{ - simulate_rx_msg(port, PD_HEADER(PD_CTRL_GOOD_CRC, role, role, id, 0, - pd_port[port].rev, 0), 0, NULL); -} - -static void simulate_discovery_identity(int port) -{ - uint16_t header = PD_HEADER(PD_DATA_VENDOR_DEF, PD_ROLE_SOURCE, - 0, pd_port[port].msg_rx_id, - 1, pd_port[port].rev, 0); - uint32_t msg = VDO(USB_SID_PD, - 1, /* Structured VDM */ - VDO_SVDM_VERS(1) | - VDO_CMDT(CMDT_INIT) | - CMD_DISCOVER_IDENT); - - simulate_rx_msg(port, header, 1, (const uint32_t *)&msg); -} - -static int test_vpd_host_src_detection(void) -{ - int port = PORT0; - - mock_set_vconn(VCONN_0); - host_disconnect_source(); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - /* - * TEST: - * Host is configured properly and start state is UNATTACHED_SNK - */ - TEST_ASSERT(check_host_ra_rd()); - TEST_ASSERT(get_state_tc(port) == TC_UNATTACHED_SNK); - - /* - * TEST: - * Host PORT Source Connection Detected - */ - - host_connect_source(VBUS_0); - mock_set_vconn(VCONN_0); - - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_ATTACH_WAIT_SNK); - - /* - * TEST: - * Host CC debounce in ATTACH_WAIT_SNK state - */ - - host_disconnect_source(); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(5 * MSEC); - - /* - * TEST: - * Host CC debounce in ATTACH_WAIT_SNK state - */ - - host_connect_source(VBUS_0); - mock_set_vconn(VCONN_0); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(50 * MSEC); - - /* - * TEST: - * Host Port Connection Removed - */ - host_disconnect_source(); - - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_UNATTACHED_SNK); - - return EC_SUCCESS; -} - -static int test_vpd_host_src_detection_vbus(void) -{ - int port = PORT0; - - mock_set_vconn(VCONN_0); - host_disconnect_source(); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - /* - * TEST: - * Host is configured properly and start state is UNATTACHED_SNK - */ - - TEST_ASSERT(check_host_ra_rd()); - TEST_ASSERT(get_state_tc(port) == TC_UNATTACHED_SNK); - - /* - * TEST: - * Host Port Source Connection Detected - */ - - host_connect_source(VBUS_0); - mock_set_vconn(VCONN_0); - - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_ATTACH_WAIT_SNK); - - /* - * TEST: - * Host Port Source Detected for tCCDebounce and Host Port VBUS - * Detected. - */ - - host_connect_source(VBUS_5); - - wait_for_state_change(port, PD_T_CC_DEBOUNCE + 10 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_ATTACHED_SNK); - - /* - * TEST: - * Host Port VBUS Removed - */ - - host_connect_source(VBUS_0); - - wait_for_state_change(port, 10 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_UNATTACHED_SNK); - - wait_for_state_change(port, 10 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_ATTACH_WAIT_SNK); - - return EC_SUCCESS; -} - -static int test_vpd_host_src_detection_vconn(void) -{ - int port = PORT0; - - mock_set_vconn(VCONN_0); - host_disconnect_source(); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - /* - * TEST: - * Host is configured properly and start state is UNATTACHED_SNK - */ - - TEST_ASSERT(check_host_ra_rd()); - TEST_ASSERT(get_state_tc(port) == TC_UNATTACHED_SNK); - - /* - * TEST: - * Host Source Connection Detected - */ - - host_connect_source(VBUS_0); - mock_set_vconn(VCONN_0); - - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_ATTACH_WAIT_SNK); - - /* - * TEST: - * Host Port Source Detected for tCCDebounce and VCONN Detected - */ - - host_connect_source(VBUS_0); - mock_set_vconn(VCONN_3); - - wait_for_state_change(port, PD_T_CC_DEBOUNCE + 10 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_ATTACHED_SNK); - - /* VCONN was detected. Make sure RA is removed */ - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - TEST_ASSERT(check_host_rd()); - - /* - * TEST: - * Host Port VCONN Removed - */ - - mock_set_vconn(VCONN_0); - - wait_for_state_change(port, 10 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_UNATTACHED_SNK); - - host_disconnect_source(); - - return EC_SUCCESS; -} - -static int test_vpd_host_src_detection_message_reception(void) -{ - int port = PORT0; - uint32_t expected_vdm_header = VDO(USB_VID_GOOGLE, - 1, /* Structured VDM */ - VDO_SVDM_VERS(1) | - VDO_CMDT(CMDT_RSP_ACK) | - CMD_DISCOVER_IDENT); - uint32_t expected_vdo_id_header = VDO_IDH( - 0, /* Not a USB Host */ - 1, /* Capable of being enumerated as USB Device */ - IDH_PTYPE_VPD, - 0, /* Modal Operation Not Supported */ - USB_VID_GOOGLE); - uint32_t expected_vdo_cert = 0; - uint32_t expected_vdo_product = VDO_PRODUCT( - CONFIG_USB_PID, - USB_BCD_DEVICE); - uint32_t expected_vdo_vpd = VDO_VPD( - VPD_HW_VERSION, - VPD_FW_VERSION, - VPD_MAX_VBUS_20V, - VPD_VBUS_IMP(VPD_VBUS_IMPEDANCE), - VPD_GND_IMP(VPD_GND_IMPEDANCE), -#ifdef CONFIG_USB_TYPEC_CTVPD - VPD_CTS_SUPPORTED -#else - VPD_CTS_NOT_SUPPORTED -#endif - ); - - mock_set_vconn(VCONN_0); - host_disconnect_source(); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - /* - * TEST: - * Host is configured properly and start state is UNATTACHED_SNK - */ - - TEST_ASSERT(check_host_ra_rd()); - TEST_ASSERT(get_state_tc(port) == TC_UNATTACHED_SNK); - - /* - * Transition to ATTACHED_SNK - */ - - host_connect_source(VBUS_5); - - wait_for_state_change(port, 10 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_ATTACH_WAIT_SNK); - - wait_for_state_change(port, PD_T_CC_DEBOUNCE + 20 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_ATTACHED_SNK); - - /* Run state machines to enable rx monitoring */ - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - - /* - * TEST: - * Reception of Discovery Identity message - */ - - simulate_discovery_identity(port); - task_wait_event(30 * MSEC); - - TEST_ASSERT(verify_goodcrc(port, - PD_ROLE_SINK, pd_port[port].msg_rx_id)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - inc_rx_id(port); - - /* Test Discover Identity Ack */ - TEST_ASSERT(pd_test_tx_msg_verify_sop_prime(port)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, - PD_HEADER(PD_DATA_VENDOR_DEF, PD_PLUG_FROM_CABLE, 0, - pd_port[port].msg_tx_id, 5, pd_port[port].rev, 0))); - TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_vdm_header)); - TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_vdo_id_header)); - TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_vdo_cert)); - TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_vdo_product)); - TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_vdo_vpd)); - TEST_ASSERT(pd_test_tx_msg_verify_crc(port)); - TEST_ASSERT(pd_test_tx_msg_verify_eop(port)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - - /* Ack was good. Send GoodCRC */ - simulate_goodcrc(port, PD_ROLE_SOURCE, pd_port[port].msg_tx_id); - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(30 * MSEC); - inc_tx_id(port); - - /* - * TEST: - * Host Port VBUS Removed - */ - - host_connect_source(VBUS_0); - - wait_for_state_change(port, 100 * MSEC); - - TEST_EQ(get_state_tc(port), TC_UNATTACHED_SNK, "%d"); - - host_disconnect_source(); - - return EC_SUCCESS; -} - -#if defined(TEST_USB_TYPEC_CTVPD) -static int test_ctvpd_behavior_case1(void) -{ - int port = PORT0; - - mock_set_vconn(VCONN_0); - host_disconnect_source(); - TEST_ASSERT(ct_disconnect_source()); - TEST_ASSERT(ct_disconnect_sink()); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - /* - * CASE 1: The following tests the behavior when a DRP is connected to a - * Charge-Through VCONN-Powered USB Device (abbreviated CTVPD), - * with no Power Source attached to the ChargeThrough port on - * the CTVPD. - */ - - /* 1. DRP and CTVPD are both in the unattached state */ - TEST_ASSERT(get_state_tc(port) == TC_UNATTACHED_SNK); - - /* - * a. DRP alternates between Unattached.SRC and Unattached.SNK - * - * b. CTVPD has applied Rd on its Charge-Through port’s CC1 and CC2 - * pins and Rd on the Host-side port’s CC pin - */ - TEST_ASSERT(check_host_ra_rd()); - TEST_ASSERT(check_ct_ccs_rd()); - - /* - * 2. DRP transitions from Unattached.SRC to AttachWait.SRC to - * Attached.SRC - * - * a. DRP in Unattached.SRC detects the CC pull-down of CTVPD which - * is in Unattached.SNK and DRP enters AttachWait.SRC - * b. DRP in AttachWait.SRC detects that pull down on CC persists for - * tCCDebounce, enters Attached.SRC and turns on VBUS and VCONN - */ - host_connect_source(VBUS_5); - mock_set_vconn(VCONN_3); - - /* - * 3. CTVPD transitions from Unattached.SNK to Attached.SNK through - * AttachWait.SNK. - * - * a. CTVPD detects the host-side CC pull-up of the DRP and CTVPD - * enters AttachWait.SNK - * b. CTVPD in AttachWait.SNK detects that pull up on the Host-side - * port’s CC persists for tCCDebounce, VCONN present and enters - * Attached.SNK - * c. CTVPD present a high-impedance to ground (above zOPEN) on its - * Charge-Through port’s CC1 and CC2 pins - */ - wait_for_state_change(port, 40 * MSEC); - TEST_ASSERT(get_state_tc(port) == TC_ATTACH_WAIT_SNK); - - wait_for_state_change(port, PD_T_CC_DEBOUNCE + 40 * MSEC); - TEST_ASSERT(get_state_tc(port) == TC_ATTACHED_SNK); - TEST_ASSERT(check_ct_ccs_hz()); - - /* - * 4. While DRP and CTVPD are in their respective attached states, DRP - * discovers the ChargeThrough CTVPD and transitions to - * CTUnattached.SNK - * - * a. DRP (as Source) queries the device identity via USB PD - * (Device Identity Command) on SOP’. - * b. CTVPD responds on SOP’, advertising that it is a - * Charge-Through VCONN-Powered USB Device - * c. DRP (as Source) removes VBUS - * d. DRP (as Source) changes its Rp to a Rd - * e. DRP (as Sink) continues to provide VCONN and enters - * CTUnattached.SNK - */ - host_disconnect_source(); - - /* - * 5. CTVPD transitions to CTUnattached.VPD - * - * a. CTVPD detects VBUS removal, VCONN presence, the low Host-side - * CC pin and enters CTUnattached.VPD - * b. CTVPD changes its host-side Rd to a Rp advertising 3.0 A - * c. CTVPD isolates itself from VBUS - * d. CTVPD apply Rd on its Charge-Through port’s CC1 and CC2 pins - */ - wait_for_state_change(port, 40 * MSEC); - TEST_ASSERT(get_state_tc(port) == TC_CT_UNATTACHED_VPD); - - /* - * 6. While the CTVPD in CTUnattached.VPD state and the DRP in - * CTUnattached.SNK state: - * - * a. CTVPD monitors Charge-Though CC pins for a source or sink; - * when a Power Source attach is detected, enters - * CTAttachWait.VPD; when a sink is detected, enters - * CTAttachWait.Unsupported - * b. CTVPD monitors VCONN for Host detach and when detected, enters - * Unattached.SNK - * c. DRP monitors VBUS and CC for CTVPD detach for tVPDDetach and - * when detected, enters Unattached.SNK - * d. DRP monitors VBUS for Power Source attach and when detected, - * enters CTAttached.SNK - */ - /* Attach Power Source */ - TEST_ASSERT(ct_connect_source(CC2, VBUS_0)); - - wait_for_state_change(port, 40 * MSEC); - TEST_ASSERT(get_state_tc(port) == TC_CT_ATTACH_WAIT_VPD); - - /* Remove Power Source */ - TEST_ASSERT(ct_disconnect_source()); - - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_CT_UNATTACHED_VPD); - - /* Attach Sink */ - TEST_ASSERT(ct_connect_sink(CC1, SRC_CON_DEF)); - - wait_for_state_change(port, PD_T_DRP_SNK); - - TEST_ASSERT(get_state_tc(port) == TC_CT_UNATTACHED_UNSUPPORTED); - - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_CT_ATTACH_WAIT_UNSUPPORTED); - - /* Remove VCONN (Host detach) */ - mock_set_vconn(VCONN_0); - - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_UNATTACHED_SNK); - - return EC_SUCCESS; -} - -static int test_ctvpd_behavior_case2(void) -{ - int port = PORT0; - - mock_set_vconn(VCONN_0); - host_disconnect_source(); - TEST_ASSERT(ct_disconnect_source()); - TEST_ASSERT(ct_disconnect_sink()); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - /* - * CASE 2: The following tests the behavior when a Power Source is - * connected to a Charge-Through VCONN-Powered USB Device - * (abbreviated CTVPD), with a Host already attached to the - * Host-Side port on the CTVPD. - */ - - /* - * 1. DRP is in CTUnattached.SNK state, CTVPD in CTUnattached.VPD, and - * Power Source in the unattached state - * - * a. CTVPD has applied Rd on the Charge-Through port’s CC1 and CC2 - * pins and Rp termination advertising 3.0 A on the Host-side - * port’s CC pin - */ - TEST_ASSERT(get_state_tc(port) == TC_UNATTACHED_SNK); - - host_connect_source(VBUS_5); - mock_set_vconn(VCONN_3); - - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_ATTACH_WAIT_SNK); - - wait_for_state_change(port, PD_T_CC_DEBOUNCE + 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_ATTACHED_SNK); - - /* Remove Host CC */ - mock_set_host_cc_source_voltage(0); - - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_CT_UNATTACHED_VPD); - TEST_ASSERT(check_ct_ccs_rd()); - TEST_ASSERT(check_host_rp3a0()); - - /* - * 2. Power Source transitions from Unattached.SRC to Attached.SRC - * through AttachWait.SRC. - * - * a. Power Source detects the CC pull-down of the CTVPD and enters - * AttachWait.SRC - * b. Power Source in AttachWait.SRC detects that pull down on CC - * persists for tCCDebounce, enters Attached.SRC and turns on - * VBUS - */ - TEST_ASSERT(ct_connect_source(CC2, VBUS_5)); - - /* - * 3. CTVPD transitions from CTUnattached.VPD through CTAttachWait.VPD - * to CTAttached.VPD - * - * a. CTVPD detects the Source’s Rp on one of its Charge-Through CC - * pins, and transitions to CTAttachWait.VPD - * b. CTVPD finishes any active USB PD communication on SOP’ and - * ceases to respond to SOP’ queries - * c. CTVPD in CTAttachWait.VPD detects that the pull up on - * Charge-Through CC pin persists for tCCDebounce, detects VBUS - * and enters CTAttached.VPD - * d. CTVPD connects the active Charge-Through CC pin to the - * Host-side port’s CC pin - * e. CTVPD disables its Rp termination advertising 3.0 A on the - * Host-side port’s CC pin - * f. CTVPD disables its Rd on the Charge-Through CC pins - * g. CTVPD connects VBUS from the Charge-Through side to the Host - * side - */ - - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_CT_ATTACH_WAIT_VPD); - - wait_for_state_change(port, PD_T_CC_DEBOUNCE + 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_CT_ATTACHED_VPD); - TEST_ASSERT(moch_get_ct_cl_sel() == CT_CC2); - TEST_ASSERT(check_host_cc_open()); - TEST_ASSERT(check_ct_ccs_hz()); - TEST_ASSERT(mock_get_vbus_pass_en()); - - /* - * 4. DRP (as Sink) transitions to CTAttached.SNK - * a. DRP (as Sink) detects VBUS, monitors vRd for available current - * and enter CTAttached.SNK - */ - - /* - * 5. While the devices are all in their respective attached states: - * a. CTVPD monitors VCONN for DRP detach and when detected, - * enters CTDisabled.VPD - * b. CTVPD monitors VBUS and CC for Power Source detach and when - * detected, enters CTUnattached.VPD within tVPDCTDD - * c. DRP (as Sink) monitors VBUS for Charge-Through Power Source - * detach and when detected, enters CTUnattached.SNK - * d. DRP (as Sink) monitors VBUS and CC for CTVPD detach and when - * detected, enters Unattached.SNK (and resumes toggling between - * Unattached.SNK and Unattached.SRC) - * e. Power Source monitors CC for CTVPD detach and when detected, - * enters Unattached.SRC - */ - mock_set_vconn(VCONN_0); - - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_CT_DISABLED_VPD); - - return EC_SUCCESS; -} - -static int test_ctvpd_behavior_case3(void) -{ - int port = PORT0; - - mock_set_vconn(VCONN_0); - host_disconnect_source(); - TEST_ASSERT(ct_disconnect_source()); - TEST_ASSERT(ct_disconnect_sink()); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - /* - * CASE 3: The following describes the behavior when a Power Source is - * connected to a ChargeThrough VCONN-Powered USB Device - * (abbreviated CTVPD), with no Host attached to the Host-side - * port on the CTVPD. - */ - - /* - * 1. CTVPD and Power Source are both in the unattached state - * a. CTVPD has applied Rd on the Charge-Through port’s CC1 and CC2 - * pins and Rd on the Host-side port’s CC pin - */ - TEST_ASSERT(get_state_tc(port) == TC_UNATTACHED_SNK); - - TEST_ASSERT(check_ct_ccs_rd()); - TEST_ASSERT(check_host_ra_rd()); - TEST_ASSERT(ct_connect_source(CC2, VBUS_5)); - - /* - * 2. Power Source transitions from Unattached.SRC to Attached.SRC - * through AttachWait.SRC. - * - * a. Power Source detects the CC pull-down of the CTVPD and enters - * AttachWait.SRC - * b. Power Source in AttachWait.SRC detects that pull down on CC - * persists for tCCDebounce, enters Attached.SRC and turns on - * VBUS - */ - - /* 3. CTVPD alternates between Unattached.SNk and Unattached.SRC - * - * a. CTVPD detects the Source’s Rp on one of its Charge-Through CC - * pins, detects VBUS for tCCDebounce and starts alternating - * between Unattached.SRC and Unattached.SNK - */ - wait_for_state_change(port, PD_T_CC_DEBOUNCE + 40 * MSEC); - TEST_ASSERT(get_state_tc(port) == TC_UNATTACHED_SRC); - - /* - * 4. While the CTVPD alternates between Unattached.SRC and - * Unattached.SNK state and the Power Source in Attached.SRC state: - * - * a. CTVPD monitors the Host-side port’s CC pin for device attach - * and when detected, enters AttachWait.SRC - * b. CTVPD monitors VBUS for Power Source detach and when detected, - * enters Unattached.SNK - * c. Power Source monitors CC for CTVPD detach and when detected, - * enters Unattached.SRC - */ - - /* Attached host side device */ - host_connect_sink(SRC_CON_DEF); - - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_ATTACH_WAIT_SRC); - - /* Remove VBUS */ - TEST_ASSERT(ct_disconnect_source()); - - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_UNATTACHED_SNK); - - return EC_SUCCESS; -} - -static int test_ctvpd_behavior_case4(void) -{ - int port = PORT0; - uint32_t expected_vdm_header = VDO(USB_VID_GOOGLE, - 1, /* Structured VDM */ - VDO_SVDM_VERS(1) | - VDO_CMDT(CMDT_RSP_ACK) | - CMD_DISCOVER_IDENT); - uint32_t expected_vdo_id_header = VDO_IDH( - 0, /* Not a USB Host */ - 1, /* Capable of being enumerated as USB Device */ - IDH_PTYPE_VPD, - 0, /* Modal Operation Not Supported */ - USB_VID_GOOGLE); - uint32_t expected_vdo_cert = 0; - uint32_t expected_vdo_product = VDO_PRODUCT( - CONFIG_USB_PID, - USB_BCD_DEVICE); - uint32_t expected_vdo_vpd = VDO_VPD( - VPD_HW_VERSION, - VPD_FW_VERSION, - VPD_MAX_VBUS_20V, - VPD_VBUS_IMP(VPD_VBUS_IMPEDANCE), - VPD_GND_IMP(VPD_GND_IMPEDANCE), - VPD_CTS_SUPPORTED - ); - - init_port(port); - mock_set_vconn(VCONN_0); - host_disconnect_source(); - TEST_ASSERT(ct_disconnect_source()); - TEST_ASSERT(ct_disconnect_sink()); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - /* - * CASE 4: The following describes the behavior when a DRP is connected - * to a Charge-Through VCONN-Powered USB Device - * (abbreviated CTVPD), with a Power Source already attached to - * the Charge-Through side on the CTVPD. - */ - - /* - * 1. DRP, CTVPD and Sink are all in the unattached state - * - * a. DRP alternates between Unattached.SRC and Unattached.SNK - * b. CTVPD has applied Rd on its Charge-Through port’s CC1 and CC2 - * pins and Rd on the Host-side port’s CC pin - */ - TEST_ASSERT(get_state_tc(port) == TC_UNATTACHED_SNK); - - TEST_ASSERT(check_ct_ccs_rd()); - TEST_ASSERT(check_host_ra_rd()); - - /* - * 2. DRP transitions from Unattached.SRC to AttachWait.SRC to - * Attached.SRC - * - * a. DRP in Unattached.SRC detects the CC pull-down of CTVPD which - * is in Unattached.SNK and DRP enters AttachWait.SRC - * b. DRP in AttachWait.SRC detects that pull down on CC persists - * for tCCDebounce, enters Attached.SRC and turns on VBUS and - * VCONN - */ - - host_connect_source(VBUS_5); - mock_set_vconn(VCONN_3); - - /* - * 3. CTVPD transitions from Unattached.SNK to Attached.SNK through - * AttachWait.SNK. - * - * a. CTVPD detects the host-side CC pull-up of the DRP and CTVPD - * enters AttachWait.SNK - * b. CTVPD in AttachWait.SNK detects that pull up on the - * Host-side port’s CC persists for tCCDebounce, VCONN present - * and enters Attached.SNK - * c. CTVPD present a high-impedance to ground (above zOPEN) on its - * Charge-Through port’s CC1 and CC2 pins - */ - - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_ATTACH_WAIT_SNK); - - wait_for_state_change(port, PD_T_CC_DEBOUNCE + 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_ATTACHED_SNK); - TEST_ASSERT(check_ct_ccs_hz()); - - /* - * 4. While DRP and CTVPD are in their respective attached states, DRP - * discovers the ChargeThrough CTVPD and transitions to - * CTUnattached.SNK - * - * a. DRP (as Source) queries the device identity via USB PD - * (Discover Identity Command) on SOP’. - * b. CTVPD responds on SOP’, advertising that it is a - * Charge-Through VCONN-Powered USB Device - * c. DRP (as Source) removes VBUS - * d. DRP (as Source) changes its Rp to a Rd - * e. DRP (as Sink) continues to provide VCONN and enters - * CTUnattached.SNK - */ - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - simulate_discovery_identity(port); - task_wait_event(40 * MSEC); - - TEST_ASSERT(verify_goodcrc(port, - PD_ROLE_SINK, pd_port[port].msg_rx_id)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - inc_rx_id(port); - - /* Test Discover Identity Ack */ - TEST_ASSERT(pd_test_tx_msg_verify_sop_prime(port)); - TEST_ASSERT(pd_test_tx_msg_verify_short(port, - PD_HEADER(PD_DATA_VENDOR_DEF, PD_PLUG_FROM_CABLE, 0, - pd_port[port].msg_tx_id, 5, pd_port[port].rev, 0))); - TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_vdm_header)); - TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_vdo_id_header)); - TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_vdo_cert)); - TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_vdo_product)); - TEST_ASSERT(pd_test_tx_msg_verify_word(port, expected_vdo_vpd)); - TEST_ASSERT(pd_test_tx_msg_verify_crc(port)); - TEST_ASSERT(pd_test_tx_msg_verify_eop(port)); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - /* Ack was good. Send GoodCRC */ - simulate_goodcrc(port, PD_ROLE_SOURCE, pd_port[port].msg_tx_id); - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - inc_tx_id(port); - - /* - * 5. CTVPD transitions to CTUnattached.VPD - * - * a. CTVPD detects VBUS removal, VCONN presence, the low Host-side - * CC pin and enters CTUnattached.VPD - * b. CTVPD changes its host-side Rd to a Rp termination advertising - * 3.0 A - * c. CTVPD isolates itself from VBUS - * d. CTVPD apply Rd on its Charge-Through port’s CC1 and CC2 pins - */ - host_disconnect_source(); - - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_CT_UNATTACHED_VPD); - TEST_ASSERT(check_ct_ccs_rd()); - TEST_ASSERT(check_host_rp3a0()); - - /* - * 6. CTVPD alternates between CTUnattached.VPD and - * CTUnattached.Unsupported - */ - wait_for_state_change(port, PD_T_DRP_SRC + 10 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_CT_UNATTACHED_UNSUPPORTED); - - wait_for_state_change(port, PD_T_DRP_SRC + 10 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_CT_UNATTACHED_VPD); - TEST_ASSERT(ct_connect_source(CC2, VBUS_5)); - - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_CT_ATTACH_WAIT_VPD); - - return EC_SUCCESS; -} - -static int test_ctvpd_behavior_case5(void) -{ - int port = PORT0; - - mock_set_vconn(VCONN_0); - host_disconnect_source(); - TEST_ASSERT(ct_disconnect_source()); - TEST_ASSERT(ct_disconnect_sink()); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - /* - * CASE 5: The following describes the behavior when a Power Source is - * connected to a ChargeThrough VCONN-Powered USB Device - * (abbreviated CTVPD), with a DRP (with dead battery) attached - * to the Host-side port on the CTVPD. - */ - - /* - * 1. DRP, CTVPD and Power Source are all in the unattached state - * - * a. DRP apply dead battery Rd - * b. CTVPD apply Rd on the Charge-Through port’s CC1 and CC2 pins - * and Rd on the Host-side port’s CC pin - */ - TEST_ASSERT(get_state_tc(port) == TC_UNATTACHED_SNK); - - TEST_ASSERT(check_ct_ccs_rd()); - TEST_ASSERT(check_host_ra_rd()); - - /* - * 2. Power Source transitions from Unattached.SRC to Attached.SRC - * through AttachWait.SRC. - * - * a. Power Source detects the CC pull-down of the CTVPD and enters - * AttachWait.SRC - * b. Power Source in AttachWait.SRC detects that pull down on CC - * persists for tCCDebounce, enters Attached.SRC and enable VBUS - */ - TEST_ASSERT(ct_connect_source(CC2, VBUS_5)); - - /* - * 3. CTVPD alternates between Unattached.SNK and Unattached.SRC - * - * a. CTVPD detects the Source’s Rp on one of its Charge-Through CC - * pins, detects VBUS for tCCDebounce and starts alternating - * between Unattached.SRC and Unattached.SNK - */ - - wait_for_state_change(port, PD_T_CC_DEBOUNCE + 40 * MSEC); - TEST_ASSERT(get_state_tc(port) == TC_UNATTACHED_SRC); - - /* Connect Host With Dead Battery */ - host_connect_sink(SRC_CON_DEF); - - /* - * 4. CTVPD transitions from Unattached.SRC to Try.SNK through - * AttachWait.SRC - * - * a. CTVPD in Unattached.SRC detects the CC pull-down of DRP which - * is in Unattached.SNK and CTVPD enters AttachWait.SRC - * b. CTVPD in AttachWait.SRC detects that pull down on CC persists - * for tCCDebounce and enters Try.SNK - * c. CTVPD disables Rp termination advertising Default USB Power on - * the Host-side port’s CC - * d. CTVPD enables Rd on the Host-side port’s CC - */ - - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_ATTACH_WAIT_SRC); - - wait_for_state_change(port, PD_T_CC_DEBOUNCE + 10 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_TRY_SNK); - TEST_ASSERT(check_host_ra_rd()); - - /* 5. DRP in dead battery condition remains in Unattached.SNK */ - - /* - * 6. CTVPD transitions from Try.SNK to Attached.SRC through - * TryWait.SRC - * - * a. CTVPD didn’t detect the CC pull-up of the DRP for - * tTryDebounce after tDRPTry and enters TryWait.SRC - * b. CTVPD disables Rd on the Host-side port’s CC - * c. CTVPD enables Rp termination advertising Default USB Power on - * the Host-side port’s CC - * d. CTVPD detects the CC pull-down of the DRP for tTryCCDebounce - * and enters Attached.SRC - * e. CTVPD connects VBUS from the Charge-Through side to the Host - * side - */ - wait_for_state_change(port, PD_T_TRY_CC_DEBOUNCE + - PD_T_DRP_TRY + 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_TRY_WAIT_SRC); - TEST_ASSERT(check_host_rpusb()); - - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_ATTACHED_SRC); - TEST_ASSERT(mock_get_vbus_pass_en()); - - /* - * 7. DRP transitions from Unattached.SNK to Attached.SNK through - * AttachWait.SNK - * - * a. DRP in Unattached.SNK detects the CC pull-up of CTVPD which is - * in Attached.SRC and DRP enters AttachWait.SNK - * b. DRP in AttachWait.SNK detects that pull up on CC persists for - * tCCDebounce, VBUS present and enters Attached.SNK - */ - - /* - * 8. While the devices are all in their respective attached states: - * a. CTVPD monitors the Host-side port’s CC pin for device attach - * and when detected, enters Unattached.SNK - * b. CTVPD monitors VBUS for Power Source detach and when detected, - * enters Unattached.SNK - * c. Power Source monitors CC for CTVPD detach and when detected, - * enters Unattached.SRC - * d. DRP monitors VBUS for CTVPD detach and when detected, enters - * Unattached.SNK - * e. Additionally, the DRP may query the identity of the cable via - * USB PD on SOP’ when it has sufficient battery power and when - * a Charge-Through VPD is identified enters TryWait.SRC if - * implemented, or enters Unattached.SRC if TryWait.SRC is not - * supported - */ - TEST_ASSERT(ct_connect_source(CC2, VBUS_0)); - - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_UNATTACHED_SNK); - - return EC_SUCCESS; -} - -static int test_ctvpd_behavior_case6(void) -{ - int port = PORT0; - - mock_set_vconn(VCONN_0); - host_disconnect_source(); - TEST_ASSERT(ct_disconnect_source()); - TEST_ASSERT(ct_disconnect_sink()); - - task_wake(PD_PORT_TO_TASK_ID(port)); - task_wait_event(40 * MSEC); - - /* - * CASE 6: The following describes the behavior when a DRP is connected - * to a Charge-Through VCONN-Powered USB Device - * (abbreviated CTVPD) and a Sink is attached to the - * Charge-Through port on the CTVPD. - */ - - /* - * 1. DRP, CTVPD and Sink are all in the unattached state - * - * a. DRP alternates between Unattached.SRC and Unattached.SNK - * b. CTVPD has applied Rd on its Charge-Through port’s CC1 and CC2 - * pins and Rd on the Host-side port’s CC pin - */ - TEST_ASSERT(get_state_tc(port) == TC_UNATTACHED_SNK); - TEST_ASSERT(check_ct_ccs_rd()); - TEST_ASSERT(check_host_ra_rd()); - - /* - * 2. DRP transitions from Unattached.SRC to AttachWait.SRC to - * Attached.SRC - * - * a. DRP in Unattached.SRC detects the CC pull-down of CTVPD which - * is in Unattached.SNK and DRP enters AttachWait.SRC - * b. DRP in AttachWait.SRC detects that pull down on CC persists - * for tCCDebounce, enters Attached.SRC and turns on VBUS and - * VCONN - */ - host_connect_source(VBUS_5); - mock_set_vconn(VCONN_3); - - /* - * 3. CTVPD transitions from Unattached.SNK to Attached.SNK through - * AttachWait.SNK. - * - * a. CTVPD detects the host-side CC pull-up of the DRP and CTVPD - * enters AttachWait.SNK - * b. CTVPD in AttachWait.SNK detects that pull up on the Host-side - * port’s CC persists for tCCDebounce, VCONN present and enters - * Attached.SNK - * c. CTVPD present a high-impedance to ground (above zOPEN) on its - * Charge-Through port’s CC1 and CC2 pins - */ - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_ATTACH_WAIT_SNK); - - wait_for_state_change(port, PD_T_CC_DEBOUNCE + 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_ATTACHED_SNK); - TEST_ASSERT(check_ct_ccs_hz()); - - /* - * 4. While DRP and CTVPD are in their respective attached states, DRP - * discovers the ChargeThrough CTVPD and transitions to - * CTUnattached.SNK - * - * a. DRP (as Source) queries the device identity via USB PD - * (Discover Identity Command) on SOP’. - * b. CTVPD responds on SOP’, advertising that it is a - * Charge-Through VCONN-Powered USB Device - * c. DRP (as Source) removes VBUS - * d. DRP (as Source) changes its Rp to a Rd - * e. DRP (as Sink) continues to provide VCONN and enters - * CTUnattached.SNK - */ - - host_disconnect_source(); - host_connect_sink(SRC_CON_DEF); - - /* - * 5. CTVPD transitions to CTUnattached.VPD - * - * a. CTVPD detects VBUS removal, VCONN presence, the low Host-side - * CC pin and enters CTUnattached.VPD - * b. CTVPD changes its host-side Rd to a Rp termination advertising - * 3.0 A - * c. CTVPD isolates itself from VBUS - * d. CTVPD apply Rd on its Charge-Through port’s CC1 and CC2 pins - */ - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_CT_UNATTACHED_VPD); - TEST_ASSERT(check_host_rp3a0()); - TEST_ASSERT(mock_get_vbus_pass_en() == 0); - TEST_ASSERT(check_ct_ccs_rd()); - - /* - * 6. CTVPD alternates between CTUnattached.VPD and - * CTUnattached.Unsupported - * - * a. CTVPD detects SRC.open on its Charge-Through CC pins and - * starts alternating between CTUnattached.VPD and - * CTUnattached.Unsupported - */ - wait_for_state_change(port, PD_T_DRP_SNK + 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_CT_UNATTACHED_UNSUPPORTED); - - wait_for_state_change(port, PD_T_DRP_SNK + 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_CT_UNATTACHED_VPD); - - wait_for_state_change(port, PD_T_DRP_SNK + 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_CT_UNATTACHED_UNSUPPORTED); - - /* - * 7. CTVPD transitions from CTUnattached.Unsupported to CTTry.SNK - * through CTAttachWait.Unsupported - * - * a. CTVPD in CTUnattached.Unsupported detects the CC pull-down of - * the Sink which is in Unattached.SNK and CTVPD enters - * CTAttachWait.Unsupported - * b. CTVPD in CTAttachWait.Unsupported detects that pull down on CC - * persists for tCCDebounce and enters CTTry.SNK - * c. CTVPD disables Rp termination advertising Default USB Power on - * the ChargeThrough port’s CC pins - * d. CTVPD enables Rd on the Charge-Through port’s CC pins - */ - TEST_ASSERT(ct_connect_sink(CC1, SRC_CON_DEF)); - - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_CT_ATTACH_WAIT_UNSUPPORTED); - - wait_for_state_change(port, PD_T_CC_DEBOUNCE + 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_CT_TRY_SNK); - TEST_ASSERT(check_ct_ccs_rd()); - - /* - * 8. CTVPD transitions from CTTry.SNK to CTAttached.Unsupported - * - * a. CTVPD didn’t detect the CC pull-up of the potential Source - * for tDRPTryWait after tDRPTry and enters - * CTAttached.Unsupported - */ - - wait_for_state_change(port, PD_T_DRP_TRY + PD_T_TRY_WAIT + 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_CT_ATTACHED_UNSUPPORTED); - - /* - * 9. While the CTVPD in CTAttached.Unsupported state, the DRP in - * CTUnattached.SNK state and the Sink in Unattached.SNK state: - * - * a. CTVPD disables the Rd termination on the Charge-Through - * port’s CC pins and applies Rp termination advertising - * Default USB Power - * b. CTVPD exposes a USB Billboard Device Class to the DRP - * indicating that it is connected to an unsupported device on - * its Charge Through port - * c. CTVPD monitors Charge-Though CC pins for Sink detach and when - * detected, enters CTUnattached.VPD - * d. CTVPD monitors VCONN for Host detach and when detected, enters - * Unattached.SNK - * e. DRP monitors CC for CTVPD detach for tVPDDetach and when - * detected, enters Unattached.SNK - * f. DRP monitors VBUS for CTVPD Charge-Through source attach and, - * when detected, enters CTAttached.SNK - */ - - TEST_ASSERT(check_ct_ccs_cc1_rpusb()); - TEST_ASSERT(mock_get_present_billboard() == BB_SNK); - - TEST_ASSERT(ct_disconnect_sink()); - - wait_for_state_change(port, 40 * MSEC); - - TEST_ASSERT(get_state_tc(port) == TC_CT_UNATTACHED_VPD); - - return EC_SUCCESS; -} -#endif - -void run_test(void) -{ - test_reset(); - - init_port(PORT0); - - /* VPD and CTVPD tests */ - RUN_TEST(test_vpd_host_src_detection); - RUN_TEST(test_vpd_host_src_detection_vbus); - RUN_TEST(test_vpd_host_src_detection_vconn); - RUN_TEST(test_vpd_host_src_detection_message_reception); - - /* CTVPD only tests */ -#if defined(TEST_USB_TYPEC_CTVPD) - /* DRP to VCONN-Powered USB Device (CTVPD) Behavior Tests */ - RUN_TEST(test_ctvpd_behavior_case1); - RUN_TEST(test_ctvpd_behavior_case2); - RUN_TEST(test_ctvpd_behavior_case3); - RUN_TEST(test_ctvpd_behavior_case4); - RUN_TEST(test_ctvpd_behavior_case5); - RUN_TEST(test_ctvpd_behavior_case6); -#endif - - /* Do basic state machine sanity checks last. */ - RUN_TEST(test_tc_no_parent_cycles); - RUN_TEST(test_tc_no_empty_state); - RUN_TEST(test_tc_all_states_named); - - /* - * Since you have to include TypeC layer when adding PE layer, the - * PE test would have the same build dependencies, so go ahead and test - * te PE statemachine here so we don't have to create another test exe - */ - RUN_TEST(test_pe_no_parent_cycles); - RUN_TEST(test_pe_no_empty_state); - RUN_TEST(test_pe_all_states_named); - - test_print_result(); -} - diff --git a/test/usb_typec_ctvpd.tasklist b/test/usb_typec_ctvpd.tasklist deleted file mode 100644 index eb41326e3e..0000000000 --- a/test/usb_typec_ctvpd.tasklist +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TEST_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST \ - TASK_TEST(PD_C0, pd_task, NULL, LARGER_TASK_STACK_SIZE) diff --git a/test/usb_typec_drp_acc_trysrc.c b/test/usb_typec_drp_acc_trysrc.c deleted file mode 100644 index 205ef6ad3a..0000000000 --- a/test/usb_typec_drp_acc_trysrc.c +++ /dev/null @@ -1,154 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Test USB Type-C VPD and CTVPD module. - */ -#include "charge_manager.h" -#include "mock/tcpc_mock.h" -#include "mock/usb_mux_mock.h" -#include "task.h" -#include "test_util.h" -#include "timer.h" -#include "usb_mux.h" -#include "usb_pd_tcpm.h" -#include "usb_sm_checks.h" - -#define PORT0 0 - -/* Install Mock TCPC and MUX drivers */ -const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .drv = &mock_tcpc_driver, - }, -}; - -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { - { - .driver = &mock_usb_mux_driver, - } -}; - -void charge_manager_set_ceil(int port, enum ceil_requestor requestor, int ceil) -{ - /* Do Nothing, but needed for linking */ -} - -__maybe_unused static int test_mux_con_dis_as_src(void) -{ - /* Update CC lines send state machine event to process */ - mock_tcpc.cc1 = TYPEC_CC_VOLT_RD; - mock_tcpc.cc2 = TYPEC_CC_VOLT_OPEN; - task_set_event(TASK_ID_PD_C0, PD_EVENT_CC, 0); - pd_set_dual_role(0, PD_DRP_TOGGLE_ON); - - /* This wait trainsitions through AttachWait.SRC then Attached.SRC */ - task_wait_event(SECOND); - - /* We are in Attached.SRC now */ - TEST_EQ(mock_usb_mux.state, TYPEC_MUX_USB, "%d"); - TEST_EQ(mock_usb_mux.num_set_calls, 1, "%d"); - - mock_tcpc.cc1 = TYPEC_CC_VOLT_OPEN; - mock_tcpc.cc2 = TYPEC_CC_VOLT_OPEN; - task_set_event(TASK_ID_PD_C0, PD_EVENT_CC, 0); - - /* This wait will go through TryWait.SNK then to Unattached.SNK */ - task_wait_event(10 * SECOND); - - /* We are in Unattached.SNK. The mux should have detached */ - TEST_EQ(mock_usb_mux.state, TYPEC_MUX_NONE, "%d"); - TEST_EQ(mock_usb_mux.num_set_calls, 2, "%d"); - - return EC_SUCCESS; -} - -__maybe_unused static int test_mux_con_dis_as_snk(void) -{ - /* Update CC lines send state machine event to process */ - mock_tcpc.cc1 = TYPEC_CC_VOLT_RP_3_0; - mock_tcpc.cc2 = TYPEC_CC_VOLT_OPEN; - mock_tcpc.vbus_level = 1; - task_set_event(TASK_ID_PD_C0, PD_EVENT_CC, 0); - - /* This wait will go through AttachWait.SNK to Attached.SNK */ - task_wait_event(5 * SECOND); - - /* We are in Attached.SNK now */ - TEST_EQ(mock_usb_mux.state, TYPEC_MUX_USB, "%d"); - TEST_EQ(mock_usb_mux.num_set_calls, 1, "%d"); - - mock_tcpc.cc1 = TYPEC_CC_VOLT_OPEN; - mock_tcpc.cc2 = TYPEC_CC_VOLT_OPEN; - mock_tcpc.vbus_level = 0; - task_set_event(TASK_ID_PD_C0, PD_EVENT_CC, 0); - - /* This wait will go through TryWait.SNK then to Unattached.SNK */ - task_wait_event(10 * SECOND); - - /* We are in Unattached.SNK. The mux should have detached */ - TEST_EQ(mock_usb_mux.state, TYPEC_MUX_NONE, "%d"); - TEST_EQ(mock_usb_mux.num_set_calls, 2, "%d"); - - return EC_SUCCESS; -} - -__maybe_unused static int test_power_role_set(void) -{ - /* Print out header changes for easier debugging */ - mock_tcpc.should_print_header_changes = true; - - /* Update CC lines send state machine event to process */ - mock_tcpc.cc1 = TYPEC_CC_VOLT_OPEN; - mock_tcpc.cc2 = TYPEC_CC_VOLT_RD; - task_set_event(TASK_ID_PD_C0, PD_EVENT_CC, 0); - task_wait_event(10 * SECOND); - - /* We are in Attached.SRC now */ - TEST_EQ(mock_tcpc.power_role, PD_ROLE_SOURCE, "%d"); - TEST_EQ(mock_tcpc.data_role, PD_ROLE_DFP, "%d"); - - /* - * We allow 2 separate calls to update the header since power and data - * role updates can be separate calls depending on the state is came - * from. - */ - TEST_LE(mock_tcpc.num_calls_to_set_header, 2, "%d"); - - return EC_SUCCESS; -} - -/* Reset the mocks before each test */ -void before_test(void) -{ - mock_usb_mux_reset(); - mock_tcpc_reset(); -} - -void after_test(void) -{ - /* Disconnect any CC lines */ - mock_tcpc.cc1 = TYPEC_CC_VOLT_OPEN; - mock_tcpc.cc2 = TYPEC_CC_VOLT_OPEN; - task_set_event(TASK_ID_PD_C0, PD_EVENT_CC, 0); -} - -void run_test(void) -{ - test_reset(); - - /* Ensure that PD task initializes its state machine */ - task_wake(TASK_ID_PD_C0); - task_wait_event(5 * MSEC); - - RUN_TEST(test_mux_con_dis_as_src); - RUN_TEST(test_mux_con_dis_as_snk); - RUN_TEST(test_power_role_set); - - /* Do basic state machine sanity checks last. */ - RUN_TEST(test_tc_no_parent_cycles); - RUN_TEST(test_tc_no_empty_state); - RUN_TEST(test_tc_all_states_named); - - test_print_result(); -} diff --git a/test/usb_typec_drp_acc_trysrc.mocklist b/test/usb_typec_drp_acc_trysrc.mocklist deleted file mode 100644 index 71c2e2cee9..0000000000 --- a/test/usb_typec_drp_acc_trysrc.mocklist +++ /dev/null @@ -1,8 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - #define CONFIG_TEST_MOCK_LIST \ - MOCK(USB_MUX) \ - MOCK(TCPC) diff --git a/test/usb_typec_drp_acc_trysrc.tasklist b/test/usb_typec_drp_acc_trysrc.tasklist deleted file mode 100644 index eb41326e3e..0000000000 --- a/test/usb_typec_drp_acc_trysrc.tasklist +++ /dev/null @@ -1,10 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/** - * See CONFIG_TEST_TASK_LIST in config.h for details. - */ -#define CONFIG_TEST_TASK_LIST \ - TASK_TEST(PD_C0, pd_task, NULL, LARGER_TASK_STACK_SIZE) diff --git a/test/usb_typec_vpd.tasklist b/test/usb_typec_vpd.tasklist deleted file mode 120000 index 3e39415ded..0000000000 --- a/test/usb_typec_vpd.tasklist +++ /dev/null @@ -1 +0,0 @@ -usb_typec_ctvpd.tasklist
\ No newline at end of file diff --git a/test/vpd_api.c b/test/vpd_api.c deleted file mode 100644 index 960c0c664b..0000000000 --- a/test/vpd_api.c +++ /dev/null @@ -1,586 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "registers.h" -#include "vpd_api.h" -#include "driver/tcpm/tcpm.h" -#include "console.h" -/* - * Polarity based on 'DFP Perspective' (see table USB Type-C Cable and Connector - * Specification) - * - * CC1 CC2 STATE POSITION - * ---------------------------------------- - * open open NC N/A - * Rd open UFP attached 1 - * open Rd UFP attached 2 - * open Ra pwr cable no UFP N/A - * Ra open pwr cable no UFP N/A - * Rd Ra pwr cable & UFP 1 - * Ra Rd pwr cable & UFP 2 - * Rd Rd dbg accessory N/A - * Ra Ra audio accessory N/A - * - * Note, V(Rd) > V(Ra) - */ -#ifndef PD_SRC_RD_THRESHOLD -#define PD_SRC_RD_THRESHOLD PD_SRC_DEF_RD_THRESH_MV -#endif -#ifndef PD_SRC_VNC -#define PD_SRC_VNC PD_SRC_DEF_VNC_MV -#endif - -#ifndef CC_RA -#define CC_RA(port, cc, sel) (cc < pd_src_rd_threshold[ct_cc_rp_value]) -#endif -#define CC_RD(cc) ((cc >= PD_SRC_RD_THRESHOLD) && (cc < PD_SRC_VNC)) -#ifndef CC_NC -#define CC_NC(port, cc, sel) (cc >= PD_SRC_VNC) -#endif - -/* - * Polarity based on 'UFP Perspective'. - * - * CC1 CC2 STATE POSITION - * ---------------------------------------- - * open open NC N/A - * Rp open DFP attached 1 - * open Rp DFP attached 2 - * Rp Rp Accessory attached N/A - */ -#ifndef PD_SNK_VA -#define PD_SNK_VA PD_SNK_VA_MV -#endif - -#define CC_RP(cc) (cc >= PD_SNK_VA) - -/* Mock Board State */ -static enum vpd_pwr mock_vconn_pwr_sel_odl; -static enum vpd_gpo mock_cc1_cc2_rd_l; -static enum vpd_gpo mock_cc_db_en_od; -static enum vpd_gpo mock_cc_rpusb_odh; -static enum vpd_cc mock_ct_cl_sel; -static int mock_mcu_cc_en; -static enum vpd_billboard mock_present_billboard; -static int mock_red_led; -static int mock_green_led; -static int mock_vbus_pass_en; - -static int mock_read_host_vbus; -static int mock_read_ct_vbus; -static int mock_read_vconn; - -static struct mock_pin mock_cc2_rpusb_odh; -static struct mock_pin mock_cc2_rp3a0_rd_l; -static struct mock_pin mock_cc1_rpusb_odh; -static struct mock_pin mock_cc1_rp3a0_rd_l; -static struct mock_pin mock_cc_vpdmcu; -static struct mock_pin mock_cc_rp3a0_rd_l; - -/* Charge-Through pull up/down enabled */ -static int ct_cc_pull; -/* Charge-Through pull up value */ -static int ct_cc_rp_value; - -/* Charge-Through pull up/down enabled */ -static int host_cc_pull; -/* Charge-Through pull up value */ -static int host_cc_rp_value; - -/* Voltage thresholds for Ra attach in normal SRC mode */ -static int pd_src_rd_threshold[TYPEC_RP_RESERVED] = { - PD_SRC_DEF_RD_THRESH_MV, - PD_SRC_1_5_RD_THRESH_MV, - PD_SRC_3_0_RD_THRESH_MV, -}; - -enum vpd_pwr mock_get_vconn_pwr_source(void) -{ - return mock_vconn_pwr_sel_odl; -} - -int mock_get_ct_cc1_rpusb(void) -{ - return mock_cc1_rpusb_odh.value; -} - -int mock_get_ct_cc2_rpusb(void) -{ - return mock_cc2_rpusb_odh.value; -} - -enum vpd_gpo mock_get_ct_rd(void) -{ - return mock_cc1_cc2_rd_l; -} - -enum vpd_gpo mock_get_cc_rpusb_odh(void) -{ - return mock_cc_rpusb_odh; -} - -enum vpd_gpo mock_get_cc_db_en_od(void) -{ - return mock_cc_db_en_od; -} - -enum vpd_cc moch_get_ct_cl_sel(void) -{ - return mock_ct_cl_sel; -} - -int mock_get_mcu_cc_en(void) -{ - return mock_mcu_cc_en; -} - -enum vpd_billboard mock_get_present_billboard(void) -{ - return mock_present_billboard; -} - -int mock_get_red_led(void) -{ - return mock_red_led; -} - -int mock_get_green_led(void) -{ - return mock_green_led; -} - -int mock_get_vbus_pass_en(void) -{ - return mock_vbus_pass_en; -} - -void mock_set_host_cc_sink_voltage(int v) -{ - mock_cc_vpdmcu.value = v; -} - -void mock_set_host_cc_source_voltage(int v) -{ - mock_cc_vpdmcu.value2 = v; -} - -void mock_set_host_vbus(int v) -{ - mock_read_host_vbus = v; -} - -void mock_set_ct_vbus(int v) -{ - mock_read_ct_vbus = v; -} - -void mock_set_vconn(int v) -{ - mock_read_vconn = v; -} - -int mock_get_cfg_cc2_rpusb_odh(void) -{ - return mock_cc2_rpusb_odh.cfg; -} - -int mock_set_cc2_rpusb_odh(int v) -{ - if (mock_cc2_rpusb_odh.cfg == PIN_ADC) { - mock_cc2_rpusb_odh.value = v; - return 1; - } - return 0; -} - -int mock_get_cfg_cc2_rp3a0_rd_l(void) -{ - return mock_cc2_rp3a0_rd_l.cfg; -} - -int mock_set_cc2_rp3a0_rd_l(int v) -{ - if (mock_cc2_rp3a0_rd_l.cfg == PIN_ADC) { - mock_cc2_rp3a0_rd_l.value = v; - return 1; - } - - return 0; -} - -int mock_get_cc1_rpusb_odh(void) -{ - return mock_cc1_rpusb_odh.cfg; -} - -int mock_set_cc1_rpusb_odh(int v) -{ - if (mock_cc1_rpusb_odh.cfg == PIN_ADC) { - mock_cc1_rpusb_odh.value = v; - return 1; - } - - return 0; -} - -int mock_get_cfg_cc_vpdmcu(void) -{ - return mock_cc_vpdmcu.cfg; -} - -enum vpd_pin mock_get_cfg_cc_rp3a0_rd_l(void) -{ - return mock_cc_rp3a0_rd_l.cfg; -} - -int mock_get_cc_rp3a0_rd_l(void) -{ - return mock_cc_rp3a0_rd_l.value; -} - -int mock_get_cfg_cc1_rp3a0_rd_l(void) -{ - return mock_cc1_rp3a0_rd_l.cfg; -} - -int mock_set_cc1_rp3a0_rd_l(int v) -{ - if (mock_cc1_rp3a0_rd_l.cfg == PIN_ADC) { - mock_cc1_rp3a0_rd_l.value = v; - return 1; - } - - return 0; -} - -/* Convert CC voltage to CC status */ -static int vpd_cc_voltage_to_status(int cc_volt, int cc_pull) -{ - /* If we have a pull-up, then we are source, check for Rd. */ - if (cc_pull == TYPEC_CC_RP) { - if (CC_NC(0, cc_volt, 0)) - return TYPEC_CC_VOLT_OPEN; - else if (CC_RA(0, cc_volt, 0)) - return TYPEC_CC_VOLT_RA; - else - return TYPEC_CC_VOLT_RD; - /* If we have a pull-down, then we are sink, check for Rp. */ - } else if (cc_pull == TYPEC_CC_RD || cc_pull == TYPEC_CC_RA_RD) { - if (cc_volt >= TYPE_C_SRC_3000_THRESHOLD) - return TYPEC_CC_VOLT_RP_3_0; - else if (cc_volt >= TYPE_C_SRC_1500_THRESHOLD) - return TYPEC_CC_VOLT_RP_1_5; - else if (CC_RP(cc_volt)) - return TYPEC_CC_VOLT_RP_DEF; - else - return TYPEC_CC_VOLT_OPEN; - } else { - /* If we are open, then always return 0 */ - return 0; - } -} - -void vpd_ct_set_pull(int pull, int rp_value) -{ - ct_cc_pull = pull; - - switch (pull) { - case TYPEC_CC_RP: - ct_cc_rp_value = rp_value; - vpd_cc1_cc2_db_en_l(GPO_HIGH); - switch (rp_value) { - case TYPEC_RP_USB: - vpd_config_cc1_rp3a0_rd_l(PIN_ADC, 0); - vpd_config_cc2_rp3a0_rd_l(PIN_ADC, 0); - vpd_config_cc1_rpusb_odh(PIN_GPO, 1); - vpd_config_cc2_rpusb_odh(PIN_GPO, 1); - break; - case TYPEC_RP_3A0: - vpd_config_cc1_rpusb_odh(PIN_ADC, 0); - vpd_config_cc2_rpusb_odh(PIN_ADC, 0); - vpd_config_cc1_rp3a0_rd_l(PIN_GPO, 1); - vpd_config_cc2_rp3a0_rd_l(PIN_GPO, 1); - break; - } - break; - case TYPEC_CC_RD: - vpd_config_cc1_rpusb_odh(PIN_ADC, 0); - vpd_config_cc2_rpusb_odh(PIN_ADC, 0); - vpd_config_cc1_rp3a0_rd_l(PIN_ADC, 0); - vpd_config_cc2_rp3a0_rd_l(PIN_ADC, 0); - vpd_cc1_cc2_db_en_l(GPO_LOW); - break; - case TYPEC_CC_OPEN: - vpd_cc1_cc2_db_en_l(GPO_HIGH); - vpd_config_cc1_rpusb_odh(PIN_ADC, 0); - vpd_config_cc2_rpusb_odh(PIN_ADC, 0); - vpd_config_cc1_rp3a0_rd_l(PIN_ADC, 0); - vpd_config_cc2_rp3a0_rd_l(PIN_ADC, 0); - break; - } -} - -void vpd_ct_get_cc(int *cc1, int *cc2) -{ - int cc1_v; - int cc2_v; - - switch (ct_cc_pull) { - case TYPEC_CC_RP: - switch (ct_cc_rp_value) { - case TYPEC_RP_USB: - cc1_v = mock_cc1_rp3a0_rd_l.value; - cc2_v = mock_cc2_rp3a0_rd_l.value; - break; - case TYPEC_RP_3A0: - cc1_v = mock_cc1_rpusb_odh.value; - cc2_v = mock_cc2_rpusb_odh.value; - break; - } - - if (!cc1_v && !cc2_v) { - cc1_v = PD_SRC_VNC; - cc2_v = PD_SRC_VNC; - } - break; - case TYPEC_CC_RD: - cc1_v = mock_cc1_rpusb_odh.value; - cc2_v = mock_cc2_rpusb_odh.value; - break; - case TYPEC_CC_OPEN: - *cc1 = 0; - *cc2 = 0; - return; - } - - *cc1 = vpd_cc_voltage_to_status(cc1_v, ct_cc_pull); - *cc2 = vpd_cc_voltage_to_status(cc2_v, ct_cc_pull); -} - -void vpd_host_set_pull(int pull, int rp_value) -{ - host_cc_pull = pull; - - switch (pull) { - case TYPEC_CC_RP: - vpd_cc_db_en_od(GPO_LOW); - host_cc_rp_value = rp_value; - switch (rp_value) { - case TYPEC_RP_USB: - vpd_config_cc_rp3a0_rd_l(PIN_CMP, 0); - vpd_cc_rpusb_odh(GPO_HIGH); - break; - case TYPEC_RP_3A0: - vpd_cc_rpusb_odh(GPO_HZ); - vpd_config_cc_rp3a0_rd_l(PIN_GPO, 1); - break; - } - break; - case TYPEC_CC_RD: - vpd_cc_rpusb_odh(GPO_HZ); - vpd_cc_db_en_od(GPO_LOW); - - vpd_config_cc_rp3a0_rd_l(PIN_GPO, 0); - break; - case TYPEC_CC_RA_RD: - vpd_cc_rpusb_odh(GPO_HZ); - vpd_config_cc_rp3a0_rd_l(PIN_GPO, 0); - - /* - * RA is connected to VCONN - * RD is connected to CC - */ - vpd_cc_db_en_od(GPO_HZ); - break; - case TYPEC_CC_OPEN: - vpd_cc_rpusb_odh(GPO_HZ); - vpd_config_cc_rp3a0_rd_l(PIN_CMP, 0); - vpd_cc_db_en_od(GPO_LOW); - - /* - * Do nothing. CC is open on entry to this function - */ - break; - } -} - -void vpd_host_get_cc(int *cc) -{ - int v; - - if (host_cc_pull == TYPEC_CC_OPEN) { - *cc = 0; - return; - } else if (host_cc_pull == TYPEC_CC_RP) { - v = mock_cc_vpdmcu.value; - } else { - v = mock_cc_vpdmcu.value2; - } - - *cc = vpd_cc_voltage_to_status(v, host_cc_pull); -} - -void vpd_rx_enable(int en) -{ - if (en) { - mock_ct_cl_sel = 0; - mock_mcu_cc_en = 1; - } - - tcpm_set_polarity(0, 0); - tcpm_set_rx_enable(0, en); -} - -/* - * PA1: Configure as ADC, CMP, or GPO - */ -void vpd_config_cc_vpdmcu(enum vpd_pin cfg, int en) -{ - mock_cc_vpdmcu.cfg = cfg; - - if (cfg == PIN_GPO) - mock_cc_vpdmcu.value = en ? 1 : 0; -} - -/* - * PA2: Configure as COMP2_INM6 or GPO - */ -void vpd_config_cc_rp3a0_rd_l(enum vpd_pin cfg, int en) -{ - mock_cc_rp3a0_rd_l.cfg = cfg; - - if (cfg == PIN_GPO) - mock_cc_rp3a0_rd_l.value = en ? 1 : 0; -} - -/* - * PA4: Configure as ADC, CMP, or GPO - */ -void vpd_config_cc1_rp3a0_rd_l(enum vpd_pin cfg, int en) -{ - mock_cc1_rp3a0_rd_l.cfg = cfg; - - if (cfg == PIN_GPO) - mock_cc1_rp3a0_rd_l.value = en ? 1 : 0; -} - -/* - * PA5: Configure as ADC, COMP, or GPO - */ -void vpd_config_cc2_rp3a0_rd_l(enum vpd_pin cfg, int en) -{ - mock_cc2_rp3a0_rd_l.cfg = cfg; - - if (cfg == PIN_GPO) - mock_cc2_rp3a0_rd_l.value = en ? 1 : 0; -} - -/* - * PB0: Configure as ADC or GPO - */ -void vpd_config_cc1_rpusb_odh(enum vpd_pin cfg, int en) -{ - mock_cc1_rpusb_odh.cfg = cfg; - - if (cfg == PIN_GPO) - mock_cc1_rpusb_odh.value = en ? 1 : 0; -} - -/* - * PB1: Configure as ADC or GPO - */ -void vpd_config_cc2_rpusb_odh(enum vpd_pin cfg, int en) -{ - mock_cc2_rpusb_odh.cfg = cfg; - - if (cfg == PIN_GPO) - mock_cc2_rpusb_odh.value = en ? 1 : 0; -} - -int vpd_read_host_vbus(void) -{ - return mock_read_host_vbus; -} - -int vpd_read_ct_vbus(void) -{ - return mock_read_ct_vbus; -} - -int vpd_read_vconn(void) -{ - return mock_read_vconn; -} - -int vpd_is_host_vbus_present(void) -{ - return (vpd_read_host_vbus() >= PD_SNK_VA); -} - -int vpd_is_ct_vbus_present(void) -{ - return (vpd_read_ct_vbus() >= PD_SNK_VA); -} - -int vpd_is_vconn_present(void) -{ - return (vpd_read_vconn() >= PD_SNK_VA); -} - -int vpd_read_rdconnect_ref(void) -{ - return 200; /* 200 mV */ -} - -void vpd_red_led(int on) -{ - mock_red_led = on ? 0 : 1; -} - -void vpd_green_led(int on) -{ - mock_green_led = on ? 0 : 1; -} - -void vpd_vbus_pass_en(int en) -{ - mock_vbus_pass_en = en ? 1 : 0; -} - -void vpd_present_billboard(enum vpd_billboard bb) -{ - mock_present_billboard = bb; -} - -void vpd_mcu_cc_en(int en) -{ - mock_mcu_cc_en = en ? 1 : 0; -} - -void vpd_ct_cc_sel(enum vpd_cc sel) -{ - mock_ct_cl_sel = sel; -} - -/* Set as GPO High, GPO Low, or High-Z */ -void vpd_cc_db_en_od(enum vpd_gpo val) -{ - mock_cc_db_en_od = val; -} - -void vpd_cc_rpusb_odh(enum vpd_gpo val) -{ - mock_cc_rpusb_odh = val; -} - -void vpd_cc1_cc2_db_en_l(enum vpd_gpo val) -{ - mock_cc1_cc2_rd_l = val; -} - -void vpd_vconn_pwr_sel_odl(enum vpd_pwr en) -{ - mock_vconn_pwr_sel_odl = en; -} diff --git a/test/vpd_api.h b/test/vpd_api.h deleted file mode 100644 index 3db4803288..0000000000 --- a/test/vpd_api.h +++ /dev/null @@ -1,333 +0,0 @@ -/* Copyright 2019 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Vconn Power Device API module */ - -#ifndef __CROS_EC_VPD_API_H -#define __CROS_EC_VPD_API_H - -#include "adc.h" -#include "gpio.h" -#include "usb_pd.h" - -/* - * Type C power source charge current limits are identified by their cc - * voltage (set by selecting the proper Rd resistor). Any voltage below - * TYPE_C_SRC_DEFAULT_THRESHOLD will not be identified as a type C charger. - */ -#define TYPE_C_SRC_DEFAULT_THRESHOLD 200 /* mV */ -#define TYPE_C_SRC_1500_THRESHOLD 660 /* mV */ -#define TYPE_C_SRC_3000_THRESHOLD 1230 /* mV */ - - -enum vpd_pin { - PIN_ADC, - PIN_CMP, - PIN_GPO -}; - -enum vpd_gpo { - GPO_HZ, - GPO_HIGH, - GPO_LOW -}; - -enum vpd_pwr { - PWR_VCONN, - PWR_VBUS, -}; - -enum vpd_cc { - CT_OPEN, - CT_CC1, - CT_CC2 -}; - -enum vpd_billboard { - BB_NONE, - BB_SRC, - BB_SNK -}; - -struct mock_pin { - enum vpd_pin cfg; - int value; - int value2; -}; - -enum vpd_pwr mock_get_vconn_pwr_source(void); -enum vpd_gpo mock_get_ct_rd(void); -enum vpd_gpo mock_get_cc_rp1a5_odh(void); -enum vpd_gpo mock_get_cc_rpusb_odh(void); -enum vpd_gpo mock_get_cc_db_en_od(void); -enum vpd_cc moch_get_ct_cl_sel(void); -int mock_get_mcu_cc_en(void); -enum vpd_billboard mock_get_present_billboard(void); -int mock_get_red_led(void); -int mock_get_green_led(void); -int mock_get_vbus_pass_en(void); -int mock_set_cc_vpdmcu(int v); -void mock_set_host_vbus(int v); -void mock_set_ct_vbus(int v); -void mock_set_vconn(int v); -int mock_get_cfg_cc2_rpusb_odh(void); -int mock_set_cc2_rpusb_odh(int v); -int mock_get_cfg_cc2_rp3a0_rd_l(void); -int mock_set_cc2_rp3a0_rd_l(int v); -int mock_get_cfg_cc1_rpusb_odh(void); -int mock_set_cc1_rpusb_odh(int v); -int mock_get_cfg_cc_vpdmcu(void); -int mock_get_cc_vpdmcu(int v); -enum vpd_pin mock_get_cfg_cc_rp3a0_rd_l(void); -int mock_get_cc_rp3a0_rd_l(void); -int mock_get_cfg_cc1_rp3a0_rd_l(void); -int mock_set_cc1_rp3a0_rd_l(int v); -void mock_set_host_cc_sink_voltage(int v); -void mock_set_host_cc_source_voltage(int v); -int mock_get_ct_cc1_rpusb(void); -int mock_get_ct_cc2_rpusb(void); - -/** - * Set Charge-Through Rp or Rd on CC lines - * - * @param pull Either TYPEC_CC_RP or TYPEC_CC_RD - * @param rp_value When pull is RP, set this to - * TYPEC_RP_USB or TYPEC_RP_1A5. Ignored - * for TYPEC_CC_RD - */ -void vpd_ct_set_pull(int pull, int rp_value); - -/** - * Get the status of the Charge-Through CC lines - * - * @param cc1 Either TYPEC_CC_VOLT_OPEN, - * TYPEC_CC_VOLT_RA, - * TYPEC_CC_VOLT_RD, - * any other value is considered RP - * @param cc2 Either TYPEC_CC_VOLT_OPEN, - * TYPEC_CC_VOLT_RA, - * TYPEC_CC_VOLT_RD, - * any other value is considered RP - */ -void vpd_ct_get_cc(int *cc1, int *cc2); - -/** - * Set Host Rp or Rd on CC lines - * - * @param pull Either TYPEC_CC_RP or TYPEC_CC_RD - * @param rp_value When pull is RP, set this to - * TYPEC_RP_USB or TYPEC_RP_1A5. Ignored - * for TYPEC_CC_RD - */ -void vpd_host_set_pull(int pull, int rp_value); - -/** - * Get the status of the Host CC line - * - * @param cc Either TYPEC_CC_VOLT_SNK_DEF, TYPEC_CC_VOLT_SNK_1_5, - * TYPEC_CC_VOLT_SNK_3_0, or TYPEC_CC_RD - */ -void vpd_host_get_cc(int *cc); - -/** - * Set RX Enable flag - * - * @param en 1 for enable, 0 for disable - */ -void vpd_rx_enable(int en); - -/** - * Configure the cc_vpdmcu pin as ADC, CMP, or GPO - * - * @param cfg PIN_ADC, PIN_CMP, or PIN_GPO - * @param en When cfg is PIN_GPO, 1 sets pin high - * and 0 sets pin low. Else ignored - */ -void vpd_config_cc_vpdmcu(enum vpd_pin cfg, int en); - -/** - * Configure the cc_rp3a0_rd_l pin as ADC, CMP, or GPO - * - * @param cfg PIN_ADC, PIN_CMP, or PIN_GPO - * @param en When cfg is PIN_GPO, 1 sets pin high - * and 0 sets pin low. Else ignored - */ -void vpd_config_cc_rp3a0_rd_l(enum vpd_pin cfg, int en); - -/** - * Configure the cc1_rp3a0_rd_l pin as ADC, CMP, or GPO - * - * @param cfg PIN_ADC, PIN_CMP, or PIN_GPO - * @param en When cfg is PIN_GPO, 1 sets pin high - * and 0 sets pin low. Else ignored - */ -void vpd_config_cc1_rp3a0_rd_l(enum vpd_pin cfg, int en); - -/** - * Configure the cc2_rp3a0_rd_l pin as ADC, CMP, or GPO - * - * @param cfg PIN_ADC, PIN_CMP, or PIN_GPO - * @param en When cfg is PIN_GPO, 1 sets pin high - * and 0 sets pin low. Else ignored - */ -void vpd_config_cc2_rp3a0_rd_l(enum vpd_pin cfg, int en); - -/** - * Configure the cc1_rpusb_odh pin as ADC, CMP, or GPO - * - * @param cfg PIN_ADC, PIN_CMP, or PIN_GPO - * @param en When cfg is PIN_GPO, 1 sets pin high - * and 0 sets pin low. Else ignored - */ -void vpd_config_cc1_rpusb_odh(enum vpd_pin cfg, int en); - -/** - * Configure the cc2_rpusb_odh pin as ADC, CMP, or GPO - * - * @param cfg PIN_ADC, PIN_CMP, or PIN_GPO - * @param en When cfg is PIN_GPO, 1 sets pin high - * and 0 sets pin low. Else ignored - */ -void vpd_config_cc2_rpusb_odh(enum vpd_pin cfg, int en); - -/** - * Configure the cc_db_en_od pin to High-Impedance, low, or high - * - * @param val GPO_HZ, GPO_HIGH, GPO_LOW - */ -void vpd_cc_db_en_od(enum vpd_gpo val); - -/** - * Configure the cc_rpusb_odh pin to High-Impedance, low, or high - * - * @param val GPO_HZ, GPO_HIGH, GPO_LOW - */ -void vpd_cc_rpusb_odh(enum vpd_gpo val); - -/** - * Configure the cc_rp1a5_odh pin to High-Impedance, low, or high - * - * @param val GPO_HZ, GPO_HIGH, GPO_LOW - */ -void vpd_cc_rp1a5_odh(enum vpd_gpo val); - -/** - * Configure the cc1_cc2_db_en_l pin to High-Impedance, low, or high - * - * @param val GPO_HZ, GPO_HIGH, GPO_LOW - */ -void vpd_cc1_cc2_db_en_l(enum vpd_gpo val); - -/** - * Get status of host vbus - * - * @return 1 if host vbus is present, else 0 - */ -int vpd_is_host_vbus_present(void); - -/** - * Get status of charge-through vbus - * - * @return 1 if charge-through vbus is present, else 0 - */ -int vpd_is_ct_vbus_present(void); - -/** - * Get status of vconn - * - * @return 1 if vconn is present, else 0 - */ -int vpd_is_vconn_present(void); - -/** - * Read Host VBUS voltage. Range from 22000mV to 3000mV - * - * @return vbus voltage - */ -int vpd_read_host_vbus(void); - -/** - * Read Host CC voltage. - * - * @return cc voltage - */ -int vpd_read_cc_host(void); - -/** - * Read voltage on cc_vpdmcu pin - * - * @return cc_vpdmcu voltage - */ -int vpd_read_cc_vpdmcu(void); - -/** - * Read charge-through VBUS voltage. Range from 22000mV to 3000mV - * - * @return charge-through vbus voltage - */ -int vpd_read_ct_vbus(void); - -/** - * Read VCONN Voltage. Range from 5500mV to 3000mV - * - * @return vconn voltage - */ -int vpd_read_vconn(void); - -/** - * Turn ON/OFF Red LED. Should be off when performing power - * measurements. - * - * @param on 0 turns LED off, any other value turns it ON - */ -void vpd_red_led(int on); - -/** - * Turn ON/OFF Green LED. Should be off when performing power - * measurements. - * - * @param on 0 turns LED off, any other value turns it ON - */ -void vpd_green_led(int on); - -/** - * Connects/Disconnects the Host VBUS to the Charge-Through VBUS. - * - * @param en 0 disconnectes the VBUS, any other value connects VBUS. - */ -void vpd_vbus_pass_en(int en); - -/** - * Preset Billboard device - * - * @param bb BB_NONE no billboard presented, - * BB_SRC source connected but not in charge-through - * BB_SNK sink connected - */ -void vpd_present_billboard(enum vpd_billboard bb); - -/** - * Enables the MCU to host cc communication - * - * @param en 1 enabled, 0 disabled - */ -void vpd_mcu_cc_en(int en); - -/** - * Selects which supply to power the VPD from - * - * @param en PWR_VCONN or PWR_VBUS - */ -void vpd_vconn_pwr_sel_odl(enum vpd_pwr en); - -/** - * Controls if the Charge-Through's CC1, CC2, or neither is - * connected to Host CC - * - * @param sel CT_OPEN neither, CT_CC1 cc1, CT_CC2 cc2 - */ -void vpd_ct_cc_sel(enum vpd_cc sel); - -#endif /* __CROS_EC_VPD_API_H */ |