[PATCH][TESTBUG] JDK-8214052: Wrong shell used

jesper.wilhelmsson at oracle.com jesper.wilhelmsson at oracle.com
Sat Dec 8 04:00:13 UTC 2018


> On 8 Dec 2018, at 04:46, Sergey <merkel05 at gmail.com> wrote:
> 
> Hi Jesper,
> 
> I've missed that the $res variable is assigned as a result of
> `egrep -ce` so it is safe to treat both cases as integers.
> 
> I hope I'm not overthinking here. Anyway, I've changed
> both places to use "-ne", please see updated patch inlined
> below

Yes, both places are comparing the result of a grep -c, so it seems they should be handled the same way. Wether it's using string comparison or integer comparison doesn't really matter to me, as long as they are the same.

Thank you for providing this fix!
The latest patch looks good to me. I'll sponsor it.
/Jesper

> 
> 
> diff --git a/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfoOnCompilation/run.sh b/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfoOnCompilation/run.sh
> --- a/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfoOnCompilation/run.sh
> +++ b/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfoOnCompilation/run.sh
> @@ -27,7 +27,7 @@
> 
>  ver=$(${TESTED_JAVA_HOME}/bin/java ${JAVA_OPTS} -version 2>&1)
>  isComp=$( echo ${ver} | grep -c "compiled mode")
> -if [[ $isComp  != 1 ]]; then
> +if [ "$isComp" -ne 1 ]; then
>          echo "skipped. This test works only with -Xcomp"
>          exit
>  fi
> @@ -40,7 +40,7 @@
>  res=$(${TESTED_JAVA_HOME}/bin/java ${JAVA_OPTS} -XX:+PrintCodeCacheOnCompilation -XX:-Inline vm.compiler.CodeCacheInfoOnCompilation.PrintOnCall | egrep -ce "${pattern}")
>  echo "res: " ${res}
> 
> -if (( "${res}" != "0" )); then
> +if [ "$res" -ne 0 ]; then
>          echo "passed"
>          true
>  else
> 
> Regards,
> Sergei
> 
> On Sat, 8 Dec 2018 at 04:24, Sergey <merkel05 at gmail.com <mailto:merkel05 at gmail.com>> wrote:
> Hi Jesper,
> 
> I’ve double checked with “test”s man page
> http://man7.org/linux/man-pages/man1/test.1.html <http://man7.org/linux/man-pages/man1/test.1.html>
> In particular this part:
> 
> STRING1 != STRING2
>               the strings are not equal
> 
> INTEGER1 -ne INTEGER2
>               INTEGER1 is not equal to INTEGER2
> and applied those respectively.
> 
> Do you think I better use “!=” in both places?
> 
> Regards,
> Sergei
> 
> On Sat, 8 Dec 2018 at 04:10, <jesper.wilhelmsson at oracle.com <mailto:jesper.wilhelmsson at oracle.com>> wrote:
> Hi,
> 
> Why do you replace != with -ne in one case and not in the other?
> 
> Thanks,
> /Jesper
> 
> > On 8 Dec 2018, at 02:19, Sergey <merkel05 at gmail.com <mailto:merkel05 at gmail.com>> wrote:
> >
> > Hi everyone,
> >
> > Could anyone please review that tiny fix for test script below?
> > That would be extremely great if anyone could sponsor the change as well.
> >
> > Thanks and regards,
> > Sergei
> >
> > On Thu, Dec 6, 2018, 08:37 Sergey <merkel05 at gmail.com <mailto:merkel05 at gmail.com> wrote:
> >
> >> Hi,
> >>
> >> I've posted the original mail to the wrong mailing list and thanks to
> >> David for guidance.
> >>
> >> Problem goes as follows: as stated in the bug description [1] there are few
> >> places in the tests where extended bash syntax is being used.
> >>
> >> First one is (as per ticket in the headline):
> >>
> >> - vmTestbase/vm/compiler/CodeCacheInfoOnCompilation
> >>
> >> I've made a quick fix for that one and patch could be found
> >> inlined below.
> >>
> >> Moreover what I've noticed is that grep gives me
> >> another test script:
> >>
> >> - GeneratePropertyPassword.sh [2]
> >>
> >> that seems to be linked with another ticket [3] which is closed,
> >> though it still uses the bash "[[" extension. Perhaps this [4] fix
> >> needs to be reapplied.
> >>
> >> In regards to the patch below, please let me know if I've missed
> >> something. Changes were successfully tested with `dash v0.5.10.2-1`.
> >>
> >> [1] https://bugs.openjdk.java.net/browse/JDK-8214052 <https://bugs.openjdk.java.net/browse/JDK-8214052>
> >> [2]
> >> http://hg.openjdk.java.net/jdk/sandbox/file/413c28945e0f/test/jdk/sun/management/jmxremote/bootstrap/GeneratePropertyPassword.sh#l37 <http://hg.openjdk.java.net/jdk/sandbox/file/413c28945e0f/test/jdk/sun/management/jmxremote/bootstrap/GeneratePropertyPassword.sh#l37>
> >> [3] https://bugs.openjdk.java.net/browse/JDK-8025886 <https://bugs.openjdk.java.net/browse/JDK-8025886>
> >> [4] http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/a2551e12a9ea0.5.10.2-1 <http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/a2551e12a9ea0.5.10.2-1>
> >>
> >> Regards,
> >> su -
> >>
> >> diff --git
> >> a/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfoOnCompilation/run.sh
> >> b/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfoOnCompilation/run.sh
> >> ---
> >> a/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfoOnCompilation/run.sh
> >> +++
> >> b/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfoOnCompilation/run.sh
> >> @@ -27,7 +27,7 @@
> >>
> >> ver=$(${TESTED_JAVA_HOME}/bin/java ${JAVA_OPTS} -version 2>&1)
> >> isComp=$( echo ${ver} | grep -c "compiled mode")
> >> -if [[ $isComp  != 1 ]]; then
> >> +if [ "$isComp" -ne 1 ]; then
> >>         echo "skipped. This test works only with -Xcomp"
> >>         exit
> >> fi
> >> @@ -40,7 +40,7 @@
> >> res=$(${TESTED_JAVA_HOME}/bin/java ${JAVA_OPTS}
> >> -XX:+PrintCodeCacheOnCompilation -XX:-Inline
> >> vm.compiler.CodeCacheInfoOnCompilation.PrintOnCall | egrep -ce "${pattern}")
> >> echo "res: " ${res}
> >>
> >> -if (( "${res}" != "0" )); then
> >> +if [ "$res" != "0" ]; then
> >>         echo "passed"
> >>         true
> >> else
> >>
> 



More information about the hotspot-dev mailing list