[LTP] [PATCH] lib/tst_test.c: Fix tst_brk() handling
Cyril Hrubis
chrubis@suse.cz
Thu Apr 3 16:12:27 CEST 2025
Hi!
> One thing I'm worried is the fact that some shell loader tests core dumped in CI:
> https://github.com/pevik/ltp/actions/runs/14242818586/job/39916477770
> e.g. these which are supposed to TBROK due broken metadata:
> shell_loader_invalid_block.sh, shell_loader_no_metadata.sh,
> shell_loader_wrong_metadata.sh:
>
> Segmentation fault (core dumped)
Ah, that's because if we call tst_brk() before we finished
initialization results is not defined. We need at least:
diff --git a/lib/tst_test.c b/lib/tst_test.c
index c6395a5eb..6b1100b09 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -407,7 +407,8 @@ void tst_vbrk_(const char *file, const int lineno, int ttype, const char *fmt,
* current process.
*/
if (TTYPE_RESULT(ttype) == TBROK) {
- tst_atomic_inc(&results->abort_flag);
+ if (results)
+ tst_atomic_inc(&results->abort_flag);
/*
* If TBROK was called from one of the child processes we kill
> I also wonder if tst_brk() related doc should be updated.
I did update the documentation comment in the tst_test.h.
> Isn't there anything which should be updated in doc/old/C-Test-API.asciidoc ?
> This docs will stay with us for some time, the conversion to kerneldoc takes
> time, it'd be good to keep it updated (valuable texts will be migrated to
> kerneldoc).
>
> Maybe parts:
> 1.8 Doing the test in the child process
> 1.9 Fork() and Parent-child synchronization
> (both code examples and the description).
I will have a look.
> very nit: please before merge fix typos in both code and commit message:
> exitting => exiting
> countes|countes => counters
> immediatelly => immediately
> filtesystem => filesyste
Uff, will do.
> NOTE: test_brk_pass could be added to lib/newlib_tests/runtest.sh. I would also
> prefer, if we changed tests to behave like testcases/lib/run_tests.sh, i.e.
> allow to run all tests and check exit code (intermediate step before we compare
> the test output).
Rewriting the tests is a more complex task that should be done in a
separate patchset.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list