On Fri, 27 Sep 2024 13:59:35 +0200 "Thomas Schmitt" <scdbac...@gmx.net> wrote:
> Hi, > > Glenn Washburn wrote: > > [...] grub-shell-luks-tester cleans up after > > itself, if it returns success. grub_cmd_cryptomount has a test that > > expects failure. But grub-shell-luks-tester doesn't know that this is > > an expected failure and should cleanup and grub_cmd_cryptomount doesn't > > ever cleanup after grub-shell-luks-tester. Perhaps > > grub-shell-luks-tester should be passed a parameter to indicate > > expected failure (eg. --xfail). Have any other ideas? > > I agree to the idea of an option to invert the effect of > [ "$RET:-1" -eq 0 ] in cleanup() of tests/util/grub-shell-luks-tester.in . > > Assuming variable "xfail" is be set to a non-empty string exactly if > argument "--xfail" is given, i'd replace: > > if [ -z "$debug" ] && [ "${RET:-1}" -eq 0 ]; then > rm -rf "$lukstestdir" || : > fi > > by: > > if [ -z "$debug" ]; then > if [ -n "$xfail" ]; then > if [ "${RET:-0}" -ne 0 ]; then > rm -rf "$lukstestdir" || : > fi > else > if [ "${RET:-1}" -eq 0 ]; then > rm -rf "$lukstestdir" || : > fi > fi > fi > > Equivalent, but heavily economizing on line count would be: > > if [ -z "$debug" ] && [ -n "$xfail" ] && [ "${RET:-0}" -ne 0 ]; then > rm -rf "$lukstestdir" || : > elif [ -z "$debug" ] && [ -z "$xfail" ] && [ "${RET:-1}" -eq 0 ]; then > rm -rf "$lukstestdir" || : > fi > > I tested both code pieces in a dry-run script with the 12 variations of > debug={"", "1"} , xfail={"", "1"} , RET={undefined, "0", "1"} . RET should never be undefined because $? always has a numerical value. And in my change I default xfail to 0. So I change the if statement to: if [ -z "$debug" ] && [ "$RET" -eq "$xfail" ]; then This is a lot simpler, though perhaps a tad less clear. Do you see a reason why this is less desirable? Glenn > Decision for removal happened only with: > (debug="", xfail="", RET="0") > (debug="", xfail="1", RET="1") > > The first code performs less []-expressions and seems clearer to me at > the price of doubled line count. > > > Have a nice day :) > > Thomas > _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel