summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
* test: modify comments in read_match_secret fail invalid paramFiras Sammoura2022-09-121-8/+1
| | | | | | | | | | | | | | | | | | | Remove the comments before TEST_ASSERT in test_fp_command_read_match_secret_fail_fgr_large_than_max and test_fp_command_read_match_secret_fail_fgr_less_than_zero test functions. The comments are not necessary since the code is self-documenting by itself. BRANCH=None BUG=b:242720387 TEST=make run-fpsensor_state TEST=make runhosttests Signed-off-by: Firas Sammoura <fsammoura@google.com> Change-Id: I0e87201f2418ea5017733db8a175bbdaa577020e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3891671 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Bobby Casey <bobbycasey@google.com>
* test: Add test for read_match_secret succeedFiras Sammoura2022-09-121-0/+56
| | | | | | | | | | | | | | | | | | | | Add test for fp_command_read_match_secret when the number of matched finger is within the allowed range of [0 5[, the state deadline value is valid, the state is readable with the correct matched finger number, and a valid positive_match_salt is derived. The test should succeed and return the message EC_SUCCESS. The response positive_match_secret should also align with the expected one given a tpm_seed, positive_match_salt, and user_id. BRANCH=None BUG=b:242720387 TEST=make run-fpsensor_state TEST=make runhosttests Signed-off-by: Firas Sammoura <fsammoura@google.com> Change-Id: I21f9a621d5eb6cd8a4635a83e930d74cb45f4d7f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872716 Reviewed-by: Bobby Casey <bobbycasey@google.com>
* test: Add test for read_match_secret resp errorFiras Sammoura2022-09-121-0/+32
| | | | | | | | | | | | | | | | | | | | Add a test for fp_command_read_match_secret when the number of matched finger is within the allowed range of [0 5[, the state deadline value is valid, the state is readable with the correct matched finger number, and and a trivial positive_match_salt. The test should fail with the error message EC_RES_ERROR. Add a trivial mock value for the positive_match_salt and a default fake value for the positive_match_salt in the fpsensor_state_mock library. BRANCH=None BUG=b:242720387 TEST=make run-fpsensor_state TEST=make runhosttests Signed-off-by: Firas Sammoura <fsammoura@google.com> Change-Id: I9af4cb13a1b6f63049205cad9684050d5eb1f885 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872553 Reviewed-by: Bobby Casey <bobbycasey@google.com>
* test: add tests for read_match_secret access deniedFiras Sammoura2022-09-091-0/+58
| | | | | | | | | | | | | | | | | | Add tests for fp_command_read_match_secret when the number of matched finger is within the allowed range [0 5[, the state deadline value is valid, and the state is either unreadable or has the wrong matched finger number. The test should fail with the error message EC_RES_ACCESS_DENIED. BRANCH=None BUG=b:242720387 TEST=make run-fpsensor_state TEST=make runhosttests Signed-off-by: Firas Sammoura <fsammoura@google.com> Change-Id: I771546c65cdb629776d06e1c380b683515404eac Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3871749 Reviewed-by: Bobby Casey <bobbycasey@google.com>
* test: Add test for read_match_secret fail timeoutFiras Sammoura2022-09-091-0/+21
| | | | | | | | | | | | | | | | | Add test for fp_command_read_match_secret when the number of fgr is within the allowed range [0 5[ while the state deadline value is smaller than allowed expiration timeline. The test should fail with the error message EC_RES_TIMEOUT. BRANCH=None BUG=b:242720387 TEST=make run-fpsensor_state TEST=make runhosttests Signed-off-by: Firas Sammoura <fsammoura@google.com> Change-Id: I8228e451b35cb5f5967022edc7fc611b0647398a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3871745 Reviewed-by: Bobby Casey <bobbycasey@google.com>
* test: Add tests for read_match_secret fail invalid paramFiras Sammoura2022-09-091-0/+38
| | | | | | | | | | | | | | | | Add tests for fp_command_read_match_secret function when the number of fgr is outside the allowed limit [0 5[. The test should fail with the error message EC_RES_INVALID_PARAM. BRANCH=None BUG=b:242720387 TEST=make run-fpsensor_state TEST=make runhosttests Signed-off-by: Firas Sammoura <fsammoura@google.com> Change-Id: I578161d489610bacbb6ae223a159a99274bd2710 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3870027 Reviewed-by: Bobby Casey <bobbycasey@google.com>
* fpsensor: Remove nested designators for C++ compatibilityTom Hughes2022-09-061-10/+12
| | | | | | | | | | | | | | | | | | When compiling these files as C++, a warning is emitted: nested designators are a C99 extension [-Werror,-Wc99-designator] .deadline.val = 0, ^~~~~~~~~~~~~ BRANCH=none BUG=b:234181908 TEST=./util/compare_build.sh -b fp => MATCH Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I68945ee33290d4416cf1b948cdb6e5e90c7da34b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872808 Reviewed-by: Bobby Casey <bobbycasey@google.com>
* tree-wide: const-ify argv for console commandsCaveh Jalali2022-09-01101-138/+137
| | | | | | | | | | | | | | | | | | | | | | | This updates the API for console commands from "int cmd(int argc, char **argv)" to "int cmd(int argc, const char **argv)" which is more accurate and in line with common convention. BRANCH=none BUG=b:244387210 TEST="make buildall" passes TEST="zmake build -a" passes TEST="util/compare_build.sh -b all" passes TEST="./twister -v -T zephyr/test" passes Cq-Depend: chrome-internal:4960125 Cq-Depend: chrome-internal:4959932 Change-Id: I57de9f35b85b8f3c7119df36aefb2abf25d2625f Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3863941 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* test: add tests for host command PD get/write log entryYuval Peress2022-09-011-0/+4
| | | | | | | | | | | | | | | | Verify that the boundary conditions are met for the PD get and write log entry commands as well as verify that the log entries are added to the log FIFO. BRANCH=none BUG=b:236075606 TEST=twister -s zephyr/test/drivers/driver.host_cmd Signed-off-by: Yuval Peress <peress@google.com> Change-Id: Ifb246ad6e964dac25d3f70868cb031d80585d99a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3863942 Reviewed-by: Al Semjonovs <asemjonovs@google.com> Commit-Queue: Al Semjonovs <asemjonovs@google.com>
* Prism: Remove const keyword from rgbkbd_type variableParth Malkan2022-08-301-1/+1
| | | | | | | | | | | | | | Rgbkbd_type could be set at runtime, remove const. BUG=b:242259557 BRANCH=none TEST=None Cq-Depend: chromium:3864981, chromium:3861817, chromium:3866411 Signed-off-by: Parth Malkan <parthmalkan@google.com> Change-Id: I92bd1e326d20b272afe5bede850f6bb090e86c16 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3864982 Reviewed-by: YH Lin <yueherngl@chromium.org>
* test: Add test for get_ikm succeedFiras Sammoura2022-08-301-0/+33
| | | | | | | | | | | | | | | Add test for get_ikm succeeds when the tmp seed is set and the rollback can successfully get the secret. BRANCH=None BUG=b:242720240 TEST=make run-fpsensor_crypto TEST=make runhosttests Signed-off-by: Firas Sammoura <fsammoura@google.com> Change-Id: I14d0887aa2ecafe4565141a89ad5fb43317cc1a7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3863124 Reviewed-by: Bobby Casey <bobbycasey@google.com>
* test: Add test for get ikm failure with when secret failFiras Sammoura2022-08-301-0/+23
| | | | | | | | | | | | | | | Add a test for get_ikm when the tmp seed is set and the rollback_get_secret is failing. BRANCH=None BUG=b:242720240 TEST=make run-fpsensor_crypto TEST=make runhosttests Signed-off-by: Firas Sammoura <fsammoura@google.com> Change-Id: Ida1f40943eb5fa7795a658a1c8a318036f164d11 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3861202 Reviewed-by: Bobby Casey <bobbycasey@google.com>
* test: Add test for get ikm failure when seed not setFiras Sammoura2022-08-301-1/+12
| | | | | | | | | | | | | | | | | | Add a test for get_ikm when the fp tpm seed is not set. Change the declaration of get_ikm function inside fpsensor_crypto.c to test_export_static such that it can be visible in the test library. Declare get_ikm as an extern function inside the test/fpsensor_crypto.c file. BRANCH=None BUG=b:242720240 TEST=make run-fpsensor_crypto TEST=make runhosttests Signed-off-by: Firas Sammoura <fsammoura@google.com> Change-Id: Ibd4993bbeb6e8d166b3d0307fd1b3c90c55cc264 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3862148 Reviewed-by: Bobby Casey <bobbycasey@google.com>
* test: Add test for fpsensor trivial key failureBobby Casey2022-08-302-0/+90
| | | | | | | | | | | | | | | | | | | Add a test for derive_positive_match_secret when compute_hmac_sha256 returns a trivial key (either 0x00 or 0xFF). This required mocking compute_hmac_sha256 to get the proper test behavior. Since other tests depend upon a proper SHA256 hash to be generated, either all key/message combinations would need to be mocked or some calls to compute_hmac_sha256 need to be passed through to hmac_SHA256. The latter option was chosen for the best flexibility moving forward. BRANCH=none BUG=b:242720910 TEST=make runhosttests Signed-off-by: Bobby Casey <bobbycasey@google.com> Change-Id: I959e23cfadb5460e62af90ffba74a0cd3b9d9a7f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3838935 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* 8042: Add tests for more atkbd and 8042 controller commandsRaul E Rangel2022-08-221-1/+219
| | | | | | | | | | | | | | Improving test coverage. BUG=b:242886255 BRANCH=none TEST=run unit tests Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: I57e208ee8640f256b0ecd5806d805ee575aa7f12 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3846996 Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* 8042: Add tests that verify keyboard inhibit behaviorRaul E Rangel2022-08-221-0/+122
| | | | | | | | | | | | | | | | Now that we have control over the output buffer, we can build more complex tests. These tests verify the keyboard inhibit functionality of the 8042 controller. This exposed two bugs in the 8042/keyboard implementation. BUG=b:242886255 BRANCH=none TEST=run unit tests Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: Ib8e84be88f4298d2c257c14989efa2571be86c70 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3846285 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* test/stdlib: Account for bugs in the builtin stdlib implementationTom Hughes2022-08-221-17/+127
| | | | | | | | | | | | | | | | | | The strstr and strtoull implementations in EC's builtin C standard library have some bugs. For now, create separate asserts depending on whether we're using the builtin standard library or the one from the toolchain. BRANCH=none BUG=b:234181908, b:243192369 TEST=make USE_BUILTIN_STDLIB=0 run-stdlib -j TEST=make run-stdlib -j Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ibcf7655c94373c63464bb3812afb5d37115f8880 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3843215 Reviewed-by: Andrea Grandi <agrandi@google.com> Reviewed-by: Bobby Casey <bobbycasey@google.com>
* 8042: Abort test runner if the test gets into a bad stateRaul E Rangel2022-08-221-4/+12
| | | | | | | | | | | | | | | | | If we can't propagate an error code, we can't fail a test. The next best thing we can do is abort the test runner. Since tests have the ability to leak state, it's possible for an earlier failing test to break a later test. By aborting we prevent getting flooded with false failures. BUG=b:242886255 BRANCH=none TEST=run unit tests Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: Iebdeadeeaa584a65da5329858aa24abfa6e76b03 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3846284 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* 8042: Merge aux_to_host and kbd/ctrl to host queues in kb_8042 testRaul E Rangel2022-08-221-70/+90
| | | | | | | | | | | | | | | Instead of queuing up to_host data, we can actually simulate the output buffer. This allows us to verify that the 8042 controller code correctly waits and queues up response codes internally. BUG=b:242886255 BRANCH=none TEST=run unit tests Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: Ic7cfe21210da099b0a696a111d378817ecc32e7e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3846283 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* 8042: Fix test_power_buttonRaul E Rangel2022-08-221-0/+5
| | | | | | | | | | | | | | | | test_power_button was making some bad assumptions about the state of keystroke enable. The power button also has a 100ms debounce time we need to take into account, otherwise we will miss the event. This change makes the test more robust. BUG=b:242886255 BRANCH=none TEST=run unit tests Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: If10d690c3e96c9e21abee8046cdd13d86257e7f2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3846282 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* test/printf: Fix printf test when using toolchain C standard libTom Hughes2022-08-221-8/+51
| | | | | | | | | | | | | | | Account for bugs in the EC builtin C standard library printf implementation with conditionals until the implementation is fixed. BRANCH=none BUG=b:234181908, b:239233116 TEST=make USE_BUILTIN_STDLIB=0 run-printf TEST=make run-printf Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I1b9a50a41342dfb81e9e7057fad69056ec7acfc8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3843214 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* ec: Add test for chipset_get_shutdown_reasonPablo Ceballos2022-08-223-0/+44
| | | | | | | | | | | | | | BRANCH=none BUG=b:242708232 TEST=make buildall -j Change-Id: Ic134433cb1a85be277806bf285656b12305c3c3b Signed-off-by: Pablo Ceballos <pceballos@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3843066 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Pablo Ceballos <pceballos@chromium.org> Auto-Submit: Pablo Ceballos <pceballos@chromium.org> Tested-by: Pablo Ceballos <pceballos@chromium.org>
* 8042: Add some keyboard inhibit unit testsRaul E Rangel2022-08-201-0/+58
| | | | | | | | | | | | | | | | Verify the I8042_DIS_KB and I8042_ENA_KB commands work as expected. Also test the behavior when keys are pressed while the controller is inhibited. This uncovered wrong behavior. BUG=b:242886255 BRANCH=none TEST=run unit tests Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: I13b795d81715d1d51fa3f7efb2c1d9246b43e8c4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3843090 Reviewed-by: Yuval Peress <peress@google.com> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* 8042: Move VERIFY_AUX methods so they are next to VERIFY_LPC_CHARRaul E Rangel2022-08-191-31/+31
| | | | | | | | | | | | | | | VERIFY_LPC_CHAR had to be moved in the previous CL, this CL completes the move. BUG=b:242886255 BRANCH=none TEST=run unit tests Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: I6f51cf07cc45611525b35ca6865e6afd637dc666 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3842201 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Yuval Peress <peress@google.com>
* 8042: Rework mock lpc_keyboard_put_char to use a queueRaul E Rangel2022-08-191-52/+62
| | | | | | | | | | | | | | | | | | | | | By using a queue, we no longer have to manually clear the lpc_char_buf array in __verify_lpc_char. This also means we need to verify all the response codes since we are no longer clearing the queue before every verify. This makes the test more robust. I don't check the IRQ flag yet. This will happen in a follow up CL when I write some tests to verify it. Since I needed to rewrite VERIFY_LPC_CHAR_DELAY as part of this change, I also made it so it can verify character sequences with NULL characters. BUG=b:242886255 BRANCH=none TEST=run unit tests Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: Ia91c341bb0004e6de2e44474b00db0c2918517f6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3842200 Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* 8042: Add return code to read_cmd_byteRaul E Rangel2022-08-191-12/+19
| | | | | | | | | | | | | | | This return code will be used in a follow up CL to verify the length of lpc_char_buf before reading the array. This will avoid reading a possibly uninitialized queue entry. BUG=b:242886255 BRANCH=none TEST=run unit tests Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: I816cbb69e6743e74124f6b847aaa126d12499487 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3843089 Reviewed-by: Yuval Peress <peress@google.com>
* 8042: Add return values to test helpers and convert to macrosRaul E Rangel2022-08-191-31/+47
| | | | | | | | | | | | | | | | We currently don't verify that the helpers are behaving as expected. This change adds return codes and adds macro wrappers that check the return codes. BUG=b:242886255 BRANCH=none TEST=run unit tests Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: If33bf2d4381ab8eb5199fb6b22a2d93467f31d7d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3842199 Reviewed-by: Yuval Peress <peress@google.com> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* 8042: Add unit tests for AUX portRaul E Rangel2022-08-192-0/+190
| | | | | | | | | | | | | | | Add unit tests for all the AUX port functionality. BUG=b:242886255 BRANCH=none TEST=run unit tests Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: Iac8ca466c90a3dadc6aa175037c1ba5663063f0d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3840654 Reviewed-by: Yuval Peress <peress@google.com> Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Yuval Peress <peress@google.com>
* ec: Add test for console buffer commandsJeremy Bettis2022-08-191-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The line at zephyr/shim/src/console_buffer.c:40 that removes nul characters is intermittently covered. Add test to verify on legacy and zephyr both, since they are different implementations. Fix the code in console_buf_notify_chars to keep writing even after a nul character. Change to always set write_count_out even when not writing. BRANCH=None BUG=b:243050723 TEST=./twister --coverage TEST=console_edit ; make clobber &&\ make TEST_FLAG=TEST_COVERAGE=y build/coverage/${TEST?}.info && \ genhtml -q -s --branch-coverage -o build/coverage/${TEST?}_rpt \ build/coverage/${TEST?}.info Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: Id3db8c0a20f648f2ae272d9d221ccdfecbf79693 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3840662 Reviewed-by: Wai-Hong Tam <waihong@google.com> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* 8042: Rename I8042_CMD to ATKBD_CMD and move to a different fileRaul E Rangel2022-08-181-4/+5
| | | | | | | | | | | | | | | | | | | These are actually AT Keyboard commands, and not specific to the i8042 controller. Using the correct prefix will make it easier to understand which device we are interacting with. I also moved the definitions into a different file to make it clear that there is a separation between the two protocols. BUG=b:242886255 BRANCH=none TEST=build guybrush Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: I160f1d71edbce80606d8bcb01dbeb0d2192cfa93 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3835508 Code-Coverage: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Yuval Peress <peress@google.com> Reviewed-by: Jeremy Bettis <jbettis@chromium.org>
* charge_state: Add PWR_STATE_FORCED_IDLE stateParth Malkan2022-08-181-3/+3
| | | | | | | | | | | | | | | | | | Add PWR_STATE_FORCED_IDLE state which indicates PWR_STATE_IDLE state is forced when charge control is not normal. Also update led.c files for boards to replace chflag use with new PWR_STATE_FORCED_IDLE. BUG=b:241167493 TEST=make buildall, zmake build --all, make runhosttests -j BRANCH=None Signed-off-by: Parth Malkan <parthmalkan@google.com> Cq-Depend: chromium:3807136 Change-Id: Ib00ed3df977482a4430b0c3d16a2a0e305bbd47f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3807134 Reviewed-by: Wai-Hong Tam <waihong@google.com>
* ec: Add tests for printing fixed point numbersJeremy Bettis2022-08-161-0/+8
| | | | | | | | | | | | | | | | | | | | | | The coverage reports are flaky, and sometimes cover the overflow errors and sometimes not. Add tests for those overflow conditions in both legacy and zephyr, and add tests for the related fixed point formatting as well. BRANCH=None BUG=b:242543903 FIXED=b:242543903 TEST=ran tests Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I2229e1d1b956d207aabad4025921fef9fa8a541d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3833911 Reviewed-by: Simon Glass <sjg@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Simon Glass <sjg@chromium.org>
* TCMPV2: Add USB PD power button support in S0/S0ix/S3 statesJameson Thies2022-08-161-2/+3
| | | | | | | | | | | | | | | | | | | | | Currently a USB PD power button can only be used wake a device which is shutdown. To account for devices which use a USB PD power button and cannot enable a HID interface, this CL adds USB PD power button support to Suspend and On power states. When a device is either suspended or on, a short USB PD power button press will simulate a 500ms power button press and a long USB PD power button press will shutdown the device. BUG=b:236022894 TEST=make try_build_boards, make runhosttests and zmake test test-drivers. Also working interactively with a dock that supports sending alerts on button presses. BRANCH=None Signed-off-by: Jameson Thies <jthies@google.com> Change-Id: I3a8adaa01dbf07a03b0e1451d3a5af5d5f39c442 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3794615 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* run_device_tests.py: Fix Pylint error consider-using-withAndrea Grandi2022-08-121-15/+14
| | | | | | | | | | | | | | | | | | | | | Pylint recommends using with for the allocation of the ThreadPoolExecutor object. The script uses the non-default shutdown() argument wait=False to try to avoid to hang at the end of the test execution. However, the additional argument does not actually prevent the hang from happening and can be removed. Fix the Pylint error using "with" as recommended. BUG=b:239100048 TEST=cros lint test/run_device_tests.py BRANCH=none Signed-off-by: Andrea Grandi <agrandi@google.com> Change-Id: Ia645221fa3630dfcc4fa9d9d1d1581fdb35797ca Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3766500 Reviewed-by: Tom Hughes <tomhughes@chromium.org> Reviewed-by: Bobby Casey <bobbycasey@google.com>
* ec: Fix unstable coverage in charge_managerJeremy Bettis2022-08-121-0/+3
| | | | | | | | | | | | | | | | | | The function charger_detect_debounced() is often called after the test ends. Add a 2 sec sleep to the end of the test just to make sure that function gets called at least once. BRANCH=None BUG=b:242036305 FIXES=b:242036305 TEST=See bug. Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: Ie2700a12a71b1bbaeaa0101b389975a3794fe6d6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3824929 Tested-by: Jeremy Bettis <jbettis@chromium.org> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com>
* ec: Fix test if build with clangJeremy Bettis2022-08-091-0/+2
| | | | | | | | | | | | | | | | Add #ifdef around gcc only pragma BRANCH=None BUG=None TEST=make test-coverage -j72 CC=clang Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: Ia14014ecb6ce912e86a1a673f97411d07318cd40 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3818126 Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Fabio Baltieri <fabiobaltieri@google.com>
* util: remove unused includesYuval Peress2022-08-054-1/+4
| | | | | | | | | | | | | | | | Remove these includes as they're not needed in this header. Instead, the includes should go where they're actually being used. BRANCH=none BUG=b:240574048 TEST=make buildall -j TEST=zmake build -a Signed-off-by: Yuval Peress <peress@google.com> Change-Id: I64b10af3216654b2a20caa1cabd267661a0bca39 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3791980 Reviewed-by: Tristan Honscheid <honscheid@google.com> Commit-Queue: Tristan Honscheid <honscheid@google.com>
* ec: Fix stack smashing in motion_sense_fifoJeremy Bettis2022-08-041-12/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | The struct ec_response_motion_sense_fifo_info contains one of those annoying [0] arrays, therefore you need to actually allocate extra space for the data after the end of the struct. Change all allocations of struct ec_response_motion_sense_fifo_info to actually use a uint8_t[] instead that is sizeof(struct ec_response_motion_sense_fifo_info) + sizeof(uint16_t) * MAX_MOTION_SENSORS. Added comment to motion_sense_fifo_get_info() to warn people about the pointer they pass into the function. BRANCH=None BUG=b:237305991 TEST=make run-coverage-motion_sense_fifo in chroot, and gitlab docker Change-Id: I23bc3168c43ce1e4cb20584e6a455773a789ff02 Signed-off-by: Jeremy Bettis <jbettis@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3812496 Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Aaron Massey <aaronmassey@google.com>
* motion_sense_fifo: Reset timestamp only when ODR changesGwendal Grignou2022-08-031-34/+4
| | | | | | | | | | | | | | | | | | | | | Timestamp spreading is reset after each fifo commit. It prevents the fifo logic to operate when the EC takes more than a period to collect the samples. Reset timestamp spreading only when ODR changes. Move needed fields inside motion_sense_fifo to handle virtual sensors. Fixes commit bc9660a4b3e8 ("common: motionsense fifo: Reset the initialized bits after commit") BUG=b:168335284,b:237305991,b:217580259 BRANCH=all TEST=make run-motion_sense_fifo Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: If7265079f7fc7f4e7e22dd80865305f4553df020 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3754212 Reviewed-by: Yuval Peress <peress@google.com>
* motion_sense_fifo: Move lost to motion_sensor_fifoGwendal Grignou2022-08-031-3/+0
| | | | | | | | | | | | | | Move lost field from the sensor object to inside motion_sense_fifo: It is not used anywhere else. BUG=b:237305991 BRANCH=brya TEST=make -j BOARD=crota Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Change-Id: Idfb159ed9025e859e86bb494cf5da98df9cf4a36 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3754211 Reviewed-by: Yuval Peress <peress@google.com>
* TCPMv2: Add BIST shared modeDiana Z2022-08-031-0/+8
| | | | | | | | | | | | | | | | | | Systems which have a shared power reserve over ports are required to implement BIST shared test mode. This mode will force us to advertise more current than we can actually support, but it is only for test purposes and the tester should not actually draw past our VIF declared maximum. BRANCH=None BUG=b:237256250 TEST=zmake testall Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Iacb17e0b3eb14c5b38220c7008aa3d2a8f0607a9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3789835 Commit-Queue: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* ec: Switch black to 80 cols and reformat filesJeremy Bettis2022-07-262-27/+73
| | | | | | | | | | | | | | | | | | | | Add pyproject.toml config file to set black to 80 columns. Remove column length overrides from other config files. Reformat python files to 80 cols. BRANCH=None BUG=b:238434058 TEST=presubmit/CQ Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I870a68f1bb751f4bad97024045f6e3075489e80f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3764071 Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* Revert "tree: Add OWNERS files for fingerprint-related files"Jeremy Bettis2022-07-261-87/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 9d2aa487915b7be23f3e0aeff9266cb204e9cbfa. Reason for revert: Having only fp team owners on these files prevents refactorings. Original change's description: > tree: Add OWNERS files for fingerprint-related files > > There are already OWNERS files for the core fingerprint-related code, > but we were missing some utilities and tests. > > BRANCH=none > BUG=b:227673625 > TEST=none > > Signed-off-by: Tom Hughes <tomhughes@chromium.org> > Change-Id: I0adf9bebf651ff34eab29d127bf749e4f101405d > Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3565043 > Reviewed-by: Andrea Grandi <agrandi@google.com> > Reviewed-by: Bobby Casey <bobbycasey@google.com> BRANCH=none BUG=b:227673625 TEST=none Change-Id: Ic5374c962a912783654246f498dbca98f6055075 Signed-off-by: Jeremy Bettis <jbettis@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3788138 Tested-by: Jeremy Bettis <jbettis@chromium.org> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* run_device_tests.py: Refactor main() into smaller functionsAndrea Grandi2022-07-201-95/+103
| | | | | | | | | | | | | | | | | | | | | | | Pylint reports several errors in the main() function, which has grown over time to include many lines: R0914: Too many local variables (21/15) (too-many-locals) R0912: Too many branches (18/12) (too-many-branches) R0915: Too many statements (84/50) (too-many-statements) Break down the function into smaller ones that are within the guidelines recommended by the linter. BUG=b:239100048 TEST=cros lint test/run_device_tests.py TEST=./test/run_device_tests.py --flasher=jtrace --remote=localhost \ --jlink_port=19020 --board dartmonkey => PASS BRANCH=none Signed-off-by: Andrea Grandi <agrandi@google.com> Change-Id: I77d4ddd20b102894428ef6999f4f2ead53ce6d44 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3766499 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* run_device_tests.py: Update disabled linter optionsAndrea Grandi2022-07-201-4/+2
| | | | | | | | | | | | | | | | | | The latest version of Pylint introduced new checkers that are flagging errors in lines of code where Pylint errors had already been disabled. Update pylint disable directives to suppress import errors. Explicitly set check=False (default value) so subprocess-run-check is no longer required. BUG=b:239100048 TEST=cros lint test/run_device_tests.py BRANCH=none Signed-off-by: Andrea Grandi <agrandi@google.com> Change-Id: I6d2dd2f1660cb34f2bff0a1ed073825b80f5da6a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3766498 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* run_device_tests.py: Disable pylint error broad-exceptAndrea Grandi2022-07-201-2/+2
| | | | | | | | | | | | | | | | | | Pylint reports an error when generic exception are used: W0703: Catching too general exception Exception (broad-except) This is intentional since we want to ensure all failures in these operations are ignored to avoid disruptions. BUG=b:239100048 TEST=cros lint test/run_device_tests.py BRANCH=none Signed-off-by: Andrea Grandi <agrandi@google.com> Change-Id: Id413d4f46626afa805c734b9abcad931852a471e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3766497 Reviewed-by: Bobby Casey <bobbycasey@google.com> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* run_device_tests.py: Add missing docstringsAndrea Grandi2022-07-201-1/+6
| | | | | | | | | | | | | | | | Pylint reports several missing docstring errors: C0116: Missing function or method docstring (missing-function-docstring) Add documentation where required. BUG=b:239100048 TEST=cros lint test/run_device_tests.py BRANCH=none Signed-off-by: Andrea Grandi <agrandi@google.com> Change-Id: I006cd21faf3e149b8fb76a49e644afd16db316e2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3766496 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* run_device_tests.py: Simplify code using dataclassAndrea Grandi2022-07-201-58/+36
| | | | | | | | | | | | | | | | | | | | | Pylint reports the following error in the declarations of BoardConfig and TestConfig: R0903: Too few public methods (0/2) (too-few-public-methods) Simplify their declarations using dataclass. Also suppress R0902: too-many-instance-attributes for TestConfig. BUG=b:239100048 TEST=cros lint test/run_device_tests.py TEST=./test/run_device_tests.py --flasher=jtrace --remote=localhost \ --jlink_port=19020 --board dartmonkey => PASS BRANCH=none Signed-off-by: Andrea Grandi <agrandi@google.com> Change-Id: Iba406667546e172e55e30c0044e06419c1d5595c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3766495 Reviewed-by: Tom Hughes <tomhughes@chromium.org>
* test/printf: Account for differences in the builtin printfTom Hughes2022-07-191-55/+123
| | | | | | | | | | | | | | | | | EC's printf implementation has some bugs, which results in different output when compared to printf from the standard library. Account for these with a conditional until they are fixed. BRANCH=none BUG=b:234181908, b:238433667, b:239233116 TEST=make BOARD=dartmonkey test-printf TEST=make run-printf Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Ie8006a128f5cc1c32f1248c004697c61f4ac001a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3750110 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
* tree: Move printf declarations to stdio.hTom Hughes2022-07-191-1/+9
| | | | | | | | | | | | | | | | | The "builtin" directory is EC's copy of the C standard library headers. Move the declarations for printf functions that are provided by the standard library to the "builtin" directory. This change makes it easier for future changes to optionally build with the C standard library instead of the standalone EC subset. BRANCH=none BUG=b:172020503, b:234181908, b:237823627 TEST=make buildall Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I4a5b4f8b98b972e86c4cca65d4910b5aa07ec524 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3712034 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>