Hi Petr, On Thu, 2020-08-27 at 15:55 +0200, Petr Vorel wrote: > > > > + if ! tst_is_num $KEYRING_ID; then > > > > + tst_brk TBROK "unable to parse the new keyring id ('$KEYRING_ID')" > > > > + fi > > > > + > > > Instead of using TST_DATAROOT, which is defined as > > > "$LTPROOT/datafiles", use LTPROOT directly to define the path to the > > > cert. Adding the following will allow the test to run from the build > > > directory. > > > if [ ! -f $cert_file ]; then > > > cert_file="$LTPROOT/../datafiles/ima_keys/x509_ima.der" > > > fi > > Yes, this will work if you set LTPROOT to <ltp git>/testcases/kernel/security/integrity/ima/tests/: When running any of the tests from build tree test directory - ltp/testcases/kernel/security/integrity/ima/tests, supplying LTPROOT isn't necessary. "IMA: Refactor datafiles directory" broke running the other tests directly from the build tree as well. > > $ cd <ltp git>/testcases/kernel/security/integrity/ima/tests/ > > $ LTPROOT=$PWD PATH="../../../../../lib/:.:$PATH" ./ima_keys.sh > > But, according to doc [1] $LTPROOT is "Prefix for installed LTP, the default is > > /opt/ltp.". Using it like this is confusing (if we want to misuse $LTPROOT, one > > would expect it's a cloned git root directory). Running from git root it'd have > > to be: > > $ cd <ltp git> > > $ LTPROOT=$PWD/testcases/kernel/security/integrity/ima/tests/ \ > > PATH="testcases/lib:testcases/kernel/security/integrity/ima/tests/:$PATH" ima_keys.sh > > TL;DR: I'd really prefer people run IMA from installed LTP (make && make install > > in both testcases/lib and testcases/kernel/security/integrity/ima/ is just enough), > > but I'll add this hack to make your testing easier :). But fixing this in > > tst_test.sh is really needed. I'm looking ... > > Suggesting this diff from v4: > > + # hack when running ima_keys.sh locally from ima_keys.sh directory > + # LTPROOT=$PWD PATH="../../../../../lib/:.:$PATH" ./ima_keys.sh > + if [ ! -f "$cert_file" ]; then > + cert_file="$LTPROOT/../datafiles/ima_keys/x509_ima.der" > + fi > > Visible also on > https://github.com/pevik/ltp/tree/Lachlan_Sneff/ima_keys.sh-second-test.v4.fixes > > Not sure if you still doing review & testing, thus waiting for your comments > or tags. Sorry, yes I'm planning to. Mimi > > Kind regards, > Petr > > > > Mimi > > Kind regards, > > Petr > > [1] https://github.com/linux-test-project/ltp/wiki/User-Guidelines