summaryrefslogtreecommitdiff
path: root/zephyr/test/drivers/default/src/tcpci_test_common.c
Commit message (Collapse)AuthorAgeFilesLines
* tcpci: allow get_chip_info callers to update the cachePeter Marheine2023-01-221-4/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some drivers massage retrieved chip info in assorted ways (usually because the chips misbehave), but it's both confusing and inefficient how that interacts with cached chip info because the consuming driver needs to always interpose itself between possibly-cached values and its caller, usually requiring another layer of caching. This adds a new tcpci_get_chip_info_mutable() function that works like tcpci_get_chip_info(), but the caller can provide a function that modifies the cached data in order to do any required massaging. A callback is used rather than an output pointer to give the implementation freedom to change its behavior more, such as by adding locking to prevent the latent concurrency bugs that currently lurk in it. This also fixes a bug in the previous implementation where partial data would be cached if an error occurred in reading certain TCPC registers. BUG=b:244502337 TEST=make buildall; zmake build -a; twister BRANCH=none Change-Id: Ia3dcac109eb22bf0326e3fd1722aa64fe9f73f50 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4179431 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* zephyr/test: Sort header filesJeremy Bettis2022-11-151-4/+3
| | | | | | | | | | | | | | | | | | | Sort all headers in zephyr/test with the clang-format rules used by the zephyr project. BRANCH=None BUG=b:247100970 TEST=CQ Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I2428eea11e18ee4bed6bc366fd69d4254d936c10 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4022253 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* ec: Remove all zassume usagesJeremy Bettis2022-10-311-1/+1
| | | | | | | | | | | | | | | | | | | | Since zassume is being used in scenarios where no one would use ztest_test_skip(), convert all zassumes to zasserts. BRANCH=None BUG=b:256650891 TEST=./twister Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I1dc806e25f64f8dbef6f7d10cfe2f46ea4887e61 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3937539 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Auto-Submit: Jeremy Bettis <jbettis@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Aaron Massey <aaronmassey@google.com> Commit-Queue: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Aaron Massey <aaronmassey@google.com>
* zephyr: remove the msg NULL parameter in ztest macrosMichał Barnaś2022-10-101-79/+79
| | | | | | | | | | | | | | | | | This commit removes the last NULL parameter that was required by the zassert_* and zassume_* macros. BRANCH=main BUG=b:242982518 TEST=run twister Change-Id: I8970ee0a755e103367c5edcdf0fd469337c66721 Signed-off-by: Michał Barnaś <mb@semihalf.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3838329 Reviewed-by: Keith Short <keithshort@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Michał Barnaś <barnas@google.com> Tested-by: Michał Barnaś <barnas@google.com>
* Update license boilerplate text in source code filesMike Frysinger2022-09-121-1/+1
| | | | | | | | | | | | | | | Normally we don't do this, but enough changes have accumulated that we're doing a tree-wide one-off update of the name & style. BRANCH=none BUG=chromium:1098010 TEST=`repo upload` works Change-Id: Icd3a1723c20595356af83d190b2c6a9078b3013b Signed-off-by: Mike Frysinger <vapier@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3891203 Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
* zephyr: Replace deprecated zephyr.h with kernel.hAaron Massey2022-09-081-1/+1
| | | | | | | | | | | | | | | | | | The zephyr.h header has been formally deprecated upstream thus causing a build failure when downstreaming. Replace zephyr.h with kernel.h BRANCH=none BUG=none TEST=zmake build -a Signed-off-by: Aaron Massey <aaronmassey@google.com> Change-Id: I0e6095160ab7248edde00f5c8336bc8d01c6b937 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3885035 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Al Semjonovs <asemjonovs@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
* Zephyr emul: Clarify TCPCI message typeDiana Z2022-08-261-8/+8
| | | | | | | | | | | | | | | | | Both the TCPCI emulator and the partner emulator have message structures with a member named "type". Re-name the TCPCI "type" to reduce confusion when the code references msg->type in both files. BRANCH=None BUG=b:243151272 TEST=./twister -T ./zephyr/test Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: I600e8b046a701f53f21157a15d5073a127209076 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3859559 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Commit-Queue: Keith Short <keithshort@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: test: Add tcpci_hard_reset_reinit testDevin Lu2022-08-241-0/+17
| | | | | | | | | | | | | | | | | Add coverage for tcpci_hard_reset_reinit. BUG=b:239183823 BRANCH=none TEST=twister -T zephyr/test/drivers Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Change-Id: Ibc61086f7531654a2d400fa9554141538f5166ec Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3837606 Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Jeremy Bettis <jbettis@chromium.org> Tested-by: Devin Lu <devin.lu@quantatw.com> Commit-Queue: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
* zephyr: shim: add all missing include/ prefixesFabio Baltieri2022-08-041-1/+1
| | | | | | | | | | | | | | | Add all the missing include/ prefixes to the various #include around the zephyr tests so that they build with LEGACY_INCLUDE_PATH=n. BRANCH=none BUG=none TEST=zmake testall Cq-Depend: chromium:3807663 Change-Id: I81cea4f291eea61e674ef2fa61bdc60407c5f142 Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3810411 Reviewed-by: Keith Short <keithshort@chromium.org>
* zephyr: test: Migrate to upstream emulator APIAaron Massey2022-08-011-67/+88
| | | | | | | | | | | | | | | | | Migrate the existing emulators and tests to use the new upstream emulator API. Majority of these changes was the removal of struct i2c_emul usages in favor of direct usages of struct emul. BRANCH=none BUG=b:240291860 TEST=zmake test -a Signed-off-by: Aaron Massey <aaronmassey@google.com> Cq-Depend: chromium:3776856 Change-Id: I09c509ffc34ac3b28fbd4dece0acebcc36cc0932 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3781964 Reviewed-by: Yuval Peress <peress@google.com> Tested-by: Yuval Peress <peress@google.com>
* zephyr: test: migrate drivers test to twisterYuval Peress2022-07-251-0/+992
1. Move the common test logic to drivers/common with its own CMakeLists.txt 2. Move the drivers test suites to drivers/default with its own CMakeLists.txt 3. Add a Kconfig for each suite that can enable it, use Zephyr's add_subdirectory_ifdef to control which suites get added to the biary and verify that at least 1 suite was added. 4. Add a check for ZMAKE_PROJECT_NAME to still allow zmake commands 5. Add testcase.yaml which runs all the tests BRANCH=none BUG=b:240093007 TEST=./twister --coverage -p native_posix -T zephyr/test/drivers Signed-off-by: Yuval Peress <peress@google.com> Change-Id: Ib9d4ea4a8431539391cc5349a7a8fd7a7d21f120 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3784043 Reviewed-by: Tristan Honscheid <honscheid@google.com> Commit-Queue: Tristan Honscheid <honscheid@google.com>