RFR [6943190] TEST_BUG: java/lang/Runtime/exec/ExecWithInput.java hardcodes path to cat

Martin Buchholz martinrb at google.com
Sun Mar 16 00:41:16 UTC 2014


Thanks for trying to make these tests more robust.

  33     private static final String[] paths = {"/bin", "/usr/bin",
  34             "/usr/local/bin", "/system/bin", "/sbin", "/usr/bin/sbin",
  35             "/usr/local/sbin", "/system/sbin"};


I think in practice { "/bin", "/usr/bin" } would work very well.  I would
definitely leave out /usr/local, since that is a location for non-standard
program variants to be installed.  I don't know anything about /system - I
would leave it out.  Pedants would suggest getting the system default PATH
using "getconf PATH", and that might get you /usr/xpg4/bin, but probably
overkill here.

I wouldn't fall back to looking on PATH.  There should be as few
dependencies on the user's environment as possible.

I would leave out the crufty windows-checking code from each test, and
instead write test code like:

If (UnixCommands.tee() == null || UnixCommands.cat() == null)
  return;

Imagine these tests will be run on some other strange OS someday.



On Fri, Mar 14, 2014 at 9:58 AM, Ivan Gerasimov
<ivan.gerasimov at oracle.com>wrote:

> Hello!
>
> This is a friendly reminder.
> Can someone with the Reviewer status please help review this?
>
> In short: we have a few java tests that run shell commands.
> In some tests the path to the command is omitted, in other tests an
> absolute path is given.
> In the third group of tests, the *other* absolute path to the same
> commands is used.
>
> As Martin suggested, I added searching for the command at certain fixed
> directories before using it.
>
> The final webrev can be found here:
> http://cr.openjdk.java.net/~igerasim/6943190/2/webrev/
>
> Thanks in advance,
> Ivan
>
>
>



More information about the core-libs-dev mailing list