Skip to content

Commit

Permalink
Java scenario test for networking (#244)
Browse files Browse the repository at this point in the history
Disabling java-network scenario test for now due to #245
  • Loading branch information
hukoyu authored May 15, 2020
1 parent a3f3e2c commit 79cec48
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions .azure-pipelines/scripts/disabled_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ tests/basic/network/Makefile
tests/containers/unencrypted/env/Makefile
tests/virtio/ping_test/Makefile
tests/virtio/python_read/Makefile
tests/languages/java/network/Makefile
4 changes: 4 additions & 0 deletions tests/languages/java/network/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM openjdk:8-alpine
COPY ./app /app
WORKDIR /app
RUN javac -source 1.8 -target 1.8 *.java
34 changes: 34 additions & 0 deletions tests/languages/java/network/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
include ../../../common.mk

APP_ROOT=app
PROG_SRC=${APP_ROOT}/MainApp.java
PROG=MainApp

DISK_IMAGE=sgxlkl-java.img
IMAGE_SIZE=400M

ifeq ($(SGXLKL_VERBOSE),)
SGXLKL_ENV=\
SGXLKL_TAP=sgxlkl_tap0 SGXLKL_VERBOSE=1 SGXLKL_KERNEL_VERBOSE=1 SGXLKL_TRACE_LKL_SYSCALL=0 SGXLKL_TRACE_SIGNAL=0
else
SGXLKL_ENV=
endif

.DELETE_ON_ERROR:
.PHONY: run run-hw run-sw clean

$(DISK_IMAGE): $(PROG_SRC)
${SGXLKL_DISK_TOOL} create --size=${IMAGE_SIZE} --docker=Dockerfile ${DISK_IMAGE}

run: run-hw run-sw

run-hw: $(DISK_IMAGE)
@echo "sgx-lkl-java --hw-debug ${DISK_IMAGE} ${PROG}"
@${SGXLKL_ENV} ${SGXLKL_JAVA_RUN} --hw-debug ${DISK_IMAGE} ${PROG}

run-sw: $(DISK_IMAGE)
@echo "sgx-lkl-java --sw-debug ${DISK_IMAGE} ${PROG}"
@${SGXLKL_ENV} ${SGXLKL_JAVA_RUN} --sw-debug ${DISK_IMAGE} ${PROG}

clean:
rm -f $(DISK_IMAGE)
19 changes: 19 additions & 0 deletions tests/languages/java/network/app/MainApp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import java.io.*;
import java.net.*;

public class MainApp
{
public static void main(String[] args) throws MalformedURLException {
URL url = new URL("https://www.microsoft.com/");

try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"))) {
for (String line; (line = reader.readLine()) != null;) {
System.out.println(line);
}
} catch(Exception e) {
System.out.println(e);
System.exit(1);
}
}

}

0 comments on commit 79cec48

Please sign in to comment.