Beispiel #1
0
        public void TestDebugSymlink()
        {
            using (var mtouch = new MTouchTool()) {
                mtouch.CreateTemporaryApp();
                mtouch.Debug  = true;
                mtouch.Linker = LinkerOption.DontLink;
                mtouch.AssertExecute(MTouchAction.BuildSim, "build");

                AssertSymlinked(mtouch.AppPath);
            }
        }
Beispiel #2
0
        public void TestGssTv()
        {
            using (var mtouch = new MTouchTool()) {
                mtouch.Profile = Profile.tvOS;
                mtouch.CreateTemporaryApp(code: MonoNativeGss);
                mtouch.Linker = LinkerOption.LinkAll;

                mtouch.AssertExecuteFailure(MTouchAction.BuildSim, "build");
                mtouch.AssertError(5214, "Native linking failed, undefined symbol: _NetSecurityNative_ImportUserName. This symbol was referenced by the managed member X.NetSecurityNative_ImportUserName. Please verify that all the necessary frameworks have been referenced and native libraries linked.");
            }
        }
Beispiel #3
0
        public void TestDeviceLinkOut()
        {
            using (var mtouch = new MTouchTool()) {
                mtouch.CreateTemporaryApp();
                mtouch.Linker = LinkerOption.LinkSdk;
                mtouch.AssertExecute(MTouchAction.BuildDev, "build");

                AssertStaticLinked(mtouch);
                Assert.That(mtouch.NativeSymbolsInExecutable, Does.Not.Contain("_mono_native_initialize"));
                Assert.That(mtouch.NativeSymbolsInExecutable, Does.Not.Contain("_NetSecurityNative_ImportUserName"));
            }
        }
Beispiel #4
0
        public void TestDebugLinkAll()
        {
            using (var mtouch = new MTouchTool()) {
                mtouch.CreateTemporaryApp(code: MonoNativeInitialize);
                mtouch.Debug  = true;
                mtouch.Linker = LinkerOption.LinkAll;
                mtouch.AssertExecute(MTouchAction.BuildSim, "build");

                AssertStaticLinked(mtouch);
                Assert.That(mtouch.NativeSymbolsInExecutable, Does.Contain("_mono_native_initialize"));
                Assert.That(mtouch.NativeSymbolsInExecutable, Does.Not.Contain("_NetSecurityNative_ImportUserName"));
            }
        }
Beispiel #5
0
        public void TestDeviceFrameworkLinkOut()
        {
            using (var mtouch = new MTouchTool()) {
                mtouch.CreateTemporaryApp();
                mtouch.Linker = LinkerOption.LinkAll;
                mtouch.AssemblyBuildTargets.Add("@all=framework");
                mtouch.TargetVer = "10.0";

                mtouch.AssertExecute(MTouchAction.BuildDev, "build");

                var files = Directory.EnumerateFiles(mtouch.AppPath, "libmono-native*", SearchOption.AllDirectories).Select(Path.GetFileName);
                Assert.That(files.Count, Is.EqualTo(0), "No libmono-native* library");
            }
        }
Beispiel #6
0
        public void TestGss()
        {
            using (var mtouch = new MTouchTool()) {
                mtouch.CreateTemporaryApp(code: MonoNativeGss);
                mtouch.Linker = LinkerOption.LinkAll;
                mtouch.AssertExecute(MTouchAction.BuildSim, "build");

                AssertStaticLinked(mtouch);
                var symbols = mtouch.NativeSymbolsInExecutable;
                Assert.That(symbols, Does.Contain("_mono_native_initialize"));
                Assert.That(symbols, Does.Contain("_NetSecurityNative_ImportUserName"));

                var otool_exe = ExecutionHelper.Execute("otool", new [] { "-L", mtouch.NativeExecutablePath }, hide_output: true);
                Assert.That(otool_exe, Does.Contain("/System/Library/Frameworks/GSS.framework/GSS"));
            }
        }
Beispiel #7
0
        public void TestDeviceDylib(Profile profile, string version, string mono_native_dylib)
        {
            using (var mtouch = new MTouchTool()) {
                mtouch.Profile = profile;
                if (profile == Profile.watchOS)
                {
                    mtouch.CreateTemporaryWatchKitExtension(code: MonoNativeWatchInitialize, extraCode: MonoNativeInitialize);
                }
                else
                {
                    mtouch.CreateTemporaryApp(code: MonoNativeInitialize);
                }
                mtouch.Linker = LinkerOption.LinkAll;
                mtouch.AssemblyBuildTargets.Add("@all=dynamiclibrary");
                mtouch.TargetVer = version;

                mtouch.AssertExecute(MTouchAction.BuildDev, "build");

                var files = Directory.EnumerateFiles(mtouch.AppPath, "libmono-native*", SearchOption.AllDirectories).Select(Path.GetFileName);
                Assert.That(files.Count, Is.EqualTo(1), "One single libmono-native* library");
                Assert.That(files.First(), Is.EqualTo(mono_native_dylib));

                var mono_native_path = Path.Combine(mtouch.AppPath, mono_native_dylib);

                var symbols     = MTouch.GetNativeSymbols(mono_native_path);
                var otool_dylib = ExecutionHelper.Execute("otool", new [] { "-L", mono_native_path }, hide_output: true);

                Assert.That(symbols, Does.Contain("_mono_native_initialize"));
                Assert.That(otool_dylib, Does.Contain($"@rpath/{mono_native_dylib}"));
                Assert.That(otool_dylib.Replace(mono_native_path, ""), Does.Not.Contain("/Users/"));

                if (profile == Profile.iOS)
                {
                    Assert.That(symbols, Does.Contain("_NetSecurityNative_ImportUserName"));
                    Assert.That(otool_dylib, Does.Contain("/System/Library/Frameworks/GSS.framework/GSS"));
                }
                else
                {
                    Assert.That(symbols, Does.Not.Contain("_NetSecurityNative_ImportUserName"));
                    Assert.That(otool_dylib, Does.Not.Contain("/System/Library/Frameworks/GSS.framework/GSS"));
                }

                var otool_exe = ExecutionHelper.Execute("otool", new [] { "-L", mtouch.NativeExecutablePath }, hide_output: true);
                Assert.That(otool_exe, Does.Not.Contain("GSS"));
                Assert.That(otool_exe, Does.Contain($"@rpath/{mono_native_dylib}"));
            }
        }
Beispiel #8
0
        void AssertStaticLinked(MTouchTool app)
        {
            var files = Directory.EnumerateFiles(app.AppPath, "libmono-native*", SearchOption.AllDirectories).Select(Path.GetFileName);

            Assert.That(files.Count, Is.EqualTo(0), "No libmono-native* libraries");
        }