-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8356706: Foreign tests timeout after passing on linux-x64-zero #25248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. | ||
| * Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved. | ||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| * | ||
| * This code is free software; you can redistribute it and/or modify it | ||
|
|
@@ -23,7 +23,7 @@ | |
|
|
||
| /* | ||
| * @test | ||
| * @run testng/othervm --enable-native-access=ALL-UNNAMED StdLibTest | ||
| * @run testng/othervm/timeout=600 --enable-native-access=ALL-UNNAMED StdLibTest | ||
| */ | ||
|
|
||
| import java.lang.invoke.MethodHandle; | ||
|
|
@@ -51,33 +51,33 @@ | |
|
|
||
| public class StdLibTest extends NativeTestHelper { | ||
|
|
||
| final static Linker abi = Linker.nativeLinker(); | ||
| static final Linker abi = Linker.nativeLinker(); | ||
|
|
||
| private StdLibHelper stdLibHelper = new StdLibHelper(); | ||
| private static final StdLibHelper STD_LIB_HELPER = new StdLibHelper(); | ||
|
|
||
| @Test(dataProvider = "stringPairs") | ||
| void test_strcat(String s1, String s2) throws Throwable { | ||
| assertEquals(stdLibHelper.strcat(s1, s2), s1 + s2); | ||
| assertEquals(STD_LIB_HELPER.strcat(s1, s2), s1 + s2); | ||
| } | ||
|
|
||
| @Test(dataProvider = "stringPairs") | ||
| void test_strcmp(String s1, String s2) throws Throwable { | ||
| assertEquals(Math.signum(stdLibHelper.strcmp(s1, s2)), Math.signum(s1.compareTo(s2))); | ||
| assertEquals(Math.signum(STD_LIB_HELPER.strcmp(s1, s2)), Math.signum(s1.compareTo(s2))); | ||
| } | ||
|
|
||
| @Test(dataProvider = "strings") | ||
| void test_puts(String s) throws Throwable { | ||
| assertTrue(stdLibHelper.puts(s) >= 0); | ||
| assertTrue(STD_LIB_HELPER.puts(s) >= 0); | ||
| } | ||
|
|
||
| @Test(dataProvider = "strings") | ||
| void test_strlen(String s) throws Throwable { | ||
| assertEquals(stdLibHelper.strlen(s), s.length()); | ||
| assertEquals(STD_LIB_HELPER.strlen(s), s.length()); | ||
| } | ||
|
|
||
| @Test(dataProvider = "instants") | ||
| void test_time(Instant instant) throws Throwable { | ||
| StdLibHelper.Tm tm = stdLibHelper.gmtime(instant.getEpochSecond()); | ||
| StdLibHelper.Tm tm = STD_LIB_HELPER.gmtime(instant.getEpochSecond()); | ||
| LocalDateTime localTime = LocalDateTime.ofInstant(instant, ZoneOffset.UTC); | ||
| assertEquals(tm.sec(), localTime.getSecond()); | ||
| assertEquals(tm.min(), localTime.getMinute()); | ||
|
|
@@ -97,17 +97,17 @@ void test_time(Instant instant) throws Throwable { | |
| void test_qsort(List<Integer> ints) throws Throwable { | ||
| if (ints.size() > 0) { | ||
| int[] input = ints.stream().mapToInt(i -> i).toArray(); | ||
| int[] sorted = stdLibHelper.qsort(input); | ||
| int[] sorted = STD_LIB_HELPER.qsort(input); | ||
| Arrays.sort(input); | ||
| assertEquals(sorted, input); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| void test_rand() throws Throwable { | ||
| int val = stdLibHelper.rand(); | ||
| int val = STD_LIB_HELPER.rand(); | ||
| for (int i = 0 ; i < 100 ; i++) { | ||
| int newVal = stdLibHelper.rand(); | ||
| int newVal = STD_LIB_HELPER.rand(); | ||
| if (newVal != val) { | ||
| return; //ok | ||
| } | ||
|
|
@@ -131,7 +131,7 @@ void test_printf(List<PrintfArg> args) throws Throwable { | |
| String expected = String.format(javaFormatString, args.stream() | ||
| .map(a -> a.javaValue).toArray()); | ||
|
|
||
| int found = stdLibHelper.printf(nativeFormatString, args); | ||
| int found = STD_LIB_HELPER.printf(nativeFormatString, args); | ||
| assertEquals(found, expected.length()); | ||
| } | ||
|
|
||
|
|
@@ -140,41 +140,41 @@ void testSystemLibraryBadLookupName() { | |
| assertTrue(LINKER.defaultLookup().find("strlen\u0000foobar").isEmpty()); | ||
| } | ||
|
|
||
| static class StdLibHelper { | ||
| static final class StdLibHelper { | ||
|
|
||
| final static MethodHandle strcat = abi.downcallHandle(abi.defaultLookup().find("strcat").get(), | ||
| static final MethodHandle strcat = abi.downcallHandle(abi.defaultLookup().findOrThrow("strcat"), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drive-by cleanup to blessed order. |
||
| FunctionDescriptor.of(C_POINTER, C_POINTER, C_POINTER)); | ||
|
|
||
| final static MethodHandle strcmp = abi.downcallHandle(abi.defaultLookup().find("strcmp").get(), | ||
| static final MethodHandle strcmp = abi.downcallHandle(abi.defaultLookup().findOrThrow("strcmp"), | ||
| FunctionDescriptor.of(C_INT, C_POINTER, C_POINTER)); | ||
|
|
||
| final static MethodHandle puts = abi.downcallHandle(abi.defaultLookup().find("puts").get(), | ||
| static final MethodHandle puts = abi.downcallHandle(abi.defaultLookup().findOrThrow("puts"), | ||
| FunctionDescriptor.of(C_INT, C_POINTER)); | ||
|
|
||
| final static MethodHandle strlen = abi.downcallHandle(abi.defaultLookup().find("strlen").get(), | ||
| static final MethodHandle strlen = abi.downcallHandle(abi.defaultLookup().findOrThrow("strlen"), | ||
| FunctionDescriptor.of(C_INT, C_POINTER)); | ||
|
|
||
| final static MethodHandle gmtime = abi.downcallHandle(abi.defaultLookup().find("gmtime").get(), | ||
| static final MethodHandle gmtime = abi.downcallHandle(abi.defaultLookup().findOrThrow("gmtime"), | ||
| FunctionDescriptor.of(C_POINTER.withTargetLayout(Tm.LAYOUT), C_POINTER)); | ||
|
|
||
| // void qsort( void *ptr, size_t count, size_t size, int (*comp)(const void *, const void *) ); | ||
| final static MethodHandle qsort = abi.downcallHandle(abi.defaultLookup().find("qsort").get(), | ||
| static final MethodHandle qsort = abi.downcallHandle(abi.defaultLookup().findOrThrow("qsort"), | ||
| FunctionDescriptor.ofVoid(C_POINTER, C_SIZE_T, C_SIZE_T, C_POINTER)); | ||
|
|
||
| final static FunctionDescriptor qsortComparFunction = FunctionDescriptor.of(C_INT, | ||
| static final FunctionDescriptor qsortComparFunction = FunctionDescriptor.of(C_INT, | ||
| C_POINTER.withTargetLayout(C_INT), C_POINTER.withTargetLayout(C_INT)); | ||
|
|
||
| final static MethodHandle qsortCompar; | ||
| static final MethodHandle qsortCompar; | ||
|
|
||
| final static MethodHandle rand = abi.downcallHandle(abi.defaultLookup().find("rand").get(), | ||
| static final MethodHandle rand = abi.downcallHandle(abi.defaultLookup().findOrThrow("rand"), | ||
| FunctionDescriptor.of(C_INT)); | ||
|
|
||
| final static MethodHandle vprintf = abi.downcallHandle(abi.defaultLookup().find("vprintf").get(), | ||
| static final MethodHandle vprintf = abi.downcallHandle(abi.defaultLookup().findOrThrow("vprintf"), | ||
| FunctionDescriptor.of(C_INT, C_POINTER, C_POINTER)); | ||
|
|
||
| final static MemorySegment printfAddr = abi.defaultLookup().find("printf").get(); | ||
| static final MemorySegment printfAddr = abi.defaultLookup().findOrThrow("printf"); | ||
|
|
||
| final static FunctionDescriptor printfBase = FunctionDescriptor.of(C_INT, C_POINTER); | ||
| static final FunctionDescriptor printfBase = FunctionDescriptor.of(C_INT, C_POINTER); | ||
|
|
||
| static { | ||
| try { | ||
|
|
@@ -225,7 +225,7 @@ Tm gmtime(long arg) throws Throwable { | |
| } | ||
| } | ||
|
|
||
| static class Tm { | ||
| static final class Tm { | ||
|
|
||
| //Tm pointer should never be freed directly, as it points to shared memory | ||
| private final MemorySegment base; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
STD_LIB_HELPERis now a constant.