From bf6f6c6d9547645e6c1988ebb510f415e7336500 Mon Sep 17 00:00:00 2001 From: Richard Leitner Date: Fri, 15 Jun 2018 12:05:55 +0200 Subject: oeqa: runtime: add java & javac testcases These testcases verify that java and javac are working. They will be used as "quality-gate" test for accepting patches in the future. Signed-off-by: Richard Leitner --- lib/oeqa/files/test.jar | Bin 0 -> 8164 bytes lib/oeqa/files/test.java | 8 ++++++ lib/oeqa/runtime/cases/java.py | 60 ++++++++++++++++++++++++++++++++++++++++ lib/oeqa/runtime/cases/javac.py | 32 +++++++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 lib/oeqa/files/test.jar create mode 100644 lib/oeqa/files/test.java create mode 100644 lib/oeqa/runtime/cases/java.py create mode 100644 lib/oeqa/runtime/cases/javac.py diff --git a/lib/oeqa/files/test.jar b/lib/oeqa/files/test.jar new file mode 100644 index 0000000..a539b22 Binary files /dev/null and b/lib/oeqa/files/test.jar differ diff --git a/lib/oeqa/files/test.java b/lib/oeqa/files/test.java new file mode 100644 index 0000000..a661972 --- /dev/null +++ b/lib/oeqa/files/test.java @@ -0,0 +1,8 @@ +package test; + +public class test { + public static void main(String[] args) { + System.out.println("the answer is 42"); + } + +} diff --git a/lib/oeqa/runtime/cases/java.py b/lib/oeqa/runtime/cases/java.py new file mode 100644 index 0000000..feb572b --- /dev/null +++ b/lib/oeqa/runtime/cases/java.py @@ -0,0 +1,60 @@ +import os + +from oeqa.runtime.case import OERuntimeTestCase +from oeqa.core.decorator.depends import OETestDepends +from oeqa.core.decorator.oeid import OETestID +from oeqa.runtime.decorator.package import OEHasPackage + +class JavaTest(OERuntimeTestCase): + + @classmethod + def setUpClass(cls): + myfilesdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../files/') + src = os.path.join(myfilesdir, 'test.jar') + dst = '/tmp/test.jar' + cls.tc.target.copyTo(src, dst) + + @classmethod + def tearDownClass(cls): + dst = '/tmp/test.jar' + cls.tc.target.run('rm %s' % dst) + + @OETestDepends(['ssh.SSHTest.test_ssh']) + def test_java_exists(self): + status, output = self.target.run('which java') + msg = 'java binary not in PATH or not on target.' + self.assertEqual(status, 0, msg=msg) + + @OETestDepends(['java.JavaTest.test_java_exists']) + def test_java_version(self): + status, output = self.target.run('java -version') + msg = 'Exit status was not 0. Output: %s' % output + self.assertEqual(status, 0, msg=msg) + # check java version (somehow...) + + @OETestDepends(['java.JavaTest.test_java_exists']) + def test_java_jar_works(self): + status, output = self.target.run('java -jar /tmp/test.jar') + msg = 'Exit status was not 0. Output: %s' % output + self.assertEqual(status, 0, msg=msg) + + msg = 'Incorrect output: %s' % output + self.assertEqual(output, "the answer is 42", msg=msg) + + @OETestDepends(['java.JavaTest.test_java_exists']) + def test_java_jar_int_mode(self): + status, output = self.target.run('java -showversion -Xint -jar /tmp/test.jar') + msg = 'Exit status was not 0. Output: %s' % output + self.assertEqual(status, 0, msg=msg) + + msg = 'Incorrect mode: %s' % output + self.assertIn(', interpreted mode)', output, msg=msg) + + @OETestDepends(['java.JavaTest.test_java_exists']) + def test_java_jar_comp_mode(self): + status, output = self.target.run('java -showversion -Xcomp -jar /tmp/test.jar') + msg = 'Exit status was not 0. Output: %s' % output + self.assertEqual(status, 0, msg=msg) + + msg = 'Incorrect mode: %s' % output + self.assertIn(', compiled mode)', output, msg=msg) diff --git a/lib/oeqa/runtime/cases/javac.py b/lib/oeqa/runtime/cases/javac.py new file mode 100644 index 0000000..ad6de25 --- /dev/null +++ b/lib/oeqa/runtime/cases/javac.py @@ -0,0 +1,32 @@ +import os + +from oeqa.runtime.case import OERuntimeTestCase +from oeqa.core.decorator.depends import OETestDepends +from oeqa.core.decorator.oeid import OETestID +from oeqa.runtime.decorator.package import OEHasPackage + +class JavacTest(OERuntimeTestCase): + + @classmethod + def setUpClass(cls): + myfilesdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../files/') + src = os.path.join(myfilesdir, 'test.java') + dst = '/tmp/test.java' + cls.tc.target.copyTo(src, dst) + + @classmethod + def tearDownClass(cls): + dst = '/tmp/test.java /tmp/test.class' + cls.tc.target.run('rm %s' % dst) + + @OETestDepends(['java.JavaTest.test_java_exists']) + def test_javac_exists(self): + status, output = self.target.run('which javac') + msg = 'javac binary not in PATH or not on target.' + self.assertEqual(status, 0, msg=msg) + + @OETestDepends(['javac.JavacTest.test_javac_exists']) + def test_javac_works(self): + status, output = self.target.run('javac /tmp/test.java') + msg = 'Exit status was not 0. Output: %s' % output + self.assertEqual(status, 0, msg=msg) -- cgit v1.2.3-54-g00ecf