* Makefile: Modify test to build `test.dll' and use that as an input
authorJonathan Pryor <jpryor@novell.com>
Thu, 14 Sep 2006 13:37:32 +0000 (13:37 -0000)
committerJonathan Pryor <jpryor@novell.com>
Thu, 14 Sep 2006 13:37:32 +0000 (13:37 -0000)
  assembly to mono-shlib-cop.exe, and not mono-shlib-cop.exe itself.  This
  permits mono-shlib-cop.exe to be "clean", as it doesn't need to have
  deliberate errors inserted into it for use by the unit test.
* mono-shlib-cop.cs: Remove methods used for unit test.
* mono-shlib-cop.exe.config: Add <dllmap/> entry for libglib-2.0, so that
  `mono-shlib-cop mono-shlib-cop.exe` doesn't return any errors/warnings.
  This is requested by meebey@#mono, so that mono-shlib-cop doesn't itself
  require development libraries to execute (complicating the packaging
  process on debian).
* mono-shlib-cop.exe.out: Removed; not used anymore.
* test.cs: Added; test input file for mono-shlib-cop.
* test.dll.out: Added; expected output for `mono-shlib-cop test.dll`.

svn path=/trunk/mcs/; revision=65393

mcs/tools/mono-shlib-cop/ChangeLog
mcs/tools/mono-shlib-cop/Makefile
mcs/tools/mono-shlib-cop/mono-shlib-cop.cs
mcs/tools/mono-shlib-cop/mono-shlib-cop.exe.config
mcs/tools/mono-shlib-cop/mono-shlib-cop.exe.out [deleted file]
mcs/tools/mono-shlib-cop/test.cs [new file with mode: 0644]
mcs/tools/mono-shlib-cop/test.dll.config [new file with mode: 0644]
mcs/tools/mono-shlib-cop/test.dll.out [new file with mode: 0644]

index ce43be2001f10751e71b976e7379b9a4c9dfefef..1de3faa6669deb469c1327e06d9cb40db59cf939 100644 (file)
@@ -1,3 +1,19 @@
+2006-09-14  Jonathan Pryor  <jonpryor@vt.edu>
+
+       * Makefile: Modify test to build `test.dll' and use that as an input
+         assembly to mono-shlib-cop.exe, and not mono-shlib-cop.exe itself.  This
+         permits mono-shlib-cop.exe to be "clean", as it doesn't need to have
+         deliberate errors inserted into it for use by the unit test.
+       * mono-shlib-cop.cs: Remove methods used for unit test.
+       * mono-shlib-cop.exe.config: Add <dllmap/> entry for libglib-2.0, so that
+         `mono-shlib-cop mono-shlib-cop.exe` doesn't return any errors/warnings.
+         This is requested by meebey@#mono, so that mono-shlib-cop doesn't itself
+         require development libraries to execute (complicating the packaging
+         process on debian).
+       * mono-shlib-cop.exe.out: Removed; not used anymore.
+       * test.cs: Added; test input file for mono-shlib-cop.
+       * test.dll.out: Added; expected output for `mono-shlib-cop test.dll`.
+
 2005-09-07  Jonathan Pryor  <jonpryor@vt.edu>
 
        * mono-shlib-cop.cs: Use Assembly.LoadWithPartialName instead of
index 034918ac21c1ca02b66cbaed95c19b18837e2537..d17fd22e348ca94c277f8703c73bfe3f70830512 100644 (file)
@@ -6,12 +6,22 @@ LOCAL_MCS_FLAGS = -r:Mono.Posix.dll -r:Mono.GetOptions.dll
 
 PROGRAM = mono-shlib-cop.exe
 
+TEST_INPUT = test.dll
+
 include ../../build/executable.make
 
-test-local: $(PROGRAM)
+test-local: $(PROGRAM) $(TEST_INPUT)
+
+clean-local: cleanup
+
+cleanup:
+       -rm $(TEST_INPUT)
 
 run-test-local: run-mono-shlib-cop-test
 
-run-mono-shlib-cop-test: $(PROGRAM)
-       $(RUNTIME) $< $< | diff - mono-shlib-cop.exe.out
+run-mono-shlib-cop-test: $(PROGRAM) $(TEST_INPUT)
+       $(RUNTIME) $(PROGRAM) $(TEST_INPUT) | diff - test.dll.out
+
+$(TEST_INPUT) : test.cs
+       $(CSCOMPILE) -target:library $< -out:$@
 
index 87fc670a5f1c3fac0defa00bd85e502adaf215c5..7a35c76ed029a64e6cd9f8809c55b9475dc9c470 100644 (file)
@@ -497,11 +497,6 @@ namespace Mono.Unmanaged.Check {
        }
 
        class Runner {
-               [DllImport ("does-not-exist")]
-                       private static extern void Foo ();
-
-               [DllImport ("another-native-lib")]
-                       private static extern void Bar ();
 
                public static void Main (string[] args)
                {
index f8b1e59e60f626b31ee6815eead5f9dceb17c66e..f7687dc74baa9591d298b251159a7e647f66dd4d 100644 (file)
@@ -1,4 +1,5 @@
 <configuration>
        <dllmap dll="does-not-exist" target="libc.so.6"/>
        <dllmap dll="libgmodule-2.0.so" target="libgmodule-2.0.so.0"/>
+       <dllmap dll="libglib-2.0.so" target="libglib-2.0.so.0"/>
 </configuration>
diff --git a/mcs/tools/mono-shlib-cop/mono-shlib-cop.exe.out b/mcs/tools/mono-shlib-cop/mono-shlib-cop.exe.out
deleted file mode 100644 (file)
index f925e25..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-error: in Mono.Unmanaged.Check.Runner.Foo: library `libc.so.6' is missing symbol `Foo'
-error: in Mono.Unmanaged.Check.Runner.Bar: Could not load library `another-native-lib': ./libanother-native-lib.so: cannot open shared object file: No such file or directory
-warning: in Mono.Unmanaged.Check.AssemblyChecker.g_free: Library `libglib-2.0.so' might be a development library
diff --git a/mcs/tools/mono-shlib-cop/test.cs b/mcs/tools/mono-shlib-cop/test.cs
new file mode 100644 (file)
index 0000000..d67d7b7
--- /dev/null
@@ -0,0 +1,70 @@
+//
+// test.cs: Unit test for mono-shlib-cop.exe
+//
+// Compile as:
+//    mcs -target:library test.cs -out:test.dll
+//
+// Authors:
+//  Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2005 Jonathan Pryor
+//
+
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.InteropServices;
+
+namespace Mono.Unmanaged.Check {
+
+       class Test {
+               // OK
+               [DllImport ("libgmodule-2.0.so")]
+               private static extern int g_module_close (IntPtr handle);
+
+               // Warning
+               [DllImport ("libglib-2.0.so")]
+               private static extern void g_free (IntPtr mem);
+
+               // Error: no such library
+               [DllImport ("does-not-exist")]
+               private static extern void Foo ();
+
+               // Error: no such method (library name remapped in .dll.config)
+               [DllImport ("renamed-lib")]
+               private static extern void RenameMe ();
+
+               // Error: no such method
+               [DllImport ("libc")]
+               private static extern void DoesNotExist ();
+
+               Test ()
+               {
+                       g_module_close (IntPtr.Zero);
+                       g_free (IntPtr.Zero);
+                       Foo ();
+                       RenameMe ();
+                       DoesNotExist ();
+               }
+       }
+}
+
diff --git a/mcs/tools/mono-shlib-cop/test.dll.config b/mcs/tools/mono-shlib-cop/test.dll.config
new file mode 100644 (file)
index 0000000..6120663
--- /dev/null
@@ -0,0 +1,4 @@
+<configuration>
+       <dllmap dll="libgmodule-2.0.so" target="libgmodule-2.0.so.0"/>
+       <dllmap dll="renamed-lib" target="libc.so.6"/>
+</configuration>
diff --git a/mcs/tools/mono-shlib-cop/test.dll.out b/mcs/tools/mono-shlib-cop/test.dll.out
new file mode 100644 (file)
index 0000000..d5698c3
--- /dev/null
@@ -0,0 +1,4 @@
+error: in Mono.Unmanaged.Check.Test.Foo: Could not load library `does-not-exist': ./libdoes-not-exist.so: cannot open shared object file: No such file or directory
+error: in Mono.Unmanaged.Check.Test.RenameMe: library `libc.so.6' is missing symbol `RenameMe'
+error: in Mono.Unmanaged.Check.Test.DoesNotExist: library `libc.so.6' is missing symbol `DoesNotExist'
+warning: in Mono.Unmanaged.Check.Test.g_free: Library `libglib-2.0.so' might be a development library