summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Bettis <jbettis@google.com>2022-05-06 15:58:13 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-05-11 22:58:28 +0000
commit4b38a923f7f120b80430fcc045c5e163d061188e (patch)
tree7ffea88e13829e2f7b640fbe7b431ac9517c6bbe
parent499030dd4e27c290fb8c59eb36110c67bccb0bba (diff)
downloadchrome-ec-4b38a923f7f120b80430fcc045c5e163d061188e.tar.gz
ec: Make tests pass with TEST_ASAN=y
There are some mismatched enums and other errors that prevent building with asan. Fix them all. Change the cq builder to prevent these breakages in the future. If the tests pass with ASAN in the chroot, they will likely pass in gitlab with coverage enabled. BRANCH=None BUG=None TEST=make clobber ; make -j8 runtests && echo PASS make clobber ; make -j8 TEST_ASAN=y runtests && echo PASS Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I6d86fd5750282e0257eb97f65b31046a1613a453 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3631365 Reviewed-by: Keith Short <keithshort@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
-rw-r--r--common/online_calibration.c8
-rwxr-xr-xfirmware_builder.py5
-rw-r--r--test/build.mk3
-rw-r--r--test/usb_prl_old.c8
-rw-r--r--test/usb_sm_checks.c10
5 files changed, 19 insertions, 15 deletions
diff --git a/common/online_calibration.c b/common/online_calibration.c
index 3bc56f85c7..6ff46f4714 100644
--- a/common/online_calibration.c
+++ b/common/online_calibration.c
@@ -201,11 +201,9 @@ void online_calibration_init(void)
struct motion_sensor_t *s = motion_sensors + i;
void *type_specific_data = NULL;
- if (s->online_calib_data) {
- s->online_calib_data->last_temperature = -1;
- type_specific_data =
- s->online_calib_data->type_specific_data;
- }
+ s->online_calib_data->last_temperature = -1;
+ type_specific_data =
+ s->online_calib_data->type_specific_data;
if (!type_specific_data)
continue;
diff --git a/firmware_builder.py b/firmware_builder.py
index 1a7b6c8749..6b5d094edf 100755
--- a/firmware_builder.py
+++ b/firmware_builder.py
@@ -211,6 +211,11 @@ def test(opts):
print(f"# Running {' '.join(cmd)}.")
subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True)
+ # Verify the tests pass with ASan also
+ cmd = ['make', 'TEST_ASAN=y', target, f'-j{opts.cpus}']
+ print(f"# Running {' '.join(cmd)}.")
+ subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True)
+
def main(args):
"""Builds, bundles, or tests all of the EC targets.
diff --git a/test/build.mk b/test/build.mk
index 3184f0a8f1..fac9544ca4 100644
--- a/test/build.mk
+++ b/test/build.mk
@@ -47,7 +47,10 @@ test-list-host += inductive_charging
# test-list-host += interrupt
test-list-host += irq_locking
test-list-host += is_enabled
+ifeq ($(TEST_ASAN),)
+# is_enabled_error fails with TEST_ASAN
test-list-host += is_enabled_error
+endif
test-list-host += kasa
test-list-host += kb_8042
test-list-host += kb_mkbp
diff --git a/test/usb_prl_old.c b/test/usb_prl_old.c
index c4a8991bd6..a6ae6acb0e 100644
--- a/test/usb_prl_old.c
+++ b/test/usb_prl_old.c
@@ -208,7 +208,7 @@ static void cycle_through_state_machine(int port, uint32_t num, uint32_t time)
}
}
-static int simulate_request_chunk(int port, enum pd_data_msg_type msg_type,
+static int simulate_request_chunk(int port, enum pd_ext_msg_type msg_type,
int chunk_num, int len)
{
uint16_t header = PD_HEADER(msg_type, get_partner_power_role(port),
@@ -568,7 +568,7 @@ static int verify_data_msg_transmission(int port,
}
static int simulate_send_data_msg_request_from_pe(int port,
- enum tcpci_msg_type type, enum pd_ctrl_msg_type msg_type, int len)
+ enum tcpci_msg_type type, enum pd_data_msg_type msg_type, int len)
{
int i;
uint8_t *buf = tx_emsg[port].buf;
@@ -590,7 +590,7 @@ static int simulate_send_data_msg_request_from_pe(int port,
}
static int verify_extended_data_msg_transmission(int port,
- enum pd_data_msg_type msg_type, int len)
+ enum pd_ext_msg_type msg_type, int len)
{
int i;
int j;
@@ -703,7 +703,7 @@ static int verify_extended_data_msg_transmission(int port,
}
static int simulate_send_extended_data_msg(int port,
- enum tcpci_msg_type type, enum pd_ctrl_msg_type msg_type,
+ enum tcpci_msg_type type, enum pd_ext_msg_type msg_type,
int len)
{
int i;
diff --git a/test/usb_sm_checks.c b/test/usb_sm_checks.c
index 468e6f0254..49b2dbae28 100644
--- a/test/usb_sm_checks.c
+++ b/test/usb_sm_checks.c
@@ -116,7 +116,7 @@ __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)
+static int test_all_states_named(const struct test_sm_data *const sm_data)
{
int i;
@@ -125,12 +125,10 @@ static int test_all_states_named(const struct test_sm_data * const sm_data)
state_printed = 0;
- if (current->entry)
+ if (current->entry &&
+ (i >= sm_data->names_size || sm_data->names[i] == NULL)) {
current->entry(0);
-
- if (state_printed) {
- if (i >= sm_data->names_size ||
- sm_data->names[i] == NULL) {
+ if (state_printed) {
ccprintf("State %d does not have a name!\n", i);
TEST_ASSERT(0);
}