Re: [PATCH] rust: rust_is_available: support testing with `bash` as `/bin/sh`

Onur Özkan <[email protected]> Thu, 23 Jul 2026 16:42:05 +0300
Newsgroups org.kernel.vger.linux-kbuild,org.kernel.vger.rust-for-linux
Message-ID <[email protected]>
On Sun, 19 Jul 2026 15:07:23 +0200=0D
Miguel Ojeda <[email protected]> wrote:=0D
=0D
> `command -v` behaves differently on `dash` vs. `bash` when faced with=0D
> a file without the execute bit.=0D
> =0D
> Thus, for the non-executable `rustc` and `bindgen` tests, support both=0D
> possible outputs that the script currently gives.=0D
> =0D
> This makes the test script clean on distributions like Fedora.=0D
> =0D
> Signed-off-by: Miguel Ojeda <[email protected]>=0D
> ---=0D
> Independently, we could add a custom check for the non-exec case in the=0D
> actual shell script, but back then it was decided with Kbuild to avoid=0D
> overcomplicating it for rare cases (which anyway give an error).=0D
> =0D
>  scripts/rust_is_available_test.py | 14 ++++++++++++--=0D
>  1 file changed, 12 insertions(+), 2 deletions(-)=0D
> =0D
> diff --git a/scripts/rust_is_available_test.py b/scripts/rust_is_availabl=
e_test.py=0D
> index d6d54b7ea42a..752c59d5f55f 100755=0D
> --- a/scripts/rust_is_available_test.py=0D
> +++ b/scripts/rust_is_available_test.py=0D
> @@ -177,7 +177,12 @@ else:=0D
> =0D
>      def test_rustc_nonexecutable(self):=0D
>          result =3D self.run_script(self.Expected.FAILURE, { "RUSTC": sel=
f.nonexecutable })=0D
> -        self.assertIn(f"Running '{self.nonexecutable}' to check the Rust=
 compiler version failed with", result.stderr)=0D
> +        self.assertTrue(=0D
> +            # `dash`.=0D
> +            f"Running '{self.nonexecutable}' to check the Rust compiler =
version failed with" in result.stderr or=0D
> +            # `bash`.=0D
> +            f"Rust compiler '{self.nonexecutable}' could not be found." =
in result.stderr=0D
> +        )=0D
> =0D
>      def test_rustc_unexpected_binary(self):=0D
>          result =3D self.run_script(self.Expected.FAILURE, { "RUSTC": sel=
f.unexpected_binary })=0D
> @@ -205,7 +210,12 @@ else:=0D
> =0D
>      def test_bindgen_nonexecutable(self):=0D
>          result =3D self.run_script(self.Expected.FAILURE, { "BINDGEN": s=
elf.nonexecutable })=0D
> -        self.assertIn(f"Running '{self.nonexecutable}' to check the Rust=
 bindings generator version failed with", result.stderr)=0D
> +        self.assertTrue(=0D
> +            # `dash`.=0D
> +            f"Running '{self.nonexecutable}' to check the Rust bindings =
generator version failed with" in result.stderr or=0D
> +            # `bash`.=0D
> +            f"Rust bindings generator '{self.nonexecutable}' could not b=
e found." in result.stderr=0D
> +        )=0D
> =0D
>      def test_bindgen_unexpected_binary(self):=0D
>          result =3D self.run_script(self.Expected.FAILURE, { "BINDGEN": s=
elf.unexpected_binary })=0D
> =0D
> base-commit: 880c43b185ca52239e75bc546cc4f4d9154d0fed=0D
> --=0D
> 2.55.0=0D
=0D
Nit: You can add some useful failure message, something like "$binary could=
 not=0D
found in the system". The default failure message for assertTrue is somethi=
ng=0D
like "False is not True", which is not helpful. But the failed lines will a=
lso=0D
be printed so it's not entirely unclear as well.=0D
=0D
With/without that:=0D
=0D
Reviewed-by: Onur =C3=96zkan <[email protected]>=0D