Skip to content

Commit f78759e

Browse files
ioannisgcarlescufi
authored andcommitted
tests: error_hook: documentation and style fixes in README
Add documentation, style and typo fixes in the README. Signed-off-by: Ioannis Glaropoulos <[email protected]>
1 parent 8ce99a8 commit f78759e

File tree

1 file changed

+23
-20
lines changed

1 file changed

+23
-20
lines changed

tests/ztest/error_hook/README.txt

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@ Title: A common fatal error and assert fail handler
22

33
Description:
44

5-
These two common handler is in order to reduce the redundancy code writing
6-
for fatal and assert handler for error case testing. They can be used both
7-
in kernel and userspace, and are also SMP safe.
5+
These two common handlers are developed in order to reduce the redundancy
6+
code writing for fatal and assert handler for error case testing. They can
7+
be used both in kernel and userspace, and they are also SMP safe.
88

99

1010
Why doing this
1111
==============
1212

1313
When writing error testing case (or we call it negative test case), we might
1414
have to write self-defined k_sys_fatal_handler or post_assert_handler to deal
15-
with the errors we caught, in order to make test going on. This mean much
16-
identical code would be written. So we try to make it as a common part and
17-
let other test case or app can reuse it.
15+
with the errors we caught, in order to make the test continue. This means much
16+
identical code would be written. So we try to move the error handler definition
17+
into a common part and let other test suites or applications reuse it, instead
18+
of defining their own.
1819

19-
And when error happened, it sometimes need a special action to make our testing
20-
program back to normal, such as release some resource hold before error
21-
happened. This is why we add a hook on it, in order to achieve that goal.
20+
And when error happens, we sometimes need a special action to make our testing
21+
program return back to normal, such as releasing some resource hold before the
22+
error happened. This is why we add a hook on it, in order to achieve that goal.
2223

2324

2425
How to use it in you app
@@ -48,43 +49,45 @@ Step4: call ztest_set_assert_valid(true) before where your target function
4849
call.
4950

5051

51-
You can choose to use one or both of them, depneds on your need.
52-
If you use none of them, you can still defined your own fatal or assert handler
52+
You can choose to use one or both of them, depending on your needs.
53+
If you use none of them, you can still define your own fatal or assert handler
5354
as usual.
5455

5556

5657
Test example in this test set
5758
=============================
5859

5960
This test verifies if the common fatal error and assert fail handler works.
60-
If the expected error got caught, the test case pass.
61+
If the expected error was caught, the test case will pass.
6162

6263
test_catch_assert_fail
6364
- To call a function then giving the condition to trigger the assert fail,
6465
then catch it by the assert handler.
6566

6667
test_catch_fatal_error
67-
- start a thread to test trigger a null address then catch fatal error.
68-
- start a thread to test trigger a illegal instruction then catch fatal
69-
error.
70-
- start a thread to test trigger a divide zero error then catch fatal error.
71-
- start a thread to call k_oops() then catch fatal error.
72-
- start a thread to call k_panel() then catch fatal error.
68+
- start a thread to test triggerring a null address dereferencing, then catch
69+
the (expected) fatal error.
70+
- start a thread to test triggerring an illegal instruction, then catch
71+
the (expected) fatal error.
72+
- start a thread to test triggerring a divide-by-zero error, then catch
73+
the (expected) fatal error.
74+
- start a thread to call k_oops() then catch the (expected) fatal error.
75+
- start a thread to call k_panel() then catch the (expected) fatal error.
7376

7477
test_catch_assert_in_isr
7578
- start a thread to enter ISR context by calling irq_offload(), then trigger
7679
an assert fail then catch it.
7780

7881
test_catch_z_oops
7982
- Pass illegal address by syscall, then inside the syscall handler, the
80-
Z_OOPS macro will trigger a fatal error then got caught.
83+
Z_OOPS macro will trigger a fatal error that will get caught (as expected).
8184

8285

8386

8487
Limitation of this usage
8588
========================
8689

87-
Trigger an fatal error in ISR context, that will cause problem due to
90+
Trigger a fatal error in ISR context, that will cause problem due to
8891
the interrupt stack is already abnormal when we want to continue other
8992
test case, we do not recover it so far.
9093

0 commit comments

Comments
 (0)