+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
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:$@
--- /dev/null
+//
+// 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 ();
+ }
+ }
+}
+