summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJeremy Bettis <jbettis@google.com>2022-10-06 15:33:56 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-10-31 19:42:45 +0000
commit0ee5a8129d31a25e83803200b36988a3cda2f99a (patch)
tree9cae43951981cd41fef2cba249b76599d8c83663 /docs
parent68aaceab6d42796457f2f89f113e30dcd9ae64b4 (diff)
downloadchrome-ec-0ee5a8129d31a25e83803200b36988a3cda2f99a.tar.gz
ec: Remove all zassume usages
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>
Diffstat (limited to 'docs')
-rw-r--r--docs/zephyr/ztest.md37
1 files changed, 5 insertions, 32 deletions
diff --git a/docs/zephyr/ztest.md b/docs/zephyr/ztest.md
index 437c79d12e..84faa9371f 100644
--- a/docs/zephyr/ztest.md
+++ b/docs/zephyr/ztest.md
@@ -151,38 +151,11 @@ Other useful flags:
## Using assumptions
-The `zassume_*` API is used to minimize failures while allowing us to find out
-exactly what's going wrong. When writing a test, only assert on code you're
-testing. Any dependencies should use the `zassume_*` API. If the assumption
-fails, your test will be marked as skipped and Twister will report an error.
-Generally speaking, if an assumption fails, either the test wasn't set up
-correctly, or there should be another test that's testing the dependency.
-
-### Example: when to use an assumption
-
-In a given project layout we might have several components (A, B, C, and D). In
-this scenario, components B, C, and D all depend on A to function. In each test
-for B, C, and D we'll include the following:
-
-```c
-static void test_suite_before(void *f)
-{
- struct my_suite_fixture *fixture = f;
-
- zassume_ok(f->a->init(), "Failed to initialize A, see test suite 'a_init'");
-}
-```
-
-The above will call A's init function and assume that it returned 0 (status OK).
-If this assumption fails, then B, C, and D will all be marked as skipped along
-with a log message telling us to look at the test suite 'a_init'.
-
-Key takeaways:
-1. If it's code that you depend on (module/library/logic), use assume. It's not
- what you're testing, you shouldn't raise false failures.
-2. Document why/where you believe that the logic should have been tested. If we
- end up skipping this test, we should know where the tests that should have
- caught the error belong.
+The `zassume*` API is used to skip tests when certain preconditions are not
+met. Please don't use it. In our tests we shouldn't ever need to skip tests
+since we control all dependencies. If for some reason you actually need to skip
+a test use `ztest_test_skip()` since that will indicate that you intended to
+skip and didn't use assume by mistake when you meant to use assert.
## Debugging