diff --git a/configure.ac b/configure.ac index 239a2d8..1a0a698 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,3 @@ -dnl Warning: This is an automatically generated file, do not edit! dnl Process this file with autoconf to produce a configure script. AC_PREREQ([2.54]) AC_INIT([CPPInterop], [0.99.1]) @@ -17,6 +16,11 @@ SHAMROCK_EXPAND_DATADIR AC_PROG_INSTALL +AC_PATH_PROG(MONO, mono, no) +if test "x$MONO" = "xno"; then + AC_MSG_ERROR([mono Not found]) +fi + AC_PATH_PROG(GMCS, mcs, no) if test "x$GMCS" = "xno"; then AC_MSG_ERROR([mcs Not found]) @@ -47,6 +51,8 @@ fi dnl package checks, common for all configs +PKG_CHECK_MODULES([MONO_NUNIT], [mono-nunit]) + dnl package checks, per config diff --git a/src/Mono.VisualC.Code/Makefile.am b/src/Mono.VisualC.Code/Makefile.am index 12db2f8..1808be5 100644 --- a/src/Mono.VisualC.Code/Makefile.am +++ b/src/Mono.VisualC.Code/Makefile.am @@ -31,8 +31,6 @@ MONO_VISUALC_CODE_DLL_MDB= endif COMPILE_TARGET = library -PROJECT_REFERENCES = \ - $(BUILD_DIR)/Mono.VisualC.Interop.dll AL=al2 SATELLITE_ASSEMBLY_NAME=$(notdir $(basename $(ASSEMBLY))).resources.dll @@ -97,6 +95,6 @@ $(build_xamlg_list): %.xaml.g.cs: %.xaml $(ASSEMBLY_MDB): $(ASSEMBLY) -$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) $(DLL_REFERENCES) $(PROJECT_REFERENCES) $(build_xamlg_list) $(build_satellite_assembly_list) +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) $(DLL_REFERENCES) $(build_xamlg_list) $(build_satellite_assembly_list) mkdir -p $(shell dirname $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$(ASSEMBLY) -target:$(COMPILE_TARGET) $(build_sources_embed) $(build_resources_embed) $(build_references_ref) diff --git a/src/generator/Makefile.am b/src/generator/Makefile.am index da5fa97..dafcd84 100644 --- a/src/generator/Makefile.am +++ b/src/generator/Makefile.am @@ -31,8 +31,6 @@ GENERATOR_EXE_MDB= endif COMPILE_TARGET = exe -PROJECT_REFERENCES = \ - $(BUILD_DIR)/Mono.VisualC.Interop.dll AL=al2 SATELLITE_ASSEMBLY_NAME=$(notdir $(basename $(ASSEMBLY))).resources.dll @@ -93,6 +91,6 @@ $(build_xamlg_list): %.xaml.g.cs: %.xaml $(ASSEMBLY_MDB): $(ASSEMBLY) -$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) $(DLL_REFERENCES) $(PROJECT_REFERENCES) $(build_xamlg_list) $(build_satellite_assembly_list) +$(ASSEMBLY): $(build_sources) $(build_resources) $(build_datafiles) $(DLL_REFERENCES) $(build_xamlg_list) $(build_satellite_assembly_list) mkdir -p $(shell dirname $(ASSEMBLY)) $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$(ASSEMBLY) -target:$(COMPILE_TARGET) $(build_sources_embed) $(build_resources_embed) $(build_references_ref) diff --git a/tests/AbiTests.cs b/tests/AbiTests.cs new file mode 100644 index 0000000..28790e4 --- /dev/null +++ b/tests/AbiTests.cs @@ -0,0 +1,69 @@ +using System; +using NUnit.Framework; + +using Tests.Support; + +namespace Tests { + + [TestFixture] + public class AbiTests { + + [Test] + public void test_0_class_return () + { + // Section 3.1.4: + // Classes with non-default copy ctors/destructors are returned using a hidden + // argument + var c = ClassWithCopyCtor.Return (42); + Assert.AreEqual (42, c.GetX (), "#1"); + + var c2 = ClassWithDtor.Return (43); + Assert.AreEqual (43, c2.GetX (), "#2"); + + // This class is returned normally + var c3 = ClassWithoutCopyCtor.Return (44); + Assert.AreEqual (44, c3.GetX (), "#3"); + } + + // An object as ref argument + [Test] + public void test_0_class_arg () + { + var c1 = new Class (4); + var c2 = new Class (5); + + c1.CopyTo (c2); + Assert.AreEqual (4, c2.GetX (), "#1"); + } + + // A null object as ref argument + [Test] + public void test_0_class_arg_null () + { + var c1 = new Class (4); + Assert.That (c1.IsNull (null), "#1"); + } + + // An object as byval argument + [Test] + public void test_0_class_arg_byval () + { + var c1 = new Class (4); + var c2 = new Class (5); + + c1.CopyFromValue (c2); + Assert.AreEqual (5, c1.GetX (), "#1"); + } + + // A null object as byval argument + [Test] + [ExpectedException (typeof (ArgumentException))] + public void test_0_class_arg_byval_null () + { + var c1 = new Class (4); + c1.CopyFromValue (null); + } + + } + +} \ No newline at end of file diff --git a/tests/CppInstancePtrTests.cs b/tests/CppInstancePtrTests.cs index 602fff1..b5a8388 100644 --- a/tests/CppInstancePtrTests.cs +++ b/tests/CppInstancePtrTests.cs @@ -37,14 +37,6 @@ namespace Tests { cppip.Dispose (); } - [Test] - [ExpectedException (typeof(ArgumentNullException))] - public void TestForNonStaticWrapperWithNull () - { - CppInstancePtr cppip = CppInstancePtr.ForManagedObject (null); - cppip.Dispose (); - } - [Test] [ExpectedException (typeof (ObjectDisposedException))] public void TestDisposed () @@ -52,25 +44,9 @@ namespace Tests { CppInstancePtr cppip = CppInstancePtr.ForManagedObject (CppMockObject.Instance); cppip.Dispose (); // should throw - Console.WriteLine (cppip.Native); + Assert.Fail (); } - [Test] - public void TestFromNativePtr () - { - IntPtr native = CreateCSimpleSubClass (0); - CppInstancePtr cppip = new CppInstancePtr (native); - Assert.AreEqual (native, cppip.Native); - Assert.IsFalse (cppip.IsManagedAlloc, "#A1"); - cppip.Dispose (); - DestroyCSimpleSubClass (native); - } - - [DllImport("CPPTestLib")] - private static extern IntPtr CreateCSimpleSubClass (int x); - - [DllImport("CPPTestLib")] - private static extern void DestroyCSimpleSubClass (IntPtr cppip); } } diff --git a/tests/ItaniumAbiTests.cs b/tests/ItaniumAbiTests.cs deleted file mode 100644 index 81c069d..0000000 --- a/tests/ItaniumAbiTests.cs +++ /dev/null @@ -1,25 +0,0 @@ -// -// ItaniumAbiTests.cs: Test cases to exercise the ItaniumAbi -// -// Author: -// Alexander Corrado (alexander.corrado@gmail.com) -// -// Copyright (C) 2010 Alexander Corrado -// - -using System; -using NUnit.Framework; - -using Mono.VisualC.Interop.ABI; - -namespace Tests { - [TestFixture] - public class ItaniumAbiTests : SharedAbiTests { - - public ItaniumAbiTests () : base (new ItaniumAbi ()) - { - } - - } -} - diff --git a/tests/Makefile.am b/tests/Makefile.am index 136f8ca..cfb6400 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -7,17 +7,20 @@ INTEROP_DLL = \ TEST_DLL = $(BUILD_DIR)/Test.dll HDR = \ - Native/test.h + Native/AbiTests.h NATIVE = \ Native/NUnit.cpp \ - Native/test.cpp + Native/AbiTests.cpp MANAGED = \ + AbiTests.cs \ + CppInstancePtrTests.cs \ Support/CppMockObject.cs \ - Support/CppNUnitAsserts.cs \ - test.cs + Support/CppNUnitAsserts.cs +REFERENCES = \ + -pkg:mono-nunit all: $(TEST_DLL) @@ -32,10 +35,10 @@ $(BUILD_DIR)/libTest-inline.so: $(HEADERS) $(NATIVE) generated: test.xml $(RM) -r generated - mono --debug $(BUILD_DIR)/generator.exe -o=$@ -ns=CppTests -lib=Test test.xml + mono --debug $(BUILD_DIR)/generator.exe -o=$@ -ns=Tests -lib=Test test.xml $(TEST_DLL): generated $(MANAGED) $(BUILD_DIR)/libTest.so $(BUILD_DIR)/libTest-inline.so - mcs -out:$@ -target:library -unsafe -r:$(INTEROP_DLL) generated/*.cs $(MANAGED) + mcs -out:$@ -target:library -unsafe $(REFERENCES) -r:$(INTEROP_DLL) generated/*.cs $(MANAGED) clean: $(RM) -rf $(TEST_DLL) generated $(BUILD_DIR)/libTest.so $(BUILD_DIR)/libTest-inline.so test.xml diff --git a/tests/MsvcAbiTests.cs b/tests/MsvcAbiTests.cs deleted file mode 100644 index 5578128..0000000 --- a/tests/MsvcAbiTests.cs +++ /dev/null @@ -1,24 +0,0 @@ -// -// MsvcAbiTests.cs: Test cases to exercise the MsvcAbi -// -// Author: -// Alexander Corrado (alexander.corrado@gmail.com) -// -// Copyright (C) 2010 Alexander Corrado -// - -using System; -using NUnit.Framework; - -using Mono.VisualC.Interop.ABI; - -namespace Tests { - [TestFixture] - public class MsvcAbiTests : SharedAbiTests { - - public MsvcAbiTests () : base (new MsvcAbi ()) - { - } - } -} - diff --git a/tests/Native/test.cpp b/tests/Native/AbiTests.cpp similarity index 95% rename from tests/Native/test.cpp rename to tests/Native/AbiTests.cpp index 0d1c562..fd0ace3 100644 --- a/tests/Native/test.cpp +++ b/tests/Native/AbiTests.cpp @@ -1,5 +1,5 @@ -#include "test.h" +#include "AbiTests.h" ClassWithCopyCtor::ClassWithCopyCtor(const ClassWithCopyCtor& f) { x = f.x; diff --git a/tests/Native/test.h b/tests/Native/AbiTests.h similarity index 100% rename from tests/Native/test.h rename to tests/Native/AbiTests.h diff --git a/tests/SharedAbiTests.cs b/tests/SharedAbiTests.cs deleted file mode 100644 index c590d95..0000000 --- a/tests/SharedAbiTests.cs +++ /dev/null @@ -1,43 +0,0 @@ -// -// SharedAbiTests.cs: Test cases that are shared by all ABIs -// -// Author: -// Alexander Corrado (alexander.corrado@gmail.com) -// -// Copyright (C) 2010 Alexander Corrado -// - -using System; -using NUnit.Framework; - -using Mono.VisualC.Interop; -using Mono.VisualC.Interop.ABI; - -using Tests.Support; - -namespace Tests { - public class SharedAbiTests { - - protected CppLibrary test_lib { get; private set; } - protected IVirtualMethodTestClass virtual_test_class { get; private set; } - - protected SharedAbiTests (CppAbi abi) - { - this.test_lib = new CppLibrary ("CPPTestLib", abi); - this.virtual_test_class = test_lib.GetClass ("VirtualMethodTestClass"); - CppNUnitAsserts.Init (); - } - - [Test] - public void TestVirtualMethods () - { - CppInstancePtr vmtc = VirtualMethodTestClass.Create (); - - virtual_test_class.V0 (vmtc, 1, 2, 3); - - VirtualMethodTestClass.Destroy (vmtc); - } - - } -} - diff --git a/tests/Support/CppMockObject.cs b/tests/Support/CppMockObject.cs index ce420b8..6c19920 100644 --- a/tests/Support/CppMockObject.cs +++ b/tests/Support/CppMockObject.cs @@ -22,7 +22,7 @@ namespace Tests.Support { { } - public IntPtr Native { + public CppInstancePtr Native { get { throw new System.NotImplementedException (); } diff --git a/tests/Tests.csproj b/tests/Tests.csproj index 2567c33..9494663 100644 --- a/tests/Tests.csproj +++ b/tests/Tests.csproj @@ -30,7 +30,6 @@ true false true - true @@ -56,47 +55,46 @@ AllRules.ruleset - - - - - - - - - - - - + + - - - {B01E6282-144E-481A-8E1F-95F708DFBC2D} - CPPTestLib - - - {4A864586-93C5-4DC1-8A80-F094A88506D7} - Mono.VisualC.Interop - - False - .NET Framework 3.5 SP1 Client Profile - false False - .NET Framework 3.5 SP1 - true False - Windows Installer 3.1 - true + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/test.cs b/tests/test.cs deleted file mode 100644 index a6468a4..0000000 --- a/tests/test.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using CppTests; - -public class Tests -{ - public static void Main (String[] args) { - TestDriver.RunTests (typeof (Tests), args); - } - - public static int test_0_class_return () { - // Section 3.1.4: - // Classes with non-default copy ctors/destructors are returned using a hidden - // argument - var c = ClassWithCopyCtor.Return (42); - if (c.GetX () != 42) - return 1; - - var c2 = ClassWithDtor.Return (43); - if (c2.GetX () != 43) - return 2; - - // This class is returned normally - var c3 = ClassWithoutCopyCtor.Return (44); - if (c3.GetX () != 44) - return 3; - return 0; - } - - // An object as ref argument - public static int test_0_class_arg () { - var c1 = new Class (4); - var c2 = new Class (5); - - c1.CopyTo (c2); - return c2.GetX () == 4 ? 0 : 1; - } - - // A null object as ref argument - public static int test_0_class_arg_null () { - var c1 = new Class (4); - - return c1.IsNull (null) ? 0 : 1; - } - - // An object as byval argument - public static int test_0_class_arg_byval () { - var c1 = new Class (4); - var c2 = new Class (5); - - c1.CopyFromValue (c2); - return c1.GetX () == 5 ? 0 : 1; - } - - // A null object as byval argument - public static int test_0_class_arg_byval_null () { - var c1 = new Class (4); - - try { - c1.CopyFromValue (null); - } catch (ArgumentException) { - return 0; - } - return 1; - } - -} diff --git a/tests/tests.pc.in b/tests/tests.pc.in deleted file mode 100644 index 1350e51..0000000 --- a/tests/tests.pc.in +++ /dev/null @@ -1,6 +0,0 @@ -Name: Tests -Description: Tests -Version: 0.1 - -Requires: -Libs: -r:@expanded_libdir@/@PACKAGE@/Tests.dll