/* * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.controller.distribution; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.List; public class Sanity { static void copy(InputStream in, OutputStream out) throws IOException { while (true) { int c = in.read(); if (c == -1) break; out.write((char)c); } } public static void main(String[] args) throws IOException, InterruptedException { String cwd = System.getProperty("user.dir"); System.out.println("Current working directory = " + cwd); String os = System.getProperty("os.name").toLowerCase(); List script = new ArrayList(); if(os.contains("windows")){ script.add("cmd.exe"); script.add("/c"); script.add("runsanity.bat"); } else { script.add("./runsanity.sh"); } ProcessBuilder processBuilder = new ProcessBuilder(); processBuilder.inheritIO().command(script); Process p = processBuilder.start(); copy(p.getInputStream(), System.out); p.waitFor(); System.out.println("Test exited with exitValue = " + p.exitValue()); System.exit(p.exitValue()); } }