2009-05-15 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Fri, 15 May 2009 21:35:12 +0000 (21:35 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Fri, 15 May 2009 21:35:12 +0000 (21:35 -0000)
* cli-tables-tests.md: Add tests for the exported type table.

* assembly-with-module.il: Old file not longer needed.

* assembly-with-module.cs: File use to generate
tests for the exported table.

* module.il: Same. This file is written in MSIL because
gmcs/SRE can't handle the AssemblyAttributesGoHere hack.

* Makefile: Adjust the build to the new files.

svn path=/trunk/mono/; revision=134253

mono/tests/metadata-verifier/Changelog
mono/tests/metadata-verifier/Makefile
mono/tests/metadata-verifier/assembly-with-module.cs [new file with mode: 0644]
mono/tests/metadata-verifier/assembly-with-module.il [deleted file]
mono/tests/metadata-verifier/cli-tables-tests.md
mono/tests/metadata-verifier/module.il [new file with mode: 0755]

index e1ee1aaf9ba6e4f1c12a5288bda29b71a0a4fbcb..c8648e8d536e3f18142f6becd70569246857ffd5 100644 (file)
@@ -1,3 +1,17 @@
+2009-05-15 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * cli-tables-tests.md: Add tests for the exported type table.
+
+       * assembly-with-module.il: Old file not longer needed.
+
+       * assembly-with-module.cs: File use to generate
+       tests for the exported table.
+
+       * module.il: Same. This file is written in MSIL because
+       gmcs/SRE can't handle the AssemblyAttributesGoHere hack.
+
+       * Makefile: Adjust the build to the new files.
+
 2009-05-15 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * cli-tables-tests.md: Add tests for the file table.
index ee0be6074568af8d1b9517557a2716fc3b35e10a..6ff3863e88fd537a68299dcaf1aa4abc7d8b6e5c 100644 (file)
@@ -31,6 +31,12 @@ assembly-with-events.exe: assembly-with-events.cs
 assembly-with-properties.exe: assembly-with-properties.cs
        gmcs assembly-with-properties.cs
 
+module.netmodule: module.il
+       ilasm2 /dll /output:module.netmodule module.il
+
+assembly-with-module.exe: assembly-with-module.cs module.netmodule
+       gmcs assembly-with-module.cs -addmodule:module.netmodule
+
 TEST_BINARIES = assembly-with-resource.exe \
        assembly-with-complex-type.exe \
        assembly-with-methods.exe \
diff --git a/mono/tests/metadata-verifier/assembly-with-module.cs b/mono/tests/metadata-verifier/assembly-with-module.cs
new file mode 100644 (file)
index 0000000..d71ab33
--- /dev/null
@@ -0,0 +1,12 @@
+using System;
+using System.Reflection.Emit;
+using System.Runtime.CompilerServices;
+
+[assembly:TypeForwardedTo(typeof(AssemblyBuilder))]
+
+class Driver {
+       public static void Main (){
+               Console.WriteLine (typeof (Module.Exported));
+               Console.WriteLine (new Module.Exported.NestedClass ());
+       }
+}
diff --git a/mono/tests/metadata-verifier/assembly-with-module.il b/mono/tests/metadata-verifier/assembly-with-module.il
deleted file mode 100644 (file)
index d4084e7..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-.assembly extern mscorlib
-{
-  .ver 2:0:0:0
-  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
-}
-
-.assembly 'assembly_with_module'
-{
-  .hash algorithm 0x00008004
-  .ver  0:0:0:0
-}
-
-.module assembly_with_module.exe
-.module extern 'simple-assembly.exe'
-
-.method public static void Main () cil managed 
-{
-       .entrypoint
-       .maxstack 8
-       ret 
-}
-
index 6e438ca72ca7fda94fb4d90d15640ea5e9ab8543..345c69371143865f1da8145502da70940f042db9 100644 (file)
@@ -122,9 +122,9 @@ typedef-table {
 
        #This part of the test suite only verifies structural properties, not table relationships       
 
-       #Flags invalid bits: 9,11,14,15,19,21,24-31
+       #Flags invalid bits: 6,9,14,15,19,21,24-31
+       invalid offset table-row ( 2 1 ) set-bit 6
        invalid offset table-row ( 2 1 ) set-bit 9
-       invalid offset table-row ( 2 1 ) set-bit 11
        invalid offset table-row ( 2 1 ) set-bit 14
        invalid offset table-row ( 2 1 ) set-bit 15
        invalid offset table-row ( 2 1 ) set-bit 19
@@ -1069,3 +1069,52 @@ file-table {
        #TODO check for dups based on name
        #TODO check for images with rows in file and assembly tables
 }
+
+exported-type-table {
+       assembly assembly-with-module.exe
+
+       #flags is valid (it's a TypeAttribute flag set) (3)
+       #Flags invalid bits: 6,9,14,15,19,21,24-31
+       invalid offset table-row (0x27 0) set-bit 6 #this is a mysterious bit on MS
+       invalid offset table-row (0x27 0) set-bit 9
+       invalid offset table-row (0x27 0) set-bit 14
+       invalid offset table-row (0x27 0) set-bit 15
+       invalid offset table-row (0x27 0) set-bit 19
+       valid offset table-row (0x27 0) set-bit 21 #this is the non specified FORWARDER bit
+       invalid offset table-row (0x27 0) set-bit 24
+       invalid offset table-row (0x27 0) set-bit 25
+       invalid offset table-row (0x27 0) set-bit 26
+       invalid offset table-row (0x27 0) set-bit 27
+       invalid offset table-row (0x27 0) set-bit 28
+       invalid offset table-row (0x27 0) set-bit 29
+       invalid offset table-row (0x27 0) set-bit 30
+       invalid offset table-row (0x27 0) set-bit 31
+
+       #type 0 is toplevel
+       #type 1 is nested
+       #if Implementation points to file table visibility must be public (4)
+       #invalid offset table-row (0x27 0) set-uint 0x100005 #LAMEIMPL/SPEC this check is not really relevant
+
+       #if Implementation points to exported type table visibility must be nested public (5)
+       #invalid offset table-row (0x27 1) set-uint 0x100005 #LAMEIMPL/SPEC this check is not really relevant
+       
+       #typename is a valid non-empty string (7)
+       invalid offset table-row (0x27 0) + 8 set-ushort 0
+       invalid offset table-row (0x27 0) + 8 set-ushort 0x9900
+       
+       #typenamedpace is a valid string (8,9)
+       invalid offset table-row (0x27 0) + 10 set-ushort 0x9900
+
+       #nested types must have an empty typenamespace (11)
+       valid offset table-row (0x27 1) + 10 set-ushort 0
+       invalid offset table-row (0x27 1) + 10 set-ushort 1 #LAMEIMPL ms doesn't check this.
+
+       #12 implementation is a valid non empty token (12)
+       invalid offset table-row (0x27 0) + 12 set-ushort 0
+       invalid offset table-row (0x27 0) + 12 set-ushort 0x8880
+
+       #TODO check if a type in the exported table is not defined in the current module (2)
+       #TODO check if target type is valid and public (6)
+       #TODO check for dups (14,15,16)
+}
+
diff --git a/mono/tests/metadata-verifier/module.il b/mono/tests/metadata-verifier/module.il
new file mode 100755 (executable)
index 0000000..23ab419
--- /dev/null
@@ -0,0 +1,70 @@
+\r
+//  Microsoft (R) .NET Framework IL Disassembler.  Version 3.5.21022.8\r
+//  Copyright (c) Microsoft Corporation.  All rights reserved.\r
+\r
+\r
+\r
+// Metadata version: v2.0.50727\r
+.assembly extern mscorlib\r
+{\r
+  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..\r
+  .ver 2:0:0:0\r
+}\r
+.module module.netmodule\r
+// MVID: {6EC23D5F-E5C7-4DA2-9E39-4E18B7D0CB11}\r
+.imagebase 0x00400000\r
+.file alignment 0x00000200\r
+.stackreserve 0x00100000\r
+.subsystem 0x0003       // WINDOWS_CUI\r
+.corflags 0x00000001    //  ILONLY\r
+// Image base: 0x00E90000\r
+\r
+\r
+// =============== CLASS MEMBERS DECLARATION ===================\r
+\r
+.class public auto ansi beforefieldinit Module.Exported\r
+       extends [mscorlib]System.Object\r
+{\r
+  .class auto ansi nested public beforefieldinit NestedClass\r
+         extends [mscorlib]System.Object\r
+  {\r
+    .method public hidebysig virtual instance string \r
+            ToString() cil managed\r
+    {\r
+      // Code size       11 (0xb)\r
+      .maxstack  1\r
+      .locals init (string V_0)\r
+      IL_0000:  nop\r
+      IL_0001:  ldstr      "test"\r
+      IL_0006:  stloc.0\r
+      IL_0007:  br.s       IL_0009\r
+\r
+      IL_0009:  ldloc.0\r
+      IL_000a:  ret\r
+    } // end of method NestedClass::ToString\r
+\r
+    .method public hidebysig specialname rtspecialname \r
+            instance void  .ctor() cil managed\r
+    {\r
+      // Code size       7 (0x7)\r
+      .maxstack  8\r
+      IL_0000:  ldarg.0\r
+      IL_0001:  call       instance void [mscorlib]System.Object::.ctor()\r
+      IL_0006:  ret\r
+    } // end of method NestedClass::.ctor\r
+\r
+  } // end of class NestedClass\r
+\r
+  .method public hidebysig specialname rtspecialname \r
+          instance void  .ctor() cil managed\r
+  {\r
+    // Code size       7 (0x7)\r
+    .maxstack  8\r
+    IL_0000:  ldarg.0\r
+    IL_0001:  call       instance void [mscorlib]System.Object::.ctor()\r
+    IL_0006:  ret\r
+  } // end of method Exported::.ctor\r
+\r
+} // end of class Module.Exported\r
+\r
+