support/testing: TestOpenJdk: remove stime() function call

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@smile.fr>
Signed-off-by: Julien Olivain <ju.o@free.fr>
(cherry picked from commit 681b92664d)
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
This commit is contained in:
Romain Naour
2025-08-31 23:38:43 +02:00
committed by Thomas Perale
parent de2bf5404b
commit c50e95e026

View File

@@ -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()
{