From 05173aa66f96dd27f09959334d0624cf2d88896d Mon Sep 17 00:00:00 2001 From: Andrea Cervesato Date: Tue, 19 Mar 2024 16:37:16 +0100 Subject: [PATCH] Refactor LTP library guidelines documentation The LTP library guidelines documentation has been refactored, simplifying the overall structure, cleaning up the make check error messages which were moved into the test writing guidelines. --- doc_new/developers/ltp_library.rst | 42 ++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/doc_new/developers/ltp_library.rst b/doc_new/developers/ltp_library.rst index b780b6870ed..85b69c11c93 100644 --- a/doc_new/developers/ltp_library.rst +++ b/doc_new/developers/ltp_library.rst @@ -1,4 +1,42 @@ .. SPDX-License-Identifier: GPL-2.0-or-later -LTP Library development -======================= +LTP Library guidelines +====================== + +General Rules +------------- + +When we extend library API, we need to apply the same general rules that we use +when writing tests, plus: + +#. LTP library tests must go inside ``lib/newlib_tests`` directory +#. LTP documentation has to be updated according to API changes + +Shell API +--------- + +API source code is in ``tst_test.sh``, ``tst_security.sh`` and ``tst_net.sh`` +(all in ``testcases/lib`` directory). + +Changes in the shell API should not introduce uncommon dependencies +(use basic commands installed everywhere by default). + +Shell libraries +~~~~~~~~~~~~~~~ + +Aside from shell API libraries in ``testcases/lib``, it's worth putting +common code for a group of tests into a shell library. The filename +should end with ``_lib.sh`` and the library should load ``tst_test.sh`` or +``tst_net.sh``. + +Shell libraries should have conditional expansion for ``TST_SETUP`` or +``TST_CLEANUP``, to avoid surprises when test specific setup/cleanup function is +redefined by shell library. + +.. code-block:: bash + + # ipsec_lib.sh + # SPDX-License-Identifier: GPL-2.0-or-later + TST_SETUP="${TST_SETUP:-ipsec_lib_setup}" + ... + . tst_test.sh