• Petr Machata's avatar
    selftests: forwarding: Have RET track kselftest framework constants · 596c8819
    Petr Machata authored
    The variable RET keeps track of whether the test under execution has so far
    failed or not. Currently it works in binary fashion: zero means everything
    is fine, non-zero means something failed. log_test() then uses the value to
    given a human-readable message.
    
    In order to allow log_test() to report skips and xfails, the semantics of
    RET need to be more fine-grained. Therefore have RET value be one of
    kselftest framework constants: $ksft_fail, $ksft_xfail, etc.
    
    The current logic in check_err() is such that first non-zero value of RET
    trumps all those that follow. But that is not right when RET has more
    fine-grained value semantics. Different outcomes have different weights.
    
    The results of PASS and XFAIL are mostly the same: they both communicate a
    test that did not go wrong. SKIP communicates lack of tooling, which the
    user should go and try to fix, and as such should not be overridden by the
    passes. So far, the higher-numbered statuses can be considered weightier.
    But FAIL should be the weightiest.
    
    Add a helper, ksft_status_merge(), which merges two statuses in a way that
    respects the above conditions. Express it in a generic manner, because exit
    status merge is subtly different, and we want to reuse the same logic.
    
    Use the new helper when setting RET in check_err().
    
    Re-express check_fail() in terms of check_err() to avoid duplication.
    Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
    Link: https://lore.kernel.org/r/7dfff51cc925c7a3ac879b9050a0d6a327c8d21f.1711464583.git.petrm@nvidia.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    596c8819
lib.sh 2.16 KB