[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-quality-discuss
Subject:    Re: jtreg shell tests
From:       Jonathan Gibbons <jonathan.gibbons () oracle ! com>
Date:       2019-02-05 1:08:24
Message-ID: 8a7404b2-47da-6c05-8133-3b452228c083 () oracle ! com
[Download RAW message or body]

I have published an updated version of these notes on the OpenJDK 
website [1].

I have also pushed updates to the jtreg repo. With this version I can 
successfully   run shell tests
in the following environments:

  * Ubuntu Linux (I'm assuming macOS and other POSIX systems will be the
    same)
  * Windows/Cygwin
  * Windows/WSL, testing a Windows JDK (requires jtreg to be run with a
    Windows JDK)
  * Windows/WSL, testing a Linux JDK (requires jtreg to be run with a
    Linux JDK)

-- Jon

[1] http://openjdk.java.net/jtreg/shellTests.html


On 01/25/2019 04:43 PM, Jonathan Gibbons wrote:
> With all the recent discussion regarding how to support the use of 
> Windows Subsystem for Linux (WSL)
> as an alternate to Cygwin, it seems worth writing up some 
> recommendations on writing jtreg shell tests.
> The intent of these notes is that they will evolve into a page in the 
> jtreg section on the OpenJDK website.
>
> The focus is specifically about different approaches to providing the 
> ability to run a shell test on all
> supported platforms, by means of abstracting the significant 
> differences into a series of environment
> variables that are set according to the environment in which the test 
> is running.
>
> Option 1.
>
> Convert the test to Java. In general, this continues to be the 
> recommended alternative.
>
>
> Option 2.
>
> Use a shell `case` statement, like the following, or a variant thereof:
>
>     OS=`uname -s`;
>     case "$OS" in
>            Windows* | CYGWIN* )
>                    FS="\\"
>                    PS=";"
>                    NULL=NUL
>                    ;;
>
>            Linux )
>                    if [ -r $TESTJAVA/bin/java.exe ]; then
>                           FS="\\"
>                            PS=";"
>                           EXE_SUFFIX=".exe"
>                    else
>                            FS="/"
>                            PS=":"
>                    fi
>                    NULL=/dev/null
>                    ;;
>
>            * )
>                    FS="/"
>                    PS=":"
>                    NULL=/dev/null
>     esac
>
> Option 3.
>
> Use a shared library script to embody the behavior in the previous 
> example.   jtreg now provides a new `TESTROOT` environment variable, 
> which makes it easy to reference a shared script in a constant manner 
> from any shell test, wherever the test is within the test suite. Since 
> the library script is used to set environment variables like `FS`, 
> `PS`, and `NULL`, it should be executed with `source` and not `bash` 
> or `sh`.
>
>
> Option 4.
>
> jtreg now sets the following environment variables when running a 
> shell script: `FS`, `PS`, `NULL` and `EXE_SUFFIX`.   This may be enough 
> to completely avoid the need for a `case` statement in each shell 
> script or the use of a shared library script to set these variables.
>
>
> Running scripts standalone.
>
> One concern when working with shell tests has been the ability to run 
> the test "stand-alone", without the use of jtreg. In the past, this 
> was seen as justification for the explicit use of the `case` statement 
> in each shell test. However, the need to run shell tests standalone no 
> longer seems to be a significant concern. For those that do want to 
> run shell tests by themselves, it is worth noting that once a test has 
> been run by jtreg, the ".jtr" file contains "rerun" sections with 
> details on how to run each action of the test. You can either 
> copy/paste/edit from the ".jtr" file directly, or use the jtreg 
> `-show:rerun` option to output the information to the standard output 
> stream.
>
>
>


[Attachment #3 (text/html)]

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>I have published an updated version of these notes on the OpenJDK
      website [1].</p>
    <p>I have also pushed updates to the jtreg repo. With this version I
      can successfully   run shell tests<br>
      in the following environments:<br>
    </p>
    <ul>
      <li>Ubuntu Linux (I'm assuming macOS and other POSIX systems will
        be the same)<br>
      </li>
      <li>Windows/Cygwin</li>
      <li>
        Windows/WSL, testing a Windows JDK (requires jtreg to be run
        with a Windows JDK)</li>
      <li>
        Windows/WSL, testing a Linux JDK (requires jtreg to be run with
        a Linux JDK)</li>
    </ul>
    <p>-- Jon<br>
    </p>
    <p>[1] <a class="moz-txt-link-freetext" \
href="http://openjdk.java.net/jtreg/shellTests.html">http://openjdk.java.net/jtreg/shellTests.html</a><br>
  </p>
    <br>
    <div class="moz-cite-prefix">On 01/25/2019 04:43 PM, Jonathan
      Gibbons wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:fc540396-2921-dccc-ba8b-cdce2bd724d0@oracle.com">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      With all the recent discussion regarding how to support the use of
      Windows Subsystem for Linux (WSL)<br>
      as an alternate to Cygwin, it seems worth writing up some
      recommendations on writing jtreg shell tests.<br>
      The intent of these notes is that they will evolve into a page in
      the jtreg section on the OpenJDK website.<br>
      <br>
      The focus is specifically about different approaches to providing
      the ability to run a shell test on all <br>
      supported platforms, by means of abstracting the significant
      differences into a series of environment<br>
      variables that are set according to the environment in which the
      test is running.<br>
      <br>
      Option 1. <br>
      <br>
      Convert the test to Java. In general, this continues to be the
      recommended alternative.<br>
      <br>
      <br>
      Option 2.<br>
      <br>
      Use a shell `case` statement, like the following, or a variant
      thereof:<br>
      <blockquote><tt>OS=`uname -s`; </tt><tt><br>
        </tt><tt>case "$OS" in </tt><tt><br>
        </tt><tt>       Windows* | CYGWIN* ) </tt><tt><br>
        </tt><tt>               FS="\\" </tt><tt><br>
        </tt><tt>               PS=";" </tt><tt><br>
                         NULL=NUL<br>
        </tt><tt>               ;; </tt><tt><br>
        </tt> <tt><br>
        </tt><tt>       Linux ) </tt><tt><br>
        </tt><tt>               if [ -r $TESTJAVA/bin/java.exe ]; then </tt><tt><br>
        </tt><tt>                      FS="\\" </tt><tt><br>
        </tt><tt>                       PS=";" </tt><tt><br>
        </tt><tt>                      EXE_SUFFIX=".exe" </tt><tt><br>
        </tt><tt>               else </tt><tt><br>
        </tt><tt>                       FS="/" </tt><tt><br>
        </tt><tt>                       PS=":" </tt><tt><br>
        </tt><tt>               fi </tt><tt><br>
                         NULL=/dev/null<br>
        </tt><tt>               ;; </tt><tt><br>
        </tt> <tt><br>
        </tt><tt>       * ) </tt><tt><br>
        </tt><tt>               FS="/" </tt><tt><br>
        </tt><tt>               PS=":" </tt><tt><br>
                         NULL=/dev/null<br>
        </tt><tt>esac<br>
        </tt><br>
      </blockquote>
      Option 3.<br>
      <br>
      Use a shared library script to embody the behavior in the previous
      example.   jtreg now provides a new `TESTROOT` environment
      variable, which makes it easy to reference a shared script in a
      constant manner from any shell test, wherever the test is within
      the test suite. Since the library script is used to set
      environment variables like `FS`, `PS`, and `NULL`, it should be
      executed with `source` and not `bash` or `sh`.<br>
      <br>
      <br>
      Option 4.<br>
      <br>
      jtreg now sets the following environment variables when running a
      shell script: `FS`, `PS`, `NULL` and `EXE_SUFFIX`.   This may be
      enough to completely avoid the need for a `case` statement in each
      shell script or the use of a shared library script to set these
      variables.<br>
      <br>
      <br>
      Running scripts standalone.<br>
      <br>
      One concern when working with shell tests has been the ability to
      run the test "stand-alone", without the use of jtreg. In the past,
      this was seen as justification for the explicit use of the `case`
      statement in each shell test. However, the need to run shell tests
      standalone no longer seems to be a significant concern. For those
      that do want to run shell tests by themselves, it is worth noting
      that once a test has been run by jtreg, the ".jtr" file contains
      "rerun" sections with details on how to run each action of the
      test. You can either copy/paste/edit from the ".jtr" file
      directly, or use the jtreg `-show:rerun` option to output the
      information to the standard output stream.<br>
      <blockquote><tt><br>
          <br>
        </tt></blockquote>
    </blockquote>
    <br>
  </body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic