grub-fstest: Show error message if command causes grub_errno
cover grub-fstest: Show error message if command causes grub_errno
Most return values of function execute_command() are ignored in util/grub-fstest.c. Only one of two "loopback" occasions and the command "cryptomount" care. They perform grub_util_error() if the return value is non-zero.
So there seems to be a general lack of handling of problems found in the drivers or command implementations.
On the other hand, all tests which use grub-fstest are accustomed to this silence about problems. Internal processing of grub-fstest does possibly important things after an error occurs and before the program ends. It seems inappropriate to immediately bail out when execute_command() encounters grub_errno != GRUB_ERROR_NONE.
So i propose a patch which just counts the occurences of grub_errno in execute_command(), reports grub_errmsg, and resets grub_errno. Processing goes on as is tradition. But at the end of the program, a non-zero error count causes a non-zero exit value.
Example:
$ gunzip <tests/iso9660_ce_loop2.iso.gz >/tmp/iso9660_ce_loop2.iso $ ./grub-fstest /tmp/iso9660_ce_loop2.iso ls / ls : GRUB error 9 with message 'suspecting endless CE loop' ./grub-fstest: error: encountered 1 error during command execution. $ echo $? 1
(I will submit an addon patch which changes the grub_errno display to
ls : GRUB_ERR_BAD_FS with message 'suspecting endless CE loop'
by adding a new function grub_errno_to_name() to err.[ch].)
A new program option -E re-activates the current behavior. I.e. it disables counting, reporting, and non-zero exit caused by grub_errno.
After installing help2man and running ./configure i get from "make" a file grub-fstest.1 which mentions the new option. (I fail to find file grub-fstest.info which is promised by the text in grub-fstest.1. Package texinfo is installed.)
I duely checked the impact of this change on "make check:
Installed are the Debian 12 packages which INSTALL prescribes. "make check" was run as superuser with the old and the new version of grub-fstest. Then i compared the outputs about PASS and FAIL.
The only test which newly failed is iso9660_ce_loop in tests/iso9660_test.in because it takes non-zero exit as indication of timeout, but will now regularly receive non-zero because iso9660_ce_loop.iso is intentionally bad.
So patch 2/2 adds -E to the run of grub-fstest with iso9660_ce_loop. This makes tests/iso9660_test PASS again.
4 tests yielded SKIP due to my platform "efi" and target "x86_64":
tests/fddboot_test.in
tests/netboot_test.in
tests/pseries_test.in
tests/core_compress_test.in
They are small and i can see no reference to grub-fstest in them.
6 tests yielded FAIL with both versions of grub-fstest. They seem unrelated to grub-fstest:
- erofs_test says:
mkfs.erofs -Eforce-inode-compact -L g;/éт 莭😁 /tmp/grub-fs-tester.2024062018
0702880665192.erofs_compact.XeJ/erofs_compact_512_4096_1_0.img /tmp/grub-fs-tester.20240620180702880665192.erofs_compact.XeJ/master
mkfs.erofs: invalid option -- 'L'
The test seems to expect something other than erofs-utils_1.5-1_amd64.deb
of Debian 12.
- exfat_test shows the help text of mkfs.exfat. In grub-fs-tester i see
x"exfat")
"mkfs.$fs" -s $((BLKSIZE/512)) -n "$FSLABEL" "${MOUNTDEVICE}"But mkfs.exfat has neither option -s nor -n in help text or man page. mkexfatfs offers: -n volume-name -s sectors-per-cluster
- hfs_test says:
LABEL FAIL
Device loop0: Filesystem type hfs - Label `untitled' ...
grub-fs-tester does:
FSLABEL="grub_t;/estéàèèéie fiucnree";;
"mkfs.hfs" -b $BLKSIZE -v "`echo $FSLABEL |recode utf8..macroman`" -h "${MOUNTDEVICE}" man mkfs.hfs shows man newfs_hfs, where -v is mentioned as:
-v volume-name
Volume name (file system name) in ascii or UTF-8 format.
(Was already so in Debian 11.)
So the recode filter seems unneeded and unhelpful.
- luks1_test says:
./grub-probe: error: disk `lvm/grub-fs-tester.20230401111443076506440.luks1.PDo' not found.
UUID FAIL
96efa19ce89c41279912b6a3b26a99d3- luks2_test says:
./grub-probe: error: disk `lvm/grub-fs-tester.20230401111450278223161.luks2.NWP' not found.
UUID FAIL
8a1f1e83695d4dd1b6b73fcb542b73da- grub_func_test reports checksum problems
tests/video_checksum.c:checksum:615: assert failed: 0 Checksum cmdline_cat_2560x1440xrgba8888:44 failed: 0x62031fea vs 0x8071678a
-----------------------------------------------------------------------
Thomas Schmitt (2):
grub-fstest: Show error message if command causes grub_errno
tests: Use new grub-fstest option -E with iso9660_ce_loop test
tests/iso9660_test.in | 2 +- util/grub-fstest.c | 30 +++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-)
--
2.39.2
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 1/2 grub-fstest: Show error message if command causes grub_errno
Check grub_errno after a command was performed. If not GRUB_ERR_NONE then print grub_errno and grub_errmsg. Count the errors and exit 1 with a message if the count is larger than zero when function fs_test() ends. The number of printed messages is restricted to 3.
Introduce a new option -E which re-enables the old behavior which did not show grub_errmsg and did not exit with non-zero value if grub_errno was found not being GRUB_ERR_NONE.
--- util/grub-fstest.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-)
util/grub-fstest.c +29 -1
@@ -47,16 +47,33 @@#pragma GCC diagnostic error "-Wmissing-prototypes"#pragma GCC diagnostic error "-Wmissing-declarations" +static int execute_error_count =0 ; +static int no_cmd_error =0 ; +static grub_err_t execute_command (const char *name,int n,char **args) {grub_command_t cmd; +grub_err_t ret; cmd =grub_command_find (name);if (! cmd)grub_util_error (_ ("can't find command `%s'" ), name); -return (cmd->func) (cmd, n, args); + ret = (cmd->func) (cmd, n, args); +if (grub_errno !=GRUB_ERR_NONE && !no_cmd_error) + { + execute_error_count++; +if (execute_error_count <=3 ) +grub_err_printf (_ ("%s : GRUB error %d with message '%s'\n" ), + name, (int ) grub_errno, grub_errmsg); +else if (execute_error_count ==4 ) +grub_err_printf (_ ("%s : more GRUB errors encountered but not shown\n" ), + name); + grub_errno =GRUB_ERR_NONE ; + grub_errmsg[0 ] =0 ; + } +return ret; }enum {
@@ -510,6 +527,12 @@ fstest (int n)grub_free (loop_name);grub_free (argv[0 ]); } + +if (execute_error_count ==1 ) +grub_util_error (_ ("encountered 1 error during command execution" )); +else if (execute_error_count >0 ) +grub_util_error (_ ("encountered %d errors during command execution" ), + execute_error_count); }static struct argp_option options[] = {
@@ -535,6 +558,7 @@ static struct argp_option options[] = { N_("FILE|prompt"), 0, N_("Load zfs crypto key."), 2}, {"verbose", 'v', NULL, 0, N_("print verbose messages."), 2}, {"uncompress", 'u', NULL, 0, N_("Uncompress data."), 2}, + {"no-cmd-error", 'E', NULL, 0, N_("Ignore errors of command execution."), 2}, {0, 0, 0, 0, 0, 0} };
@@ -638,6 +662,10 @@ argp_parser (int key, char *arg, struct argp_state *state) uncompress =1 ;return 0 ; +case 'E' : + no_cmd_error =1 ; +return 0 ; +case ARGP_KEY_END :if (args_count < num_disks) {
--
2.39.2
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 2/2 tests: Use new grub-fstest option -E with iso9660_ce_loop test
In reply to Thomas Schmitt via Grub-develThis part of tests/iso9660_test works on an intentionally bad ISO which with older versions of GRUB will cause an endless cycle. Therefore the test runs grub-fstest under the program timeout. A non-zero exit value is taken as indication that the timeout was triggered. Non-empty output from grub-fstest is taken as indication that a CE entry was skipped by an old bug, thus breaking the endless cycle by mistake.
A change in grub-fstest causes output of an error message and a non-zero exit value when the bad ISO is handled properly.
So add the new grub-fstest option -E to the run of grub-fstest on iso9660_ce_loop.iso and iso9660_ce_loop2.iso. This suppresses the error message and the non-zero exit value.
--- tests/iso9660_test.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/iso9660_test.in +1 -1
@@ -20,7 +20,7 @@ for fs in iso9660_ce_loop iso9660_ce_loop2; do { echo "Failed to make temporary directory"; exit 99; } gunzip <"$srcdir"/tests/${fs}.iso.gz >"${tempdir}/${fs}.iso" || exit 99 output=$(LC_ALL=C timeout -s KILL "60" \ - "@builddir@/grub-fstest" "${tempdir}/${fs}.iso" ls / ) || ret=$? + "@builddir@/grub-fstest" -E "${tempdir}/${fs}.iso" ls / ) || ret=$? rm -rf "$tempdir" if [ "${ret:-0}" -ne 0 -o -n "$output" ]; then echo "FAIL ($fs)"
--
2.39.2
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Hi,
somehow i managed to omit the first paragraph of the cover letter:
---------------------------------------------------------------------
grub-fstest describes itself as "debug tool for filesystem driver" but fails to forward to the user the grub_errno status and grub_errmsg of the drivers under command "ls". Further it does not indicate such errors by its exit status.
Reason is that function grub_cmd_ls() in grub-core/commands/ls.c unconditionally returns 0 and that grub_errno is not used anywhere in util/grub-fstest.c.
---------------------------------------------------------------------
Have a nice day :)
Thomas
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel