diff mbox series

[08/10] selftests: mptcp: Add the uapi headers include variable

Message ID 20220118112909.1885705-9-usama.anjum@collabora.com (mailing list archive)
State New
Headers show
Series selftests: Fix separate output directory builds | expand

Commit Message

Muhammad Usama Anjum Jan. 18, 2022, 11:29 a.m. UTC
Out of tree build of this test fails if relative path of the output
directory is specified. Remove the un-needed include paths and use
KHDR_INCLUDES to correctly reach the headers.

Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/net/mptcp/Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Matthieu Baerts Jan. 18, 2022, 9:47 p.m. UTC | #1
Hi Muhammad,

On 18/01/2022 12:29, Muhammad Usama Anjum wrote:
> Out of tree build of this test fails if relative path of the output
> directory is specified. Remove the un-needed include paths and use
> KHDR_INCLUDES to correctly reach the headers.

Thank you for looking at that!

> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
>  tools/testing/selftests/net/mptcp/Makefile | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/mptcp/Makefile b/tools/testing/selftests/net/mptcp/Makefile
> index 0356c4501c99..fed6866d3b73 100644
> --- a/tools/testing/selftests/net/mptcp/Makefile
> +++ b/tools/testing/selftests/net/mptcp/Makefile
> @@ -1,9 +1,8 @@
>  # SPDX-License-Identifier: GPL-2.0
>  
> -top_srcdir = ../../../../..

Removing this line breaks our CI validating MPTCP selftests. That's
because this "top_srcdir" variable is needed in the "lib.mk" file which
is included at the end of this Makefile.

But that's maybe a misuse from our side. Indeed to avoid compiling
binaries and more from the VM, our CI does that as a preparation job
before starting the VM and run MPTCP selftests:

  $ make O=(...) INSTALL_HDR_PATH=(...)/kselftest/usr headers_install
  $ make O=(...) -C tools/testing/selftests/net/mptcp

From the VM, we re-use the same source directory and we can start
individual tests without having to compile anything else:

  $ cd tools/testing/selftests/net/mptcp
  $ ./mptcp_connect.sh

We want to do that because some scripts are launched multiple times with
different parameters.

With your modifications, we can drop the headers_install instruction but
we need to pass new parameters to the last 'make' command:

  $ make O=(...) top_srcdir=../../../../.. \
                 KHDR_INCLUDES=-I(...)/usr/include \
         -C tools/testing/selftests/net/mptcp

Or is there a better way to do that?
Can we leave the definition of "top_srcdir" like it was or did we miss
something else?

>  KSFT_KHDR_INSTALL := 1
>  
> -CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g  -I$(top_srcdir)/usr/include
> +CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g $(KHDR_INCLUDES)
>  
>  TEST_PROGS := mptcp_connect.sh pm_netlink.sh mptcp_join.sh diag.sh \
>  	      simult_flows.sh mptcp_sockopt.sh

Note: I see there is a very long recipients list. If my issue is not
directly due to your modifications, we can probably continue the
discussion with a restricted audience.

Cheers,
Matt
Muhammad Usama Anjum Jan. 19, 2022, 8:22 a.m. UTC | #2
Hi Matthieu,

Thank you for putting details below.

On 1/19/22 2:47 AM, Matthieu Baerts wrote:
> Hi Muhammad,
> 
> On 18/01/2022 12:29, Muhammad Usama Anjum wrote:
>> Out of tree build of this test fails if relative path of the output
>> directory is specified. Remove the un-needed include paths and use
>> KHDR_INCLUDES to correctly reach the headers.
> 
> Thank you for looking at that!
> 
>> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
>> ---
>>  tools/testing/selftests/net/mptcp/Makefile | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/tools/testing/selftests/net/mptcp/Makefile b/tools/testing/selftests/net/mptcp/Makefile
>> index 0356c4501c99..fed6866d3b73 100644
>> --- a/tools/testing/selftests/net/mptcp/Makefile
>> +++ b/tools/testing/selftests/net/mptcp/Makefile
>> @@ -1,9 +1,8 @@
>>  # SPDX-License-Identifier: GPL-2.0
>>  
>> -top_srcdir = ../../../../..
> 
> Removing this line breaks our CI validating MPTCP selftests. That's
> because this "top_srcdir" variable is needed in the "lib.mk" file which
> is included at the end of this Makefile.
> 
> But that's maybe a misuse from our side. Indeed to avoid compiling
> binaries and more from the VM, our CI does that as a preparation job
> before starting the VM and run MPTCP selftests:
> 
>   $ make O=(...) INSTALL_HDR_PATH=(...)/kselftest/usr headers_install
>   $ make O=(...) -C tools/testing/selftests/net/mptcp
> 
> From the VM, we re-use the same source directory and we can start
> individual tests without having to compile anything else:
> 
>   $ cd tools/testing/selftests/net/mptcp
>   $ ./mptcp_connect.sh
> 
> We want to do that because some scripts are launched multiple times with
> different parameters.
> 
> With your modifications, we can drop the headers_install instruction but
> we need to pass new parameters to the last 'make' command:
> 
>   $ make O=(...) top_srcdir=../../../../.. \
>                  KHDR_INCLUDES=-I(...)/usr/include \
>          -C tools/testing/selftests/net/mptcp
> 
> Or is there a better way to do that?
> Can we leave the definition of "top_srcdir" like it was or did we miss
> something else?
> 
It seems like I've missed this use cases where people can build only one
individual test. It is not my intention to break individual test builds.
I shouldn't be fixing one thing while breaking something else. I'll
update these patches such that individual tests are also build-able. For
this to happen, I'll just add $(KHDR_INCLUDES) to the build flags while
leaving everything else intact. I'll send a V2.

>>  KSFT_KHDR_INSTALL := 1
>>  
>> -CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g  -I$(top_srcdir)/usr/include
>> +CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g $(KHDR_INCLUDES)
>>  
>>  TEST_PROGS := mptcp_connect.sh pm_netlink.sh mptcp_join.sh diag.sh \
>>  	      simult_flows.sh mptcp_sockopt.sh
> 
> Note: I see there is a very long recipients list. If my issue is not
> directly due to your modifications, we can probably continue the
> discussion with a restricted audience.
> 
> Cheers,
> Matt
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/mptcp/Makefile b/tools/testing/selftests/net/mptcp/Makefile
index 0356c4501c99..fed6866d3b73 100644
--- a/tools/testing/selftests/net/mptcp/Makefile
+++ b/tools/testing/selftests/net/mptcp/Makefile
@@ -1,9 +1,8 @@ 
 # SPDX-License-Identifier: GPL-2.0
 
-top_srcdir = ../../../../..
 KSFT_KHDR_INSTALL := 1
 
-CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g  -I$(top_srcdir)/usr/include
+CFLAGS =  -Wall -Wl,--no-as-needed -O2 -g $(KHDR_INCLUDES)
 
 TEST_PROGS := mptcp_connect.sh pm_netlink.sh mptcp_join.sh diag.sh \
 	      simult_flows.sh mptcp_sockopt.sh