-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8349288: runtime/os/windows/TestAvailableProcessors.java fails on localized Windows platform #23536
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
Conversation
…alized Windows platform
…alized Windows platform
…alized Windows platform
|
👋 Welcome back ktakakuri! A progress list of the required criteria for merging this PR into |
|
@ktakakuri This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 2002 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@dholmes-ora, @AlanBateman) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
|
@ktakakuri The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
…alized Windows platform
dholmes-ora
left a comment
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.
@ktakakuri I need to evaluate whether this is a general purpose fix that should work everywhere.
test/hotspot/jtreg/runtime/os/windows/TestAvailableProcessors.java
Outdated
Show resolved
Hide resolved
test/hotspot/jtreg/runtime/os/windows/TestAvailableProcessors.java
Outdated
Show resolved
Hide resolved
| command.addAll(List.of("cmd.exe", "/c", "set", "PATH=%PATH%;C:\\Windows\\System32;C:\\Windows\\System32\\wbem", "&&")); | ||
| command.addAll(List.of("chcp", "437", ">nul", "2>&1", "&&")); |
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.
I see the use of chcp in the test ./tools/jpackage/helpers/jdk/jpackage/test/Executor.java so that is okay. However it doesn't set the path and it does not seem necessary to do so, and potentially assumes what the paths are anyway. So I think you can simplify this a little.
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.
As well as tools/jpackage/windows/Win8301247Test.java, the tools tests is not included in jdk/tier1, so it will not run in GHA?
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.
Sorry I'm not sure what you are asking.
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.
I think tools/jpackage/helpers/jdk/jpackage/test/Executor.java is not run in GHA.
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.
Correct. That is a tier2 test and IIUC GHA only runs tier1.
But I'm not sure why you're asking. I was pointing out that the jpackage test uses chcp in a simpler way than you have used, so I was suggesting you simplify your code and see if it still works.
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.
Running TestAvailableProcessors.java in GHA without adding the PATH failed. Additional processing is required to pass GHA.
Since the jpackage tests are not run in GHA, there is no need to add PATH.
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.
Hmmm .... okay. This is ony a test so if things go wrong we can re-adjust the test.
…alized Windows platform
| command.addAll(List.of("cmd.exe", "/c", "set", "PATH=%PATH%;C:\\Windows\\System32;C:\\Windows\\System32\\wbem", "&&")); | ||
| command.addAll(List.of("chcp", "437", ">nul", "2>&1", "&&")); |
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.
Hmmm .... okay. This is ony a test so if things go wrong we can re-adjust the test.
|
/integrate |
|
@ktakakuri |
|
@ktakakuri hotspot changes require two reviews. I will try to drum up another reviewer. |
|
/reviewers 2 |
|
@sendaoYan Only the author of the pull request or Reviewers are allowed to change the number of required reviewers. |
| var processBuilder = new ProcessBuilder(systeminfoPath); | ||
| List<String> command = new ArrayList<>(); | ||
| // Force language to English before running systeminfo to get the OS version | ||
| command.addAll(List.of("cmd.exe", "/c", "set", "PATH=%PATH%;C:\\Windows\\System32;C:\\Windows\\System32\\wbem", "&&")); |
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.
Not sure about hardcoding C:\Windows in tests as Windows could be installed on a different volume. Don't you need to use the value of %SystemRoot% to the directory?
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.
I thought it unfortunate that a path needed to be specified, but there is a precedent for assuming C:\Windows:
./jdk/java/lang/ProcessHandle/ProcessUtil.java:
return Platform.isWindows() && p.info().command().orElse("").endsWith("C:\\Windows\\System32\\conhost.exe");
though a more general approach would be similar to ./jdk/java/lang/RuntimeTests/exec/WinCommand.java:
File systemRoot =
getenv("SystemRoot") != null ? new File(getenv("SystemRoot")) :
getenv("WINDIR") != null ? new File(getenv ("WINDIR")) :
null;
if (systemRoot == null || ! systemRoot.isDirectory())
return; // Not Windows as we know it
String systemDirW = new File(systemRoot, "System32").getPath();
I was also reminded that testing under non-US-English locales is not really supported:
https://htmlpreview.github.io/?https://raw.githubusercontent.com/openjdk/jdk/master/doc/building.html#windows
The recommended and supported way of building the JDK on Windows is to set both the system locale and the user locale to US English. The system setting can be changed by going to the Control Panel, choosing "Regional Settings" -> "Administrative" and then pressing on the "Change System Locale" button.
Since this is annoying for users who prefer another locale, we strive to get the building and testing to work on other locales as well. This is on a "best effort" level, so beware! You might get odd results in both building and testing. If you do, remember that locales other than US English are not supported nor recommended.
It is also imperative to install the US English language pack in Visual Studio. For details, see Microsoft Visual Studio.
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.
Thank you for your review. I changed it to use System.getenv().
…alized Windows platform
|
I need to re-test this in our CI system. |
|
@ktakakuri please merge this with latest master as it is getting along way behind - thanks. |
| System.getenv("WINDIR") != null ? new File(System.getenv ("WINDIR")) : | ||
| null; | ||
| if (systemRoot == null || ! systemRoot.isDirectory()) | ||
| return; // Not Windows as we know it |
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.
This doesn't compile - the function returns a String.
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.
Even if systemRoot fails to recognize the system, it does not matter if chcp can be executed, so I removed the judgment.
dholmes-ora
left a comment
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.
Thanks for update. Nothing further from me.
As we are passed RDP1 this will get commited into JDK 26, but as a test fix it is also eligible to be backported to JDK 25 if you chose.
|
@AlanBateman This PR requires two approvals. I apologize for the long delay, but could you review it? |
| if (systemRoot == null) { | ||
| throw new RuntimeException("SystemRoot or WINDIR environment variable is not set."); | ||
| } | ||
| String systemDirW = new File(systemRoot, "System32").getPath(); |
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.
A drive-by comment is that you could remove the duplicate calls to getenv and just use a simple Path resolve. e.g.
String systemRoot = System.getenv("SystemRoot");
if (systemRoot == null) {
systemRoot = System.getenv("WINDIR");
if (systemRoot == null) {
// throw
}
}
String system32 = Path.of(systemRoot, "System32").toString();
| // Force language to English before running systeminfo to get the OS version | ||
| command.addAll(List.of("cmd.exe", "/c", "set", "PATH=%PATH%;" + systemDirW + ";" + systemDirW + "\\wbem", "&&")); | ||
| command.addAll(List.of("chcp", "437", ">nul", "2>&1", "&&")); | ||
| command.add(systeminfoPath); |
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.
I assume it would be more correct to say that it switches the active code page to cp437, the default code page for US english.
Sure, just have some drive by comments, switching to cp437 should be okay. |
…alized Windows platform
|
@AlanBateman Thank you for the suggested fixes. I modified the code as such. |
|
@ktakakuri This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a |
|
/reviewers 2 |
|
@ktakakuri |
|
@AlanBateman I fixed the code as you suggested. Could you please review it? |
|
@dholmes-ora I have made some fixes, so please review it again. |
dholmes-ora
left a comment
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.
Sorry I did not see that further updates had occurred.
Seems okay.
Thanks
|
@ktakakuri This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a |
|
@AlanBateman I know you're busy, but I'm looking forward to your review. |
| * @run testng TestAvailableProcessors | ||
| */ | ||
|
|
||
| import java.io.File; |
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.
I assume this is a left-over from early iterations.
AlanBateman
left a comment
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.
Looks okay to me, thanks for moving away from the hardcoded root.
|
/integrate |
|
@ktakakuri |
|
/sponsor |
|
Going to push as commit 9e3fa32.
Your commit was automatically rebased without conflicts. |
|
@dholmes-ora @ktakakuri Pushed as commit 9e3fa32. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
To resolve runtime/os/windows/TestAvailableProcessors.java failure, I made "systeminfo.exe" executed with "chcp 437". This ensures that the English message "OS Version: " is output on localized windows platforms.
I added the path C:\Windows\System32 to make chcp command recognized on the GHA Windows test machine. Without this addition, GHA will fail.
After this fix, I verified that the test passed.
#22142
I refer to this fix.
tools/jpackage/windows/Win8301247Test.java does not run in GHA, so the problems with recognition of chcp command did not occur before.
Thanks.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/23536/head:pull/23536$ git checkout pull/23536Update a local copy of the PR:
$ git checkout pull/23536$ git pull https://git.openjdk.org/jdk.git pull/23536/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 23536View PR using the GUI difftool:
$ git pr show -t 23536Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/23536.diff
Using Webrev
Link to Webrev Comment