diff options
Diffstat (limited to 'zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c')
-rw-r--r-- | zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c | 64 |
1 files changed, 12 insertions, 52 deletions
diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c index c57054881d..c73cf26f37 100644 --- a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c +++ b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c @@ -3,6 +3,10 @@ * found in the LICENSE file. */ +#include <zephyr/sys/byteorder.h> +#include <zephyr/sys/slist.h> +#include <zephyr/ztest.h> + #include "battery.h" #include "battery_smart.h" #include "dps.h" @@ -15,18 +19,11 @@ #include "test/drivers/utils.h" #include "usb_pd.h" -#include <zephyr/shell/shell_dummy.h> -#include <zephyr/sys/byteorder.h> -#include <zephyr/sys/slist.h> -#include <zephyr/ztest.h> - #define BATTERY_NODE DT_NODELABEL(battery) #define GPIO_BATT_PRES_ODL_PATH DT_PATH(named_gpios, ec_batt_pres_odl) #define GPIO_BATT_PRES_ODL_PORT DT_GPIO_PIN(GPIO_BATT_PRES_ODL_PATH, gpios) -#define TEST_PORT 0 - struct usb_attach_5v_3a_pd_source_fixture { struct tcpci_partner_data source_5v_3a; struct tcpci_src_emul_data src_ext; @@ -39,8 +36,8 @@ static void *usb_attach_5v_3a_pd_source_setup(void) static struct usb_attach_5v_3a_pd_source_fixture test_fixture; /* Get references for the emulators */ - test_fixture.tcpci_emul = EMUL_GET_USBC_BINDING(TEST_PORT, tcpc); - test_fixture.charger_emul = EMUL_GET_USBC_BINDING(TEST_PORT, chg); + test_fixture.tcpci_emul = EMUL_GET_USBC_BINDING(0, tcpc); + test_fixture.charger_emul = EMUL_GET_USBC_BINDING(0, chg); /* Initialized the charger to supply 5V and 3A */ tcpci_partner_init(&test_fixture.source_5v_3a, PD_REV20); @@ -73,7 +70,7 @@ static void control_battery_present(bool present) DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_BATT_PRES_ODL_PATH, gpios)); /* 0 means battery present */ - zassert_ok(gpio_emul_input_set(dev, GPIO_BATT_PRES_ODL_PORT, !present)); + zassume_ok(gpio_emul_input_set(dev, GPIO_BATT_PRES_ODL_PORT, !present)); } ZTEST_SUITE(usb_attach_5v_3a_pd_source, drivers_predicate_post_main, @@ -85,7 +82,7 @@ ZTEST(usb_attach_5v_3a_pd_source, test_battery_is_charging) const struct emul *emul = EMUL_DT_GET(BATTERY_NODE); uint16_t battery_status; - zassert_ok(sbat_emul_get_word_val(emul, SB_BATTERY_STATUS, + zassume_ok(sbat_emul_get_word_val(emul, SB_BATTERY_STATUS, &battery_status)); zassert_equal(battery_status & STATUS_DISCHARGING, 0, "Battery is discharging: %d", battery_status); @@ -93,8 +90,7 @@ ZTEST(usb_attach_5v_3a_pd_source, test_battery_is_charging) ZTEST(usb_attach_5v_3a_pd_source, test_charge_state) { - struct ec_response_charge_state state = - host_cmd_charge_state(TEST_PORT); + struct ec_response_charge_state state = host_cmd_charge_state(0); zassert_true(state.get_state.ac, "AC_OK not triggered"); zassert_true(state.get_state.chg_voltage > 0, @@ -165,16 +161,16 @@ ZTEST_F(usb_attach_5v_3a_pd_source, test_disconnect_charge_state) struct ec_response_charge_state charge_state; disconnect_source_from_port(fixture->tcpci_emul, fixture->charger_emul); - charge_state = host_cmd_charge_state(TEST_PORT); + charge_state = host_cmd_charge_state(0); zassert_false(charge_state.get_state.ac, "AC_OK not triggered"); zassert_equal(charge_state.get_state.chg_current, 0, "Max charge current expected 0mA, but was %dmA", charge_state.get_state.chg_current); zassert_equal(charge_state.get_state.chg_input_current, - CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT, + CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT, "Charge input current limit expected %dmA, but was %dmA", - CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT, + CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT, charge_state.get_state.chg_input_current); } @@ -325,39 +321,3 @@ ZTEST_F(usb_attach_5v_3a_pd_source, test_dps_enable) dps_enable(true); zassert_true(dps_is_enabled()); } - -ZTEST_F(usb_attach_5v_3a_pd_source, test_dps_info) -{ - const struct shell *shell_zephyr = get_ec_shell(); - - const char *outbuffer; - uint32_t buffer_size; - /* Arbitrary array size for sprintf should not need this amount */ - char format_buffer[100]; - - shell_backend_dummy_clear_output(shell_zephyr); - - /* Print current status to console */ - zassert_ok(shell_execute_cmd(shell_zephyr, "dps"), NULL); - outbuffer = shell_backend_dummy_get_output(shell_zephyr, &buffer_size); - - /* Should include extra information about the charging port */ - /* Charging Port */ - sprintf(format_buffer, "C%d", TEST_PORT); - zassert_not_null(strstr(outbuffer, format_buffer)); - /* We are a sink to a 5v3a source, so check requested mv/ma */ - sprintf(format_buffer, "Requested: %dmV/%dmA", 5000, 3000); - zassert_not_null(strstr(outbuffer, format_buffer)); - /* - * Measured input power is shown (values vary so not asserting on - * numbers) - */ - zassert_not_null(strstr(outbuffer, "Measured:")); - /* Efficient Voltage - Value varies based on battery*/ - zassert_not_null(strstr(outbuffer, "Efficient:")); - /* Battery Design Voltage (varies based on battery) */ - zassert_not_null(strstr(outbuffer, "Batt:")); - /* PDMaxMV */ - sprintf(format_buffer, "PDMaxMV: %dmV", pd_get_max_voltage()); - zassert_not_null(strstr(outbuffer, format_buffer)); -} |