Skip to content

Commit

Permalink
8326718: Test java/util/Formatter/Padding.java should timeout on larg…
Browse files Browse the repository at this point in the history
…e inputs before fix in JDK-8299677

Reviewed-by: rgiulietti
  • Loading branch information
chadrako authored and rgiulietti committed Mar 6, 2024
1 parent e92ecd9 commit 4f33608
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions test/jdk/java/util/Formatter/Padding.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, 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
Expand All @@ -23,7 +23,7 @@

/*
* @test
* @bug 4906370
* @bug 4906370 8299677 8326718
* @summary Tests to excercise padding on int and double values,
* with various flag combinations.
* @run junit Padding
Expand All @@ -40,6 +40,9 @@

public class Padding {

private static final String tenMillionZeros = "0".repeat(10_000_000);
private static final String tenMillionBlanks = " ".repeat(10_000_000);

static Arguments[] padding() {
return new Arguments[] {
/* blank padding, right adjusted, optional plus sign */
Expand All @@ -49,27 +52,31 @@ static Arguments[] padding() {
arguments(" 12", "%4d", 12),
arguments(" 12", "%5d", 12),
arguments(" 12", "%10d", 12),
arguments(tenMillionBlanks + "12", "%10000002d", 12),

arguments("-12", "%1d", -12),
arguments("-12", "%2d", -12),
arguments("-12", "%3d", -12),
arguments(" -12", "%4d", -12),
arguments(" -12", "%5d", -12),
arguments(" -12", "%10d", -12),
arguments(tenMillionBlanks + "-12", "%10000003d", -12),

arguments("1.2", "%1.1f", 1.2),
arguments("1.2", "%2.1f", 1.2),
arguments("1.2", "%3.1f", 1.2),
arguments(" 1.2", "%4.1f", 1.2),
arguments(" 1.2", "%5.1f", 1.2),
arguments(" 1.2", "%10.1f", 1.2),
arguments(tenMillionBlanks + "1.2", "%10000003.1f", 1.2),

arguments("-1.2", "%1.1f", -1.2),
arguments("-1.2", "%2.1f", -1.2),
arguments("-1.2", "%3.1f", -1.2),
arguments("-1.2", "%4.1f", -1.2),
arguments(" -1.2", "%5.1f", -1.2),
arguments(" -1.2", "%10.1f", -1.2),
arguments(tenMillionBlanks + "-1.2", "%10000004.1f", -1.2),

/* blank padding, right adjusted, mandatory plus sign */
arguments("+12", "%+1d", 12),
Expand All @@ -78,27 +85,31 @@ static Arguments[] padding() {
arguments(" +12", "%+4d", 12),
arguments(" +12", "%+5d", 12),
arguments(" +12", "%+10d", 12),
arguments(tenMillionBlanks + "+12", "%+10000003d", 12),

arguments("-12", "%+1d", -12),
arguments("-12", "%+2d", -12),
arguments("-12", "%+3d", -12),
arguments(" -12", "%+4d", -12),
arguments(" -12", "%+5d", -12),
arguments(" -12", "%+10d", -12),
arguments(tenMillionBlanks + "-12", "%+10000003d", -12),

arguments("+1.2", "%+1.1f", 1.2),
arguments("+1.2", "%+2.1f", 1.2),
arguments("+1.2", "%+3.1f", 1.2),
arguments("+1.2", "%+4.1f", 1.2),
arguments(" +1.2", "%+5.1f", 1.2),
arguments(" +1.2", "%+10.1f", 1.2),
arguments(tenMillionBlanks + "+1.2", "%+10000004.1f", 1.2),

arguments("-1.2", "%+1.1f", -1.2),
arguments("-1.2", "%+2.1f", -1.2),
arguments("-1.2", "%+3.1f", -1.2),
arguments("-1.2", "%+4.1f", -1.2),
arguments(" -1.2", "%+5.1f", -1.2),
arguments(" -1.2", "%+10.1f", -1.2),
arguments(tenMillionBlanks + "-1.2", "%+10000004.1f", -1.2),

/* blank padding, right adjusted, mandatory blank sign */
arguments(" 12", "% 1d", 12),
Expand All @@ -107,27 +118,31 @@ static Arguments[] padding() {
arguments(" 12", "% 4d", 12),
arguments(" 12", "% 5d", 12),
arguments(" 12", "% 10d", 12),
arguments(tenMillionBlanks + "12", "% 10000002d", 12),

arguments("-12", "% 1d", -12),
arguments("-12", "% 2d", -12),
arguments("-12", "% 3d", -12),
arguments(" -12", "% 4d", -12),
arguments(" -12", "% 5d", -12),
arguments(" -12", "% 10d", -12),
arguments(tenMillionBlanks + "-12", "% 10000003d", -12),

arguments(" 1.2", "% 1.1f", 1.2),
arguments(" 1.2", "% 2.1f", 1.2),
arguments(" 1.2", "% 3.1f", 1.2),
arguments(" 1.2", "% 4.1f", 1.2),
arguments(" 1.2", "% 5.1f", 1.2),
arguments(" 1.2", "% 10.1f", 1.2),
arguments(tenMillionBlanks + "1.2", "% 10000003.1f", 1.2),

arguments("-1.2", "% 1.1f", -1.2),
arguments("-1.2", "% 2.1f", -1.2),
arguments("-1.2", "% 3.1f", -1.2),
arguments("-1.2", "% 4.1f", -1.2),
arguments(" -1.2", "% 5.1f", -1.2),
arguments(" -1.2", "% 10.1f", -1.2),
arguments(tenMillionBlanks + "-1.2", "% 10000004.1f", -1.2),

/* blank padding, left adjusted, optional sign */
arguments("12", "%-1d", 12),
Expand All @@ -136,27 +151,31 @@ static Arguments[] padding() {
arguments("12 ", "%-4d", 12),
arguments("12 ", "%-5d", 12),
arguments("12 ", "%-10d", 12),
arguments("12" + tenMillionBlanks, "%-10000002d", 12),

arguments("-12", "%-1d", -12),
arguments("-12", "%-2d", -12),
arguments("-12", "%-3d", -12),
arguments("-12 ", "%-4d", -12),
arguments("-12 ", "%-5d", -12),
arguments("-12 ", "%-10d", -12),
arguments("-12" + tenMillionBlanks, "%-10000003d", -12),

arguments("1.2", "%-1.1f", 1.2),
arguments("1.2", "%-2.1f", 1.2),
arguments("1.2", "%-3.1f", 1.2),
arguments("1.2 ", "%-4.1f", 1.2),
arguments("1.2 ", "%-5.1f", 1.2),
arguments("1.2 ", "%-10.1f", 1.2),
arguments("1.2" + tenMillionBlanks, "%-10000003.1f", 1.2),

arguments("-1.2", "%-1.1f", -1.2),
arguments("-1.2", "%-2.1f", -1.2),
arguments("-1.2", "%-3.1f", -1.2),
arguments("-1.2", "%-4.1f", -1.2),
arguments("-1.2 ", "%-5.1f", -1.2),
arguments("-1.2 ", "%-10.1f", -1.2),
arguments("-1.2" + tenMillionBlanks, "%-10000004.1f", -1.2),

/* blank padding, left adjusted, mandatory plus sign */
arguments("+12", "%-+1d", 12),
Expand All @@ -165,27 +184,31 @@ static Arguments[] padding() {
arguments("+12 ", "%-+4d", 12),
arguments("+12 ", "%-+5d", 12),
arguments("+12 ", "%-+10d", 12),
arguments("+12" + tenMillionBlanks, "%-+10000003d", 12),

arguments("-12", "%-+1d", -12),
arguments("-12", "%-+2d", -12),
arguments("-12", "%-+3d", -12),
arguments("-12 ", "%-+4d", -12),
arguments("-12 ", "%-+5d", -12),
arguments("-12 ", "%-+10d", -12),
arguments("-12" + tenMillionBlanks, "%-+10000003d", -12),

arguments("+1.2", "%-+1.1f", 1.2),
arguments("+1.2", "%-+2.1f", 1.2),
arguments("+1.2", "%-+3.1f", 1.2),
arguments("+1.2", "%-+4.1f", 1.2),
arguments("+1.2 ", "%-+5.1f", 1.2),
arguments("+1.2 ", "%-+10.1f", 1.2),
arguments("+1.2" + tenMillionBlanks, "%-+10000004.1f", 1.2),

arguments("-1.2", "%-+1.1f", -1.2),
arguments("-1.2", "%-+2.1f", -1.2),
arguments("-1.2", "%-+3.1f", -1.2),
arguments("-1.2", "%-+4.1f", -1.2),
arguments("-1.2 ", "%-+5.1f", -1.2),
arguments("-1.2 ", "%-+10.1f", -1.2),
arguments("-1.2" + tenMillionBlanks, "%-+10000004.1f", -1.2),

/* blank padding, left adjusted, mandatory blank sign */
arguments(" 12", "%- 1d", 12),
Expand All @@ -194,27 +217,31 @@ static Arguments[] padding() {
arguments(" 12 ", "%- 4d", 12),
arguments(" 12 ", "%- 5d", 12),
arguments(" 12 ", "%- 10d", 12),
arguments(" 12" + tenMillionBlanks, "%- 10000003d", 12),

arguments("-12", "%- 1d", -12),
arguments("-12", "%- 2d", -12),
arguments("-12", "%- 3d", -12),
arguments("-12 ", "%- 4d", -12),
arguments("-12 ", "%- 5d", -12),
arguments("-12 ", "%- 10d", -12),
arguments("-12" + tenMillionBlanks, "%- 10000003d", -12),

arguments(" 1.2", "%- 1.1f", 1.2),
arguments(" 1.2", "%- 2.1f", 1.2),
arguments(" 1.2", "%- 3.1f", 1.2),
arguments(" 1.2", "%- 4.1f", 1.2),
arguments(" 1.2 ", "%- 5.1f", 1.2),
arguments(" 1.2 ", "%- 10.1f", 1.2),
arguments(" 1.2" + tenMillionBlanks, "%- 10000004.1f", 1.2),

arguments("-1.2", "%- 1.1f", -1.2),
arguments("-1.2", "%- 2.1f", -1.2),
arguments("-1.2", "%- 3.1f", -1.2),
arguments("-1.2", "%- 4.1f", -1.2),
arguments("-1.2 ", "%- 5.1f", -1.2),
arguments("-1.2 ", "%- 10.1f", -1.2),
arguments("-1.2" + tenMillionBlanks, "%- 10000004.1f", -1.2),

/* zero padding, right adjusted, optional sign */
arguments("12", "%01d", 12),
Expand All @@ -223,27 +250,31 @@ static Arguments[] padding() {
arguments("0012", "%04d", 12),
arguments("00012", "%05d", 12),
arguments("0000000012", "%010d", 12),
arguments(tenMillionZeros + "12", "%010000002d", 12),

arguments("-12", "%01d", -12),
arguments("-12", "%02d", -12),
arguments("-12", "%03d", -12),
arguments("-012", "%04d", -12),
arguments("-0012", "%05d", -12),
arguments("-000000012", "%010d", -12),
arguments("-" + tenMillionZeros + "12", "%010000003d", -12),

arguments("1.2", "%01.1f", 1.2),
arguments("1.2", "%02.1f", 1.2),
arguments("1.2", "%03.1f", 1.2),
arguments("01.2", "%04.1f", 1.2),
arguments("001.2", "%05.1f", 1.2),
arguments("00000001.2", "%010.1f", 1.2),
arguments(tenMillionZeros + "1.2", "%010000003.1f", 1.2),

arguments("-1.2", "%01.1f", -1.2),
arguments("-1.2", "%02.1f", -1.2),
arguments("-1.2", "%03.1f", -1.2),
arguments("-1.2", "%04.1f", -1.2),
arguments("-01.2", "%05.1f", -1.2),
arguments("-0000001.2", "%010.1f", -1.2),
arguments("-" + tenMillionZeros + "1.2", "%010000004.1f", -1.2),

/* zero padding, right adjusted, mandatory plus sign */
arguments("+12", "%+01d", 12),
Expand All @@ -252,27 +283,31 @@ static Arguments[] padding() {
arguments("+012", "%+04d", 12),
arguments("+0012", "%+05d", 12),
arguments("+000000012", "%+010d", 12),
arguments("+" + tenMillionZeros + "12", "%+010000003d", 12),

arguments("-12", "%+01d", -12),
arguments("-12", "%+02d", -12),
arguments("-12", "%+03d", -12),
arguments("-012", "%+04d", -12),
arguments("-0012", "%+05d", -12),
arguments("-000000012", "%+010d", -12),
arguments("-" + tenMillionZeros + "12", "%+010000003d", -12),

arguments("+1.2", "%+01.1f", 1.2),
arguments("+1.2", "%+02.1f", 1.2),
arguments("+1.2", "%+03.1f", 1.2),
arguments("+1.2", "%+04.1f", 1.2),
arguments("+01.2", "%+05.1f", 1.2),
arguments("+0000001.2", "%+010.1f", 1.2),
arguments("+" + tenMillionZeros + "1.2", "%+010000004.1f", 1.2),

arguments("-1.2", "%+01.1f", -1.2),
arguments("-1.2", "%+02.1f", -1.2),
arguments("-1.2", "%+03.1f", -1.2),
arguments("-1.2", "%+04.1f", -1.2),
arguments("-01.2", "%+05.1f", -1.2),
arguments("-0000001.2", "%+010.1f", -1.2),
arguments("-" + tenMillionZeros + "1.2", "%+010000004.1f", -1.2),

/* zero padding, right adjusted, mandatory blank sign */
arguments(" 12", "% 01d", 12),
Expand All @@ -281,27 +316,31 @@ static Arguments[] padding() {
arguments(" 012", "% 04d", 12),
arguments(" 0012", "% 05d", 12),
arguments(" 000000012", "% 010d", 12),
arguments(" " + tenMillionZeros + "12", "% 010000003d", 12),

arguments("-12", "% 01d", -12),
arguments("-12", "% 02d", -12),
arguments("-12", "% 03d", -12),
arguments("-012", "% 04d", -12),
arguments("-0012", "% 05d", -12),
arguments("-000000012", "% 010d", -12),
arguments("-" + tenMillionZeros + "12", "% 010000003d", -12),

arguments(" 1.2", "% 01.1f", 1.2),
arguments(" 1.2", "% 02.1f", 1.2),
arguments(" 1.2", "% 03.1f", 1.2),
arguments(" 1.2", "% 04.1f", 1.2),
arguments(" 01.2", "% 05.1f", 1.2),
arguments(" 0000001.2", "% 010.1f", 1.2),
arguments(" " + tenMillionZeros + "1.2", "% 010000004.1f", 1.2),

arguments("-1.2", "% 01.1f", -1.2),
arguments("-1.2", "% 02.1f", -1.2),
arguments("-1.2", "% 03.1f", -1.2),
arguments("-1.2", "% 04.1f", -1.2),
arguments("-01.2", "% 05.1f", -1.2),
arguments("-0000001.2", "% 010.1f", -1.2),
arguments("-" + tenMillionZeros + "1.2", "% 010000004.1f", -1.2),

};
}
Expand Down

3 comments on commit 4f33608

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 4f33608 Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 4f33608 Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoeLin the backport was successfully created on the branch backport-GoeLin-4f336085 in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 4f336085 from the openjdk/jdk repository.

The commit being backported was authored by Chad Rakoczy on 6 Mar 2024 and was reviewed by Raffaello Giulietti.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:

$ git fetch https://github.com/openjdk-bots/jdk21u-dev.git backport-GoeLin-4f336085:backport-GoeLin-4f336085
$ git checkout backport-GoeLin-4f336085
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u-dev.git backport-GoeLin-4f336085

Please sign in to comment.