[oe] [meta-java][PATCH v3 2/2] openjdk-12: Add test cases for openjdk-12

Richard Leitner richard.leitner at skidata.com
Tue Jan 21 11:30:12 UTC 2020


Hi,

On Tue, Dec 31, 2019 at 03:19:48PM +0800, mohamad.noor.alim.hussin at intel.com wrote:
> From: Mohamad Noor Alim Hussin <mohamad.noor.alim.hussin at intel.com>
> 
> There are 2 test cases added. Test case number 1 specifically to
> test openjdk-12. The list of test cases as follows
> 
>  1) test_java12_jar_comp_mode
>  2) test_java_runtime
> 
> 1) test_java12_jar_comp_mode
> This test case will execute java code in jar format using jvm compilation mode.
> 
> 2) test_java_runtime
> This test case will compile java code and execute with classpath.
> 
> Signed-off-by: Mohamad Noor Alim Hussin <mohamad.noor.alim.hussin at intel.com>
> ---
>  lib/oeqa/files/hello.java       |  5 +++++
>  lib/oeqa/runtime/cases/java.py  | 15 +++++++++++++++
>  lib/oeqa/runtime/cases/javac.py | 27 +++++++++++++++++++++++----
>  3 files changed, 43 insertions(+), 4 deletions(-)
>  create mode 100644 lib/oeqa/files/hello.java
> 
> diff --git a/lib/oeqa/files/hello.java b/lib/oeqa/files/hello.java
> new file mode 100644
> index 0000000..b750670
> --- /dev/null
> +++ b/lib/oeqa/files/hello.java
> @@ -0,0 +1,5 @@
> +class hello {
> +    public static void main(String args[]){
> +        System.out.println("Hello Java here!");
> +    }
> +}

I don't get why you add a new java file which will be compiled for
testing. Can you please explain it to me?
We already have "test.java", why aren't you using this one?

regards;rl

> diff --git a/lib/oeqa/runtime/cases/java.py b/lib/oeqa/runtime/cases/java.py
> index c1e1498..9a73311 100644
> --- a/lib/oeqa/runtime/cases/java.py
> +++ b/lib/oeqa/runtime/cases/java.py
> @@ -81,3 +81,18 @@ class JavaTest(OERuntimeTestCase):
>  
>          msg = 'Incorrect mode: %s' % output
>          self.assertIn(', compiled mode)', output, msg=msg)
> +
> +    # As OpenJDK-12 doesn't support compiled mode (JIT) for arm yet we skip this
> +    # test for now.
> +    @OEHasPackage(["openjre-12", "openjdk-12"])
> +    @OETestDepends(['java.JavaTest.test_java_exists'])
> +    @skipIfInDataVar('TUNE_FEATURES', 'armv4', 'OpenJDK 12 compiled mode not yet supported for armv4')
> +    @skipIfInDataVar('TUNE_FEATURES', 'armv5', 'OpenJDK 12 compiled mode not yet supported for armv5')
> +    @skipIfInDataVar('TUNE_FEATURES', 'armv6', 'OpenJDK 12 compiled mode not yet supported for armv6')
> +    def test_java12_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
> index 39ae298..06905b4 100644
> --- a/lib/oeqa/runtime/cases/javac.py
> +++ b/lib/oeqa/runtime/cases/javac.py
> @@ -9,13 +9,22 @@ 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)
> +        java_src = ['test.java', 'hello.java']
> +        for j in java_src:
> +            src = os.path.join(myfilesdir, j)
> +            dst = '/tmp/%s' % j
> +            cls.tc.target.copyTo(src, dst)
>  
>      @classmethod
>      def tearDownClass(cls):
> -        dst = '/tmp/test.java /tmp/test.class'
> +        java_src = ['test.java', 'hello.java']
> +        dst = []
> +        d = '/tmp'
> +        for j in java_src:
> +            jc = j.replace('.java', '.class')
> +            dst.append(os.path.join(d, j))
> +            dst.append(os.path.join(d, jc))
> +        dst = ' '.join(dst)
>          cls.tc.target.run('rm %s' % dst)
>  
>      @OETestDepends(['java.JavaTest.test_java_exists'])
> @@ -29,3 +38,13 @@ class JavacTest(OERuntimeTestCase):
>          status, output = self.target.run('javac /tmp/test.java')
>          msg = 'Exit status was not 0. Output: %s' % output
>          self.assertEqual(status, 0, msg=msg)
> +
> +    @OETestDepends(['javac.JavacTest.test_javac_works'])
> +    def test_java_runtime(self):
> +        status, output = self.target.run('javac /tmp/hello.java')
> +        msg = 'Exit status was not 0. Output: %s' % output
> +        self.assertEqual(status, 0, msg=msg)
> +
> +        status, output = self.target.run('java -cp /tmp hello')
> +        msg = 'Exit status was not 0. Output: %s' % output
> +        self.assertEqual(status, 0, msg=msg)
> -- 
> 2.19.1
> 
> -- 
> _______________________________________________
> Openembedded-devel mailing list
> Openembedded-devel at lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-devel


More information about the Openembedded-devel mailing list