Author: jonpryor
Date: 2005-04-28 20:54:11 -0400 (Thu, 28 Apr 2005)
New Revision: 43758
Modified:
trunk/mcs/class/Mono.Posix/Test/Mono.Unix/ChangeLog
trunk/mcs/class/Mono.Posix/Test/Mono.Unix/StdlibTest.cs
Log:
* StdlibTest.cs: Calling a P/Invoke function from signal-handler
context is
*bad*, which is why I've had so much trouble getting consistent
results
getting this test to work -- it was broken by design. Instead, just
save
the signum passed to the handler (which is reentrant safe), and
compare
the saved value with the expected value after the signal handler
returns.
This should always work. Use SIGURG instead of SIGUSR1 because
SIGURG is
ignored by default (allowing us to call it without adding your own
handler), unlike SIGUSR1 which terminates the program.
Modified: trunk/mcs/class/Mono.Posix/Test/Mono.Unix/ChangeLog
===================================================================
--- trunk/mcs/class/Mono.Posix/Test/Mono.Unix/ChangeLog 2005-04-29 00:19:42 UTC
(rev 43757)
+++ trunk/mcs/class/Mono.Posix/Test/Mono.Unix/ChangeLog 2005-04-29 00:54:11 UTC
(rev 43758)
@@ -1,3 +1,14 @@
+2005-04-28 Jonathan Pryor <[EMAIL PROTECTED]>
+
+ * StdlibTest.cs: Calling a P/Invoke function from signal-handler
context is
+ *bad*, which is why I've had so much trouble getting consistent
results
+ getting this test to work -- it was broken by design. Instead, just
save
+ the signum passed to the handler (which is reentrant safe), and
compare
+ the saved value with the expected value after the signal handler
returns.
+ This should always work. Use SIGURG instead of SIGUSR1 because
SIGURG is
+ ignored by default (allowing us to call it without adding your own
+ handler), unlike SIGUSR1 which terminates the program.
+
2005-03-28 Jonathan Pryor <[EMAIL PROTECTED]>
* StdioFileStreamTest.cs: Added; based on
MonoTests.System.IO.FileStreamTest.
Modified: trunk/mcs/class/Mono.Posix/Test/Mono.Unix/StdlibTest.cs
===================================================================
--- trunk/mcs/class/Mono.Posix/Test/Mono.Unix/StdlibTest.cs 2005-04-29
00:19:42 UTC (rev 43757)
+++ trunk/mcs/class/Mono.Posix/Test/Mono.Unix/StdlibTest.cs 2005-04-29
00:54:11 UTC (rev 43758)
@@ -21,15 +21,15 @@
public class StdlibTest
{
private class SignalTest {
- public Signum signalReceived;
+ public int signalReceived;
public void Handler (int sn)
{
- signalReceived = UnixConvert.ToSignum (sn);
+ signalReceived = sn;
}
}
- [Test, Ignore ("Sending Signals from inside Mono hangs the
program")]
+ [Test]
#if !NET_2_0
// .NET 1.1 marshals delegates as Stdcall functions, while
signal(3)
// expects a Cdecl function. Result: stack corruption.
@@ -45,27 +45,26 @@
st.Handler (9);
// Insert handler
- SignalHandler oh = Stdlib.signal (Signum.SIGUSR1,
+ SignalHandler oh = Stdlib.signal (Signum.SIGURG,
new SignalHandler (st.Handler));
- st.signalReceived = ~Signum.SIGUSR1;
+ st.signalReceived = ~UnixConvert.FromSignum
(Signum.SIGURG);
// Send signal
- Stdlib.raise (Signum.SIGUSR1);
+ Stdlib.raise (Signum.SIGURG);
- Assert.IsTrue (st.signalReceived == Signum.SIGUSR1,
- "#IH: Signal handler not invoked for
SIGUSR1");
+ Assert.IsTrue (
+ UnixConvert.ToSignum (st.signalReceived) ==
Signum.SIGURG,
+ "#IH: Signal handler not invoked for
SIGURG");
// Reset old signal
- Stdlib.signal (Signum.SIGUSR1, oh);
+ Stdlib.signal (Signum.SIGURG, oh);
-#if IGNORE
- signalReceived = ~Signum.SIGUSR1;
- Stdlib.raise (Signum.SIGUSR1);
+ st.signalReceived = UnixConvert.FromSignum
(Signum.SIGUSR1);
+ Stdlib.raise (Signum.SIGURG);
- Assert.IsFalse (signalReceived == Signum.SIGUSR1,
+ Assert.IsFalse (UnixConvert.ToSignum
(st.signalReceived) == Signum.SIGURG,
"#IH: Signal Handler invoked when it
should have been removed!");
-#endif
}
[Test]
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches