33ff8ea18a19d84764061ff3aefbb259d1c185d2
[controller.git] / opendaylight / distribution / sanitytest / src / main / java / org / opendaylight / controller / distribution / Sanity.java
1 package org.opendaylight.controller.distribution;
2
3 import java.io.IOException;
4 import java.io.InputStream;
5 import java.io.OutputStream;
6
7 public class Sanity {
8
9     static void copy(InputStream in, OutputStream out) throws IOException {
10       while (true) {
11         int c = in.read();
12         if (c == -1) break;
13         out.write((char)c);
14       }
15     }
16
17     public static void main(String[] args) throws IOException, InterruptedException {
18         String cwd = System.getProperty("user.dir");
19
20         System.out.println("Current working directory = " + cwd);
21
22         String os = System.getProperty("os.name").toLowerCase();
23         String script = "./run.sh";
24
25         if(os.contains("windows")){
26             System.out.println("Sorry no sanity testing on Windows yet");
27             System.exit(0);
28             return;
29         }
30
31         ProcessBuilder processBuilder = new ProcessBuilder();
32         processBuilder.command(script);
33         Process p = processBuilder.start();
34
35         copy(p.getInputStream(), System.out);
36
37         p.waitFor();
38
39         System.out.println("Test exited with exitValue = " + p.exitValue());
40
41         System.exit(p.exitValue());
42     }
43 }