Skip to contentSkip to conversation

Bump new hush commits and fix old hush test behavior

PATCH In review Francis Laniel 2 participants 5 messages Sep 3, 2024 – Sep 15, 2024

lore
Share & tools
lore
#0 lore raw

cover Bump new hush commits and fix old hush test behavior

Hi!

With this series, I bumped the new hush to get the latest commits from upstream.

Also, I added back a reverted commit which goal was to fix a bad behavior in old hush test.
I had to tweak a bit this commit, but everything worked both locally and in the CI [1].

Francis Laniel (1):
cli: modern_hush: Add upstream commits up to 13 July 2024

Ion Agorria (1):
test: hush: dollar: fix bugous behavior

 common/cli_hush_modern.c   |   2 +-
 common/cli_hush_upstream.c | 150 ++++++++++++++++++++++++-------------
 test/hush/dollar.c         |  31 +++-----
 3 files changed, 110 insertions(+), 73 deletions(-)

Best regards.
---
[1]: https://github.com/u-boot/u-boot/runs/29350673974
--
2.34.1

#1 lore raw

PATCH 1/2 test: hush: dollar: fix bugous behavior

From: Ion Agorria <[email protected]>

The dollar test was merged with bugous console behavior, and instead of fixing it, this behavior was just workarounded. This was done to keep compatibility with the existing behavior.

It seems like without the fix the ut_assert_skipline(); didn't clear
console and running ut_assert_skipline(); many times would give always
OK. With e58bafc35fe3 ("lib: membuff: fix readline not returning line in case of overflow") the line is cleared correctly and next assert fails because now there
is nothing to clean which is correct if we look the this a bit above
the failing assert:

    if (gd->flags & GD_FLG_HUSH_MODERN_PARSER) {
         /*
          * For some strange reasons, the console is not empty after
          * running above command.
          * So, we reset it to not have side effects for other tests.
          */
         console_record_reset_enable();
    } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
         ut_assert_console_end();
    }

Which further confirms that tests workaround the old problem and now that problem is fixed we can remove the whole if blocks and simply place ut_assert_console_end() right after ut_assert_skipline() without any conditional and will pass green.

So this part of code goes from:

    ut_assert_skipline();
    ut_assert_skipline();

    if (gd->flags & GD_FLG_HUSH_MODERN_PARSER) {
        /* See above comments. */
        console_record_reset_enable();
    } else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
        ut_assert_console_end();
    }

to become:

    ut_assert_skipline();
    if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
        ut_assert_skipline();
    }
    ut_assert_console_end();

The if block mentioned above that calls console_record_reset_enable() is completely removed as fixed by e58bafc35fe3.

[mkorpershoek: reworded commit title]
[flaniel: remove console_record_reset_enable() if]
[flaniel: adapt second if]
---
 test/hush/dollar.c | 31 ++++++++++++-------------------
 1 file changed, 12 insertions(+), 19 deletions(-)
test/hush/dollar.c +12 -19
index 4caa07c192a..cfcb1bd3e1d 100644
@@ -53,29 +53,22 @@ static int hush_test_simple_dollar(struct unit_test_state *uts)
 	ut_asserteq(1, run_command("dollar_foo='bar quux", 0));
 	/* Next line contains error message */
 	ut_assert_skipline();
-
-	if (gd->flags & GD_FLG_HUSH_MODERN_PARSER) {
-		/*
-		 * For some strange reasons, the console is not empty after
-		 * running above command.
-		 * So, we reset it to not have side effects for other tests.
-		 */
-		console_record_reset_enable();
-	} else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
-		ut_assert_console_end();
-	}
+	ut_assert_console_end();
 
 	ut_asserteq(1, run_command("dollar_foo=bar quux\"", 0));
-	/* Two next lines contain error message */
-	ut_assert_skipline();
+	/* Next line contains error message */
 	ut_assert_skipline();
-
-	if (gd->flags & GD_FLG_HUSH_MODERN_PARSER) {
-		/* See above comments. */
-		console_record_reset_enable();
-	} else if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
-		ut_assert_console_end();
+	/*
+	 * Old parser prints the error message on two lines:
+	 * Unknown command 'quux
+	 * ' - try 'help'
+	 * While the new only prints it on one:
+	 * syntax error: unterminated \"
+	 */
+	if (gd->flags & GD_FLG_HUSH_OLD_PARSER) {
+		ut_assert_skipline();
 	}
+	ut_assert_console_end();
 
 	ut_assertok(run_command("dollar_foo='bar \"quux'", 0));
 

--
2.34.1

#2 lore raw

PATCH 2/2 cli: modern_hush: Add upstream commits up to 13 July 2024

In reply to Francis Laniel

This commit adds the following hush busybox upstream commits:
23da5c4b716b ("hush: do not exit interactive shell on some redirection errors") 14e28c18ca1a ("hush: fix "exec 3>FILE" aborting if 3 is exactly the next free fd") 6c38d0e9da2d ("hush: avoid duplicate fcntl(F_SETFD, FD_CLOEXEC) during init") 758b21402abc ("hush: detect when terminating "done"/"fi" is missing") 2639f3bc72ac ("hush: set G.ifs sooner (prevents segfault)")

Adding specific ifdef and endif guard was needed for 2639f3bc72ac.

---
 common/cli_hush_modern.c   |   2 +-
 common/cli_hush_upstream.c | 150 ++++++++++++++++++++++++-------------
 2 files changed, 98 insertions(+), 54 deletions(-)
common/cli_hush_modern.c +1 -1
index cd88c9de8ab..deb61c3389d 100644
@@ -25,7 +25,7 @@
 /*
  * BusyBox Version: UPDATE THIS WHEN PULLING NEW UPSTREAM REVISION!
  */
-#define BB_VER			"1.35.0.git7d1c7d833785"
+#define BB_VER			"1.37.0.git23da5c4b716b"
 
 /*
  * Define hush features by the names used upstream.
common/cli_hush_upstream.c +97 -53

283 lines not on this page · raw message

--
2.34.1

#3 lore raw
In reply to Francis Laniel
Quoted 12 lines · Francis Laniel

Hi!

With this series, I bumped the new hush to get the latest commits from upstream.

Also, I added back a reverted commit which goal was to fix a bad behavior in old hush test.
I had to tweak a bit this commit, but everything worked both locally and in the CI [1].

Francis Laniel (1):
cli: modern_hush: Add upstream commits up to 13 July 2024

Quoted 7 lines

Ion Agorria (1):
test: hush: dollar: fix bugous behavior

 common/cli_hush_modern.c   |   2 +-
 common/cli_hush_upstream.c | 150 ++++++++++++++++++++++++-------------
 test/hush/dollar.c         |  31 +++-----
 3 files changed, 110 insertions(+), 73 deletions(-)

Were you able to look in to the issue that caused us to have to revert back to using the old hush by default?

Signature · 1 line
Tom
#4 lore raw
In reply to Francis Laniel
Quoted 8 lines · Francis Laniel

With this series, I bumped the new hush to get the latest commits from upstream.

Also, I added back a reverted commit which goal was to fix a bad behavior in old hush test.
I had to tweak a bit this commit, but everything worked both locally and in the CI [1].

[...]

Applied to u-boot/next, thanks!

Signature · 1 line
Tom