[CRIU] [PATCH] test, app-emu: Add HelloWorld java test

Cyrill Gorcunov gorcunov at openvz.org
Wed May 2 12:05:41 EDT 2012


Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 test/app-emu/java/HelloWorld/HelloWorld.java |   20 +++++++++++++++
 test/app-emu/java/HelloWorld/run.sh          |   34 ++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 0 deletions(-)
 create mode 100644 test/app-emu/java/HelloWorld/HelloWorld.java
 create mode 100644 test/app-emu/java/HelloWorld/run.sh

diff --git a/test/app-emu/java/HelloWorld/HelloWorld.java b/test/app-emu/java/HelloWorld/HelloWorld.java
new file mode 100644
index 0000000..93a63dd
--- /dev/null
+++ b/test/app-emu/java/HelloWorld/HelloWorld.java
@@ -0,0 +1,20 @@
+/*
+ * Trivial program which requires no
+ * additional imports
+ */
+public class HelloWorld {
+	public static void main(String[] args) {
+		int nr_sleeps = 5;
+		for (;;) {
+			System.out.println("Hello World");
+			if (nr_sleeps == 0)
+				System.exit(0);
+			try {
+				Thread.sleep(1000);
+				nr_sleeps--;
+			} catch(InterruptedException ex) {
+				Thread.currentThread().interrupt();
+			}
+		}
+	}
+}
diff --git a/test/app-emu/java/HelloWorld/run.sh b/test/app-emu/java/HelloWorld/run.sh
new file mode 100644
index 0000000..207438f
--- /dev/null
+++ b/test/app-emu/java/HelloWorld/run.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+crtools="../../../../crtools"
+
+cleanup_class() {
+	rm -f ./*.class
+}
+
+javac HelloWorld.java || exit 1
+
+set -x
+
+rm -rf dump
+mkdir dump
+
+setsid java HelloWorld &
+
+pid=${!}
+
+echo Lanuched java application with pid $pid in background
+
+${crtools} dump -D dump -o dump.log -v 4  -t ${pid} || {
+	echo "Dump failed"
+	exit 1
+}
+
+echo "Dumped, restoring and waiting for completion"
+
+${crtools} restore -D dump -o restore.log -v 4 -t ${pid} || {
+	echo "Restore failed"
+	exit 1
+}
+
+echo PASS
-- 
1.7.7.6



More information about the CRIU mailing list