#fuzztesting using ProcessBuilder

8 messages · Page 1 of 1 (latest)

hybrid tinsel
#

(context: school assignment)

I've been provided with a program to test, and when messing around with it's inputs manually, I can make it error (example, index out of bounds)

However, when trying to crash it through ProcessBuilder (which was suggested as the way to build the fuzztester) I can't get a different output between crash/nocrash/ Everything looks identical. The exit code is always 1, the error stream is identical, I can't figure out a way to tell the difference between it resolving properly and not.

I'm sure that processbuilder can do this, but I just can't figure out what method I'm missing that gives this a distinct output.

Here's the code I'm using right now, I haven't done any fuzzing, just trying to get the error detection going first since nothing works without that.

import java.lang.ProcessBuilder;

public class testRunner {
    public static void  main(String[] args) {
        try {
            ProcessBuilder processBuilder = new ProcessBuilder("java", "PacketLab", "input.txt");
            Process process = processBuilder.start();
            process.waitFor();
            System.out.println("exit code: " + process.exitValue());
            System.out.println("errorStream: " + process.getErrorStream());
        }
        catch(Exception e) {
            System.out.println("caught error: " + e);
        }
    }
}```

 If I run this with valid inputs in input.txt, it outputs exactly the same exit code and errorStream as if I use invalid inputs in input.txt. But I know that if I manually run PacketLab with those inputs, it gives me an error, for example, the last time I did this, it gave this:
```Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
        at PacketLab.process(PacketLab.java:130)
        at PacketLab.main(PacketLab.java:41)```
vale kayakBOT
#

This post has been reserved for your question.

Hey @hybrid tinsel! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 720 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

pearl stag
#

in your PacketLab class, log the absolute path of the file, it's plausible it's reading the file from different dir than what you think

hybrid tinsel
#

im not supposed to change packetlab, but i assume you mean just for testing

i can alter the input txt and crash packetlab manually, so doesn't that mean its reading it from where i expect? or do you mean theres a chance my manual instance is reading from somewhere else than the instance pricessbuilder starts?

odd moss
#

Is PacketLab.class in the same directory as your test runner application?

#

and input.txt in the same directory?

#

Maybe take a look at the exception itself to find out why it happens