You've already forked linux-packaging-mono
Imported Upstream version 4.8.0.309
Former-commit-id: 5f9c6ae75f295e057a7d2971f3a6df4656fa8850
This commit is contained in:
parent
ee1447783b
commit
94b2861243
@@ -15,130 +15,169 @@ namespace Mono.Cecil.Tests {
|
||||
[Test]
|
||||
public void ImageSections ()
|
||||
{
|
||||
var image = GetResourceImage ("hello.exe");
|
||||
|
||||
Assert.AreEqual (3, image.Sections.Length);
|
||||
Assert.AreEqual (".text", image.Sections [0].Name);
|
||||
Assert.AreEqual (".rsrc", image.Sections [1].Name);
|
||||
Assert.AreEqual (".reloc", image.Sections [2].Name);
|
||||
using (var image = GetResourceImage ("hello.exe")) {
|
||||
Assert.AreEqual (3, image.Sections.Length);
|
||||
Assert.AreEqual (".text", image.Sections [0].Name);
|
||||
Assert.AreEqual (".rsrc", image.Sections [1].Name);
|
||||
Assert.AreEqual (".reloc", image.Sections [2].Name);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ImageMetadataVersion ()
|
||||
{
|
||||
var image = GetResourceImage ("hello.exe");
|
||||
Assert.AreEqual (TargetRuntime.Net_2_0, image.Runtime);
|
||||
using (var image = GetResourceImage ("hello.exe"))
|
||||
Assert.AreEqual (TargetRuntime.Net_2_0, image.RuntimeVersion.ParseRuntime ());
|
||||
|
||||
image = GetResourceImage ("hello1.exe");
|
||||
Assert.AreEqual (TargetRuntime.Net_1_1, image.Runtime);
|
||||
using (var image = GetResourceImage ("hello1.exe"))
|
||||
Assert.AreEqual (TargetRuntime.Net_1_1, image.RuntimeVersion.ParseRuntime ());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ImageModuleKind ()
|
||||
{
|
||||
var image = GetResourceImage ("hello.exe");
|
||||
Assert.AreEqual (ModuleKind.Console, image.Kind);
|
||||
using (var image = GetResourceImage ("hello.exe"))
|
||||
Assert.AreEqual (ModuleKind.Console, image.Kind);
|
||||
|
||||
image = GetResourceImage ("libhello.dll");
|
||||
Assert.AreEqual (ModuleKind.Dll, image.Kind);
|
||||
using (var image = GetResourceImage ("libhello.dll"))
|
||||
Assert.AreEqual (ModuleKind.Dll, image.Kind);
|
||||
|
||||
image = GetResourceImage ("hellow.exe");
|
||||
Assert.AreEqual (ModuleKind.Windows, image.Kind);
|
||||
using (var image = GetResourceImage ("hellow.exe"))
|
||||
Assert.AreEqual (ModuleKind.Windows, image.Kind);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MetadataHeaps ()
|
||||
{
|
||||
var image = GetResourceImage ("hello.exe");
|
||||
using (var image = GetResourceImage ("hello.exe")) {
|
||||
Assert.IsNotNull (image.TableHeap);
|
||||
|
||||
Assert.IsNotNull (image.TableHeap);
|
||||
Assert.IsNotNull (image.StringHeap);
|
||||
Assert.AreEqual (string.Empty, image.StringHeap.Read (0));
|
||||
Assert.AreEqual ("<Module>", image.StringHeap.Read (1));
|
||||
|
||||
Assert.IsNotNull (image.StringHeap);
|
||||
Assert.AreEqual (string.Empty, image.StringHeap.Read (0));
|
||||
Assert.AreEqual ("<Module>", image.StringHeap.Read (1));
|
||||
Assert.IsNotNull (image.UserStringHeap);
|
||||
Assert.AreEqual (string.Empty, image.UserStringHeap.Read (0));
|
||||
Assert.AreEqual ("Hello Cecil World !", image.UserStringHeap.Read (1));
|
||||
|
||||
Assert.IsNotNull (image.UserStringHeap);
|
||||
Assert.AreEqual (string.Empty, image.UserStringHeap.Read (0));
|
||||
Assert.AreEqual ("Hello Cecil World !", image.UserStringHeap.Read (1));
|
||||
Assert.IsNotNull (image.GuidHeap);
|
||||
Assert.AreEqual (new Guid (), image.GuidHeap.Read (0));
|
||||
Assert.AreEqual (new Guid ("C3BC2BD3-2576-4D00-A80E-465B5632415F"), image.GuidHeap.Read (1));
|
||||
|
||||
Assert.IsNotNull (image.GuidHeap);
|
||||
Assert.AreEqual (new Guid (), image.GuidHeap.Read (0));
|
||||
Assert.AreEqual (new Guid ("C3BC2BD3-2576-4D00-A80E-465B5632415F"), image.GuidHeap.Read (1));
|
||||
|
||||
Assert.IsNotNull (image.BlobHeap);
|
||||
Assert.AreEqual (new byte [0], image.BlobHeap.Read (0));
|
||||
Assert.IsNotNull (image.BlobHeap);
|
||||
Assert.AreEqual (new byte [0], image.BlobHeap.Read (0));
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TablesHeap ()
|
||||
{
|
||||
var image = GetResourceImage ("hello.exe");
|
||||
var heap = image.TableHeap;
|
||||
using (var image = GetResourceImage ("hello.exe")) {
|
||||
var heap = image.TableHeap;
|
||||
|
||||
Assert.IsNotNull (heap);
|
||||
Assert.IsNotNull (heap);
|
||||
|
||||
Assert.AreEqual (1, heap [Table.Module].Length);
|
||||
Assert.AreEqual (4, heap [Table.TypeRef].Length);
|
||||
Assert.AreEqual (2, heap [Table.TypeDef].Length);
|
||||
Assert.AreEqual (0, heap [Table.Field].Length);
|
||||
Assert.AreEqual (2, heap [Table.Method].Length);
|
||||
Assert.AreEqual (4, heap [Table.MemberRef].Length);
|
||||
Assert.AreEqual (2, heap [Table.CustomAttribute].Length);
|
||||
Assert.AreEqual (1, heap [Table.Assembly].Length);
|
||||
Assert.AreEqual (1, heap [Table.AssemblyRef].Length);
|
||||
Assert.AreEqual (1, heap [Table.Module].Length);
|
||||
Assert.AreEqual (4, heap [Table.TypeRef].Length);
|
||||
Assert.AreEqual (2, heap [Table.TypeDef].Length);
|
||||
Assert.AreEqual (0, heap [Table.Field].Length);
|
||||
Assert.AreEqual (2, heap [Table.Method].Length);
|
||||
Assert.AreEqual (4, heap [Table.MemberRef].Length);
|
||||
Assert.AreEqual (2, heap [Table.CustomAttribute].Length);
|
||||
Assert.AreEqual (1, heap [Table.Assembly].Length);
|
||||
Assert.AreEqual (1, heap [Table.AssemblyRef].Length);
|
||||
}
|
||||
}
|
||||
|
||||
[TestModule ("hello.x64.exe")]
|
||||
public void X64Module (ModuleDefinition module)
|
||||
[Test]
|
||||
public void X64Module ()
|
||||
{
|
||||
Assert.AreEqual (TargetArchitecture.AMD64, module.Image.Architecture);
|
||||
Assert.AreEqual (ModuleAttributes.ILOnly, module.Image.Attributes);
|
||||
TestModule ("hello.x64.exe", module => {
|
||||
Assert.AreEqual (TargetArchitecture.AMD64, module.Image.Architecture);
|
||||
Assert.AreEqual (ModuleAttributes.ILOnly, module.Image.Attributes);
|
||||
}, verify: !Platform.OnMono);
|
||||
}
|
||||
|
||||
[TestModule ("hello.ia64.exe")]
|
||||
public void IA64Module (ModuleDefinition module)
|
||||
[Test]
|
||||
public void X64ModuleTextOnlySection ()
|
||||
{
|
||||
Assert.AreEqual (TargetArchitecture.IA64, module.Image.Architecture);
|
||||
Assert.AreEqual (ModuleAttributes.ILOnly, module.Image.Attributes);
|
||||
TestModule ("hello.textonly.x64.exe", module => {
|
||||
Assert.AreEqual (TargetArchitecture.AMD64, module.Image.Architecture);
|
||||
Assert.AreEqual (ModuleAttributes.ILOnly, module.Image.Attributes);
|
||||
}, verify: !Platform.OnMono);
|
||||
}
|
||||
|
||||
[TestModule ("hello.x86.exe")]
|
||||
public void X86Module (ModuleDefinition module)
|
||||
[Test]
|
||||
public void IA64Module ()
|
||||
{
|
||||
Assert.AreEqual (TargetArchitecture.I386, module.Image.Architecture);
|
||||
Assert.AreEqual (ModuleAttributes.ILOnly | ModuleAttributes.Required32Bit, module.Image.Attributes);
|
||||
TestModule ("hello.ia64.exe", module => {
|
||||
Assert.AreEqual (TargetArchitecture.IA64, module.Image.Architecture);
|
||||
Assert.AreEqual (ModuleAttributes.ILOnly, module.Image.Attributes);
|
||||
}, verify: !Platform.OnMono);
|
||||
}
|
||||
|
||||
[TestModule ("hello.anycpu.exe")]
|
||||
public void AnyCpuModule (ModuleDefinition module)
|
||||
[Test]
|
||||
public void X86Module ()
|
||||
{
|
||||
Assert.AreEqual (TargetArchitecture.I386, module.Image.Architecture);
|
||||
Assert.AreEqual (ModuleAttributes.ILOnly, module.Image.Attributes);
|
||||
TestModule ("hello.x86.exe", module => {
|
||||
Assert.AreEqual (TargetArchitecture.I386, module.Image.Architecture);
|
||||
Assert.AreEqual (ModuleAttributes.ILOnly | ModuleAttributes.Required32Bit, module.Image.Attributes);
|
||||
});
|
||||
}
|
||||
|
||||
[TestModule ("delay-signed.dll")]
|
||||
public void DelaySignedAssembly (ModuleDefinition module)
|
||||
[Test]
|
||||
public void AnyCpuModule ()
|
||||
{
|
||||
Assert.IsNotNull (module.Assembly.Name.PublicKey);
|
||||
Assert.AreNotEqual (0, module.Assembly.Name.PublicKey.Length);
|
||||
Assert.AreNotEqual (ModuleAttributes.StrongNameSigned, module.Attributes & ModuleAttributes.StrongNameSigned);
|
||||
Assert.AreNotEqual (0, module.Image.StrongName.VirtualAddress);
|
||||
Assert.AreNotEqual (0, module.Image.StrongName.Size);
|
||||
TestModule ("hello.anycpu.exe", module => {
|
||||
Assert.AreEqual (TargetArchitecture.I386, module.Image.Architecture);
|
||||
Assert.AreEqual (ModuleAttributes.ILOnly, module.Image.Attributes);
|
||||
});
|
||||
}
|
||||
|
||||
[TestModule ("wp7.dll", Verify = false)]
|
||||
public void WindowsPhoneNonSignedAssembly (ModuleDefinition module)
|
||||
[Test]
|
||||
public void DelaySignedAssembly ()
|
||||
{
|
||||
Assert.AreEqual (0, module.Assembly.Name.PublicKey.Length);
|
||||
Assert.AreNotEqual (ModuleAttributes.StrongNameSigned, module.Attributes & ModuleAttributes.StrongNameSigned);
|
||||
Assert.AreEqual (0, module.Image.StrongName.VirtualAddress);
|
||||
Assert.AreEqual (0, module.Image.StrongName.Size);
|
||||
TestModule ("delay-signed.dll", module => {
|
||||
Assert.IsNotNull (module.Assembly.Name.PublicKey);
|
||||
Assert.AreNotEqual (0, module.Assembly.Name.PublicKey.Length);
|
||||
Assert.AreNotEqual (ModuleAttributes.StrongNameSigned, module.Attributes & ModuleAttributes.StrongNameSigned);
|
||||
Assert.AreNotEqual (0, module.Image.StrongName.VirtualAddress);
|
||||
Assert.AreNotEqual (0, module.Image.StrongName.Size);
|
||||
});
|
||||
}
|
||||
|
||||
[TestModule ("metro.exe", Verify = false)]
|
||||
public void MetroAssembly (ModuleDefinition module)
|
||||
[Test]
|
||||
public void WindowsPhoneNonSignedAssembly ()
|
||||
{
|
||||
Assert.AreEqual (ModuleCharacteristics.AppContainer, module.Characteristics & ModuleCharacteristics.AppContainer);
|
||||
TestModule ("wp7.dll", module => {
|
||||
Assert.AreEqual (0, module.Assembly.Name.PublicKey.Length);
|
||||
Assert.AreNotEqual (ModuleAttributes.StrongNameSigned, module.Attributes & ModuleAttributes.StrongNameSigned);
|
||||
Assert.AreEqual (0, module.Image.StrongName.VirtualAddress);
|
||||
Assert.AreEqual (0, module.Image.StrongName.Size);
|
||||
}, verify: false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MetroAssembly ()
|
||||
{
|
||||
if (Platform.OnMono)
|
||||
return;
|
||||
|
||||
TestModule ("metro.exe", module => {
|
||||
Assert.AreEqual (ModuleCharacteristics.AppContainer, module.Characteristics & ModuleCharacteristics.AppContainer);
|
||||
}, verify: false);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WindowsRuntimeComponentAssembly ()
|
||||
{
|
||||
var resolver = WindowsRuntimeAssemblyResolver.CreateInstance ();
|
||||
if (resolver == null)
|
||||
return;
|
||||
|
||||
TestModule("winrtcomp.winmd", module => {
|
||||
Assert.IsTrue (module.Assembly.Name.IsWindowsRuntime);
|
||||
}, verify: false, assemblyResolver: resolver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user