summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Leitner <richard.leitner@skidata.com>2018-06-15 12:05:55 +0200
committerRichard Leitner <richard.leitner@skidata.com>2018-06-19 14:14:52 +0200
commitbf6f6c6d9547645e6c1988ebb510f415e7336500 (patch)
tree820042ad856478be39ccaf1eb298cae763f0c04b
parent3918402ea146a93747170de3a3fd266ec89e521f (diff)
downloadmeta-java-bf6f6c6d9547645e6c1988ebb510f415e7336500.tar.gz
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 <richard.leitner@skidata.com>
-rw-r--r--lib/oeqa/files/test.jarbin0 -> 8164 bytes
-rw-r--r--lib/oeqa/files/test.java8
-rw-r--r--lib/oeqa/runtime/cases/java.py60
-rw-r--r--lib/oeqa/runtime/cases/javac.py32
4 files changed, 100 insertions, 0 deletions
diff --git a/lib/oeqa/files/test.jar b/lib/oeqa/files/test.jar
new file mode 100644
index 0000000..a539b22
--- /dev/null
+++ b/lib/oeqa/files/test.jar
Binary files 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 @@
1package test;
2
3public class test {
4 public static void main(String[] args) {
5 System.out.println("the answer is 42");
6 }
7
8}
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 @@
1import os
2
3from oeqa.runtime.case import OERuntimeTestCase
4from oeqa.core.decorator.depends import OETestDepends
5from oeqa.core.decorator.oeid import OETestID
6from oeqa.runtime.decorator.package import OEHasPackage
7
8class JavaTest(OERuntimeTestCase):
9
10 @classmethod
11 def setUpClass(cls):
12 myfilesdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../files/')
13 src = os.path.join(myfilesdir, 'test.jar')
14 dst = '/tmp/test.jar'
15 cls.tc.target.copyTo(src, dst)
16
17 @classmethod
18 def tearDownClass(cls):
19 dst = '/tmp/test.jar'
20 cls.tc.target.run('rm %s' % dst)
21
22 @OETestDepends(['ssh.SSHTest.test_ssh'])
23 def test_java_exists(self):
24 status, output = self.target.run('which java')
25 msg = 'java binary not in PATH or not on target.'
26 self.assertEqual(status, 0, msg=msg)
27
28 @OETestDepends(['java.JavaTest.test_java_exists'])
29 def test_java_version(self):
30 status, output = self.target.run('java -version')
31 msg = 'Exit status was not 0. Output: %s' % output
32 self.assertEqual(status, 0, msg=msg)
33 # check java version (somehow...)
34
35 @OETestDepends(['java.JavaTest.test_java_exists'])
36 def test_java_jar_works(self):
37 status, output = self.target.run('java -jar /tmp/test.jar')
38 msg = 'Exit status was not 0. Output: %s' % output
39 self.assertEqual(status, 0, msg=msg)
40
41 msg = 'Incorrect output: %s' % output
42 self.assertEqual(output, "the answer is 42", msg=msg)
43
44 @OETestDepends(['java.JavaTest.test_java_exists'])
45 def test_java_jar_int_mode(self):
46 status, output = self.target.run('java -showversion -Xint -jar /tmp/test.jar')
47 msg = 'Exit status was not 0. Output: %s' % output
48 self.assertEqual(status, 0, msg=msg)
49
50 msg = 'Incorrect mode: %s' % output
51 self.assertIn(', interpreted mode)', output, msg=msg)
52
53 @OETestDepends(['java.JavaTest.test_java_exists'])
54 def test_java_jar_comp_mode(self):
55 status, output = self.target.run('java -showversion -Xcomp -jar /tmp/test.jar')
56 msg = 'Exit status was not 0. Output: %s' % output
57 self.assertEqual(status, 0, msg=msg)
58
59 msg = 'Incorrect mode: %s' % output
60 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 @@
1import os
2
3from oeqa.runtime.case import OERuntimeTestCase
4from oeqa.core.decorator.depends import OETestDepends
5from oeqa.core.decorator.oeid import OETestID
6from oeqa.runtime.decorator.package import OEHasPackage
7
8class JavacTest(OERuntimeTestCase):
9
10 @classmethod
11 def setUpClass(cls):
12 myfilesdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../../files/')
13 src = os.path.join(myfilesdir, 'test.java')
14 dst = '/tmp/test.java'
15 cls.tc.target.copyTo(src, dst)
16
17 @classmethod
18 def tearDownClass(cls):
19 dst = '/tmp/test.java /tmp/test.class'
20 cls.tc.target.run('rm %s' % dst)
21
22 @OETestDepends(['java.JavaTest.test_java_exists'])
23 def test_javac_exists(self):
24 status, output = self.target.run('which javac')
25 msg = 'javac binary not in PATH or not on target.'
26 self.assertEqual(status, 0, msg=msg)
27
28 @OETestDepends(['javac.JavacTest.test_javac_exists'])
29 def test_javac_works(self):
30 status, output = self.target.run('javac /tmp/test.java')
31 msg = 'Exit status was not 0. Output: %s' % output
32 self.assertEqual(status, 0, msg=msg)