[Buildroot] [PATCH 2/2] support/testing: TestOpenJdk: remove stime() function call
Thomas Perale
thomas.perale at mind.be
Thu Sep 11 19:22:24 UTC 2025
In reply of:
> stime() has been deprecated in glibc 2.31 [1] and replaced with
> clock_settime(). Let's replace the stime() function call used in
> BR2_PACKAGE_OPENJDK_JNI_TEST sources with clock_settime().
>
> Apply the same change as busybox [2]. Make sure that timeToSet
> has been zeroed.
>
> With that fixed, the test "Call Native Library to Set System Time"
> succeed:
>
> [BRTEST# java -cp /usr/bin JniTest
> Test: Get JNI Version passed
> Test: Read Native String Constant passed
> Test: Write Java String to Native Library passed
> Test: Write Java Char Array to Native Library passed
> Test: Write String Member to Native Library passed
> Test: Set String Member from Native Library passed
> Test: Execeute Java Function from Native Library passed
> Test: Instantiate Java Class passed
> Test: Call Native Library to Set System Time passed
> [BRTEST# echo $?
> 0
>
> The last external toolchain using a glibc 2.30 was the Bootlin
> aarch64--glibc--bleeding-edge-2020.02-2, so since then TestOpenJdk
> is broken.
>
> Fixes:
> https://gitlab.com/buildroot.org/buildroot/-/jobs/11176774851
>
> [1] https://lists.gnu.org/archive/html/info-gnu/2020-02/msg00001.html
> [2] https://git.busybox.net/busybox/commit/?id=d3539be8f27b8cbfdfee460fe08299158f08bcd9
> [3] https://toolchains.bootlin.com/downloads/releases/toolchains/aarch64/readmes/aarch64--glibc--bleeding-edge-2020.02-2.txt
>
> Signed-off-by: Romain Naour <romain.naour at smile.fr>
Applied to 2025.02.x & 2025.05.x. Thanks
> ---
> .../br2-external/openjdk/package/openjdk-jni-test/native.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/support/testing/tests/package/br2-external/openjdk/package/openjdk-jni-test/native.c b/support/testing/tests/package/br2-external/openjdk/package/openjdk-jni-test/native.c
> index ed87e345af..9e926a27d9 100644
> --- a/support/testing/tests/package/br2-external/openjdk/package/openjdk-jni-test/native.c
> +++ b/support/testing/tests/package/br2-external/openjdk/package/openjdk-jni-test/native.c
> @@ -29,8 +29,10 @@ void execute_function(void(*function)(void*), void* context)
> }
> void set_time_in_seconds(int seconds)
> {
> - time_t timeToSet = seconds;
> - stime(&timeToSet);
> + struct timespec timeToSet = { 0, 0 };
> +
> + timeToSet.tv_sec = seconds;
> + clock_settime(CLOCK_REALTIME, &timeToSet);
> }
> void write_internal_time_in_seconds()
> {
> --
> 2.51.0
>
> _______________________________________________
> buildroot mailing list
> buildroot at buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
More information about the buildroot
mailing list