diff mbox series

[4/4] Makefile: add headers_install to kselftest targets

Message ID 4d34d06baf945dc31c78f873771cef3a75b60067.1657296695.git.guillaume.tucker@collabora.com (mailing list archive)
State Accepted
Headers show
Series Fix kselftest build with sub-directory | expand

Commit Message

Guillaume Tucker July 8, 2022, 4:23 p.m. UTC
Add headers_install as a dependency to kselftest targets so that they
can be run directly from the top of the tree.  The kselftest Makefile
used to try to call headers_install "backwards" but failed due to the
relative path not being consistent.

Now we can either run this directly:

  $ make O=build kselftest-all

or this:

  $ make O=build headers_install
  $ make O=build -C tools/testing/selftest all

The same commands work as well when building directly in the source
tree (no O=) or any arbitrary path (relative or absolute).

Signed-off-by: Guillaume Tucker <guillaume.tucker@collabora.com>
---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Masahiro Yamada July 12, 2022, 1:35 a.m. UTC | #1
On Sat, Jul 9, 2022 at 1:23 AM Guillaume Tucker
<guillaume.tucker@collabora.com> wrote:
>
> Add headers_install as a dependency to kselftest targets so that they
> can be run directly from the top of the tree.  The kselftest Makefile
> used to try to call headers_install "backwards" but failed due to the
> relative path not being consistent.
>
> Now we can either run this directly:
>
>   $ make O=build kselftest-all
>
> or this:
>
>   $ make O=build headers_install
>   $ make O=build -C tools/testing/selftest all
>
> The same commands work as well when building directly in the source
> tree (no O=) or any arbitrary path (relative or absolute).
>
> Signed-off-by: Guillaume Tucker <guillaume.tucker@collabora.com>
> ---
>  Makefile | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 1a6678d817bd..afc9d739ba44 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1347,10 +1347,10 @@ tools/%: FORCE
>  # Kernel selftest
>
>  PHONY += kselftest
> -kselftest:
> +kselftest: headers_install
>         $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests

Nit.
Please use 'headers' for in-kernel use of exportedI headers.

kselftest: headers


>
> -kselftest-%: FORCE
> +kselftest-%: headers_install FORCE
>         $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $*

Ditto.

kselftest-%: headers FORCE


>
>  PHONY += kselftest-merge
> --
> 2.30.2
>
Guillaume Tucker July 12, 2022, 8:32 a.m. UTC | #2
On 12/07/2022 02:35, Masahiro Yamada wrote:
> On Sat, Jul 9, 2022 at 1:23 AM Guillaume Tucker
> <guillaume.tucker@collabora.com> wrote:
>>
>> Add headers_install as a dependency to kselftest targets so that they
>> can be run directly from the top of the tree.  The kselftest Makefile
>> used to try to call headers_install "backwards" but failed due to the
>> relative path not being consistent.
>>
>> Now we can either run this directly:
>>
>>   $ make O=build kselftest-all
>>
>> or this:
>>
>>   $ make O=build headers_install
>>   $ make O=build -C tools/testing/selftest all
>>
>> The same commands work as well when building directly in the source
>> tree (no O=) or any arbitrary path (relative or absolute).
>>
>> Signed-off-by: Guillaume Tucker <guillaume.tucker@collabora.com>
>> ---
>>  Makefile | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/Makefile b/Makefile
>> index 1a6678d817bd..afc9d739ba44 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -1347,10 +1347,10 @@ tools/%: FORCE
>>  # Kernel selftest
>>
>>  PHONY += kselftest
>> -kselftest:
>> +kselftest: headers_install
>>         $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests
> 
> Nit.
> Please use 'headers' for in-kernel use of exportedI headers.
> 
> kselftest: headers
> 
> 
>>
>> -kselftest-%: FORCE
>> +kselftest-%: headers_install FORCE
>>         $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $*
> 
> Ditto.
> 
> kselftest-%: headers FORCE

Thank you all for the reviews.

I've sent a v2 with this tweak and double-checked that the
kselftest build produced exactly the same result.

Best wishes,
Guillaume
Guillaume Tucker July 13, 2022, 6:38 a.m. UTC | #3
On 08/07/2022 18:23, Guillaume Tucker wrote:
> 
>   $ make O=build headers_install
>   $ make O=build -C tools/testing/selftest all

Typo, it should be selftests:

    $ make O=build -C tools/testing/selftests all

Thanks,
Guillaume
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 1a6678d817bd..afc9d739ba44 100644
--- a/Makefile
+++ b/Makefile
@@ -1347,10 +1347,10 @@  tools/%: FORCE
 # Kernel selftest
 
 PHONY += kselftest
-kselftest:
+kselftest: headers_install
 	$(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests
 
-kselftest-%: FORCE
+kselftest-%: headers_install FORCE
 	$(Q)$(MAKE) -C $(srctree)/tools/testing/selftests $*
 
 PHONY += kselftest-merge