Merge "Update dx test 003-magic-version to support 52.0"
diff --git a/dx/tests/003-magic-version-access/class-version-52.0.txt b/dx/tests/003-magic-version-access/class-version-52.0.txt
index fe79f5e..4860ec9 100644
--- a/dx/tests/003-magic-version-access/class-version-52.0.txt
+++ b/dx/tests/003-magic-version-access/class-version-52.0.txt
@@ -1,6 +1,5 @@
#
-# classfile with an invalid version, with a higher major version
-# than the highest valid version. 51.0 (0x33.0x00)
+# classfile with the valid version 52.0 (0x34.0x00)
#
cafe babe # magic
diff --git a/dx/tests/003-magic-version-access/class-version-52.1.txt b/dx/tests/003-magic-version-access/class-version-52.1.txt
new file mode 100644
index 0000000..3522879
--- /dev/null
+++ b/dx/tests/003-magic-version-access/class-version-52.1.txt
@@ -0,0 +1,26 @@
+#
+# classfile with an invalid version, with a higher major version
+# than the highest valid version. 52.1 (0x34.0x01)
+#
+
+cafe babe # magic
+0001 # minor_version
+0034 # major_version
+0005 # constant_pool_count
+
+#
+# constant_pool
+#
+01 0005 "Small" # 0001: utf8["Small"]
+01 0010 "java/lang/Object" # 0002: utf8["java/lang/Object"]
+07 0001 # 0003: class[Small]
+07 0002 # 0004: class[java/lang/Object]
+
+ffff # access_flags
+0003 # this_class
+0004 # super_class
+0000 # interfaces_count
+0000 # fields_count
+0000 # methods_count
+
+0000 # attributes_count
diff --git a/dx/tests/003-magic-version-access/class-version-52.65535.txt b/dx/tests/003-magic-version-access/class-version-52.65535.txt
new file mode 100644
index 0000000..0439e5c
--- /dev/null
+++ b/dx/tests/003-magic-version-access/class-version-52.65535.txt
@@ -0,0 +1,26 @@
+#
+# classfile with an invalid version, with a higher major version
+# than the highest valid version. 52.65535 (0x34.0xffff)
+#
+
+cafe babe # magic
+ffff # minor_version
+0034 # major_version
+0005 # constant_pool_count
+
+#
+# constant_pool
+#
+01 0005 "Small" # 0001: utf8["Small"]
+01 0010 "java/lang/Object" # 0002: utf8["java/lang/Object"]
+07 0001 # 0003: class[Small]
+07 0002 # 0004: class[java/lang/Object]
+
+ffff # access_flags
+0003 # this_class
+0004 # super_class
+0000 # interfaces_count
+0000 # fields_count
+0000 # methods_count
+
+0000 # attributes_count
diff --git a/dx/tests/003-magic-version-access/class-version-53.0.txt b/dx/tests/003-magic-version-access/class-version-53.0.txt
new file mode 100644
index 0000000..53c001a
--- /dev/null
+++ b/dx/tests/003-magic-version-access/class-version-53.0.txt
@@ -0,0 +1,26 @@
+#
+# classfile with an invalid version, with a higher major version
+# than the highest valid version. 53.0 (0x35.0x00)
+#
+
+cafe babe # magic
+0000 # minor_version
+0035 # major_version
+0005 # constant_pool_count
+
+#
+# constant_pool
+#
+01 0005 "Small" # 0001: utf8["Small"]
+01 0010 "java/lang/Object" # 0002: utf8["java/lang/Object"]
+07 0001 # 0003: class[Small]
+07 0002 # 0004: class[java/lang/Object]
+
+ffff # access_flags
+0003 # this_class
+0004 # super_class
+0000 # interfaces_count
+0000 # fields_count
+0000 # methods_count
+
+0000 # attributes_count
diff --git a/dx/tests/003-magic-version-access/expected.txt b/dx/tests/003-magic-version-access/expected.txt
index f11b4c0..118af44 100644
--- a/dx/tests/003-magic-version-access/expected.txt
+++ b/dx/tests/003-magic-version-access/expected.txt
@@ -256,33 +256,75 @@
methods_count: 0000
attributes_count: 0000
end classfile
-reading class-version-51.1.txt...
-begin classfile
-magic: cafebabe
-minor_version: 0001
-major_version: 0033
-
-trouble parsing:
-unsupported class file version 51.1
-...while parsing class-version-51.1.txt
reading class-version-51.65535.txt...
begin classfile
magic: cafebabe
minor_version: ffff
major_version: 0033
+constant_pool_count: 0005
-trouble parsing:
-unsupported class file version 51.65535
-...while parsing class-version-51.65535.txt
+constant_pool:
+ 0001: utf8{"Small"}
+ 0002: utf8{"java/lang/Object"}
+ 0003: type{Small}
+ 0004: type{java.lang.Object}
+end constant_pool
+access_flags: public|final|super|interface|abstract|synthetic|annotation|enum|89ce
+this_class: type{Small}
+super_class: type{java.lang.Object}
+interfaces_count: 0000
+fields_count: 0000
+methods_count: 0000
+attributes_count: 0000
+end classfile
reading class-version-52.0.txt...
begin classfile
magic: cafebabe
minor_version: 0000
major_version: 0034
+constant_pool_count: 0005
+
+constant_pool:
+ 0001: utf8{"Small"}
+ 0002: utf8{"java/lang/Object"}
+ 0003: type{Small}
+ 0004: type{java.lang.Object}
+end constant_pool
+access_flags: public|final|super|interface|abstract|synthetic|annotation|enum|89ce
+this_class: type{Small}
+super_class: type{java.lang.Object}
+interfaces_count: 0000
+fields_count: 0000
+methods_count: 0000
+attributes_count: 0000
+end classfile
+reading class-version-52.1.txt...
+begin classfile
+magic: cafebabe
+minor_version: 0001
+major_version: 0034
trouble parsing:
-unsupported class file version 52.0
-...while parsing class-version-52.0.txt
+unsupported class file version 52.1
+...while parsing class-version-52.1.txt
+reading class-version-52.65535.txt...
+begin classfile
+magic: cafebabe
+minor_version: ffff
+major_version: 0034
+
+trouble parsing:
+unsupported class file version 52.65535
+...while parsing class-version-52.65535.txt
+reading class-version-53.0.txt...
+begin classfile
+magic: cafebabe
+minor_version: 0000
+major_version: 0035
+
+trouble parsing:
+unsupported class file version 53.0
+...while parsing class-version-53.0.txt
reading small-class.txt...
begin classfile
magic: cafebabe
diff --git a/dx/tests/003-magic-version-access/run b/dx/tests/003-magic-version-access/run
index 3af6118..05ea7f1 100644
--- a/dx/tests/003-magic-version-access/run
+++ b/dx/tests/003-magic-version-access/run
@@ -19,31 +19,41 @@
# trace, which is unpredictable and doesn't work well with
# expected.txt vs. out.txt comparisons.
+function check_rejected {
+ dx --dump --width=100 --strict $1
+}
+
+function check_accepted {
+ dx --debug --dump --width=100 $1
+}
+
# Bad magic (throws an expection)
-dx --dump --strict class-bad-magic.txt
+check_rejected class-bad-magic.txt
# Too small (throws an exception)
-dx --dump --strict class-version-44.0.txt
-dx --dump --strict class-version-44.65535.txt
+check_rejected class-version-44.0.txt
+check_rejected class-version-44.65535.txt
# Just right
-dx --debug --dump --width=100 class-version-45.0.txt
-dx --debug --dump --width=100 class-version-45.65535.txt
-dx --debug --dump --width=100 class-version-48.0.txt
-dx --debug --dump --width=100 class-version-48.65535.txt
-dx --debug --dump --width=100 class-version-49.0.txt
-dx --debug --dump --width=100 class-version-49.1.txt
-dx --debug --dump --width=100 class-version-49.65535.txt
-dx --debug --dump --width=100 class-version-50.0.txt
-dx --debug --dump --width=100 class-version-50.1.txt
-dx --debug --dump --width=100 class-version-50.65535.txt
-dx --debug --dump --width=100 class-version-51.0.txt
+check_accepted class-version-45.0.txt
+check_accepted class-version-45.65535.txt
+check_accepted class-version-48.0.txt
+check_accepted class-version-48.65535.txt
+check_accepted class-version-49.0.txt
+check_accepted class-version-49.1.txt
+check_accepted class-version-49.65535.txt
+check_accepted class-version-50.0.txt
+check_accepted class-version-50.1.txt
+check_accepted class-version-50.65535.txt
+check_accepted class-version-51.0.txt
+check_accepted class-version-51.65535.txt
+check_accepted class-version-52.0.txt
# Too big (throws an exception)
-dx --dump --strict class-version-51.1.txt
-dx --dump --strict class-version-51.65535.txt
-dx --dump --strict class-version-52.0.txt
+check_rejected class-version-52.1.txt
+check_rejected class-version-52.65535.txt
+check_rejected class-version-53.0.txt
# Show that we can dump the access flags even when they
# don't make any sense.
-dx --debug --dump --width=100 small-class.txt
+check_accepted small-class.txt
diff --git a/dx/tests/run-all-tests b/dx/tests/run-all-tests
index e325061..baf79e5 100755
--- a/dx/tests/run-all-tests
+++ b/dx/tests/run-all-tests
@@ -33,17 +33,7 @@
progdir=`pwd`
prog="${progdir}"/`basename "${prog}"`
-# Tests failing and require attention.
-knownBad=$(cat << 'END_BAD_LIST'
- 100-local-mismatch
- 115-merge
- 119-merge-conflict
-END_BAD_LIST
-)
-
-# Notes
-# 100 test cases seem to be optimized out by jasmin/dx. Exception type has changed.
-
+# Globals for tracking numbers of successes and failures and their names.
passed=0
surprised=0
surprisedNames=""
@@ -51,50 +41,29 @@
ignoredNames=""
failed=0
failedNames=""
-for i in *; do
- if [ -d "$i" -a -r "$i" ]; then
- if [[ "$knownBad" == *"$i"* ]]; then
- expectFail=1
- else
- expectFail=0
- fi
- output=/tmp/$$/$i
- ./run-test --output_dir "$output" "$i"
- if [ $? = 0 ]; then
- if [[ $expectFail = 0 ]]; then
- ((passed++))
- else
- echo "Failing on unexpected success of $i"
- ((surprised++))
- surprisedNames="$surprisedNames $i"
- fi
- else
- if [[ $expectFail = 0 ]]; then
- ((failed++))
- failedNames="$failedNames $i"
- else
- echo "Ignoring expected failure of $i"
- ((ignored++))
- ignoredNames="$ignoredNames $i"
- # Clean up when we expect a test to fail.
- # run-test only does this on success.
- rm -rf "$output"
- fi
- fi
- fi
-done
+# Tests failing and require attention (e.g. 115-merge)
+knownBad="100-local-mismatch 115-merge 119-merge-conflict"
-printf "\n\nTest Results\n"
-printf -- "----------------------------\n"
-printf "Pass: % 3d\n" $passed
-printf "Surprise pass: % 3d\n" $surprised
-printf "Known failures: % 3d\n" $ignored
-printf "Failures: % 3d\n" $failed
-printf -- "----------------------------\n"
-printf "Elapsed time(s): % 3d\n" $SECONDS
+function display_results {
+ printf "\n\nTest Results\n"
+ printf -- "----------------------------\n"
+ printf "Pass: % 3d\n" $passed
+ printf "Surprise pass: % 3d\n" $surprised
+ printf "Known failures: % 3d\n" $ignored
+ printf "Failures: % 3d\n" $failed
+ printf -- "----------------------------\n"
+ printf "Elapsed time(s): % 3d\n" $SECONDS
-function listFiles {
+ list_files "Unexpected successes" "$surprisedNames"
+ list_files "Known failures" "$ignoredNames"
+ list_files "Failures" "$failedNames"
+
+ needingAttention=$((failed + surprised))
+ exit $needingAttention
+}
+
+function list_files {
title=$1
if [[ "$2" = "" ]]; then
names="NONE"
@@ -109,9 +78,47 @@
done
}
-listFiles "Unexpected successes" "$surprisedNames"
-listFiles "Known failures" "$ignoredNames"
-listFiles "Failures" "$failedNames"
+function run_tests {
+ for i in *; do
+ if [ -d "$i" -a -r "$i" ]; then
+ if [[ "$knownBad" == *"$i"* ]]; then
+ expectFail=1
+ else
+ expectFail=0
+ fi
-needingAttention=$((failed + surprised))
-exit $needingAttention
+ output=/tmp/$$/$i
+ ./run-test --output_dir "$output" "$i"
+ if [ $? = 0 ]; then
+ if [[ $expectFail = 0 ]]; then
+ ((passed++))
+ else
+ echo "Failing on unexpected success of $i"
+ ((surprised++))
+ surprisedNames="$surprisedNames $i"
+ fi
+ else
+ if [[ $expectFail = 0 ]]; then
+ ((failed++))
+ failedNames="$failedNames $i"
+ else
+ echo "Ignoring expected failure of $i"
+ ((ignored++))
+ ignoredNames="$ignoredNames $i"
+ # Clean up when we expect a test to fail.
+ # run-test only does this on success.
+ rm -rf "$output"
+ fi
+ fi
+ fi
+ done
+}
+
+function handle_interrupt {
+ trap INT
+ display_results
+}
+
+trap handle_interrupt INT
+run_tests
+display_results