Skip to content

Commit

Permalink
add library download
Browse files Browse the repository at this point in the history
  • Loading branch information
wegendt-bosch committed Nov 18, 2019
1 parent b695b7d commit 50856e2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ class AbstractRuntimeTest {
}

def Stream<String> runAtMost(Path pathToExecutable, int timeInSeconds) {
return runAtMost("", pathToExecutable, timeInSeconds);
return runAtMost(pathToExecutable, #[], timeInSeconds);
}

def Stream<String> runAtMost(String prefix, Path pathToExecutable, int timeInSeconds) {
def Stream<String> runAtMost(Path pathToExecutable, String[] env, int timeInSeconds) {
println("running exe...");
println(pathToExecutable);
println("");
val Runtime rt = Runtime.getRuntime();
val Process pr = rt.exec(pathToExecutable.toString);
val Process pr = rt.exec(pathToExecutable.toString, env);
val output = new BufferedReader(new InputStreamReader(pr.inputStream));
pr.waitFor(timeInSeconds, TimeUnit.SECONDS);
if(pr.alive) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import org.junit.Test

import static extension org.eclipse.mita.base.util.BaseUtils.zip;
import java.util.stream.Collectors
import java.util.concurrent.TimeUnit

class MqttTest extends AbstractRuntimeTest {
@Test
Expand Down Expand Up @@ -38,11 +39,22 @@ class MqttTest extends AbstractRuntimeTest {
native unchecked fn exit(status: int16): void header "stdlib.h";
''').key;
val Runtime rt = Runtime.getRuntime();
val pahoLibUrl = "https://www.eclipse.org/downloads/download.php?file=/paho/1.4/Eclipse-Paho-MQTT-C-1.3.1-Linux.tar.gz";
val downloadLocation = "/tmp/paho.tar.gz";

val wgetCommand = rt.exec(#["wget", pahoLibUrl, "-O", downloadLocation]);
wgetCommand.waitFor(60, TimeUnit.SECONDS);

val extractCommand = rt.exec(#["tar", "xvzf", downloadLocation, "-C", projectPath.toString, "--strip-components=1"]);
extractCommand.waitFor(60, TimeUnit.SECONDS);

compileMita(projectPath);
compileC(projectPath, "all");
val mosquitto = runAtMost(Paths.get("mosquitto"), 60);
val mosquitto = rt.exec("mosquitto");
val executable = projectPath.resolve(Paths.get("src-gen", "build", "app"));
val lines = runAtMost("LD_LIBRARY_PATH=" + projectPath.resolve(Paths.get("lib")), executable, 60);
val lines = runAtMost(executable, #["LD_LIBRARY_PATH=" + projectPath.resolve(Paths.get("lib"))], 60);
mosquitto.destroyForcibly;
val expectedLines = (0..9).map[it.toString];
lines.collect(Collectors.toList).zip(expectedLines).forEach[
Assert.assertEquals(it.key, it.value)
Expand Down

0 comments on commit 50856e2

Please sign in to comment.