[Git][reproducible-builds/diffoscope][master] 2 commits: Fix tests using javap tools

Chris Lamb gitlab at salsa.debian.org
Wed Dec 9 10:26:45 UTC 2020



Chris Lamb pushed to branch master at Reproducible Builds / diffoscope


Commits:
77bc7d53 by Jean-Romain Garnier at 2020-12-09T10:25:01+00:00
Fix tests using javap tools

Excepted output was missing checksum values

- - - - -
06cb774f by Jean-Romain Garnier at 2020-12-09T10:25:01+00:00
Add tests for OpenJDK 14

- - - - -


4 changed files:

- tests/comparators/test_dex.py
- tests/comparators/test_java.py
- + tests/data/dex_javap_14_expected_diffs
- + tests/data/javap_14_class_expected_diff


Changes:

=====================================
tests/comparators/test_dex.py
=====================================
@@ -25,7 +25,11 @@ from diffoscope.comparators.dex import DexFile
 from diffoscope.comparators.missing_file import MissingFile
 
 from ..utils.data import load_fixture, get_data
-from ..utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
+from ..utils.tools import (
+    skip_unless_tools_exist,
+    skip_unless_tool_is_at_least,
+    skip_unless_tool_is_between,
+)
 
 from .test_java import javap_version
 
@@ -63,10 +67,7 @@ def differences(dex1, dex2):
     return dex1.compare(dex2).details
 
 
- at skip_unless_tools_exist("enjarify", "zipinfo", "javap")
- at skip_unless_tool_is_at_least("javap", javap_version, "9.0.4")
- at skip_unless_tool_is_at_least("enjarify", enjarify_version, "1.0.3")
-def test_differences(differences):
+def check_dex_differences(differences, expected_diff):
     assert differences[0].source1 == "test1.jar"
     assert differences[0].source2 == "test2.jar"
     zipinfo = differences[0].details[0]
@@ -75,11 +76,26 @@ def test_differences(differences):
     assert zipinfo.source2 == "zipinfo -v {}"
     assert classdiff.source1 == "com/example/MainActivity.class"
     assert classdiff.source2 == "com/example/MainActivity.class"
-    expected_diff = get_data("dex_expected_diffs")
     found_diff = zipinfo.unified_diff + classdiff.details[0].unified_diff
     assert expected_diff == found_diff
 
 
+ at skip_unless_tools_exist("enjarify", "zipinfo", "javap")
+ at skip_unless_tool_is_between("javap", javap_version, "9.0.4", "14.0")
+ at skip_unless_tool_is_at_least("enjarify", enjarify_version, "1.0.3")
+def test_differences(differences):
+    expected_diff = get_data("dex_expected_diffs")
+    check_dex_differences(differences, expected_diff)
+
+
+ at skip_unless_tools_exist("enjarify", "zipinfo", "javap")
+ at skip_unless_tool_is_at_least("javap", javap_version, "14.0")
+ at skip_unless_tool_is_at_least("enjarify", enjarify_version, "1.0.3")
+def test_javap_14_differences(differences):
+    expected_diff = get_data("dex_javap_14_expected_diffs")
+    check_dex_differences(differences, expected_diff)
+
+
 @skip_unless_tools_exist("enjarify", "zipinfo", "javap")
 def test_compare_non_existing(monkeypatch, dex1):
     monkeypatch.setattr(Config(), "new_file", True)


=====================================
tests/comparators/test_java.py
=====================================
@@ -25,7 +25,11 @@ from diffoscope.comparators.java import ClassFile, ProcyonDecompiler, Javap
 from diffoscope.comparators.missing_file import MissingFile
 
 from ..utils.data import load_fixture, get_data
-from ..utils.tools import skip_unless_tools_exist, skip_unless_tool_is_at_least
+from ..utils.tools import (
+    skip_unless_tools_exist,
+    skip_unless_tool_is_at_least,
+    skip_unless_tool_is_between,
+)
 
 
 class1 = load_fixture("Test1.class")
@@ -79,7 +83,7 @@ def test_diff_procyon(differences_procyon):
     diff(differences_procyon, "procyon_class_expected_diff")
 
 
- at skip_unless_tool_is_at_least("javap", javap_version, "9.0.4")
+ at skip_unless_tool_is_between("javap", javap_version, "9.0.4", "14.0")
 def test_diff_javap(differences_javap):
     """
     Java tests are kept up to date relative to the JDK version bundled in
@@ -90,6 +94,11 @@ def test_diff_javap(differences_javap):
     diff(differences_javap, "javap_class_expected_diff")
 
 
+ at skip_unless_tool_is_at_least("javap", javap_version, "14.0")
+def test_diff_javap_14(differences_javap):
+    diff(differences_javap, "javap_14_class_expected_diff")
+
+
 @skip_unless_tools_exist("procyon")
 def test_compare_non_existing_procyon(monkeypatch, class1):
     compare_non_existing(monkeypatch, class1, ProcyonDecompiler)


=====================================
tests/data/dex_javap_14_expected_diffs
=====================================
@@ -0,0 +1,46 @@
+@@ -54,15 +54,15 @@
+   version of encoding software:                   2.0
+   minimum file system compatibility required:     MS-DOS, OS/2 or NT FAT
+   minimum software version required to extract:   2.0
+   compression method:                             none (stored)
+   file security status:                           not encrypted
+   extended local header:                          no
+   file last modified on (DOS date/time):          1980 Jan 1 00:00:00
+-  32-bit CRC value (hex):                         bc28236e
++  32-bit CRC value (hex):                         59c3af78
+   compressed size:                                305 bytes
+   uncompressed size:                              305 bytes
+   length of filename:                             30 characters
+   length of extra field:                          0 bytes
+   length of file comment:                         0 characters
+   disk number on which file begins:               disk 1
+   apparent file type:                             binary
+@@ -1,8 +1,8 @@
+-  SHA-256 checksum ca6bb78f123647bf5fe7d869a959a63d0ef869fb1044e4271bb61b61fe30a69e
++  SHA-256 checksum eeb197e12d3a700cdaad1ba86cd87b18c1e83106749ce96facc5adefbf501a44
+ public class com.example.MainActivity extends android.app.Activity
+   minor version: 0
+   major version: 49
+   flags: (0x0021) ACC_PUBLIC, ACC_SUPER
+   this_class: #2                          // com/example/MainActivity
+   super_class: #4                         // android/app/Activity
+   interfaces: 0, fields: 0, methods: 2, attributes: 0
+@@ -21,16 +21,16 @@
+   #12 = Methodref          #4.#11         // android/app/Activity.onCreate:(Landroid/os/Bundle;)V
+   #13 = Integer            2130903040
+   #14 = Float              1.7412887E38f
+   #15 = Utf8               setContentView
+   #16 = Utf8               (I)V
+   #17 = NameAndType        #15:#16        // setContentView:(I)V
+   #18 = Methodref          #2.#17         // com/example/MainActivity.setContentView:(I)V
+-  #19 = Utf8               Sat Nov 21 14:20:33 CET 2015
+-  #20 = String             #19            // Sat Nov 21 14:20:33 CET 2015
++  #19 = Utf8               Thu Mar 17 11:54:42 CET 2016
++  #20 = String             #19            // Thu Mar 17 11:54:42 CET 2016
+   #21 = Utf8               Code
+ {
+   public com.example.MainActivity();
+     descriptor: ()V
+     flags: (0x0001) ACC_PUBLIC
+     Code:
+       stack=300, locals=1, args_size=1


=====================================
tests/data/javap_14_class_expected_diff
=====================================
@@ -0,0 +1,26 @@
+@@ -1,8 +1,8 @@
+-  SHA-256 checksum 1320bc60b3c655240463c7e8be150ddcacdd52c22bc618527198d9185f74fa37
++  SHA-256 checksum 5b5ebbd1e4ffb6d650a3e8789564f45b0e6f6f70abf147a0f38dec7e8acb1d33
+   Compiled from "Test.java"
+ class Test
+   minor version: 0
+   major version: 50
+   flags: (0x0020) ACC_SUPER
+   this_class: #2                          // Test
+   super_class: #3                         // java/lang/Object
+@@ -35,13 +35,13 @@
+         line 1: 0
+ 
+   public static int main(java.lang.String[]);
+     descriptor: ([Ljava/lang/String;)I
+     flags: (0x0009) ACC_PUBLIC, ACC_STATIC
+     Code:
+       stack=1, locals=1, args_size=1
+-         0: bipush        42
+-         2: ireturn
++         0: iconst_m1
++         1: ireturn
+       LineNumberTable:
+         line 3: 0
+ }
+ SourceFile: "Test.java"



View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/e30e18e922a1a6f74754ee6c23075b2bc7c139ab...06cb774f565e95d1c36f0d396aa28bc08e7e2d00

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/diffoscope/-/compare/e30e18e922a1a6f74754ee6c23075b2bc7c139ab...06cb774f565e95d1c36f0d396aa28bc08e7e2d00
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20201209/ae05cd79/attachment.htm>


More information about the rb-commits mailing list