Author: kumpera
Date: 2007-12-31 15:43:43 -0500 (Mon, 31 Dec 2007)
New Revision: 92074
Added:
trunk/mono/mono/tests/verifier/invalid_ldftn_invalid_token_out_of_bounds.il
trunk/mono/mono/tests/verifier/invalid_ldftn_invalid_token_type.il
trunk/mono/mono/tests/verifier/make_ldftn_test.sh
Modified:
trunk/mono/mono/tests/verifier/AssemblyRunner.cs
trunk/mono/mono/tests/verifier/ChangeLog
trunk/mono/mono/tests/verifier/make_tests.sh
Log:
2007-12-31 Rodrigo Kumpera <[EMAIL PROTECTED]>
* invalid_ldftn_invalid_token_out_of_bounds.il: added.
* invalid_ldftn_invalid_token_type.il: added.
* make_ldftn_test.sh: added.
* make_test.sh: new tests for ldftn.
* AssemblyRunner.cs: added BadImageFormatException
to the list of invalid code errors. Removed
some dead code and an useless message.
Modified: trunk/mono/mono/tests/verifier/AssemblyRunner.cs
===================================================================
--- trunk/mono/mono/tests/verifier/AssemblyRunner.cs 2007-12-31 20:20:18 UTC
(rev 92073)
+++ trunk/mono/mono/tests/verifier/AssemblyRunner.cs 2007-12-31 20:43:43 UTC
(rev 92074)
@@ -142,6 +142,8 @@
return RunResult.unverifiable;
} catch (TypeLoadException) {
return RunResult.unverifiable;
+ } catch (BadImageFormatException) {
+ return RunResult.invalid;
} catch (Exception e) {
Console.WriteLine ("Warning: test {0} thrown
exception {1}", assemblyName, e);
return RunResult.valid;
@@ -156,9 +158,18 @@
*/
static RunResult testWithRuntime (String path) {
String stderr = ExecuteAndFetchStderr (path);
- bool invalid = stderr.IndexOf
("InvalidProgramException") >= 0 || stderr.IndexOf ("FileLoadException") >= 0;
+ String[] knownErrors = new String[] {
+ "MissingMethodException",
+ "InvalidProgramException",
+ "FileLoadException",
+ "BadImageFormatException"
+ };
- return invalid ? RunResult.invalid : RunResult.valid;
+ foreach (String str in knownErrors) {
+ if (stderr.IndexOf (str) >= 0)
+ return RunResult.invalid;
+ }
+ return RunResult.valid;
}
/*
@@ -173,7 +184,7 @@
static RunResult decide (RunResult ad, RunResult rt, RunResult
pv, String testName) {
if (ad == RunResult.valid) {
- if (rt != RunResult.valid) {
+ if (rt != RunResult.valid) {
Console.WriteLine ("Warning: test {0}
returned valid under AD but {1} under runtime. PV said {2}, using runtime
choice", testName, rt, pv);
return rt;
}
@@ -189,7 +200,10 @@
Console.WriteLine ("Warning: test {0}
returned unverifiable under AD but {1} under PV, using AD choice", testName,
pv);
if (rt == RunResult.invalid) {
+ /*This warning doesn't help a lot since
there are cases which this happens
Console.WriteLine ("Warning: test {0}
returned unverifiable under AD but {1} under runtime. PV said {2}, using
runtime choice", testName, rt, pv);
+ */
+
return rt;
}
@@ -219,23 +233,9 @@
RunResult veredict = decide (ad, rt, pv, assemblyName);
if (veredict != expected)
- Console.WriteLine ("ERROR: test {0} expected
{1} but got {2}", assemblyName, expected, veredict);
+ Console.WriteLine ("ERROR: test {0} expected
{1} but got {2} AD {3} RT {4} PV {5}", assemblyName, expected, veredict, ad,
rt, pv);
}
- /*
- This method exists because sometimes a VerificationException is
throw for invalid code, so we try to run it as standard-alone a check again.
- */
- static void RecheckUnverifiableResult (String path, String
assembly, String op) {
- String stderr = ExecuteAndFetchStderr (path);
- bool invalid = stderr.IndexOf
("InvalidProgramException") >= 0 || stderr.IndexOf ("FileLoadException") >= 0;
-
- if (invalid) {
- if (!op.Equals ("invalid"))
- Console.WriteLine ("Test returned
invalid: "+assembly);
- }else if (!op.Equals ("unverifiable"))
- Console.WriteLine ("Test returned unverifiable:
"+assembly);
- }
-
public static void Main (String[] args) {
String dirName = ".";
if (args.Length > 0)
Modified: trunk/mono/mono/tests/verifier/ChangeLog
===================================================================
--- trunk/mono/mono/tests/verifier/ChangeLog 2007-12-31 20:20:18 UTC (rev
92073)
+++ trunk/mono/mono/tests/verifier/ChangeLog 2007-12-31 20:43:43 UTC (rev
92074)
@@ -1,3 +1,18 @@
+2007-12-31 Rodrigo Kumpera <[EMAIL PROTECTED]>
+
+ * invalid_ldftn_invalid_token_out_of_bounds.il: added.
+
+ * invalid_ldftn_invalid_token_type.il: added.
+
+ * make_ldftn_test.sh: added.
+
+ * make_test.sh: new tests for ldftn.
+
+ * AssemblyRunner.cs: added BadImageFormatException
+ to the list of invalid code errors. Removed
+ some dead code and an useless message.
+
+
2007-12-27 Rodrigo Kumpera <[EMAIL PROTECTED]>
* invalid_non_empty_stack_at_try_begin.il: added.
Added:
trunk/mono/mono/tests/verifier/invalid_ldftn_invalid_token_out_of_bounds.il
===================================================================
--- trunk/mono/mono/tests/verifier/invalid_ldftn_invalid_token_out_of_bounds.il
2007-12-31 20:20:18 UTC (rev 92073)
+++ trunk/mono/mono/tests/verifier/invalid_ldftn_invalid_token_out_of_bounds.il
2007-12-31 20:43:43 UTC (rev 92074)
@@ -0,0 +1,47 @@
+/*
+This test using a token that overflows the methoddef table
+*/
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
+}
+.assembly 'bla'
+{
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+.module ld_type.exe
+
+.class public auto ansi beforefieldinit Driver
+ extends [mscorlib]System.Object
+{
+ .method public static void Method ()
+ {
+ ret
+ }
+
+ .method public virtual void VirtMethod ()
+ {
+ ret
+ }
+
+ .method public static int32 Main ()
+ {
+ .entrypoint
+ .maxstack 2
+ .locals init (int32 bla)
+ nop
+ .emitbyte 0xFE
+ .emitbyte 0x06
+ .emitbyte 0xAA
+ .emitbyte 0xAA
+ .emitbyte 0x00
+ .emitbyte 0x06
+ pop
+ ret
+
+ }
+}
+
+
Added: trunk/mono/mono/tests/verifier/invalid_ldftn_invalid_token_type.il
===================================================================
--- trunk/mono/mono/tests/verifier/invalid_ldftn_invalid_token_type.il
2007-12-31 20:20:18 UTC (rev 92073)
+++ trunk/mono/mono/tests/verifier/invalid_ldftn_invalid_token_type.il
2007-12-31 20:43:43 UTC (rev 92074)
@@ -0,0 +1,47 @@
+/*
+This test using a token for the typedef table
+*/
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
+}
+.assembly 'bla'
+{
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+.module ld_type.exe
+
+.class public auto ansi beforefieldinit Driver
+ extends [mscorlib]System.Object
+{
+ .method public static void Method ()
+ {
+ ret
+ }
+
+ .method public virtual void VirtMethod ()
+ {
+ ret
+ }
+
+ .method public static int32 Main ()
+ {
+ .entrypoint
+ .maxstack 2
+ .locals init (int32 bla)
+ nop
+ .emitbyte 0xFE
+ .emitbyte 0x06
+ .emitbyte 0x02
+ .emitbyte 0x00
+ .emitbyte 0x00
+ .emitbyte 0x02
+ pop
+ ret
+
+ }
+}
+
+
Added: trunk/mono/mono/tests/verifier/make_ldftn_test.sh
===================================================================
--- trunk/mono/mono/tests/verifier/make_ldftn_test.sh 2007-12-31 20:20:18 UTC
(rev 92073)
+++ trunk/mono/mono/tests/verifier/make_ldftn_test.sh 2007-12-31 20:43:43 UTC
(rev 92074)
@@ -0,0 +1,70 @@
+#! /bin/sh
+
+TEST_NAME=$1
+TEST_VALIDITY=$2
+TEST_LDFTN_OP=$3
+TEST_OP=$4
+
+TEST_FILE=`echo ${TEST_VALIDITY}_${TEST_NAME} | sed -e 's/ /_/g' -e 's/\./_/g'
-e 's/&/mp/g' -e 's/\[/_/g' -e 's/\]/_/g'`_generated.il
+echo $TEST_FILE
+TEST_TYPE1=`echo $TEST_TYPE1 | sed -s 's/&/\\\&/'`
+sed -e "s/OPCODE/${TEST_OP}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -e
"s/LDFTN_OP/${TEST_LDFTN_OP}/g" > $TEST_FILE <<//EOF
+
+.assembly extern mscorlib
+{
+ .ver 2:0:0:0
+ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+}
+.assembly 'ldftn_test'
+{
+ .hash algorithm 0x00008004
+ .ver 0:0:0:0
+}
+.module ldftn_test.exe
+
+.class public Test
+ extends [mscorlib]System.Object
+{
+ .method public void Test ()
+ {
+ ret
+ }
+}
+
+
+.class public Template<T>
+ extends [mscorlib]System.Object
+{
+ .method public void Test ()
+ {
+ ret
+ }
+}
+
+.class public auto ansi beforefieldinit Driver
+ extends [mscorlib]System.Object
+{
+ .method public static void Method ()
+ {
+ ret
+ }
+
+ .method public virtual void VirtMethod ()
+ {
+ ret
+ }
+
+ .method public static int32 Main ()
+ {
+ .entrypoint
+ .maxstack 2
+ .locals init (int32 bla)
+
+ OPCODE // VALIDITY
+ LDFTN_OP
+ pop
+ ldc.i4.0
+ ret
+ }
+}
+//EOF
Property changes on: trunk/mono/mono/tests/verifier/make_ldftn_test.sh
___________________________________________________________________
Name: svn:executable
+ *
Modified: trunk/mono/mono/tests/verifier/make_tests.sh
===================================================================
--- trunk/mono/mono/tests/verifier/make_tests.sh 2007-12-31 20:20:18 UTC
(rev 92073)
+++ trunk/mono/mono/tests/verifier/make_tests.sh 2007-12-31 20:43:43 UTC
(rev 92074)
@@ -3391,3 +3391,15 @@
./make_exception_overlap_test.sh exception_same_try_with_catch_and_fault
invalid ".try TRY_BLOCK_1 to TRY_BLOCK_1_END fault handler FINALLY_BLOCK_1 to
FINALLY_BLOCK_1_END" ".try TRY_BLOCK_1 to TRY_BLOCK_1_END catch
[mscorlib]System.Exception handler CATCH_BLOCK_1 to CATCH_BLOCK_1_END" "no"
"yes"
+
+#ldftn
+./make_ldftn_test.sh ldftn_static_method valid "ldftn void class
Driver::Method()"
+./make_ldftn_test.sh ldftn_virtual_method valid "ldftn void class
Driver::VirtMethod()"
+./make_ldftn_test.sh ldftn_corlib_method valid "ldftn instance string
string::ToUpper()"
+
+#this is encoded as a memberref
+./make_ldftn_test.sh ldftn_bad_function invalid "ldftn void class
Test::NonPresent()"
+
+./make_ldftn_test.sh ldftn_overflow invalid "ldftn void class
Driver::Method()" "ldc.i4.0\n\tldc.i4.0"
+
+
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches