[tests] Add test for assembly remapping change from 100bd760a46811121b4b47ebba941d4fb...
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Thu, 10 Mar 2016 00:40:21 +0000 (01:40 +0100)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Thu, 10 Mar 2016 15:38:01 +0000 (16:38 +0100)
Testing for the remap message via grep isn't ideal, a better way to verify the assembly
version would be to check asm.GetName().Version, but unfortunately in the test environment
when MONO_PATH is set the assembly loading always fallsback to a simple file name matching
in the directory so we end up with the wrong (v4.0) assembly in that case.

mono/tests/Makefile.am
mono/tests/assembly-load-remap.cs [new file with mode: 0644]

index 3ca680c5d3cb083bb60a6fffe7b4a408db2d2854..7ed3e2813040c578a03440222ff496af4bfdb7e3 100644 (file)
@@ -1,7 +1,7 @@
 SUBDIRS = assemblyresolve gc-descriptors
 
 check-local: assemblyresolve/test/asm.dll testjit test-generic-sharing test-type-load test-cattr-type-load test-reflection-load-with-context test_platform     \
-                test-console-output test-messages test-env-options test-unhandled-exception-2 test-appdomain-unload test-process-stress rm-empty-logs
+                test-console-output test-messages test-env-options test-unhandled-exception-2 test-appdomain-unload test-process-stress test-assembly-load-remap rm-empty-logs
 check-full: test-sgen check-local
 check-parallel: compile-tests check-full
 
@@ -1429,6 +1429,13 @@ PROCESS_STRESS_TESTS=    \
 test-process-stress: $(PROCESS_STRESS_TESTS) test-runner.exe
        $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 600 $(PROCESS_STRESS_TESTS)
 
+EXTRA_DIST += assembly-load-remap.cs
+test-assembly-load-remap: assembly-load-remap.exe
+       MONO_LOG_LEVEL=warning MONO_LOG_MASK=asm $(RUNTIME) assembly-load-remap.exe "2.0.0.0" | grep "remapped to v4.0.0.0"
+       MONO_LOG_LEVEL=warning MONO_LOG_MASK=asm $(RUNTIME) assembly-load-remap.exe "4.0.0.0" | grep "remapped to" && exit 1 || exit 0
+       MONO_LOG_LEVEL=warning MONO_LOG_MASK=asm $(RUNTIME) assembly-load-remap.exe "12.0.0.0" | grep "remapped to" && exit 1 || exit 0
+       MONO_LOG_LEVEL=warning MONO_LOG_MASK=asm $(RUNTIME) assembly-load-remap.exe "14.0.0.0" | grep "remapped to" && exit 1 || exit 0
+
 coreclr-gcstress:
        $(MAKE) -C $(mono_build_root)/acceptance-tests coreclr-gcstress
 
diff --git a/mono/tests/assembly-load-remap.cs b/mono/tests/assembly-load-remap.cs
new file mode 100644 (file)
index 0000000..a206cdc
--- /dev/null
@@ -0,0 +1,18 @@
+using System;
+using System.IO;
+using System.Reflection;
+
+public class Tests
+{
+       public static void Main (string[] args)
+       {
+               if (args.Length != 1)
+                       throw new Exception ("Missing commandline args.");
+
+               string versionLoad = args [0];
+               var asm = Assembly.Load ("Microsoft.Build.Framework, Version=" + versionLoad + ", Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
+
+               if (asm == null)
+                       throw new Exception ("Assembly couldn't be loaded.");
+       }
+}