linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests: Add version file to kselftest installation dir
@ 2025-05-29  0:33 Tianyi Cui
  2025-06-02 22:48 ` Shuah Khan
  0 siblings, 1 reply; 6+ messages in thread
From: Tianyi Cui @ 2025-05-29  0:33 UTC (permalink / raw)
  To: shuah; +Cc: Tianyi Cui, linux-kselftest, linux-kernel

As titled, adding version file to kselftest installation dir, so the user
of the tarball can know which kernel version the tarball belongs to.

Signed-off-by: Tianyi Cui <1997cui@gmail.com>
---
 tools/testing/selftests/Makefile | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index a0a6ba47d600..246e9863b45b 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -291,6 +291,12 @@ ifdef INSTALL_PATH
 		$(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET COLLECTION=$$TARGET \
 			-C $$TARGET emit_tests >> $(TEST_LIST); \
 	done;
+	@if git describe HEAD > /dev/null 2>&1; then \
+		git describe HEAD > $(INSTALL_PATH)/VERSION; \
+		printf "Version saved to $(INSTALL_PATH)/VERSION\n"; \
+	else \
+		printf "Unable to get version from git describe\n"; \
+	fi
 else
 	$(error Error: set INSTALL_PATH to use install)
 endif
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] selftests: Add version file to kselftest installation dir
  2025-05-29  0:33 [PATCH] selftests: Add version file to kselftest installation dir Tianyi Cui
@ 2025-06-02 22:48 ` Shuah Khan
  2025-06-03  1:13   ` Tianyi Cui
  0 siblings, 1 reply; 6+ messages in thread
From: Shuah Khan @ 2025-06-02 22:48 UTC (permalink / raw)
  To: Tianyi Cui, shuah; +Cc: linux-kselftest, linux-kernel, Shuah Khan

On 5/28/25 18:33, Tianyi Cui wrote:
> As titled, adding version file to kselftest installation dir, so the user
> of the tarball can know which kernel version the tarball belongs to.
> 
> Signed-off-by: Tianyi Cui <1997cui@gmail.com>
> ---
>   tools/testing/selftests/Makefile | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
> index a0a6ba47d600..246e9863b45b 100644
> --- a/tools/testing/selftests/Makefile
> +++ b/tools/testing/selftests/Makefile
> @@ -291,6 +291,12 @@ ifdef INSTALL_PATH
>   		$(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET COLLECTION=$$TARGET \
>   			-C $$TARGET emit_tests >> $(TEST_LIST); \
>   	done;
> +	@if git describe HEAD > /dev/null 2>&1; then \
> +		git describe HEAD > $(INSTALL_PATH)/VERSION; \
> +		printf "Version saved to $(INSTALL_PATH)/VERSION\n"; \
> +	else \
> +		printf "Unable to get version from git describe\n"; \
> +	fi
>   else
>   	$(error Error: set INSTALL_PATH to use install)
>   endif

Why not use "make kernelrelease" to get the version?

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] selftests: Add version file to kselftest installation dir
  2025-06-02 22:48 ` Shuah Khan
@ 2025-06-03  1:13   ` Tianyi Cui
  2025-06-03 19:56     ` Shuah Khan
  0 siblings, 1 reply; 6+ messages in thread
From: Tianyi Cui @ 2025-06-03  1:13 UTC (permalink / raw)
  To: Shuah Khan, shuah; +Cc: linux-kselftest, linux-kernel

On 6/2/25 3:48 PM, Shuah Khan wrote:
> On 5/28/25 18:33, Tianyi Cui wrote:
>> As titled, adding version file to kselftest installation dir, so the user
>> of the tarball can know which kernel version the tarball belongs to.
>>
>> Signed-off-by: Tianyi Cui <1997cui@gmail.com>
>> ---
>>   tools/testing/selftests/Makefile | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/tools/testing/selftests/Makefile b/tools/testing/
>> selftests/Makefile
>> index a0a6ba47d600..246e9863b45b 100644
>> --- a/tools/testing/selftests/Makefile
>> +++ b/tools/testing/selftests/Makefile
>> @@ -291,6 +291,12 @@ ifdef INSTALL_PATH
>>           $(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET
>> COLLECTION=$$TARGET \
>>               -C $$TARGET emit_tests >> $(TEST_LIST); \
>>       done;
>> +    @if git describe HEAD > /dev/null 2>&1; then \
>> +        git describe HEAD > $(INSTALL_PATH)/VERSION; \
>> +        printf "Version saved to $(INSTALL_PATH)/VERSION\n"; \
>> +    else \
>> +        printf "Unable to get version from git describe\n"; \
>> +    fi
>>   else
>>       $(error Error: set INSTALL_PATH to use install)
>>   endif
> 
> Why not use "make kernelrelease" to get the version?

Thank you for your attention for my first patch! There are mainly two
reasons:

 1. We'd like to have the `VERSION` file written to to the tarball. This
is because driver hardware tests needs to be run on specific hardware so
that tarball is copied onto the DUT and we can compare the running
kernel version and the test version.`make kernelrelease` only print it
on screen, so we still need a way to store it into the tarball.

 2. `make kernelrelease` requires the kernel repo to be configured and
prepared, while `make -C tools/testing/selftests` can run standalone. As
a result, I don't want above to depend on `make kernelrelease`, which
may break compatibility of people's existing CI systems.

> thanks,
> -- Shuah


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] selftests: Add version file to kselftest installation dir
  2025-06-03  1:13   ` Tianyi Cui
@ 2025-06-03 19:56     ` Shuah Khan
  2025-06-10 22:00       ` [PATCH v2] selftests: Add version file to kselftest Tianyi Cui
  0 siblings, 1 reply; 6+ messages in thread
From: Shuah Khan @ 2025-06-03 19:56 UTC (permalink / raw)
  To: Tianyi Cui, shuah; +Cc: linux-kselftest, linux-kernel, Shuah Khan

On 6/2/25 19:13, Tianyi Cui wrote:
> On 6/2/25 3:48 PM, Shuah Khan wrote:
>> On 5/28/25 18:33, Tianyi Cui wrote:
>>> As titled, adding version file to kselftest installation dir, so the user
>>> of the tarball can know which kernel version the tarball belongs to.
>>>
>>> Signed-off-by: Tianyi Cui <1997cui@gmail.com>
>>> ---
>>>    tools/testing/selftests/Makefile | 6 ++++++
>>>    1 file changed, 6 insertions(+)
>>>
>>> diff --git a/tools/testing/selftests/Makefile b/tools/testing/
>>> selftests/Makefile
>>> index a0a6ba47d600..246e9863b45b 100644
>>> --- a/tools/testing/selftests/Makefile
>>> +++ b/tools/testing/selftests/Makefile
>>> @@ -291,6 +291,12 @@ ifdef INSTALL_PATH
>>>            $(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET
>>> COLLECTION=$$TARGET \
>>>                -C $$TARGET emit_tests >> $(TEST_LIST); \
>>>        done;
>>> +    @if git describe HEAD > /dev/null 2>&1; then \
>>> +        git describe HEAD > $(INSTALL_PATH)/VERSION; \
>>> +        printf "Version saved to $(INSTALL_PATH)/VERSION\n"; \
>>> +    else \
>>> +        printf "Unable to get version from git describe\n"; \

How does "git describe HEAD" here in this path?

>>> +    fi
>>>    else
>>>        $(error Error: set INSTALL_PATH to use install)
>>>    endif
>>
>> Why not use "make kernelrelease" to get the version?
> 
> Thank you for your attention for my first patch! There are mainly two
> reasons:
> 
>   1. We'd like to have the `VERSION` file written to to the tarball. This
> is because driver hardware tests needs to be run on specific hardware so
> that tarball is copied onto the DUT and we can compare the running

Okay - you want to save the version in tarball. No problem there.

> kernel version and the test version.`make kernelrelease` only print it
> on screen, 

This doesn't make sense to me. "git describe HEAD" also prints it
on the screen.

so we still need a way to store it into the tarball.

You can do the same thing you are doing running "git describe HEAD"
and create VERSION file?

> 
>   2. `make kernelrelease` requires the kernel repo to be configured and
> prepared, while `make -C tools/testing/selftests` can run standalone. As
> a result, I don't want above to depend on `make kernelrelease`, which
> may break compatibility of people's existing CI systems.

Yes "make kernelrelease" requires repo to be set up.

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] selftests: Add version file to kselftest
  2025-06-03 19:56     ` Shuah Khan
@ 2025-06-10 22:00       ` Tianyi Cui
  2025-06-10 22:12         ` [PATCH v2] selftests: Add version file to kselftest installation dir Tianyi Cui
  0 siblings, 1 reply; 6+ messages in thread
From: Tianyi Cui @ 2025-06-10 22:00 UTC (permalink / raw)
  To: shuah; +Cc: linux-kselftest, linux-kernel, skhan

Thanks for your patience for review! I've updated the patch to make it
easier to understand. Specifically, `stdout` of `git describe` is stored
into `VERSION` variable, then write into `VERSION` file rather than
print on-screen. Please refer below for the sample output and the
content in `VERSION`.

```
Emit Tests for drivers/net
Skipping non-existent dir: drivers/net/hw
Version saved to /tmp/ksft-net-drv/VERSION
make: Leaving directory
'/home/tianyicui/test/nipa/net-next/tools/testing/selftests'
➜  net-next git:(add_kversion) ✗ cat /tmp/ksft-net-drv/VERSION
v6.15-12423-g7ebe76e39b4c
```


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] selftests: Add version file to kselftest installation dir
  2025-06-10 22:00       ` [PATCH v2] selftests: Add version file to kselftest Tianyi Cui
@ 2025-06-10 22:12         ` Tianyi Cui
  0 siblings, 0 replies; 6+ messages in thread
From: Tianyi Cui @ 2025-06-10 22:12 UTC (permalink / raw)
  To: shuah; +Cc: linux-kselftest, linux-kernel, skhan, Tianyi Cui

As titled, adding version file to kselftest installation dir, so the user
of the tarball can know which kernel version the tarball belongs to.

Signed-off-by: Tianyi Cui <1997cui@gmail.com>
---
 tools/testing/selftests/Makefile | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 339b31e6a6b5..9dae84a74e7f 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -293,6 +293,13 @@ ifdef INSTALL_PATH
 		$(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET COLLECTION=$$TARGET \
 			-C $$TARGET emit_tests >> $(TEST_LIST); \
 	done;
+	@VERSION=$$(git describe HEAD 2>/dev/null); \
+	if [ -n "$$VERSION" ]; then \
+		echo "$$VERSION" > $(INSTALL_PATH)/VERSION; \
+		printf "Version saved to $(INSTALL_PATH)/VERSION\n"; \
+	else \
+		printf "Unable to get version from git describe\n"; \
+	fi
 else
 	$(error Error: set INSTALL_PATH to use install)
 endif
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-06-10 22:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-29  0:33 [PATCH] selftests: Add version file to kselftest installation dir Tianyi Cui
2025-06-02 22:48 ` Shuah Khan
2025-06-03  1:13   ` Tianyi Cui
2025-06-03 19:56     ` Shuah Khan
2025-06-10 22:00       ` [PATCH v2] selftests: Add version file to kselftest Tianyi Cui
2025-06-10 22:12         ` [PATCH v2] selftests: Add version file to kselftest installation dir Tianyi Cui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).