summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/abort.c4
-rw-r--r--test/accel_cal.c5
-rw-r--r--test/aes.c (renamed from test/aes.cc)55
-rw-r--r--test/always_memset.c5
-rw-r--r--test/base32.c5
-rw-r--r--test/benchmark.cc98
-rw-r--r--test/benchmark.tasklist9
-rw-r--r--test/build.mk7
-rw-r--r--test/button.c4
-rw-r--r--test/cec.c4
-rw-r--r--test/charge_manager.c4
-rw-r--r--test/charge_ramp.c4
-rw-r--r--test/compile_time_macros.c2
-rw-r--r--test/console_edit.c4
-rw-r--r--test/cortexm_fpu.c3
-rw-r--r--test/entropy.c2
-rw-r--r--test/fake_usbc.c8
-rw-r--r--test/fp.c1
-rw-r--r--test/fpsensor.c8
-rw-r--r--test/fpsensor_crypto.c4
-rw-r--r--test/fpsensor_hw.c (renamed from test/fpsensor_hw.cc)2
-rw-r--r--test/fpsensor_state.c4
-rw-r--r--test/ftrapv.c265
-rw-r--r--test/ftrapv.tasklist10
-rw-r--r--test/gyro_cal.c7
-rw-r--r--test/gyro_cal_init_for_test.c3
-rw-r--r--test/interrupt.c4
-rw-r--r--test/kasa.c3
-rw-r--r--test/kb_8042.c104
-rw-r--r--test/kb_scan.c3
-rw-r--r--test/libc_printf.c28
-rw-r--r--test/libc_printf.tasklist9
-rw-r--r--test/lightbar.c2
-rw-r--r--test/mag_cal.c1
-rw-r--r--test/math_util.c5
-rw-r--r--test/motion_angle.c6
-rw-r--r--test/motion_angle_tablet.c6
-rw-r--r--test/motion_lid.c6
-rw-r--r--test/motion_sense_fifo.c11
-rw-r--r--test/mpu.c26
-rw-r--r--test/mutex.c2
-rw-r--r--test/newton_fit.c3
-rw-r--r--test/nvidia_gpu.c5
-rw-r--r--test/online_calibration.c1
-rw-r--r--test/online_calibration_spoof.c5
-rw-r--r--test/panic_data.c3
-rw-r--r--test/powerdemo.c2
-rw-r--r--test/printf.c8
-rw-r--r--test/rgb_keyboard.c4
-rw-r--r--test/rng_benchmark.cc81
-rw-r--r--test/rng_benchmark.tasklist9
-rw-r--r--test/rollback.c3
-rw-r--r--test/rollback_secret.c4
-rw-r--r--test/rsa.c2
-rw-r--r--test/rtc.c2
-rwxr-xr-xtest/run_device_tests.py12
-rw-r--r--test/sha256.c2
-rw-r--r--test/shmalloc.c10
-rw-r--r--test/stdlib.c2
-rw-r--r--test/stillness_detector.c3
-rw-r--r--test/system_is_locked.c3
-rw-r--r--test/test_config.h8
-rw-r--r--test/uptime.c4
-rw-r--r--test/usb_pd_console.c4
-rw-r--r--test/usb_pd_int.c4
-rw-r--r--test/usb_pe_drp.c14
-rw-r--r--test/usb_pe_drp_noextended.c6
-rw-r--r--test/usb_pe_drp_old.c2
-rw-r--r--test/usb_prl_noextended.c2
-rw-r--r--test/usb_prl_old.c2
-rw-r--r--test/usb_sm_checks.c2
-rw-r--r--test/usb_sm_framework_h3.c2
-rw-r--r--test/usb_tcpmv2_compliance_common.c2
-rw-r--r--test/usb_tcpmv2_td_pd_ll_e3.c2
-rw-r--r--test/usb_tcpmv2_td_pd_ll_e4.c2
-rw-r--r--test/usb_tcpmv2_td_pd_ll_e5.c2
-rw-r--r--test/usb_tcpmv2_td_pd_other.c4
-rw-r--r--test/usb_tcpmv2_td_pd_src3_e1.c2
-rw-r--r--test/usb_tcpmv2_td_pd_src3_e7.c4
-rw-r--r--test/usb_tcpmv2_td_pd_src3_e8.c4
-rw-r--r--test/usb_tcpmv2_td_pd_src3_e9.c4
-rw-r--r--test/usb_tcpmv2_td_pd_src_e1.c2
-rw-r--r--test/usb_tcpmv2_td_pd_src_e2.c2
-rw-r--r--test/usb_tcpmv2_td_pd_src_e5.c2
-rw-r--r--test/usb_tcpmv2_td_pd_vndi3_e3.c2
-rw-r--r--test/usb_test/device_configuration.c5
-rw-r--r--test/usb_typec_ctvpd.c6
-rw-r--r--test/utils_str.c2
-rw-r--r--test/vboot.c4
-rw-r--r--test/version.c2
-rw-r--r--test/vpd_api.c4
91 files changed, 214 insertions, 800 deletions
diff --git a/test/abort.c b/test/abort.c
index dcc798861e..e0069e920f 100644
--- a/test/abort.c
+++ b/test/abort.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
+#include <stdlib.h>
+
#include "common.h"
#include "panic.h"
#include "system.h"
#include "task.h"
#include "test_util.h"
-#include <stdlib.h>
-
test_static int test_abort(void)
{
ccprintf("Calling abort\n");
diff --git a/test/accel_cal.c b/test/accel_cal.c
index 5c50211bd5..481d0615f2 100644
--- a/test/accel_cal.c
+++ b/test/accel_cal.c
@@ -3,11 +3,10 @@
* found in the LICENSE file.
*/
-#include "accel_cal.h"
#include "common.h"
-#include "motion_sense.h"
+#include "accel_cal.h"
#include "test_util.h"
-
+#include "motion_sense.h"
#include <math.h>
struct motion_sensor_t motion_sensors[] = {};
diff --git a/test/aes.cc b/test/aes.c
index 6986abd148..0fc220d997 100644
--- a/test/aes.cc
+++ b/test/aes.c
@@ -14,19 +14,15 @@
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
-#include "benchmark.h"
-#include "common.h"
-#include "test_util.h"
-
-extern "C" {
#include "aes.h"
#include "aes-gcm.h"
#include "builtin/assert.h"
#include "console.h"
+#include "common.h"
+#include "test_util.h"
#include "timer.h"
#include "util.h"
#include "watchdog.h"
-}
/* Temporary buffer, to avoid using too much stack space. */
static uint8_t tmp[512];
@@ -131,9 +127,8 @@ static int test_aes_gcm_raw_non_inplace(const uint8_t *key, int key_size,
static int test_aes_gcm_raw(const uint8_t *key, int key_size,
const uint8_t *plaintext, const uint8_t *ciphertext,
- std::size_t plaintext_size, const uint8_t *nonce,
- std::size_t nonce_size, const uint8_t *tag,
- std::size_t tag_size)
+ int plaintext_size, const uint8_t *nonce,
+ int nonce_size, const uint8_t *tag, int tag_size)
{
TEST_ASSERT(plaintext_size <= sizeof(tmp));
@@ -425,14 +420,14 @@ static int test_aes_gcm(void)
static void test_aes_gcm_speed(void)
{
- Benchmark benchmark({ .num_iterations = 1000 });
+ int i;
static const uint8_t key[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
const int key_size = sizeof(key);
- static uint8_t plaintext[512] = { 0 };
- const auto plaintext_size = sizeof(plaintext);
+ static const uint8_t plaintext[512] = { 0 };
+ const int plaintext_size = sizeof(plaintext);
static const uint8_t nonce[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -441,34 +436,24 @@ static void test_aes_gcm_speed(void)
uint8_t tag[16] = { 0 };
const int tag_size = sizeof(tag);
- uint8_t *encrypted_data = tmp;
+ uint8_t *out = tmp;
static AES_KEY aes_key;
static GCM128_CONTEXT ctx;
+ timestamp_t t0, t1;
assert(plaintext_size <= sizeof(tmp));
- benchmark.run("AES-GCM encrypt", [&]() {
+ t0 = get_time();
+ for (i = 0; i < 1000; i++) {
AES_set_encrypt_key(key, 8 * key_size, &aes_key);
CRYPTO_gcm128_init(&ctx, &aes_key, (block128_f)AES_encrypt, 0);
CRYPTO_gcm128_setiv(&ctx, &aes_key, nonce, nonce_size);
- CRYPTO_gcm128_encrypt(&ctx, &aes_key, plaintext, encrypted_data,
+ CRYPTO_gcm128_encrypt(&ctx, &aes_key, plaintext, out,
plaintext_size);
CRYPTO_gcm128_tag(&ctx, tag, tag_size);
- });
-
- benchmark.run("AES-GCM decrypt", [&]() {
- AES_set_encrypt_key(key, 8 * key_size, &aes_key);
- CRYPTO_gcm128_init(&ctx, &aes_key, (block128_f)AES_encrypt, 0);
- CRYPTO_gcm128_setiv(&ctx, &aes_key, nonce, nonce_size);
- auto decrypt_res =
- CRYPTO_gcm128_decrypt(&ctx, &aes_key, encrypted_data,
- plaintext, plaintext_size);
-
- auto finish_res = CRYPTO_gcm128_finish(&ctx, tag, tag_size);
- assert(decrypt_res);
- assert(finish_res);
- });
- benchmark.print_results();
+ }
+ t1 = get_time();
+ ccprintf("AES-GCM duration %lld us\n", (long long)(t1.val - t0.val));
}
static int test_aes_raw(const uint8_t *key, int key_size,
@@ -558,7 +543,7 @@ static int test_aes(void)
static void test_aes_speed(void)
{
- Benchmark benchmark({ .num_iterations = 1000 });
+ int i;
/* Test vectors from FIPS-197, Appendix C. */
static const uint8_t key[] __aligned(4) = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
@@ -572,13 +557,15 @@ static void test_aes_speed(void)
AES_KEY aes_key;
uint8_t block[AES_BLOCK_SIZE];
+ timestamp_t t0, t1;
AES_set_encrypt_key(key, 8 * key_size, &aes_key);
AES_encrypt(plaintext, block, &aes_key);
- benchmark.run("AES", [&block, &aes_key]() {
+ t0 = get_time();
+ for (i = 0; i < 1000; i++)
AES_encrypt(block, block, &aes_key);
- });
- benchmark.print_results();
+ t1 = get_time();
+ ccprintf("AES duration %lld us\n", (long long)(t1.val - t0.val));
}
void run_test(int argc, const char **argv)
diff --git a/test/always_memset.c b/test/always_memset.c
index eed15cab27..40a68d883b 100644
--- a/test/always_memset.c
+++ b/test/always_memset.c
@@ -10,11 +10,12 @@
* If optimization is disabled, the test_optimization_working test will fail.
*/
+#include <string.h>
+
#include "common.h"
-#include "cryptoc/util.h"
#include "test_util.h"
-#include <string.h>
+#include "cryptoc/util.h"
/* 256 bytes of stack is only safe enough for a memcpy. */
#define EXTRA_STACK_SIZE 256
diff --git a/test/base32.c b/test/base32.c
index 50b9d994c1..c1ec489ea0 100644
--- a/test/base32.c
+++ b/test/base32.c
@@ -5,13 +5,12 @@
* Test Base-32 encoding/decoding
*/
-#include "base32.h"
+#include <stdio.h>
#include "common.h"
+#include "base32.h"
#include "test_util.h"
#include "util.h"
-#include <stdio.h>
-
DECLARE_EC_TEST(test_crc5)
{
uint32_t seen;
diff --git a/test/benchmark.cc b/test/benchmark.cc
deleted file mode 100644
index e28bfbd999..0000000000
--- a/test/benchmark.cc
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Simple test to validate the benchmark library.
- */
-
-#include "benchmark.h"
-
-extern "C" {
-#include "test_util.h"
-}
-
-/* Sample function for the benchmark */
-static void float_mult()
-{
- float a = 1.1;
- float b = 1.1;
- int i;
-
- for (i = 0; i < 1000; ++i)
- a *= b;
-}
-
-test_static int test_valid_benchmark()
-{
- Benchmark benchmark;
-
- auto result = benchmark.run("float_mult", float_mult);
- TEST_ASSERT(result.has_value());
-
- benchmark.print_results();
- return EC_SUCCESS;
-}
-
-test_static int test_num_iterations()
-{
- Benchmark benchmark({ .num_iterations = 5 });
- int num_calls = 0;
-
- auto result = benchmark.run("call_counter", [&] { ++num_calls; });
- TEST_ASSERT(result.has_value());
- TEST_EQ(num_calls, 5, "%d");
-
- return EC_SUCCESS;
-}
-
-test_static int test_empty_benchmark_name()
-{
- Benchmark benchmark;
- TEST_ASSERT(!benchmark.run("", [] {}).has_value());
- return EC_SUCCESS;
-}
-
-test_static int test_too_many_runs()
-{
- auto benchmark = Benchmark<3>();
- TEST_ASSERT(benchmark.run("call_1", [] {}).has_value());
- TEST_ASSERT(benchmark.run("call_2", [] {}).has_value());
- TEST_ASSERT(benchmark.run("call_3", [] {}).has_value());
- TEST_ASSERT(!benchmark.run("call_4", [] {}).has_value());
-
- return EC_SUCCESS;
-}
-
-test_static int test_min_max_time()
-{
- // Run test 3 times with increasing delay of 1ms, 2ms, and 4ms
- Benchmark benchmark({ .num_iterations = 3 });
- int delay_us = 1000;
-
- auto result = benchmark.run("delay", [&delay_us] {
- udelay(delay_us);
- delay_us *= 2;
- });
- TEST_ASSERT(result.has_value());
-
- auto min_time = result.value().min_time;
- auto max_time = result.value().max_time;
-
- TEST_GE(min_time, 995U, "%u");
- TEST_LE(min_time, 1005U, "%u");
- TEST_GE(max_time, 3995U, "%u");
- TEST_LE(max_time, 4005U, "%u");
-
- return EC_SUCCESS;
-}
-
-void run_test(int argc, const char **argv)
-{
- test_reset();
- RUN_TEST(test_valid_benchmark);
- RUN_TEST(test_num_iterations);
- RUN_TEST(test_too_many_runs);
- RUN_TEST(test_empty_benchmark_name);
- RUN_TEST(test_min_max_time);
- test_print_result();
-}
diff --git a/test/benchmark.tasklist b/test/benchmark.tasklist
deleted file mode 100644
index 6d43377af5..0000000000
--- a/test/benchmark.tasklist
+++ /dev/null
@@ -1,9 +0,0 @@
-/* Copyright 2022 The ChromiumOS 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/build.mk b/test/build.mk
index 30908d309e..08e2d15c9f 100644
--- a/test/build.mk
+++ b/test/build.mk
@@ -24,7 +24,6 @@ test-list-host += aes
test-list-host += always_memset
test-list-host += base32
test-list-host += battery_get_params_smart
-test-list-host += benchmark
test-list-host += bklight_lid
test-list-host += bklight_passthru
test-list-host += body_detection
@@ -170,7 +169,6 @@ aes-y=aes.o
always_memset-y=always_memset.o
base32-y=base32.o
battery_get_params_smart-y=battery_get_params_smart.o
-benchmark-y=benchmark.o
bklight_lid-y=bklight_lid.o
bklight_passthru-y=bklight_passthru.o
body_detection-y=body_detection.o body_detection_data_literals.o motion_common.o
@@ -198,7 +196,6 @@ fpsensor-y=fpsensor.o
fpsensor_crypto-y=fpsensor_crypto.o
fpsensor_hw-y=fpsensor_hw.o
fpsensor_state-y=fpsensor_state.o
-ftrapv-y=ftrapv.o
gyro_cal-y=gyro_cal.o gyro_cal_init_for_test.o
hooks-y=hooks.o
host_command-y=host_command.o
@@ -224,9 +221,6 @@ online_calibration-y=online_calibration.o
online_calibration_spoof-y=online_calibration_spoof.o gyro_cal_init_for_test.o
rgb_keyboard-y=rgb_keyboard.o
kasa-y=kasa.o
-ifeq ($(USE_BUILTIN_STDLIB), 0)
-libc_printf-y=libc_printf.o
-endif
mpu-y=mpu.o
mutex-y=mutex.o
newton_fit-y=newton_fit.o
@@ -237,7 +231,6 @@ power_button-y=power_button.o
powerdemo-y=powerdemo.o
printf-y=printf.o
queue-y=queue.o
-rng_benchmark-y=rng_benchmark.o
rollback-y=rollback.o
rollback_entropy-y=rollback_entropy.o
rollback_secret-y=rollback_secret.o
diff --git a/test/button.c b/test/button.c
index 3a46625660..c1acba7048 100644
--- a/test/button.c
+++ b/test/button.c
@@ -15,10 +15,10 @@
#include "console.h"
#include "gpio.h"
#include "host_command.h"
-#include "keyboard_config.h"
-#include "keyboard_protocol.h"
#include "test_util.h"
#include "timer.h"
+#include "keyboard_config.h"
+#include "keyboard_protocol.h"
#include "util.h"
#define UNCHANGED -1
diff --git a/test/cec.c b/test/cec.c
index 6d385665a8..7718b7b705 100644
--- a/test/cec.c
+++ b/test/cec.c
@@ -5,11 +5,11 @@
* Test the buffer handling of HDMI CEC
*/
+#include <string.h>
+
#include "cec.h"
#include "test_util.h"
-#include <string.h>
-
struct overflow_msg {
struct cec_msg_transfer transfer;
uint8_t overflow_detector;
diff --git a/test/charge_manager.c b/test/charge_manager.c
index 9d1c888e9d..9a27a419d0 100644
--- a/test/charge_manager.c
+++ b/test/charge_manager.c
@@ -34,8 +34,8 @@ static int new_power_request[CONFIG_USB_PD_PORT_MAX_COUNT];
static enum pd_power_role power_role[CONFIG_USB_PD_PORT_MAX_COUNT];
/* Callback functions called by CM on state change */
-__override void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
+ int charge_mv)
{
active_charge_limit = charge_ma;
}
diff --git a/test/charge_ramp.c b/test/charge_ramp.c
index 056fa67c21..a4d53b31d6 100644
--- a/test/charge_ramp.c
+++ b/test/charge_ramp.c
@@ -73,8 +73,8 @@ int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state)
vbus_low_current_ma;
}
-__override void board_set_charge_limit(int port, int supplier, int limit_ma,
- int max_ma, int max_mv)
+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)
diff --git a/test/compile_time_macros.c b/test/compile_time_macros.c
index 5e5d716627..544da9e0d8 100644
--- a/test/compile_time_macros.c
+++ b/test/compile_time_macros.c
@@ -5,8 +5,8 @@
* Test compile_time_macros.h
*/
-#include "common.h"
#include "stdbool.h"
+#include "common.h"
#include "test_util.h"
static int test_BIT(void)
diff --git a/test/console_edit.c b/test/console_edit.c
index 5ec649be5f..b9753468fd 100644
--- a/test/console_edit.c
+++ b/test/console_edit.c
@@ -7,11 +7,11 @@
#include "common.h"
#include "console.h"
-#include "ec_commands.h"
#include "test_util.h"
#include "timer.h"
-#include "uart.h"
#include "util.h"
+#include "uart.h"
+#include "ec_commands.h"
static int cmd_1_call_cnt;
static int cmd_2_call_cnt;
diff --git a/test/cortexm_fpu.c b/test/cortexm_fpu.c
index f31ec63535..c27edbaf40 100644
--- a/test/cortexm_fpu.c
+++ b/test/cortexm_fpu.c
@@ -3,11 +3,12 @@
* found in the LICENSE file.
*/
+#include "test_util.h"
+
#include "cpu.h"
#include "math.h"
#include "registers.h"
#include "task.h"
-#include "test_util.h"
#include "time.h"
static volatile uint32_t fpscr;
diff --git a/test/entropy.c b/test/entropy.c
index abac349d76..8fbdb9147f 100644
--- a/test/entropy.c
+++ b/test/entropy.c
@@ -5,8 +5,8 @@
* Tests entropy source.
*/
-#include "common.h"
#include "console.h"
+#include "common.h"
#include "rollback.h"
#include "test_util.h"
#include "timer.h"
diff --git a/test/fake_usbc.c b/test/fake_usbc.c
index 6a2cab09aa..1d9c42a97a 100644
--- a/test/fake_usbc.c
+++ b/test/fake_usbc.c
@@ -5,9 +5,9 @@
* Test USB Type-C module.
*/
#include "common.h"
+#include "usb_tc_sm.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
-#include "usb_tc_sm.h"
__overridable int pd_is_vbus_present(int port)
{
@@ -304,7 +304,7 @@ void dpm_set_mode_exit_request(int port)
{
}
-void dpm_run(int port, int evt, int enable)
+void dpm_run(int port)
{
}
@@ -351,10 +351,6 @@ void dpm_handle_alert(int port, uint32_t ado)
{
}
-void dpm_set_pe_ready(int port, bool enable)
-{
-}
-
static enum tcpc_rp_value lcl_rp;
__overridable void typec_select_src_current_limit_rp(int port,
enum tcpc_rp_value rp)
diff --git a/test/fp.c b/test/fp.c
index 135670f47a..ab41868578 100644
--- a/test/fp.c
+++ b/test/fp.c
@@ -8,6 +8,7 @@
* early. e.g. CONFIG_FPU, which is needed in math_util.h.
*/
#include "common.h"
+
#include "mat33.h"
#include "mat44.h"
#include "math.h"
diff --git a/test/fpsensor.c b/test/fpsensor.c
index 2daaa0d2cf..588374d4db 100644
--- a/test/fpsensor.c
+++ b/test/fpsensor.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include "common/fpsensor/fpsensor_private.h"
+#include <stddef.h>
+#include <stdbool.h>
+
#include "ec_commands.h"
#include "mock/fpsensor_detect_mock.h"
#include "string.h"
#include "test_util.h"
-
-#include <stdbool.h>
-#include <stddef.h>
+#include "common/fpsensor/fpsensor_private.h"
static const struct ec_response_get_protocol_info expected_info[] = {
[FP_TRANSPORT_TYPE_SPI] = {
diff --git a/test/fpsensor_crypto.c b/test/fpsensor_crypto.c
index 238f2b3452..9265a608b4 100644
--- a/test/fpsensor_crypto.c
+++ b/test/fpsensor_crypto.c
@@ -3,6 +3,8 @@
* found in the LICENSE file.
*/
+#include <stdbool.h>
+
#include "builtin/assert.h"
#include "common.h"
#include "ec_commands.h"
@@ -15,8 +17,6 @@
#include "test_util.h"
#include "util.h"
-#include <stdbool.h>
-
extern int get_ikm(uint8_t *ikm);
static const uint8_t fake_positive_match_salt[] = {
diff --git a/test/fpsensor_hw.cc b/test/fpsensor_hw.c
index 3d4a6c95dd..ff5b78ace2 100644
--- a/test/fpsensor_hw.cc
+++ b/test/fpsensor_hw.c
@@ -32,7 +32,7 @@ test_static int test_fp_check_hwid(void)
return EC_SUCCESS;
}
-extern "C" void run_test(int argc, const char **argv)
+void run_test(int argc, const char **argv)
{
RUN_TEST(test_fp_check_hwid);
test_print_result();
diff --git a/test/fpsensor_state.c b/test/fpsensor_state.c
index 771523b33b..0b61e1c2d4 100644
--- a/test/fpsensor_state.c
+++ b/test/fpsensor_state.c
@@ -3,6 +3,8 @@
* found in the LICENSE file.
*/
+#include <stdbool.h>
+
#include "common.h"
#include "ec_commands.h"
#include "fpsensor_state.h"
@@ -10,8 +12,6 @@
#include "test_util.h"
#include "util.h"
-#include <stdbool.h>
-
test_static int test_fp_enc_status_valid_flags(void)
{
/* Putting expected value here because test_static should take void */
diff --git a/test/ftrapv.c b/test/ftrapv.c
deleted file mode 100644
index 1aefb8404f..0000000000
--- a/test/ftrapv.c
+++ /dev/null
@@ -1,265 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "common.h"
-#include "panic.h"
-#include "system.h"
-#include "task.h"
-#include "test_util.h"
-
-#include <stdlib.h>
-
-/*
- * trapping addition: __addvsi3.
- */
-test_static int test_ftrapv_addition(void)
-{
- int32_t test_overflow = INT32_MAX;
- int32_t ret;
-
- ccprintf("Testing signed integer addition overflow\n");
- cflush();
- ret = test_overflow + 1;
-
- /* Should never reach this. */
- ccprintf("ret: %d\n", ret);
- cflush();
-
- return EC_ERROR_UNKNOWN;
-}
-
-/*
- * trapping subtraction: __subvsi3.
- */
-test_static int test_ftrapv_subtraction(void)
-{
- int32_t test_overflow = INT32_MIN;
- int32_t ret;
-
- ccprintf("Testing signed integer subtraction overflow\n");
- cflush();
- ret = test_overflow - 1;
-
- /* Should never reach this. */
- ccprintf("ret: %d\n", ret);
- cflush();
-
- return EC_ERROR_UNKNOWN;
-}
-
-/*
- * trapping multiplication: __mulvsi3.
- */
-test_static int test_ftrapv_multiplication(void)
-{
- int32_t test_overflow = INT32_MAX;
- int32_t ret;
-
- ccprintf("Testing signed integer multiplication overflow\n");
- cflush();
- ret = test_overflow * 2;
-
- /* Should never reach this. */
- ccprintf("ret: %d\n", ret);
- cflush();
-
- return EC_ERROR_UNKNOWN;
-}
-
-/*
- * trapping negation: __negvsi2.
- */
-test_static int test_ftrapv_negation(void)
-{
- int32_t test_overflow = INT32_MIN;
- int32_t ret;
-
- ccprintf("Testing signed integer negation overflow\n");
- cflush();
- ret = -test_overflow;
-
- /* Should never reach this. */
- ccprintf("ret: %d\n", ret);
- cflush();
-
- return EC_ERROR_UNKNOWN;
-}
-
-/*
- * trapping absolute value: __absvsi2.
- *
- * TODO(b/258074414): Trapping on absolute value overflow is broken in clang.
- */
-test_static int test_ftrapv_absolute_value(void)
-{
- int32_t test_overflow = INT32_MIN;
- int32_t ret;
-
- ccprintf("Testing signed integer absolute value overflow\n");
- cflush();
-
- ret = abs(test_overflow);
-
- /* Should never reach this. */
- ccprintf("ret: %d\n", ret);
- cflush();
-
- return EC_ERROR_UNKNOWN;
-}
-
-test_static int test_panic_data(void)
-{
- const uint32_t expected_reason = 0;
- const uint32_t expected_info = 0;
- /*
- * https://developer.arm.com/documentation/dui0552/a/the-cortex-m3-processor/exception-model/exception-types
- */
- const uint8_t expected_exception = 6; /* usage fault */
-
- uint32_t reason = UINT32_MAX;
- uint32_t info = UINT32_MAX;
- uint8_t exception = UINT8_MAX;
-
- panic_get_reason(&reason, &info, &exception);
-
- TEST_EQ(reason, expected_reason, "%08x");
- TEST_EQ(info, expected_info, "%d");
- TEST_EQ(exception, expected_exception, "%d");
-
- return EC_SUCCESS;
-}
-
-test_static void run_test_step1(void)
-{
- test_set_next_step(TEST_STATE_STEP_2);
- RUN_TEST(test_ftrapv_addition);
-}
-
-test_static void run_test_step2(void)
-{
- RUN_TEST(test_panic_data);
-
- if (test_get_error_count())
- test_reboot_to_next_step(TEST_STATE_FAILED);
- else
- test_reboot_to_next_step(TEST_STATE_STEP_3);
-}
-
-test_static void run_test_step3(void)
-{
- test_set_next_step(TEST_STATE_STEP_4);
- RUN_TEST(test_ftrapv_subtraction);
-}
-
-test_static void run_test_step4(void)
-{
- RUN_TEST(test_panic_data);
-
- if (test_get_error_count())
- test_reboot_to_next_step(TEST_STATE_FAILED);
- else
- test_reboot_to_next_step(TEST_STATE_STEP_5);
-}
-
-test_static void run_test_step5(void)
-{
- test_set_next_step(TEST_STATE_STEP_6);
- RUN_TEST(test_ftrapv_multiplication);
-}
-
-test_static void run_test_step6(void)
-{
- RUN_TEST(test_panic_data);
-
- if (test_get_error_count())
- test_reboot_to_next_step(TEST_STATE_FAILED);
- else
- test_reboot_to_next_step(TEST_STATE_STEP_7);
-}
-
-test_static void run_test_step7(void)
-{
- test_set_next_step(TEST_STATE_STEP_8);
- RUN_TEST(test_ftrapv_negation);
-}
-
-test_static void run_test_step8(void)
-{
- RUN_TEST(test_panic_data);
-
- if (test_get_error_count())
- test_reboot_to_next_step(TEST_STATE_FAILED);
- else
- test_reboot_to_next_step(TEST_STATE_STEP_9);
-}
-
-test_static void run_test_step9(void)
-{
- /*
- * TODO(b/258074414): Trapping on absolute value overflow is broken in
- * clang, so skip the check.
- */
-#if 0
- test_set_next_step(TEST_STATE_STEP_10);
- RUN_TEST(test_ftrapv_absolute_value);
-#else
- test_reboot_to_next_step(TEST_STATE_STEP_10);
-#endif
-}
-
-test_static void run_test_step10(void)
-{
- /*
- * TODO(b/258074414): Trapping on absolute value overflow is broken in
- * clang, so skip the check.
- */
-#if 0
- RUN_TEST(test_panic_data);
-#endif
-
- 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();
- } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_4)) {
- run_test_step4();
- } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_5)) {
- run_test_step5();
- } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_6)) {
- run_test_step6();
- } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_7)) {
- run_test_step7();
- } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_8)) {
- run_test_step8();
- } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_9)) {
- run_test_step9();
- } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_10)) {
- run_test_step10();
- }
-}
-
-int task_test(void *unused)
-{
- if (IS_ENABLED(SECTION_IS_RW))
- test_run_multistep();
- return EC_SUCCESS;
-}
-
-void run_test(int argc, const char **argv)
-{
- test_reset();
- msleep(30); /* Wait for TASK_ID_TEST to initialize */
- task_wake(TASK_ID_TEST);
-}
diff --git a/test/ftrapv.tasklist b/test/ftrapv.tasklist
deleted file mode 100644
index 273a9664c0..0000000000
--- a/test/ftrapv.tasklist
+++ /dev/null
@@ -1,10 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * 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(TEST, task_test, NULL, TASK_STACK_SIZE)
diff --git a/test/gyro_cal.c b/test/gyro_cal.c
index cf9af0fdbc..c8e8d30589 100644
--- a/test/gyro_cal.c
+++ b/test/gyro_cal.c
@@ -5,15 +5,14 @@
#include "common.h"
#include "gyro_cal.h"
-#include "gyro_cal_init_for_test.h"
#include "gyro_still_det.h"
+#include "gyro_cal_init_for_test.h"
#include "motion_sense.h"
#include "test_util.h"
-
+#include <string.h>
+#include <stdlib.h>
#include <math.h>
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
float kToleranceGyroRps = 1e-6f;
float kDefaultGravityMps2 = 9.81f;
diff --git a/test/gyro_cal_init_for_test.c b/test/gyro_cal_init_for_test.c
index ebb1dd8799..0ba1a65e6b 100644
--- a/test/gyro_cal_init_for_test.c
+++ b/test/gyro_cal_init_for_test.c
@@ -4,9 +4,8 @@
*/
#include "common.h"
-#include "gyro_cal_init_for_test.h"
#include "timer.h"
-
+#include "gyro_cal_init_for_test.h"
#include <string.h>
#define NANO_PI (3.14159265359f)
diff --git a/test/interrupt.c b/test/interrupt.c
index fbd35253e8..efd8b47a34 100644
--- a/test/interrupt.c
+++ b/test/interrupt.c
@@ -4,6 +4,8 @@
*
* Test interrupt support of EC emulator.
*/
+#include <stdio.h>
+
#include "common.h"
#include "console.h"
#include "task.h"
@@ -11,8 +13,6 @@
#include "timer.h"
#include "util.h"
-#include <stdio.h>
-
static int main_count;
static int has_error;
static int interrupt_count;
diff --git a/test/kasa.c b/test/kasa.c
index 222fb2a0cf..23968faf7c 100644
--- a/test/kasa.c
+++ b/test/kasa.c
@@ -5,9 +5,8 @@
#include "common.h"
#include "kasa.h"
-#include "motion_sense.h"
#include "test_util.h"
-
+#include "motion_sense.h"
#include <stdio.h>
struct motion_sensor_t motion_sensors[] = {};
diff --git a/test/kb_8042.c b/test/kb_8042.c
index 0065319576..e7d7690cff 100644
--- a/test/kb_8042.c
+++ b/test/kb_8042.c
@@ -5,6 +5,7 @@
* Tests for keyboard MKBP protocol
*/
+#include <stdbool.h>
#include "atkbd_protocol.h"
#include "common.h"
#include "console.h"
@@ -23,8 +24,6 @@
#include "timer.h"
#include "util.h"
-#include <stdbool.h>
-
static const char *action[2] = { "release", "press" };
/*
@@ -262,7 +261,6 @@ static int _read_cmd_byte(uint8_t *cmd)
void before_test(void)
{
/* Make sure all tests start with the controller in the same state */
- keyboard_clear_buffer();
_write_cmd_byte(I8042_XLATE | I8042_AUX_DIS | I8042_KBD_DIS);
}
@@ -276,7 +274,7 @@ void after_test(void)
}
}
-test_static int test_8042_aux_loopback(void)
+static int test_8042_aux_loopback(void)
{
/* Disable all IRQs */
WRITE_CMD_BYTE(0);
@@ -295,7 +293,7 @@ test_static int test_8042_aux_loopback(void)
return EC_SUCCESS;
}
-test_static int test_8042_aux_two_way_communication(void)
+static int test_8042_aux_two_way_communication(void)
{
/* Enable AUX IRQ */
WRITE_CMD_BYTE(I8042_ENIRQ12);
@@ -313,7 +311,7 @@ test_static int test_8042_aux_two_way_communication(void)
return EC_SUCCESS;
}
-test_static int test_8042_aux_inhibit(void)
+static int test_8042_aux_inhibit(void)
{
/* Enable AUX IRQ, but inhibit the AUX device from sending data. */
WRITE_CMD_BYTE(I8042_ENIRQ12 | I8042_AUX_DIS);
@@ -341,7 +339,7 @@ test_static int test_8042_aux_inhibit(void)
return EC_SUCCESS;
}
-test_static int test_8042_aux_controller_commands(void)
+static int test_8042_aux_controller_commands(void)
{
uint8_t ctrl;
@@ -361,7 +359,7 @@ test_static int test_8042_aux_controller_commands(void)
return EC_SUCCESS;
}
-test_static int test_8042_aux_test_command(void)
+static int test_8042_aux_test_command(void)
{
i8042_write_cmd(I8042_TEST_MOUSE);
@@ -370,7 +368,7 @@ test_static int test_8042_aux_test_command(void)
return EC_SUCCESS;
}
-test_static int test_8042_self_test(void)
+static int test_8042_self_test(void)
{
i8042_write_cmd(I8042_RESET_SELF_TEST);
VERIFY_LPC_CHAR("\x55");
@@ -378,7 +376,7 @@ test_static int test_8042_self_test(void)
return EC_SUCCESS;
}
-test_static int test_8042_keyboard_test_command(void)
+static int test_8042_keyboard_test_command(void)
{
i8042_write_cmd(I8042_TEST_KB_PORT);
VERIFY_LPC_CHAR("\x00"); /* Data and Clock are not stuck */
@@ -386,7 +384,7 @@ test_static int test_8042_keyboard_test_command(void)
return EC_SUCCESS;
}
-test_static int test_8042_keyboard_controller_commands(void)
+static int test_8042_keyboard_controller_commands(void)
{
uint8_t ctrl;
@@ -406,7 +404,7 @@ test_static int test_8042_keyboard_controller_commands(void)
return EC_SUCCESS;
}
-test_static int test_8042_keyboard_key_pressed_while_inhibited(void)
+static int test_8042_keyboard_key_pressed_while_inhibited(void)
{
ENABLE_KEYSTROKE(1);
@@ -442,8 +440,7 @@ test_static int test_8042_keyboard_key_pressed_while_inhibited(void)
return EC_SUCCESS;
}
-test_static int
-test_8042_keyboard_key_pressed_before_inhibit_using_cmd_byte(void)
+static int test_8042_keyboard_key_pressed_before_inhibit_using_cmd_byte(void)
{
ENABLE_KEYSTROKE(1);
/* Simulate a keypress on the keyboard */
@@ -475,7 +472,7 @@ test_8042_keyboard_key_pressed_before_inhibit_using_cmd_byte(void)
return EC_SUCCESS;
}
-test_static int
+static int
test_8042_keyboard_key_pressed_before_inhibit_using_cmd_byte_with_read(void)
{
uint8_t cmd;
@@ -527,7 +524,7 @@ test_8042_keyboard_key_pressed_before_inhibit_using_cmd_byte_with_read(void)
return EC_SUCCESS;
}
-test_static int test_8042_keyboard_key_pressed_before_inhibit_using_cmd(void)
+static int test_8042_keyboard_key_pressed_before_inhibit_using_cmd(void)
{
ENABLE_KEYSTROKE(1);
/* Simulate a keypress on the keyboard */
@@ -559,7 +556,7 @@ test_static int test_8042_keyboard_key_pressed_before_inhibit_using_cmd(void)
return EC_SUCCESS;
}
-test_static int test_single_key_press(void)
+static int test_single_key_press(void)
{
ENABLE_KEYSTROKE(1);
press_key(1, 1, 1);
@@ -575,7 +572,7 @@ test_static int test_single_key_press(void)
return EC_SUCCESS;
}
-test_static int test_disable_keystroke(void)
+static int test_disable_keystroke(void)
{
ENABLE_KEYSTROKE(0);
press_key(1, 1, 1);
@@ -586,7 +583,7 @@ test_static int test_disable_keystroke(void)
return EC_SUCCESS;
}
-test_static int test_typematic(void)
+static int test_typematic(void)
{
ENABLE_KEYSTROKE(1);
@@ -613,7 +610,7 @@ test_static int test_typematic(void)
return EC_SUCCESS;
}
-test_static int test_atkbd_get_scancode(void)
+static int test_atkbd_get_scancode(void)
{
SET_SCANCODE(1);
@@ -638,7 +635,7 @@ test_static int test_atkbd_get_scancode(void)
return EC_SUCCESS;
}
-test_static int test_atkbd_set_scancode_with_keystroke_disabled(void)
+static int test_atkbd_set_scancode_with_keystroke_disabled(void)
{
ENABLE_KEYSTROKE(0);
@@ -650,7 +647,7 @@ test_static int test_atkbd_set_scancode_with_keystroke_disabled(void)
return EC_SUCCESS;
}
-test_static int test_atkbd_set_scancode_with_key_press_before_set(void)
+static int test_atkbd_set_scancode_with_key_press_before_set(void)
{
ENABLE_KEYSTROKE(0);
ENABLE_KEYSTROKE(1);
@@ -663,17 +660,26 @@ test_static int test_atkbd_set_scancode_with_key_press_before_set(void)
* ATKBD_CMD_SSCANSET should cause the keyboard to stop scanning, flush
* the keyboards output queue, and reset the typematic key.
*/
- i8042_write_data(ATKBD_CMD_SSCANSET);
- VERIFY_ATKBD_ACK();
+ keyboard_host_write(ATKBD_CMD_SSCANSET, 0);
+ /* Read out the scan code that got pushed into the output buffer before
+ * the command was sent.
+ */
+ VERIFY_LPC_CHAR("\x01");
/*
* FIXME: This is wrong. The keyboard's output queue should have been
* flushed when it received the `ATKBD_CMD_SSCANSET` command.
*/
- VERIFY_LPC_CHAR("\x01\x81");
+ VERIFY_LPC_CHAR("\x81");
+
+ /* This is the ACK for `ATKBD_CMD_SSCANSET`. */
+ VERIFY_ATKBD_ACK();
+
+ /* The keyboard has flushed the buffer so no more keys. */
+ VERIFY_NO_CHAR();
/* Finish setting scan code 1 */
- i8042_write_data(1);
+ keyboard_host_write(1, 0);
VERIFY_ATKBD_ACK();
/* Key scanning should be restored. */
@@ -684,7 +690,7 @@ test_static int test_atkbd_set_scancode_with_key_press_before_set(void)
return EC_SUCCESS;
}
-test_static int test_atkbd_set_scancode_with_key_press_during_set(void)
+static int test_atkbd_set_scancode_with_key_press_during_set(void)
{
ENABLE_KEYSTROKE(1);
@@ -692,7 +698,7 @@ test_static int test_atkbd_set_scancode_with_key_press_during_set(void)
* ATKBD_CMD_SSCANSET should cause the keyboard to stop scanning, flush
* the keyboards output queue, and reset the typematic key.
*/
- i8042_write_data(ATKBD_CMD_SSCANSET);
+ keyboard_host_write(ATKBD_CMD_SSCANSET, 0);
VERIFY_ATKBD_ACK();
/* These keypresses should be dropped. */
@@ -705,7 +711,7 @@ test_static int test_atkbd_set_scancode_with_key_press_during_set(void)
VERIFY_LPC_CHAR("\x01\x81");
/* Finish setting scan code 1 */
- i8042_write_data(1);
+ keyboard_host_write(1, 0);
VERIFY_ATKBD_ACK();
/* Key scanning should be restored. */
@@ -716,7 +722,7 @@ test_static int test_atkbd_set_scancode_with_key_press_during_set(void)
return EC_SUCCESS;
}
-test_static int test_atkbd_echo(void)
+static int test_atkbd_echo(void)
{
i8042_write_data(ATKBD_CMD_DIAG_ECHO);
VERIFY_ATKBD_ACK();
@@ -726,7 +732,7 @@ test_static int test_atkbd_echo(void)
return EC_SUCCESS;
}
-test_static int test_atkbd_get_id(void)
+static int test_atkbd_get_id(void)
{
i8042_write_data(ATKBD_CMD_GETID);
VERIFY_ATKBD_ACK();
@@ -741,10 +747,8 @@ test_static int test_atkbd_get_id(void)
return EC_SUCCESS;
}
-test_static int test_atkbd_set_leds_keypress_during(void)
+static int test_atkbd_set_leds_keypress_during(void)
{
- ENABLE_KEYSTROKE(1);
-
/* This should pause scanning. */
i8042_write_data(ATKBD_CMD_SETLEDS);
VERIFY_ATKBD_ACK();
@@ -752,20 +756,16 @@ test_static int test_atkbd_set_leds_keypress_during(void)
/* Simulate keypress while keyboard is waiting for option byte */
press_key(1, 1, 1);
press_key(1, 1, 0);
-
- /* Scancode is kept in queue during SETLEDS. */
- VERIFY_NO_CHAR();
+ /* FIXME: This is wrong, we shouldn't have any key strokes */
+ VERIFY_LPC_CHAR("\x01\x81");
i8042_write_data(0x01);
VERIFY_ATKBD_ACK();
- /* Scancode previously queued should be sent now. */
- VERIFY_LPC_CHAR("\x01\x81");
-
return EC_SUCCESS;
}
-test_static int test_atkbd_set_leds_abort_set(void)
+static int test_atkbd_set_leds_abort_set(void)
{
i8042_write_data(ATKBD_CMD_SETLEDS);
VERIFY_ATKBD_ACK();
@@ -785,7 +785,7 @@ test_static int test_atkbd_set_leds_abort_set(void)
return EC_SUCCESS;
}
-test_static int test_atkbd_set_ex_leds(void)
+static int test_atkbd_set_ex_leds(void)
{
i8042_write_data(ATKBD_CMD_EX_SETLEDS);
VERIFY_ATKBD_ACK();
@@ -801,10 +801,9 @@ test_static int test_atkbd_set_ex_leds(void)
return EC_SUCCESS;
}
-test_static int test_scancode_set2(void)
+static int test_scancode_set2(void)
{
SET_SCANCODE(2);
- ENABLE_KEYSTROKE(1);
WRITE_CMD_BYTE(READ_CMD_BYTE() | I8042_XLATE);
press_key(1, 1, 1);
@@ -821,7 +820,7 @@ test_static int test_scancode_set2(void)
return EC_SUCCESS;
}
-test_static int test_power_button(void)
+static int test_power_button(void)
{
ENABLE_KEYSTROKE(0);
@@ -858,7 +857,7 @@ test_static int test_power_button(void)
return EC_SUCCESS;
}
-test_static int test_sysjump(void)
+static int test_sysjump(void)
{
SET_SCANCODE(2);
ENABLE_KEYSTROKE(1);
@@ -869,17 +868,15 @@ test_static int test_sysjump(void)
return EC_ERROR_UNKNOWN;
}
-test_static int test_sysjump_cont(void)
+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);
@@ -888,7 +885,7 @@ test_static int test_sysjump_cont(void)
return EC_SUCCESS;
}
-test_static const struct ec_response_keybd_config keybd_config = {
+static const struct ec_response_keybd_config keybd_config = {
.num_top_row_keys = 13,
.action_keys = {
TK_BACK, /* T1 */
@@ -913,7 +910,7 @@ board_vivaldi_keybd_config(void)
return &keybd_config;
}
-test_static int test_ec_cmd_get_keybd_config(void)
+static int test_ec_cmd_get_keybd_config(void)
{
struct ec_response_keybd_config resp;
int rv;
@@ -934,25 +931,22 @@ test_static int test_ec_cmd_get_keybd_config(void)
return EC_SUCCESS;
}
-test_static int test_vivaldi_top_keys(void)
+static int test_vivaldi_top_keys(void)
{
SET_SCANCODE(2);
/* Test REFRESH key */
WRITE_CMD_BYTE(READ_CMD_BYTE() | I8042_XLATE);
-
press_key(2, 3, 1); /* Press T2 */
VERIFY_LPC_CHAR("\xe0\x67"); /* Check REFRESH scancode in set-1 */
/* Test SNAPSHOT key */
WRITE_CMD_BYTE(READ_CMD_BYTE() | I8042_XLATE);
-
press_key(4, 3, 1); /* Press T2 */
VERIFY_LPC_CHAR("\xe0\x13"); /* Check SNAPSHOT scancode in set-1 */
/* Test VOL_UP key */
WRITE_CMD_BYTE(READ_CMD_BYTE() | I8042_XLATE);
-
press_key(5, 3, 1); /* Press T2 */
VERIFY_LPC_CHAR("\xe0\x30"); /* Check VOL_UP scancode in set-1 */
diff --git a/test/kb_scan.c b/test/kb_scan.c
index 031c972d0e..82693ff525 100644
--- a/test/kb_scan.c
+++ b/test/kb_scan.c
@@ -578,7 +578,6 @@ static void run_test_step1(void)
lid_open = 1;
hook_notify(HOOK_LID_CHANGE);
test_reset();
- msleep(1);
RUN_TEST(deghost_test);
@@ -607,7 +606,6 @@ static void run_test_step2(void)
lid_open = 1;
hook_notify(HOOK_LID_CHANGE);
test_reset();
- msleep(1);
RUN_TEST(test_check_boot_esc);
@@ -622,7 +620,6 @@ static void run_test_step3(void)
lid_open = 1;
hook_notify(HOOK_LID_CHANGE);
test_reset();
- msleep(1);
RUN_TEST(test_check_boot_down);
diff --git a/test/libc_printf.c b/test/libc_printf.c
deleted file mode 100644
index 8900d9ea04..0000000000
--- a/test/libc_printf.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "test_util.h"
-
-#include <stdio.h>
-
-test_static int test_printf(void)
-{
- /*
- * The test itself is not verifying that printing works (according to
- * the test framework, this will always pass).
- *
- * Instead, the test runner (test/run_device_tests.py) looks for the
- * printed string in the test output to determine if the test passed.
- */
- printf("printf called\n");
- return EC_SUCCESS;
-}
-
-void run_test(int argc, const char **argv)
-{
- test_reset();
- RUN_TEST(test_printf);
- test_print_result();
-}
diff --git a/test/libc_printf.tasklist b/test/libc_printf.tasklist
deleted file mode 100644
index 959f62ef79..0000000000
--- a/test/libc_printf.tasklist
+++ /dev/null
@@ -1,9 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * 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/lightbar.c b/test/lightbar.c
index d51b61779e..90400d1cf5 100644
--- a/test/lightbar.c
+++ b/test/lightbar.c
@@ -5,8 +5,8 @@
#include "console.h"
#include "ec_commands.h"
-#include "host_command.h"
#include "lightbar.h"
+#include "host_command.h"
#include "test_util.h"
#include "timer.h"
#include "util.h"
diff --git a/test/mag_cal.c b/test/mag_cal.c
index fe98318258..245bad786c 100644
--- a/test/mag_cal.c
+++ b/test/mag_cal.c
@@ -6,7 +6,6 @@
#include "common.h"
#include "mag_cal.h"
#include "test_util.h"
-
#include <stdio.h>
/**
diff --git a/test/math_util.c b/test/math_util.c
index c08bd0c561..1ee9b1484b 100644
--- a/test/math_util.c
+++ b/test/math_util.c
@@ -5,15 +5,14 @@
* Test motion sense code.
*/
+#include <math.h>
+#include <stdio.h>
#include "common.h"
#include "math_util.h"
#include "motion_sense.h"
#include "test_util.h"
#include "util.h"
-#include <math.h>
-#include <stdio.h>
-
/*****************************************************************************/
/*
* Need to define motion sensor globals just to compile.
diff --git a/test/motion_angle.c b/test/motion_angle.c
index 8eb1a775e4..3f206de078 100644
--- a/test/motion_angle.c
+++ b/test/motion_angle.c
@@ -6,6 +6,9 @@
* transition.
*/
+#include <math.h>
+#include <stdio.h>
+
#include "accelgyro.h"
#include "common.h"
#include "gpio.h"
@@ -17,9 +20,6 @@
#include "test_util.h"
#include "util.h"
-#include <math.h>
-#include <stdio.h>
-
/*****************************************************************************/
/* Test utilities */
diff --git a/test/motion_angle_tablet.c b/test/motion_angle_tablet.c
index 2f458381b3..2c0c15c828 100644
--- a/test/motion_angle_tablet.c
+++ b/test/motion_angle_tablet.c
@@ -5,6 +5,9 @@
* Test motion sense code, when in tablet mode.
*/
+#include <math.h>
+#include <stdio.h>
+
#include "accelgyro.h"
#include "common.h"
#include "gpio.h"
@@ -16,9 +19,6 @@
#include "test_util.h"
#include "util.h"
-#include <math.h>
-#include <stdio.h>
-
/*****************************************************************************/
/* Test utilities */
diff --git a/test/motion_lid.c b/test/motion_lid.c
index 40e6dcb0f0..39b83ce6fc 100644
--- a/test/motion_lid.c
+++ b/test/motion_lid.c
@@ -5,6 +5,9 @@
* Test motion sense code.
*/
+#include <math.h>
+#include <stdio.h>
+
#include "accelgyro.h"
#include "common.h"
#include "gpio.h"
@@ -17,9 +20,6 @@
#include "timer.h"
#include "util.h"
-#include <math.h>
-#include <stdio.h>
-
extern enum chipset_state_mask sensor_active;
extern int wait_us;
diff --git a/test/motion_sense_fifo.c b/test/motion_sense_fifo.c
index 3cea279bda..5a977e94d0 100644
--- a/test/motion_sense_fifo.c
+++ b/test/motion_sense_fifo.c
@@ -5,16 +5,15 @@
* Test motion_sense_fifo.
*/
-#include "accelgyro.h"
#include "ec_commands.h"
-#include "hwtimer.h"
-#include "motion_sense_fifo.h"
#include "stdio.h"
-#include "task.h"
+#include "motion_sense_fifo.h"
#include "test_util.h"
-#include "timer.h"
#include "util.h"
-
+#include "hwtimer.h"
+#include "task.h"
+#include "timer.h"
+#include "accelgyro.h"
#include <sys/types.h>
mutex_t g_sensor_mutex;
diff --git a/test/mpu.c b/test/mpu.c
index dfc5877d5a..2193c0c617 100644
--- a/test/mpu.c
+++ b/test/mpu.c
@@ -3,22 +3,13 @@
* found in the LICENSE file.
*/
-/* This test file meant to be executed on a real device. Example:
- * 1. make tests BOARD=bloonchipper
- * 2. servod --board=bloonchipper
- * 3. flash_ec --board bloonchipper --image build/bloonchipper/test-mpu.bin
- * 4. Open console via dut-control raw_fpmcu_console_uart_pty
- * 5. runtest on console
- */
-
+#include <stdbool.h>
#include "mpu.h"
#include "mpu_private.h"
#include "string.h"
#include "system.h"
#include "test_util.h"
-#include <stdbool.h>
-
struct mpu_info {
bool has_mpu;
int num_mpu_regions;
@@ -181,19 +172,6 @@ test_static int test_mpu_get_rw_regions(void)
return EC_SUCCESS;
}
-test_static int test_align_down_to_bits(void)
-{
- uint32_t addr = 0x87654321;
-
- TEST_EQ(align_down_to_bits(addr, 0), addr, "%d");
- TEST_EQ(align_down_to_bits(addr, 1), 0x87654320, "%d");
- TEST_EQ(align_down_to_bits(addr, 30), 0x80000000, "%d");
- TEST_EQ(align_down_to_bits(addr, 31), 0x80000000, "%d");
- TEST_EQ(align_down_to_bits(addr, 32), addr, "%d");
- TEST_EQ(align_down_to_bits(addr, 33), addr, "%d");
- return EC_SUCCESS;
-}
-
void run_test(int argc, const char **argv)
{
enum ec_image cur_image = system_get_image_copy();
@@ -233,8 +211,6 @@ void run_test(int argc, const char **argv)
RUN_TEST(reset_mpu);
RUN_TEST(test_mpu_get_rw_regions);
RUN_TEST(reset_mpu);
- RUN_TEST(test_align_down_to_bits);
- RUN_TEST(reset_mpu);
/* This test must be last because it generates a panic */
RUN_TEST(test_mpu_update_region_valid_region);
RUN_TEST(reset_mpu);
diff --git a/test/mutex.c b/test/mutex.c
index b4066c8c4f..a03e504a0a 100644
--- a/test/mutex.c
+++ b/test/mutex.c
@@ -6,8 +6,8 @@
* Tasks for mutexes basic tests.
*/
-#include "common.h"
#include "console.h"
+#include "common.h"
#include "task.h"
#include "test_util.h"
#include "timer.h"
diff --git a/test/newton_fit.c b/test/newton_fit.c
index 62f4710f0c..07c35aad2a 100644
--- a/test/newton_fit.c
+++ b/test/newton_fit.c
@@ -4,10 +4,9 @@
*/
#include "common.h"
-#include "motion_sense.h"
#include "newton_fit.h"
+#include "motion_sense.h"
#include "test_util.h"
-
#include <stdio.h>
/*
diff --git a/test/nvidia_gpu.c b/test/nvidia_gpu.c
index b660943e04..d6086cc8c4 100644
--- a/test/nvidia_gpu.c
+++ b/test/nvidia_gpu.c
@@ -4,11 +4,12 @@
*
* Tests for Nvidia GPU.
*/
+#include <stdio.h>
+
#include "charge_manager.h"
#include "charge_state.h"
#include "common.h"
#include "console.h"
-#include "driver/nvidia_gpu.h"
#include "hooks.h"
#include "host_command.h"
#include "task.h"
@@ -17,7 +18,7 @@
#include "timer.h"
#include "util.h"
-#include <stdio.h>
+#include "driver/nvidia_gpu.h"
struct d_notify_policy d_notify_policies[] = {
AC_ATLEAST_W(100), AC_ATLEAST_W(65), AC_DC,
diff --git a/test/online_calibration.c b/test/online_calibration.c
index c845378012..cecb543eef 100644
--- a/test/online_calibration.c
+++ b/test/online_calibration.c
@@ -10,7 +10,6 @@
#include "online_calibration.h"
#include "test_util.h"
#include "timer.h"
-
#include <stdio.h>
int mkbp_send_event(uint8_t event_type)
diff --git a/test/online_calibration_spoof.c b/test/online_calibration_spoof.c
index 31c17bb8dd..44a3b812d9 100644
--- a/test/online_calibration_spoof.c
+++ b/test/online_calibration_spoof.c
@@ -5,14 +5,13 @@
#include "accel_cal.h"
#include "accelgyro.h"
-#include "gyro_cal.h"
-#include "gyro_cal_init_for_test.h"
#include "hwtimer.h"
#include "mag_cal.h"
#include "online_calibration.h"
#include "test_util.h"
+#include "gyro_cal_init_for_test.h"
+#include "gyro_cal.h"
#include "timer.h"
-
#include <stdio.h>
int mkbp_send_event(uint8_t event_type)
diff --git a/test/panic_data.c b/test/panic_data.c
index 8892c17ece..334b766dfc 100644
--- a/test/panic_data.c
+++ b/test/panic_data.c
@@ -3,11 +3,12 @@
* found in the LICENSE file.
*/
+#include "test_util.h"
+
#include "builtin/assert.h"
#include "panic.h"
#include "system.h"
#include "task.h"
-#include "test_util.h"
static int get_assert_line(void)
{
diff --git a/test/powerdemo.c b/test/powerdemo.c
index 2900401370..7a4f0c5ccb 100644
--- a/test/powerdemo.c
+++ b/test/powerdemo.c
@@ -8,9 +8,9 @@
#include "clock.h"
#include "common.h"
#include "powerdemo.h"
-#include "registers.h"
#include "task.h"
#include "timer.h"
+#include "registers.h"
static volatile enum {
POWER_STATE_IDLE = 0, /* Idle */
diff --git a/test/printf.c b/test/printf.c
index 7c037e22da..29ffdfcea4 100644
--- a/test/printf.c
+++ b/test/printf.c
@@ -3,16 +3,16 @@
* found in the LICENSE file.
*/
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stddef.h>
+
#include "common.h"
#include "compiler.h"
#include "printf.h"
#include "test_util.h"
#include "util.h"
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stddef.h>
-
#ifdef USE_BUILTIN_STDLIB
/*
* When USE_BUILTIN_STDLIB is defined, we want to test the EC printf
diff --git a/test/rgb_keyboard.c b/test/rgb_keyboard.c
index 1b6ea1bf95..d32215e649 100644
--- a/test/rgb_keyboard.c
+++ b/test/rgb_keyboard.c
@@ -4,6 +4,8 @@
*
* Tests for RGB keyboard.
*/
+#include <stdio.h>
+
#include "common.h"
#include "console.h"
#include "keyboard_backlight.h"
@@ -13,8 +15,6 @@
#include "timer.h"
#include "util.h"
-#include <stdio.h>
-
#define RGB_GRID0_COL 11
#define RGB_GRID0_ROW 6
#define RGB_GRID1_COL 11
diff --git a/test/rng_benchmark.cc b/test/rng_benchmark.cc
deleted file mode 100644
index 2e47b8ea27..0000000000
--- a/test/rng_benchmark.cc
+++ /dev/null
@@ -1,81 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Measure performance of the hardware True Random Number Generator (TRNG)
- * compared to the std::rand().
- */
-
-#include "benchmark.h"
-
-#include "console.h"
-#include <array>
-#include <cstdint>
-#include <cstdlib>
-
-extern "C" {
-#include "test_util.h"
-#include "trng.h"
-}
-
-test_static int test_rng()
-{
- constexpr int num_iterations = 100;
- Benchmark benchmark({ .num_iterations = num_iterations });
- std::array<uint32_t, num_iterations> trng_out;
- std::array<int, num_iterations> rand_out;
-
- // Try the hardware true random number generator
- trng_out.fill(0);
-
- trng_init();
- auto result = benchmark.run("trng", [&trng_out]() {
- static int i = 0;
- trng_out[i++] = trng_rand();
- });
- trng_exit();
-
- TEST_ASSERT(result.has_value());
- for (int i = 0; i < trng_out.size() - 1; ++i) {
- TEST_NE(trng_out[i], trng_out[i + 1], "%d");
- cflush();
- }
-
- // Repeat the test by turning the TNRG on and off at each iteration
- trng_out.fill(0);
- result = benchmark.run("trng_on_off", [&trng_out]() {
- trng_init();
- static int i = 0;
- trng_out[i++] = trng_rand();
- trng_exit();
- });
-
- TEST_ASSERT(result.has_value());
- for (int i = 0; i < trng_out.size() - 1; ++i) {
- TEST_NE(trng_out[i], trng_out[i + 1], "%d");
- cflush();
- }
-
- // Repeat the test using std::rand() for comparison
- rand_out.fill(0);
- result = benchmark.run("std::rand", [&rand_out]() {
- static int i = 0;
- rand_out[i++] = std::rand();
- });
-
- TEST_ASSERT(result.has_value());
- for (int i = 0; i < rand_out.size() - 1; ++i) {
- TEST_NE(rand_out[i], rand_out[i + 1], "%d");
- cflush();
- }
-
- benchmark.print_results();
- return EC_SUCCESS;
-}
-
-void run_test(int argc, const char **argv)
-{
- test_reset();
- RUN_TEST(test_rng);
- test_print_result();
-} \ No newline at end of file
diff --git a/test/rng_benchmark.tasklist b/test/rng_benchmark.tasklist
deleted file mode 100644
index 19615b9ea8..0000000000
--- a/test/rng_benchmark.tasklist
+++ /dev/null
@@ -1,9 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * 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 newline at end of file
diff --git a/test/rollback.c b/test/rollback.c
index 6324fe86fc..e2c1070ef4 100644
--- a/test/rollback.c
+++ b/test/rollback.c
@@ -3,13 +3,12 @@
* found in the LICENSE file.
*/
+#include <stdbool.h>
#include "flash.h"
#include "mpu.h"
#include "string.h"
#include "test_util.h"
-#include <stdbool.h>
-
struct rollback_info {
int region_0_offset;
int region_1_offset;
diff --git a/test/rollback_secret.c b/test/rollback_secret.c
index 46ecfa587b..4813814f19 100644
--- a/test/rollback_secret.c
+++ b/test/rollback_secret.c
@@ -3,6 +3,8 @@
* found in the LICENSE file.
*/
+#include <stdint.h>
+
#include "mock/rollback_latest_mock.h"
#include "rollback.h"
#include "rollback_private.h"
@@ -10,8 +12,6 @@
#include "system.h"
#include "test_util.h"
-#include <stdint.h>
-
extern int get_latest_rollback(struct rollback_data *data);
test_static int test_get_rollback_secret_latest_rollback_fail(void)
diff --git a/test/rsa.c b/test/rsa.c
index a63b274711..2774e9edb4 100644
--- a/test/rsa.c
+++ b/test/rsa.c
@@ -5,8 +5,8 @@
* Tests RSA implementation.
*/
-#include "common.h"
#include "console.h"
+#include "common.h"
#include "rsa.h"
#include "test_util.h"
#include "util.h"
diff --git a/test/rtc.c b/test/rtc.c
index 3a006498f2..7c38c4fa6d 100644
--- a/test/rtc.c
+++ b/test/rtc.c
@@ -5,8 +5,8 @@
* Tests for rtc time conversions
*/
-#include "common.h"
#include "console.h"
+#include "common.h"
#include "rtc.h"
#include "test_util.h"
#include "util.h"
diff --git a/test/run_device_tests.py b/test/run_device_tests.py
index 8983a60b82..4e0b0127e3 100755
--- a/test/run_device_tests.py
+++ b/test/run_device_tests.py
@@ -52,7 +52,7 @@ from concurrent.futures.thread import ThreadPoolExecutor
from dataclasses import dataclass, field
from enum import Enum
from pathlib import Path
-from typing import BinaryIO, Dict, List, Optional, Tuple
+from typing import BinaryIO, Dict, List, Optional
# pylint: disable=import-error
import colorama # type: ignore[import]
@@ -91,7 +91,6 @@ DATA_ACCESS_VIOLATION_20000000_REGEX = re.compile(
DATA_ACCESS_VIOLATION_24000000_REGEX = re.compile(
r"Data access violation, mfar = 24000000\r\n"
)
-PRINTF_CALLED_REGEX = re.compile(r"printf called\r\n")
BLOONCHIPPER = "bloonchipper"
DARTMONKEY = "dartmonkey"
@@ -197,7 +196,6 @@ class AllTests:
TestConfig(test_name="abort"),
TestConfig(test_name="aes"),
TestConfig(test_name="always_memset"),
- TestConfig(test_name="benchmark"),
TestConfig(test_name="cec"),
TestConfig(test_name="cortexm_fpu"),
TestConfig(test_name="crc"),
@@ -236,11 +234,6 @@ class AllTests:
test_name="fpsensor",
test_args=["uart"],
),
- TestConfig(test_name="ftrapv"),
- TestConfig(
- test_name="libc_printf",
- finish_regexes=[PRINTF_CALLED_REGEX],
- ),
TestConfig(
config_name="mpu_ro",
test_name="mpu",
@@ -257,7 +250,6 @@ class AllTests:
TestConfig(test_name="pingpong"),
TestConfig(test_name="printf"),
TestConfig(test_name="queue"),
- TestConfig(test_name="rng_benchmark"),
TestConfig(
config_name="rollback_region0",
test_name="rollback",
@@ -397,7 +389,7 @@ def read_file_gsutil(path: str) -> bytes:
return gsutil.stdout
-def find_section_offset_size(section: str, image: bytes) -> Tuple[int, int]:
+def find_section_offset_size(section: str, image: bytes) -> (int, int):
"""Get offset and size of the section in image"""
areas = fmap.fmap_decode(image)["areas"]
area = next(area for area in areas if area["name"] == section)
diff --git a/test/sha256.c b/test/sha256.c
index 0387d23175..4b5326d189 100644
--- a/test/sha256.c
+++ b/test/sha256.c
@@ -5,8 +5,8 @@
* Tests SHA256 implementation.
*/
-#include "common.h"
#include "console.h"
+#include "common.h"
#include "sha256.h"
#include "test_util.h"
#include "util.h"
diff --git a/test/shmalloc.c b/test/shmalloc.c
index f86efd4fa9..899876ab43 100644
--- a/test/shmalloc.c
+++ b/test/shmalloc.c
@@ -4,6 +4,11 @@
* found in the LICENSE file.
*/
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
#include "common.h"
#include "compile_time_macros.h"
#include "console.h"
@@ -11,11 +16,6 @@
#include "shared_mem.h"
#include "test_util.h"
-#include <stddef.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-
/*
* Total size of memory in the malloc pool (shared between free and allocated
* buffers.
diff --git a/test/stdlib.c b/test/stdlib.c
index 3034522c23..909502aee8 100644
--- a/test/stdlib.c
+++ b/test/stdlib.c
@@ -8,9 +8,9 @@
#include "common.h"
#include "compiler.h"
#include "console.h"
+#include "system.h"
#include "printf.h"
#include "shared_mem.h"
-#include "system.h"
#include "test_util.h"
#include "timer.h"
#include "util.h"
diff --git a/test/stillness_detector.c b/test/stillness_detector.c
index 2e82075e5e..8858d751d7 100644
--- a/test/stillness_detector.c
+++ b/test/stillness_detector.c
@@ -3,11 +3,10 @@
* found in the LICENSE file.
*/
-#include "motion_sense.h"
#include "stillness_detector.h"
+#include "motion_sense.h"
#include "test_util.h"
#include "timer.h"
-
#include <stdio.h>
/*****************************************************************************/
diff --git a/test/system_is_locked.c b/test/system_is_locked.c
index 0a517f1509..47a7977601 100644
--- a/test/system_is_locked.c
+++ b/test/system_is_locked.c
@@ -3,11 +3,12 @@
* found in the LICENSE file.
*/
+#include "test_util.h"
+
#include "flash.h"
#include "string.h"
#include "system.h"
#include "task.h"
-#include "test_util.h"
#include "write_protect.h"
static bool write_protect_enabled;
diff --git a/test/test_config.h b/test/test_config.h
index 704c3b42c1..3482449c10 100644
--- a/test/test_config.h
+++ b/test/test_config.h
@@ -305,7 +305,7 @@ enum sensor_id {
#define CONFIG_BATTERY_SMART
#define CONFIG_CHARGER
#define CONFIG_CHARGER_PROFILE_OVERRIDE
-#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 4032
+#define CONFIG_CHARGER_INPUT_CURRENT 4032
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_DISCHARGE_ON_AC_CUSTOM
#define CONFIG_I2C
@@ -346,7 +346,7 @@ int ncp15wb_calculate_temp(uint16_t adc);
#ifdef TEST_BATTERY_GET_PARAMS_SMART
#define CONFIG_BATTERY_MOCK
#define CONFIG_BATTERY_SMART
-#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 4032
+#define CONFIG_CHARGER_INPUT_CURRENT 4032
#define CONFIG_I2C
#define CONFIG_I2C_CONTROLLER
#define I2C_PORT_MASTER 0
@@ -403,7 +403,6 @@ int ncp15wb_calculate_temp(uint16_t adc);
#undef CONFIG_USB_PE_SM
#undef CONFIG_USB_TYPEC_SM
#undef CONFIG_USB_PD_HOST_CMD
-#undef CONFIG_USB_DPM_SM
#define CONFIG_USB_PRL_SM
#define CONFIG_USB_PD_TCPC
#define CONFIG_USB_PD_TCPM_STUB
@@ -424,7 +423,6 @@ int ncp15wb_calculate_temp(uint16_t adc);
#define CONFIG_USB_PD_EXTENDED_MESSAGES
#define CONFIG_USB_PD_TCPMV2
#undef CONFIG_USB_PE_SM
-#undef CONFIG_USB_DPM_SM
#undef CONFIG_USB_TYPEC_SM
#undef CONFIG_USB_PD_HOST_CMD
#define CONFIG_USB_PRL_SM
@@ -533,7 +531,6 @@ int ncp15wb_calculate_temp(uint16_t adc);
#define CONFIG_USB_POWER_DELIVERY
#undef CONFIG_USB_PRL_SM
#undef CONFIG_USB_PE_SM
-#undef CONFIG_USB_DPM_SM
#undef CONFIG_USB_PD_HOST_CMD
#endif
@@ -618,7 +615,6 @@ int ncp15wb_calculate_temp(uint16_t adc);
#define CONFIG_CMD_PD_TIMER
#undef CONFIG_USB_PD_HOST_CMD
#undef CONFIG_USB_PRL_SM
-#undef CONFIG_USB_DPM_SM
#endif
#if defined(TEST_CHARGE_MANAGER) || defined(TEST_CHARGE_MANAGER_DRP_CHARGING)
diff --git a/test/uptime.c b/test/uptime.c
index ab65820c18..0b6c9b56e6 100644
--- a/test/uptime.c
+++ b/test/uptime.c
@@ -3,6 +3,8 @@
* found in the LICENSE file.
*/
+#include <stdbool.h>
+
#include "common.h"
#include "ec_commands.h"
#include "host_command.h"
@@ -10,8 +12,6 @@
#include "timer.h"
#include "util.h"
-#include <stdbool.h>
-
static bool get_ap_reset_stats_should_succeed = true;
/* Mocks */
diff --git a/test/usb_pd_console.c b/test/usb_pd_console.c
index dc574bccf0..cb2539fea4 100644
--- a/test/usb_pd_console.c
+++ b/test/usb_pd_console.c
@@ -10,11 +10,11 @@
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
-#include "test_util.h"
-#include "usb_pd.h"
#include "usb_pe_sm.h"
+#include "usb_pd.h"
#include "usb_tc_sm.h"
#include "util.h"
+#include "test_util.h"
/* Defined in implementation */
int command_pd(int argc, const char **argv);
diff --git a/test/usb_pd_int.c b/test/usb_pd_int.c
index 1b9336361d..0072da851d 100644
--- a/test/usb_pd_int.c
+++ b/test/usb_pd_int.c
@@ -4,11 +4,11 @@
*
* 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"
-#include "task.h"
-#include "test_util.h"
#define PORT0 0
diff --git a/test/usb_pe_drp.c b/test/usb_pe_drp.c
index c4d2c924e4..8d75454c6a 100644
--- a/test/usb_pe_drp.c
+++ b/test/usb_pe_drp.c
@@ -5,13 +5,6 @@
* Test USB PE module.
*/
#include "common.h"
-#include "mock/charge_manager_mock.h"
-#include "mock/dp_alt_mode_mock.h"
-#include "mock/tcpc_mock.h"
-#include "mock/usb_mux_mock.h"
-#include "mock/usb_pd_dpm_mock.h"
-#include "mock/usb_prl_mock.h"
-#include "mock/usb_tc_sm_mock.h"
#include "task.h"
#include "test_util.h"
#include "timer.h"
@@ -20,6 +13,13 @@
#include "usb_pe.h"
#include "usb_pe_sm.h"
#include "usb_sm_checks.h"
+#include "mock/charge_manager_mock.h"
+#include "mock/usb_tc_sm_mock.h"
+#include "mock/tcpc_mock.h"
+#include "mock/usb_mux_mock.h"
+#include "mock/usb_pd_dpm_mock.h"
+#include "mock/dp_alt_mode_mock.h"
+#include "mock/usb_prl_mock.h"
/* Install Mock TCPC and MUX drivers */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
diff --git a/test/usb_pe_drp_noextended.c b/test/usb_pe_drp_noextended.c
index aa202a7dda..6108458c9c 100644
--- a/test/usb_pe_drp_noextended.c
+++ b/test/usb_pe_drp_noextended.c
@@ -5,9 +5,6 @@
* Test USB PE module.
*/
#include "common.h"
-#include "mock/tcpc_mock.h"
-#include "mock/usb_mux_mock.h"
-#include "mock/usb_tc_sm_mock.h"
#include "task.h"
#include "test_util.h"
#include "timer.h"
@@ -16,6 +13,9 @@
#include "usb_pe.h"
#include "usb_pe_sm.h"
#include "usb_sm_checks.h"
+#include "mock/usb_tc_sm_mock.h"
+#include "mock/tcpc_mock.h"
+#include "mock/usb_mux_mock.h"
/* Install Mock TCPC and MUX drivers */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
diff --git a/test/usb_pe_drp_old.c b/test/usb_pe_drp_old.c
index 4ea07c1ec9..0985a4cae9 100644
--- a/test/usb_pe_drp_old.c
+++ b/test/usb_pe_drp_old.c
@@ -7,7 +7,6 @@
#include "battery.h"
#include "common.h"
#include "gpio.h"
-#include "mock/usb_prl_mock.h"
#include "task.h"
#include "test_util.h"
#include "timer.h"
@@ -20,6 +19,7 @@
#include "usb_prl_sm.h"
#include "usb_sm_checks.h"
#include "usb_tc_sm.h"
+#include "mock/usb_prl_mock.h"
#define pe_set_flag(_p, name) pe_set_fn((_p), (name##_FN))
#define pe_clr_flag(_p, name) pe_clr_fn((_p), (name##_FN))
diff --git a/test/usb_prl_noextended.c b/test/usb_prl_noextended.c
index 609de56d49..956c0027f5 100644
--- a/test/usb_prl_noextended.c
+++ b/test/usb_prl_noextended.c
@@ -11,9 +11,9 @@
#include "test_util.h"
#include "timer.h"
#include "usb_emsg.h"
+#include "usb_pd_test_util.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
-#include "usb_pd_test_util.h"
#include "usb_pe_sm.h"
#include "usb_prl_sm.h"
#include "usb_sm_checks.h"
diff --git a/test/usb_prl_old.c b/test/usb_prl_old.c
index 609de56d49..956c0027f5 100644
--- a/test/usb_prl_old.c
+++ b/test/usb_prl_old.c
@@ -11,9 +11,9 @@
#include "test_util.h"
#include "timer.h"
#include "usb_emsg.h"
+#include "usb_pd_test_util.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
-#include "usb_pd_test_util.h"
#include "usb_pe_sm.h"
#include "usb_prl_sm.h"
#include "usb_sm_checks.h"
diff --git a/test/usb_sm_checks.c b/test/usb_sm_checks.c
index 2204326d97..a8dbdad872 100644
--- a/test/usb_sm_checks.c
+++ b/test/usb_sm_checks.c
@@ -9,10 +9,10 @@
#include "test_util.h"
#include "timer.h"
#include "usb_pd.h"
-#include "usb_pd_test_util.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
diff --git a/test/usb_sm_framework_h3.c b/test/usb_sm_framework_h3.c
index 704bae8f9b..20f9b706c6 100644
--- a/test/usb_sm_framework_h3.c
+++ b/test/usb_sm_framework_h3.c
@@ -9,10 +9,10 @@
#include "test_util.h"
#include "timer.h"
#include "usb_pd.h"
-#include "usb_pd_test_util.h"
#include "usb_sm.h"
#include "usb_tc_sm.h"
#include "util.h"
+#include "usb_pd_test_util.h"
#include "vpd_api.h"
/*
diff --git a/test/usb_tcpmv2_compliance_common.c b/test/usb_tcpmv2_compliance_common.c
index ed46d7baa0..9f839ecf1c 100644
--- a/test/usb_tcpmv2_compliance_common.c
+++ b/test/usb_tcpmv2_compliance_common.c
@@ -10,8 +10,8 @@
#include "tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tc_sm.h"
#include "usb_tcpmv2_compliance.h"
+#include "usb_tc_sm.h"
uint32_t rdo = RDO_FIXED(1, 500, 500, 0);
uint32_t pdo = PDO_FIXED(5000, 3000,
diff --git a/test/usb_tcpmv2_td_pd_ll_e3.c b/test/usb_tcpmv2_td_pd_ll_e3.c
index 8e1d46c15e..f239c87885 100644
--- a/test/usb_tcpmv2_td_pd_ll_e3.c
+++ b/test/usb_tcpmv2_td_pd_ll_e3.c
@@ -8,8 +8,8 @@
#include "tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tc_sm.h"
#include "usb_tcpmv2_compliance.h"
+#include "usb_tc_sm.h"
/*****************************************************************************
* TD.PD.LL.E3. Soft Reset Usage
diff --git a/test/usb_tcpmv2_td_pd_ll_e4.c b/test/usb_tcpmv2_td_pd_ll_e4.c
index fea5e3dc81..f315fc2a63 100644
--- a/test/usb_tcpmv2_td_pd_ll_e4.c
+++ b/test/usb_tcpmv2_td_pd_ll_e4.c
@@ -8,8 +8,8 @@
#include "tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tc_sm.h"
#include "usb_tcpmv2_compliance.h"
+#include "usb_tc_sm.h"
/*****************************************************************************
* TD.PD.LL.E4. Hard Reset Usage
diff --git a/test/usb_tcpmv2_td_pd_ll_e5.c b/test/usb_tcpmv2_td_pd_ll_e5.c
index 49b76fd44e..7c7446a7b3 100644
--- a/test/usb_tcpmv2_td_pd_ll_e5.c
+++ b/test/usb_tcpmv2_td_pd_ll_e5.c
@@ -8,8 +8,8 @@
#include "tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tc_sm.h"
#include "usb_tcpmv2_compliance.h"
+#include "usb_tc_sm.h"
/*****************************************************************************
* TD.PD.LL.E5. Soft Reset
diff --git a/test/usb_tcpmv2_td_pd_other.c b/test/usb_tcpmv2_td_pd_other.c
index 62e051a7a9..18477ac825 100644
--- a/test/usb_tcpmv2_td_pd_other.c
+++ b/test/usb_tcpmv2_td_pd_other.c
@@ -8,9 +8,9 @@
#include "tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_prl_sm.h"
-#include "usb_tc_sm.h"
#include "usb_tcpmv2_compliance.h"
+#include "usb_tc_sm.h"
+#include "usb_prl_sm.h"
int test_connect_as_nonpd_sink(void)
{
diff --git a/test/usb_tcpmv2_td_pd_src3_e1.c b/test/usb_tcpmv2_td_pd_src3_e1.c
index 9c79ea741a..4f5637ccd2 100644
--- a/test/usb_tcpmv2_td_pd_src3_e1.c
+++ b/test/usb_tcpmv2_td_pd_src3_e1.c
@@ -8,8 +8,8 @@
#include "tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tc_sm.h"
#include "usb_tcpmv2_compliance.h"
+#include "usb_tc_sm.h"
#define BUFFER_SIZE 100
diff --git a/test/usb_tcpmv2_td_pd_src3_e7.c b/test/usb_tcpmv2_td_pd_src3_e7.c
index e94b017cc6..40f65f2b9a 100644
--- a/test/usb_tcpmv2_td_pd_src3_e7.c
+++ b/test/usb_tcpmv2_td_pd_src3_e7.c
@@ -4,13 +4,13 @@
*/
#include "battery.h"
-#include "driver/tcpm/tcpci.h"
#include "mock/tcpci_i2c_mock.h"
#include "task.h"
+#include "driver/tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tc_sm.h"
#include "usb_tcpmv2_compliance.h"
+#include "usb_tc_sm.h"
#define BUFFER_SIZE 100
diff --git a/test/usb_tcpmv2_td_pd_src3_e8.c b/test/usb_tcpmv2_td_pd_src3_e8.c
index a19f6c8c82..8686226a50 100644
--- a/test/usb_tcpmv2_td_pd_src3_e8.c
+++ b/test/usb_tcpmv2_td_pd_src3_e8.c
@@ -4,13 +4,13 @@
*/
#include "battery.h"
-#include "driver/tcpm/tcpci.h"
#include "mock/tcpci_i2c_mock.h"
#include "task.h"
+#include "driver/tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tc_sm.h"
#include "usb_tcpmv2_compliance.h"
+#include "usb_tc_sm.h"
#define BUFFER_SIZE 100
diff --git a/test/usb_tcpmv2_td_pd_src3_e9.c b/test/usb_tcpmv2_td_pd_src3_e9.c
index 833a9c056f..59b7a22d74 100644
--- a/test/usb_tcpmv2_td_pd_src3_e9.c
+++ b/test/usb_tcpmv2_td_pd_src3_e9.c
@@ -4,13 +4,13 @@
*/
#include "battery.h"
-#include "driver/tcpm/tcpci.h"
#include "mock/tcpci_i2c_mock.h"
#include "task.h"
+#include "driver/tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tc_sm.h"
#include "usb_tcpmv2_compliance.h"
+#include "usb_tc_sm.h"
#define BUFFER_SIZE 100
diff --git a/test/usb_tcpmv2_td_pd_src_e1.c b/test/usb_tcpmv2_td_pd_src_e1.c
index 10166c4b65..cfb62764b2 100644
--- a/test/usb_tcpmv2_td_pd_src_e1.c
+++ b/test/usb_tcpmv2_td_pd_src_e1.c
@@ -8,8 +8,8 @@
#include "tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tc_sm.h"
#include "usb_tcpmv2_compliance.h"
+#include "usb_tc_sm.h"
/*****************************************************************************
* TD.PD.SRC.E1 Source Capabilities sent timely
diff --git a/test/usb_tcpmv2_td_pd_src_e2.c b/test/usb_tcpmv2_td_pd_src_e2.c
index fbe3e4bce7..cabba40bb9 100644
--- a/test/usb_tcpmv2_td_pd_src_e2.c
+++ b/test/usb_tcpmv2_td_pd_src_e2.c
@@ -8,8 +8,8 @@
#include "tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tc_sm.h"
#include "usb_tcpmv2_compliance.h"
+#include "usb_tc_sm.h"
#define BUFFER_SIZE 100
diff --git a/test/usb_tcpmv2_td_pd_src_e5.c b/test/usb_tcpmv2_td_pd_src_e5.c
index bc391104ab..ef40ee75cf 100644
--- a/test/usb_tcpmv2_td_pd_src_e5.c
+++ b/test/usb_tcpmv2_td_pd_src_e5.c
@@ -8,8 +8,8 @@
#include "tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tc_sm.h"
#include "usb_tcpmv2_compliance.h"
+#include "usb_tc_sm.h"
/*****************************************************************************
* TD.PD.SRC.E5 SenderResponseTimer Timeout - Request
diff --git a/test/usb_tcpmv2_td_pd_vndi3_e3.c b/test/usb_tcpmv2_td_pd_vndi3_e3.c
index 590c02a0e8..8157835328 100644
--- a/test/usb_tcpmv2_td_pd_vndi3_e3.c
+++ b/test/usb_tcpmv2_td_pd_vndi3_e3.c
@@ -8,8 +8,8 @@
#include "tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tc_sm.h"
#include "usb_tcpmv2_compliance.h"
+#include "usb_tc_sm.h"
uint32_t vdo =
VDO(USB_SID_PD, 1, VDO_SVDM_VERS(VDM_VER20) | CMD_DISCOVER_IDENT);
diff --git a/test/usb_test/device_configuration.c b/test/usb_test/device_configuration.c
index 94496fa0fc..06c71fefd9 100644
--- a/test/usb_test/device_configuration.c
+++ b/test/usb_test/device_configuration.c
@@ -5,14 +5,13 @@
*/
#include <errno.h>
+#include <getopt.h>
+#include <libusb.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <getopt.h>
-#include <libusb.h>
-
/* Options */
static uint16_t vid = 0x18d1; /* Google */
static uint16_t pid = 0x5014; /* Cr50 */
diff --git a/test/usb_typec_ctvpd.c b/test/usb_typec_ctvpd.c
index 17c3452a62..71d543cec0 100644
--- a/test/usb_typec_ctvpd.c
+++ b/test/usb_typec_ctvpd.c
@@ -10,12 +10,12 @@
#include "test_util.h"
#include "timer.h"
#include "usb_pd.h"
-#include "usb_pd_tcpm.h"
-#include "usb_pd_test_util.h"
#include "usb_sm.h"
-#include "usb_sm_checks.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
diff --git a/test/utils_str.c b/test/utils_str.c
index 4b2e3d4427..36ad63989e 100644
--- a/test/utils_str.c
+++ b/test/utils_str.c
@@ -7,8 +7,8 @@
#include "common.h"
#include "console.h"
-#include "printf.h"
#include "system.h"
+#include "printf.h"
#include "test_util.h"
#include "timer.h"
#include "util.h"
diff --git a/test/vboot.c b/test/vboot.c
index caa3d2d7cb..f75208de90 100644
--- a/test/vboot.c
+++ b/test/vboot.c
@@ -7,10 +7,10 @@
#include "common.h"
#include "rsa.h"
-#include "rsa2048-3.h"
-#include "rwsig.h"
#include "test_util.h"
#include "vboot.h"
+#include "rsa2048-3.h"
+#include "rwsig.h"
struct vboot_key {
struct vb21_packed_key vb21_key;
diff --git a/test/version.c b/test/version.c
index fea691eef7..9731863f29 100644
--- a/test/version.c
+++ b/test/version.c
@@ -9,8 +9,8 @@
#include "ec_commands.h"
#include "stddef.h"
#include "system.h"
-#include "test_util.h"
#include "util.h"
+#include "test_util.h"
/*
* Tests that fw version adheres to the expected format.
diff --git a/test/vpd_api.c b/test/vpd_api.c
index e159dcb066..51a2e76cd6 100644
--- a/test/vpd_api.c
+++ b/test/vpd_api.c
@@ -3,10 +3,10 @@
* found in the LICENSE file.
*/
-#include "console.h"
-#include "driver/tcpm/tcpm.h"
#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)