xamarin-macios/tests
Rolf Bjarne Kvinge f4b98cdf60 [tests][mtouch] Add support for reading binary plists. (#2849)
* [tests][mtouch] Add support for reading binary plists.

Some plists in Xcode 9 are now binary plists (instead of just plain xml files
like they were in previous versions of Xcode). This causes trouble for some of
our tests, so make sure we handle binary plists as well.

Fixes these failures:

1. Xamarin.MTouch.MT0091(tvOS,"tvOS") : System.Xml.XmlException : Data at the root level is invalid. Line 1, position 1.
  at System.Xml.XmlTextReaderImpl.Throw (System.Exception e) [0x00027] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
  at System.Xml.XmlTextReaderImpl.Throw (System.String res, System.String arg) [0x00029] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
  at System.Xml.XmlTextReaderImpl.Throw (System.String res) [0x00000] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
  at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace () [0x0012c] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
  at System.Xml.XmlTextReaderImpl.ParseDocumentContent () [0x002d4] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
  at System.Xml.XmlTextReaderImpl.Read () [0x0008c] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
  at System.Xml.XmlLoader.Load (System.Xml.XmlDocument doc, System.Xml.XmlReader reader, System.Boolean preserveWhitespace) [0x000a6] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
  at System.Xml.XmlDocument.Load (System.Xml.XmlReader reader) [0x0002e] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
  at Xamarin.Tests.Configuration.GetPListStringValue (System.String plist, System.String key) [0x00028] in <44c95c7e3d1e488ab633a77d9a794653>:0
  at Xamarin.MTouch.MT0091 (Xamarin.Profile profile, System.String name) [0x000ae] in <44c95c7e3d1e488ab633a77d9a794653>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <400071ddcfe64ed8a3531490bb763536>:0

2. Xamarin.MTouch.MT0091(iOS,"iOS") : System.Xml.XmlException : Data at the root level is invalid. Line 1, position 1.
  at System.Xml.XmlTextReaderImpl.Throw (System.Exception e) [0x00027] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
  at System.Xml.XmlTextReaderImpl.Throw (System.String res, System.String arg) [0x00029] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
  at System.Xml.XmlTextReaderImpl.Throw (System.String res) [0x00000] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
  at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace () [0x0012c] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
  at System.Xml.XmlTextReaderImpl.ParseDocumentContent () [0x002d4] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
  at System.Xml.XmlTextReaderImpl.Read () [0x0008c] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
  at System.Xml.XmlLoader.Load (System.Xml.XmlDocument doc, System.Xml.XmlReader reader, System.Boolean preserveWhitespace) [0x000a6] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
  at System.Xml.XmlDocument.Load (System.Xml.XmlReader reader) [0x0002e] in <03a79101ea6a4b9ba07e4ed2f6d985f5>:0
  at Xamarin.Tests.Configuration.GetPListStringValue (System.String plist, System.String key) [0x00028] in <44c95c7e3d1e488ab633a77d9a794653>:0
  at Xamarin.MTouch.MT0091 (Xamarin.Profile profile, System.String name) [0x000ae] in <44c95c7e3d1e488ab633a77d9a794653>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <400071ddcfe64ed8a3531490bb763536>:0

* [tests] The MSBuild tests now need a reference to StringUtils.
2017-10-06 13:14:57 +02:00
..
BundledResources [tests] Add support for building device tests for 32-bit or 64-bit. 2016-10-11 19:52:36 +02:00
EmbeddedResources [tests] Explicitly state the resource name for resources. 2017-02-10 16:39:38 +01:00
api-shared [registrar] Use metadata tokens instead of strings to find types and methods. (#1085) 2016-11-01 14:34:56 -04:00
apitest Merge xcode9 into d15-4[-xi] (#2710) 2017-09-15 17:53:16 -04:00
bcl-test [Do not merge yet] Update to mono 2017-04 branch (#1960) 2017-05-29 18:39:29 +02:00
bindings-framework-test Merge xcode9 into d15-4[-xi] (#2710) 2017-09-15 17:53:16 -04:00
bindings-test Merge xcode9 into d15-4[-xi] (#2710) 2017-09-15 17:53:16 -04:00
bindings-test2 [tests] Add test for bug #43689. 2017-02-10 14:46:29 +01:00
common [tests][mtouch] Add support for reading binary plists. (#2849) 2017-10-06 13:14:57 +02:00
dontlink-mac [tests] Don't create test packages by default. (#1941) 2017-03-30 18:01:15 +02:00
framework-test [tests] Fix framework-test to actually work. (#1297) 2016-12-05 18:35:53 +01:00
fsharp [test][fsharp] Add F# test for bug 52866 (#1892) 2017-03-22 07:47:57 -05:00
fsharplibrary [tests] Add support for building device tests for 32-bit or 64-bit. 2016-10-11 19:52:36 +02:00
generator Merge xcode9 into d15-4[-xi] (#2710) 2017-09-15 17:53:16 -04:00
interdependent-binding-projects [tests] Change ProjectGuid of a few projects to make sure they're unique. (#1943) 2017-03-30 14:33:26 +02:00
introspection [ModelIO] Adds Xcode 9 Beta 1 to Stable API bindings (#2832) 2017-10-05 20:32:25 +02:00
linker-ios Merge xcode9 into d15-4[-xi] (#2710) 2017-09-15 17:53:16 -04:00
mac-api-sharpie [tests] Make mdtool verbose on CI, and fix a few xbuild invocation to honor XBUILD_VERBOSITY. (#131) 2016-06-06 13:01:24 +02:00
mac-binding-project Framework tests were still binding non-linked Simple class which errors now (#2216) 2017-06-14 08:33:18 -05:00
mini [tests] Add support for building device tests for 32-bit or 64-bit. 2016-10-11 19:52:36 +02:00
misc [tests] Import 2016-05-26 15:06:52 +02:00
mmptest Merge xcode9 into d15-4[-xi] (#2710) 2017-09-15 17:53:16 -04:00
monotouch-test [ModelIO] Adds Xcode 9 Beta 1 to Stable API bindings (#2832) 2017-10-05 20:32:25 +02:00
msbuild-mac [macos] Mmp should quote paths when passing arguments to clang. Fixes #56850 (#2140) 2017-06-15 11:15:59 +02:00
mtouch Merge xcode9 into d15-4[-xi] (#2710) 2017-09-15 17:53:16 -04:00
no-mmp [tests] Import 2016-05-26 15:06:52 +02:00
qa-regression [tests] Import 2016-05-26 15:06:52 +02:00
scripted Merge xcode9 into d15-4[-xi] (#2710) 2017-09-15 17:53:16 -04:00
scriptingbridge [tests] Import 2016-05-26 15:06:52 +02:00
templates Merge xcode9 into d15-4[-xi] (#2710) 2017-09-15 17:53:16 -04:00
test-libraries Merge xcode9 into d15-4[-xi] (#2710) 2017-09-15 17:53:16 -04:00
xammac_tests Merge xcode9 into d15-4[-xi] (#2710) 2017-09-15 17:53:16 -04:00
xharness Merge xcode9 into d15-4[-xi] (#2710) 2017-09-15 17:53:16 -04:00
xtro-sharpie [CoreGraphics] Implement CoreGraphics bindings for Xcode 9. (#2812) 2017-10-02 12:02:41 +02:00
.gitignore [tests] Convert mmp tests to a standard NUnit test library. (#2067) 2017-05-08 13:20:01 +02:00
HtmlTransform.xslt [tests] Move HtmlTransform.xslt here from maccore. (#16) 2016-04-28 15:07:26 -04:00
Makefile [tests] Clean up after tests on wrench to minimize the peak diskspace requirements. (#2047) 2017-04-27 14:30:04 +02:00
README.md [tests] Update README. (#1207) 2016-11-17 14:18:39 +01:00
common.mk [tests] Import 2016-05-26 15:06:52 +02:00
package-mac-tests.sh [tests] Add scripts to install system dependencies to the XM tests package. (#847) 2016-09-19 10:02:10 -04:00
test-dependencies.sh [system-dependencies] Add logic to auto-provision cmake. (#940) 2016-10-04 10:28:41 +02:00
tests-mac.sln Merge xcode9 into d15-4[-xi] (#2710) 2017-09-15 17:53:16 -04:00
tests.sln [tests] Add support for building device tests for 32-bit or 64-bit. 2016-10-11 19:52:36 +02:00

README.md

Various tests to be executed prior to releases

Test solutions

Many of the test solutions and test projects are generated, and will only be available after running make once.

  • tests.sln: This is the base test solution for Xamarin.iOS, which targets iOS using the Unified API. Not generated.
  • tests-tvos.sln: All the TVOS test projects. Generated.
  • tests-watchos.sln: All the WatchOS test projects. Generated.
  • tests-mac.sln: This is the base test solution for Xamairn.Mac. Not generated.

Test solution/project generation

The tool that generates the test solutions / projects is called xharness, and lives in the xharness subdirectory.

Types of Tests

Unit Tests

Most of the projects are using NUnit[Lite] and looks like unit tests. They are meant to be executed on the target: simulator, devices, OSX.

In reality most of them are regression tests - but that does not change the need to execute and continually expand them to cover new code.

Introspection Tests

Introspection tests are executed on target (both simulator and device for iOS) or a specific version of OSX. The application proceed to analyze itself using:

  • System.Reflection for managed code; and
  • the ObjectiveC runtime library for native code

and compare the results. E.g. if using .NET reflection it can see a binding for a NSBundle type then it should be able to find a native NSBundle type using the ObjC runtime functions. Otherwise an error is raised...

Since the application analyze itself it must contains everything we wish to test. That's why the introspection tests are part of the dontlink.app application (for iOS) and the dontlink-mac project (for OSX).

Pros

  • They always tell the truth, which can differ from documentation

Cons

  • Incomplete - Not everything is encoded in the metadata / executable;
  • Too complete - Not every truth is good to be known (or published)

Extrospection Tests

Extrospection tests takes data from some outside sources and see if our implementation match the information, e.g.

  • Header files from the SDK;
  • Rules, like Gendarme or FxCop;

Since this is done externally there's no need to run them on the devices, simulator or even a specific version of OSX.

Pro

  • There is more data available, e.g. information lost when compiling

Con

  • The data might not represent the truth (errors, false positives...)

Test Suites

*-tests : where * is the assembly name, e.g. monotouch

Use the project defaults for linking, i.e.

  • "Don't link" for simulator

  • "Link SDK assemblies only" for devices

  • regression testing without using the linker

  • both simulator and devices are set to "Don't link"

linkall

  • regression testing using the linker on the all assemblies

  • "Link all assemblies" for both simulator/devices

linksdk

  • regression testing using the linker on the SDK assemblies

  • "Link SDK assemblies only" for both simulator/devices

bcl-test

These are the Mono BCL test suite tweaked to run on the mobile profile. It reuse the files directly from mono's repository (linking, not copying).

As other unit tests the configuration is set to mimick normal apps, e.g.

  • "Don't link" for simulator

  • "Link SDK assemblies only" for devices

Common make targets

Run every test in both the simulator and on device, using both the compat and the new profile (for the simulator both in 32 and 64bit mode).

$ make run

Run every test in the simulator, using both the compat and the new profile (both 32 and 64bit simulators).

$ make run-all-sim

Run every test on device, using both the compat and the new profile

$ make run-all-dev

Detailed make targets

  • Main target

    • run-what-where-project: Builds, installs (if applicable) and runs the specified test project on the specified platform. This is the most common target to use.
    • build-what-where-project: Will build the specified test project for the specified platform and target.
    • install-what-where-project: Will install the specified test project on a connected device. There's currently no way to select the device, so ensure you've only one connected (if many devices are connected, it's random which will used).
    • exec-what-where-project: Will run the specified test project in the simulator or on a device.
  • What

    • -ios-: iOS.
    • -tvos-: TVOS.
    • -watchos-: WatchOS

    If "What" is skipped, all variations are executed sequentially.

  • Where

    • -simclassic-: Simulator using the Classic API. Only applicable when platform is iOS.
    • -simunified-: Simulator using Unified API. The build will contain both an i386 and an x86_64 binary. Only applicable to the build-* target, while the -sim32- and -sim64- are only applicable to the exec-* targets. Only applicable when the platform is iOS.
    • -sim32-: 32bits iOS simulator using the Unified API. Not applicable to other platforms.
    • -sim64-: 64bits iOS simulator using the Unified API. Not applicable to other platforms.
    • -sim-:
      • iOS: Both the -simclassic- and -simunified- versions.
      • WatchOS/TVOS: The WatchOS/TVOS simulator.
    • -devclassic-: Device using the Classic API. Only applicable when the platform is iOS.
    • -devunified-: Device using the Unified API. The build will contain both an armv7 and an arm64 binary. It's not possible to select a 32/64bit version, you'll run what your device supports. Only applicable when the platform is iOS.
    • -dev-:
      • iOS: Both the -devclassic- and -devunified- versions.
      • WatchOS/TVOS: A Watch or TV device.
  • Examples

    $ make run-ios-sim32-monotouchtest: This will run monotouch-test using the Unified API in a 32-bit simulator. $ make run-tvos-dev-dont\ link: This will run dont link on an Apple TV device.

Utility run-* targets

These targets will build, install (if applicable) and run the specified project(s).

  • Simulator

    • run-sim-project: Builds and runs the specified test project in the simulator in compat, 32 and 64bit mode.
    • run-sim: Builds and runs all the non-bcl test projects in the simulator in compat, 32 and 64bit mode.
  • Device

    • run-dev-project: Builds and runs the specified non-bcl test project on a device in compat and native mode (if it's 32 and 64bit depends on the device; 64bit devices will run in 64bit mode and the same for 32bit devices).
    • run-devcompat: Run all the non-bcl test projects on device, in compat mode.
    • run-devdual: Run all the non-bcl test projects on device, in native mode (if it's 32 and 64bit depends on the device; 64bit devices will run in 64bit mode and the same for 32bit devices).
    • run-dev: Run all the non-bcl test projects on device, in both compat and native mode.