[bcl+runtime] Multiple small cleanups to Android.
CFLAGS="$CFLAGS -DPAGE_SIZE=4096 -DS_IWRITE=S_IWUSR"
CXXFLAGS="$CXXFLAGS -DPAGE_SIZE=4096 -DS_IWRITE=S_IWUSR"
- # The configure check can't detect this
- AC_DEFINE(HAVE_LARGE_FILE_SUPPORT, 1, [Have large file support])
-
# to bypass the underscore linker check, can't work when cross-compiling
mono_cv_uscore=yes
mono_cv_clang=no
$(PLATFORM_DEBUG_FLAGS)
FRAMEWORK_VERSION = 2.1
-NO_TEST = yes
# the tuner takes care of the install
NO_INSTALL = yes
-include $(test_makefrag)
+build-test-lib: $(test_lib)
+ @echo Building testing lib
+
endif
$(mobile_common_dirs) \
Mono.CompilerServices.SymbolWriter \
Mono.Btls.Interface \
+ Mono.Posix \
$(pcl_facade_dirs)
monotouch_dirs := \
--- /dev/null
+using System;
+using System.Reflection;
+
+// using Android.Runtime;
+// using Android.Util;
+
+namespace Mono.Unix.Android
+{
+ internal sealed class AndroidUtils
+ {
+ const string TAG = "Mono.Posix";
+
+ delegate void DetectCPUAndArchitecture (out ushort builtForCPU, out ushort runningOnCPU, out bool is64bit);
+
+ readonly static DetectCPUAndArchitecture detectCPUAndArchitecture;
+
+ static AndroidUtils ()
+ {
+ Type androidRuntime = Type.GetType ("Android.Runtime.AndroidEnvironment, Mono.Android", true);
+
+ MethodInfo mi = androidRuntime.GetMethod ("DetectCPUAndArchitecture", BindingFlags.NonPublic | BindingFlags.Static);
+ detectCPUAndArchitecture = (DetectCPUAndArchitecture) Delegate.CreateDelegate (typeof(DetectCPUAndArchitecture), mi);
+ }
+
+ public static bool AreRealTimeSignalsSafe ()
+ {
+ ushort built_for_cpu;
+ ushort running_on_cpu;
+ bool is64bit;
+
+ detectCPUAndArchitecture (out built_for_cpu, out running_on_cpu, out is64bit);
+
+ // CPUArchitecture builtForCPU = Enum.IsDefined (typeof (CPUArchitecture), built_for_cpu) ? (CPUArchitecture)built_for_cpu : CPUArchitecture.Unknown;
+ // CPUArchitecture runningOnCPU = Enum.IsDefined (typeof (CPUArchitecture), running_on_cpu) ? (CPUArchitecture)running_on_cpu : CPUArchitecture.Unknown;
+
+ // Log.Info (TAG, " Built for CPU: {0}", builtForCPU);
+ // Log.Info (TAG, "Running on CPU: {0}", runningOnCPU);
+ // Log.Info (TAG, "64-bit process: {0}", is64bit ? "yes" : "no");
+
+ // For now real-time signals aren't safe at all, alas
+ bool safe = false;
+ // Log.Info (TAG, "Real-time signals are {0}safe on this platform", safe ? String.Empty : "not ");
+
+ return safe;
+ }
+ }
+}
\ No newline at end of file
using System.IO;
using System.Runtime.InteropServices;
using Mono.Unix.Native;
+#if MONODROID
+using Mono.Unix.Android;
+#endif
namespace Mono.Unix.Native {
//
// Non-generated exports
//
-#if !MONODROID
+#if MONODROID
+ [DllImport (LIB, EntryPoint="Mono_Posix_FromRealTimeSignum")]
+ static extern int HelperFromRealTimeSignum (Int32 offset, out Int32 rval);
+
+ static int FromRealTimeSignum (Int32 offset, out Int32 rval)
+ {
+ if (!AndroidUtils.AreRealTimeSignalsSafe ())
+ throw new PlatformNotSupportedException ("Real-time signals are not supported on this Android architecture");
+ return HelperFromRealTimeSignum (offset, out rval);
+ }
+#else
[DllImport (LIB, EntryPoint="Mono_Posix_FromRealTimeSignum")]
private static extern int FromRealTimeSignum (Int32 offset, out Int32 rval);
#endif
--- /dev/null
+#include Mono.Posix.dll.sources
+./Mono.Unix.Android/AndroidUtils.cs
Microsoft.Win32/TimerElapsedEventArgsCas.cs
Microsoft.Win32/UserPreferenceChangedEventArgsCas.cs
Microsoft.Win32/UserPreferenceChangingEventArgsCas.cs
-System.Collections.Concurrent/CollectionStressTestHelper.cs
System.Collections.Specialized/BitVector32Cas.cs
System.Collections.Specialized/CollectionsUtilCas.cs
System.Collections.Specialized/HybridDictionaryCas.cs
}
[Test]
+ [Category ("LargeFileSupport")]
public void Position_Large ()
{
// fails if HAVE_LARGE_FILE_SUPPORT is not enabled in device builds
}
[Test]
+ [Category ("LargeFileSupport")]
public void Seek_Large ()
{
// fails if HAVE_LARGE_FILE_SUPPORT is not enabled in device builds
}
[Test]
- [Category ("AndroidNotWorking")] // locks with offsets bigger than Int32.Max don't work on Android
+ [Category ("LargeFileSupport")]
public void Lock_Large ()
{
// note: already worked without HAVE_LARGE_FILE_SUPPORT
}
[Test]
+ [Category ("MobileNotWorking")]
public void DefaultCtor ()
{
Assert.IsNotNull (ab.Evidence, "#1");
}
[Test]
- [Category ("AndroidNotWorking")] // DefineResource doesn't allow path in its fileName parameter and the test attempts to write to / in effect
+ [Category ("MobileNotWorking")] // DefineResource doesn't allow path in its fileName parameter and the test attempts to write to / in effect
public void TestDefineResource ()
{
ab.DefineResource ("foo", "FOO", "foo.txt", ResourceAttributes.Public);
}
[Test]
- [Category ("AndroidNotWorking")] // Missing Mono.Compilerservices.SymbolWriter assembly
public void TestDefineDynamicModule ()
{
ab.DefineDynamicModule ("foo", "foo.dll");
- ab.DefineDynamicModule ("foo2", true);
ab.DefineDynamicModule ("foo3", "foo3.dll");
+ }
+
+ [Category ("MobileNotWorking")] //XA doesn't ship SymbolWriter. https://bugzilla.xamarin.com/show_bug.cgi?id=53038
+ public void TestDefineDynamicModuleWithSymbolWriter ()
+ {
+ ab.DefineDynamicModule ("foo2", true);
ab.DefineDynamicModule ("foo4", "foo4.dll", true);
}
}
[Test]
- [Category ("AndroidNotWorking")] // Missing Mono.CompilerServices.SymbolWriter assembly
public void DefineType_Name_Null ()
{
AssemblyBuilder ab = genAssembly ();
- ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", true);
+ ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", false);
try {
mb.DefineType ((string) null);
Assert.Fail ("#1");
}
[Test]
- [Category ("AndroidNotWorking")] // Missing Mono.CompilerServices.SymbolWriter assembly
public void DefineType_Name_Empty ()
{
AssemblyBuilder ab = genAssembly ();
- ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", true);
+ ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", false);
try {
mb.DefineType (string.Empty);
Assert.Fail ("#1");
}
[Test]
- [Category ("AndroidNotWorking")] // Missing Mono.CompilerServices.SymbolWriter assembly
public void DefineType_Name_NullChar ()
{
AssemblyBuilder ab = genAssembly ();
- ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", true);
+ ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", false);
try {
mb.DefineType ("\0test");
Assert.Fail ("#1");
}
[Test]
- [Category ("AndroidNotWorking")] // Missing Mono.CompilerServices.SymbolWriter assembly
public void DefineType_InterfaceNotAbstract ()
{
AssemblyBuilder ab = genAssembly ();
- ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", true);
+ ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", false);
try {
mb.DefineType ("ITest1", TypeAttributes.Interface);
}
[Test]
- [Category ("AndroidNotWorking")] // Missing Mono.CompilerServices.SymbolWriter assembly
public void DefineType_Parent_Interface ()
{
TypeBuilder tb;
AssemblyBuilder ab = genAssembly ();
- ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", true);
+ ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", false);
tb = mb.DefineType ("Foo", TypeAttributes.Class,
typeof (ICollection));
}
[Test]
- [Category ("AndroidNotWorking")] // Missing Mono.CompilerServices.SymbolWriter assembly
public void DefineType_TypeSize ()
{
AssemblyBuilder ab = genAssembly ();
- ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", true);
+ ModuleBuilder mb = ab.DefineDynamicModule ("foo.dll", "foo.dll", false);
TypeBuilder tb = mb.DefineType ("Foo", TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.SequentialLayout,
typeof (ValueType), 1);
}
[Test]
- [Category ("AndroidNotWorking")] // Missing Mono.CompilerServices.SymbolWriter assembly
[ExpectedException (typeof (ArgumentException))]
public void DuplicateTypeName () {
AssemblyBuilder ab = genAssembly ();
- ModuleBuilder module = ab.DefineDynamicModule ("foo.dll", "foo.dll", true);
+ ModuleBuilder module = ab.DefineDynamicModule ("foo.dll", "foo.dll", false);
var itb = module.DefineType ("TBase", TypeAttributes.Public);
}
[Test]
- [Category ("AndroidNotWorking")] // Missing Mono.CompilerServices.SymbolWriter assembly
+ [Category ("MobileNotWorking")] // Missing Mono.CompilerServices.SymbolWriter assembly
public void DuplicateSymbolDocument ()
{
AssemblyBuilder ab = genAssembly ();
}
[Test]
- [Category ("AndroidNotWorking")] // Fails with System.MethodAccessException : Method `t17:.ctor ()' is inaccessible from method `t18:.ctor ()'
public void DefineDefaultConstructor_Parent_DefaultCtorInaccessible ()
{
TypeBuilder tb;
try {
Activator.CreateInstance (emitted_type);
Assert.Fail ("#1");
+
+ /* MOBILE special case MethodAccessException on reflection invokes and don't wrap them. */
+#if MOBILE
+ } catch (MethodAccessException mae) {
+ Assert.IsNull (mae.InnerException, "#2");
+ Assert.IsNotNull (mae.Message, "#3");
+ Assert.IsTrue (mae.Message.IndexOf (parent_type.FullName) != -1, "#4:" + mae.Message);
+ Assert.IsTrue (mae.Message.IndexOf (".ctor") != -1, "#4:" + mae.Message);
+ }
+#else
} catch (TargetInvocationException ex) {
Assert.AreEqual (typeof (TargetInvocationException), ex.GetType (), "#2");
Assert.IsNotNull (ex.InnerException, "#3");
Assert.IsTrue (mae.Message.IndexOf (parent_type.FullName) != -1, "#9:" + mae.Message);
Assert.IsTrue (mae.Message.IndexOf (".ctor") != -1, "#10:" + mae.Message);
}
+#endif
}
[Test]
#if !MONOTOUCH && !FULL_AOT_RUNTIME // Reflection.Emit is not supported.
[Test]
- [Category("AndroidNotWorking")] // Missing Mono.CompilerServices.SymbolWriter
public void GetModules_MissingFile ()
{
AssemblyName newName = new AssemblyName ();
AssemblyBuilder ab = Thread.GetDomain().DefineDynamicAssembly (newName, AssemblyBuilderAccess.RunAndSave, TempFolder);
- ModuleBuilder mb = ab.DefineDynamicModule ("myDynamicModule1", "myDynamicModule.dll", true);
+ ModuleBuilder mb = ab.DefineDynamicModule ("myDynamicModule1", "myDynamicModule.dll", false);
ab.Save ("test_assembly.dll");
// with the semantics of aot'ed assembly loading, as
// aot may assert when loading. This assumes that it's
// safe to greedly load everything.
-#if FULL_AOT_DESKTOP
- string [] names = { "testing_aot_full_corlib_test", "winaot_corlib_test" };
-#else
- string [] names = { "corlib_test_net_1_1", "corlib_test_net_2_0", "corlib_test_net_4_0", "corlib_test_net_4_5", "net_4_x_corlib_test", "corlib_plattest", "mscorlibtests", "BclTests" };
-#endif
+ var names = new string[] { Assembly.GetCallingAssembly ().GetName ().Name };
foreach (string s in names)
if (Assembly.LoadWithPartialName (s) != null)
}
[Test]
- [Category ("AndroidNotWorking")] // Assemblies in Xamarin.Android cannot be directly as files
+ [Category ("AndroidNotWorking")] // Xamarin.Android assemblies are bundled so they don't exist in the file system.
public void ReflectionOnlyLoadFrom ()
{
string loc = typeof (AssemblyTest).Assembly.Location;
string filename = Path.GetFileName (loc);
- Assembly assembly = Assembly.ReflectionOnlyLoadFrom (filename);
+ Assembly assembly = Assembly.ReflectionOnlyLoadFrom (loc);
Assert.IsNotNull (assembly);
Assert.IsTrue (assembly.ReflectionOnly);
}
#if !MONOTOUCH && !FULL_AOT_RUNTIME
[Test]
- [Category ("AndroidNotWorking")] // Mono.CompilerServices.SymbolWriter not available for Xamarin.Android
public void GetTypes ()
{
AssemblyName newName = new AssemblyName ();
AssemblyBuilder ab = Thread.GetDomain().DefineDynamicAssembly (newName, AssemblyBuilderAccess.RunAndSave, TempFolder);
- ModuleBuilder mb = ab.DefineDynamicModule ("myDynamicModule1", "myDynamicModule" + ".dll", true);
+ ModuleBuilder mb = ab.DefineDynamicModule ("myDynamicModule1", "myDynamicModule" + ".dll", false);
TypeBuilder tb = mb.DefineType ("Foo", TypeAttributes.Public);
tb.CreateType ();
}
[Test]
+ [Category ("SatelliteAssembliesNotWorking")]
public void TestSatellites ()
{
ResourceManager manager = new ResourceManager("Resources", GetType ().Assembly);
{
string dirname = RuntimeEnvironment.GetRuntimeDirectory ();
Assert.IsNotNull (dirname, "GetRuntimeDirectory");
-#if MONODROID
- Assert.IsTrue (dirname.Length == 0, "directory name empty");
-#else
- Assert.IsTrue (Directory.Exists (dirname), "Exists");
-#endif
+ Assert.IsTrue (dirname.Length == 0 || Directory.Exists (dirname), "Exists");
}
[Test]
protected override void Dispose (bool manual)
{
disposed = true;
-#if !MONODROID
- // Bombs on Android (ObjectDisposedException)
base.Dispose (manual);
-#endif
}
}
[Test]
[ExpectedException (typeof (ObjectDisposedException))]
- [Category ("AndroidNotWorking")] // Because of the FakeSafeHandle.Dispose issue
public void BadDispose2 ()
{
FakeSafeHandle sf = new FakeSafeHandle ();
[Test]
[ExpectedException (typeof (ObjectDisposedException))]
- [Category ("AndroidNotWorking")] // Because of the FakeSafeHandle.Dispose issue
public void BadDispose3 ()
{
FakeSafeHandle sf = new FakeSafeHandle ();
}
[Test]
- [Category ("AndroidNotWorking")] // Because of the FakeSafeHandle.Dispose issue
public void GoodDispose ()
{
int dummyHandle = 0xDEAD;
}
[Test]
- [Category ("AndroidNotWorking")] // Because of the FakeSafeHandle.Dispose issue
public void ReleaseAfterDispose1 ()
{
int dummyHandle = 0xDEAD;
[Test]
[ExpectedException (typeof (ObjectDisposedException))]
- [Category ("AndroidNotWorking")] // Because of the FakeSafeHandle.Dispose issue
public void ReleaseAfterDispose2 ()
{
FakeSafeHandle sf = new FakeSafeHandle (true);
}
[Test]
- [Category ("AndroidNotWorking")] // Not until Dispose runtime crasher in FakeSafeHandle is fixed
public void NoReleaseUnowned ()
{
FakeSafeHandle sf = new FakeSafeHandle (false);
}
[Test]
+ [Category ("MobileNotWorking")]
[ExpectedException (typeof (ArgumentNullException))]
public void GetObject_UrlNull ()
{
var nm = new AssemblyName ("asm");
var ab = AssemblyBuilder.DefineDynamicAssembly (nm,
AssemblyBuilderAccess.Run);
- var mb = ab.DefineDynamicModule("m", true);
+ var mb = ab.DefineDynamicModule("m", false);
var tb = mb.DefineType ("NameSpace,+*&[]\\.Type,+*&[]\\",
TypeAttributes.Class | TypeAttributes.Public);