On Tue, 2023-01-31 at 09:59 +0100, Roberto Sassu wrote: > From: Roberto Sassu <roberto.sassu@xxxxxxxxxx> > > Introduce these functions to let the developer specify which kernel patches > are required for the tests to be successful (either pass or fail). If a > test is not successful, print those patches in the test result summary. > > First, the developer should declare an array, named PATCHES, with the list > of all kernel patches that are required by the tests. For example: > > PATCHES=( > 'patch 1 title' > ... > 'patch N title' > ) > > Second, the developer could replace the existing expect_pass() and > expect_fail() respectively with expect_pass_if() and expect_fail_if(), and > add the indexes in the PATCHES array as the first argument, enclosed with > quotes. The other parameters of expect_pass() and expect_fail() remain the > same. > > In the following example, the PATCHES array has been added to a new test > script, tests/mmap_check.test: > > PATCHES=( > 'ima: Align ima_file_mmap() parameters with mmap_file LSM hook' > 'ima: Introduce MMAP_CHECK_REQPROT hook' > ) > > Then, expect_pass() has been replaced with expect_pass_if(): > > expect_pass_if '0' check_mmap "MMAP_CHECK" "read_implies_exec" > > The resulting output when a test fails (if the required patch is not > applied) is: > > Test: check_mmap (hook="MMAP_CHECK", test_mmap arg: "read_implies_exec") > Result (expect found): not found > Possibly missing patches: > - ima: Align ima_file_mmap() parameters with mmap_file LSM hook > > Signed-off-by: Roberto Sassu <roberto.sassu@xxxxxxxxxx> Keeping it simple like this works for now. Based on Stefan's previous comments, the variable 'idx' should probably be defined as local. Otherwise, Reviewed-by: Mimi Zohar <zohar@xxxxxxxxxxxxx>