package com.jimbru.posix;

import com.jimbru.posix.Posix;
import java.util.Arrays;

public class TestHarness {

    public static void main(String[] args) {
        if (args.length == 0) {
            System.out.println("Usage: java -jar testharness.jar <fn> <arg0> ... <argN>");
            System.exit(1);
        }

        String fn = args[0];
        String args_first = args[1];
        String[] args_rest = Arrays.copyOfRange(args, 1, args.length);

        if (fn.equals("execv")) {
            Posix.execv(args_first, args_rest);
        } else if (fn.equals("execve")) {
            Posix.execve(args_first, args_rest, new String[]{"PATH=/bin", "TEST=abc"});
        } else if (fn.equals("execvp")) {
            Posix.execvp(args_first, args_rest);
        } else {
            System.out.printf("Unknown function: %s\n", fn);
            System.exit(1);
        }
    }
}

@@ -316,37 +316,8 @@
  %7D%0A%0A
-        String fn = args%5B0%5D;%0A
     
@@ -349,16 +349,16 @@
 rgs%5B1%5D;%0A
+
         
@@ -433,34 +433,57 @@
     
-if (fn.equals(
+switch (args%5B0%5D) %7B%0A            case 
 %22execv%22
-)) %7B%0A
+:%0A    
     
@@ -538,37 +538,48 @@
     
-%7D else if (fn.equals(
+        break;%0A            case 
 %22execve%22
 )) %7B
@@ -574,21 +574,22 @@
 %22execve%22
-)) %7B%0A
+:%0A    
         
@@ -680,37 +680,48 @@
     
+   
-%7D else if (fn.equals(
+     break;%0A            case 
 %22execvp%22
 )) %7B
@@ -720,13 +720,14 @@
 cvp%22
-)) %7B%0A
+:%0A    
     
@@ -783,17 +783,48 @@
     
+    
-%7D else %7B%0A
+    break;%0A            default:%0A    
     
@@ -879,13 +879,22 @@
 n%22, 
-fn);%0A
+args%5B0%5D);%0A    
     

Use switch in TestHarness