Author: gert
Date: 2007-11-03 05:02:22 -0500 (Sat, 03 Nov 2007)
New Revision: 88777

Added:
   trunk/gert/standalone/bug334740/
   trunk/gert/standalone/bug334740/default.build
   trunk/gert/standalone/bug334740/test.cs
Modified:
   trunk/gert/standalone/known-issues
Log:
Added test for bug #334740.


Added: trunk/gert/standalone/bug334740/default.build
===================================================================
--- trunk/gert/standalone/bug334740/default.build       2007-11-03 08:46:36 UTC 
(rev 88776)
+++ trunk/gert/standalone/bug334740/default.build       2007-11-03 10:02:22 UTC 
(rev 88777)
@@ -0,0 +1,58 @@
+<project name="bug334740" default="rebuild">
+       <target name="mono-1.0">
+               <property name="csc.defines" 
value="NET_1_0,NET_1_1,ONLY_1_1,MONO" />
+       </target>
+
+       <target name="mono-2.0">
+               <property name="csc.defines" 
value="NET_1_0,NET_1_1,NET_2_0,ONLY_2_0,MONO" />
+       </target>
+
+       <target name="net-1.1">
+               <property name="csc.defines" value="NET_1_0,NET_1_1,ONLY_1_1" />
+       </target>
+
+       <target name="net-2.0">
+               <property name="csc.defines" 
value="NET_1_0,NET_1_1,NET_2_0,ONLY_2_0" />
+       </target>
+
+       <property name="frameworks" value="mono-1.0,mono-2.0,net-1.1,net-2.0" />
+
+       <target name="clean">
+               <delete>
+                       <fileset>
+                               <include name="out" />
+                               <include name="test.exe" />
+                       </fileset>
+               </delete>
+       </target>
+
+       <target name="build">
+               <property name="original.targetframework" 
value="${nant.settings.currentframework}" />
+
+               <foreach property="framework" item="String" in="${frameworks}" 
delim=",">
+                       <if test="${framework::exists(framework)}">
+                               <property name="nant.settings.currentframework" 
value="${framework}" />
+                               <call 
target="${nant.settings.currentframework}" />
+                               <call target="run" />
+                               <call target="clean" />
+                       </if>
+               </foreach>
+
+               <property name="nant.settings.currentframework" 
value="${original.targetframework}" />
+       </target>
+
+       <target name="compile">
+               <csc target="exe" define="${csc.defines}" output="test.exe" 
warnaserror="true" warninglevel="4">
+                       <sources>
+                               <include name="test.cs" />
+                       </sources>
+               </csc>
+       </target>
+
+       <target name="run" depends="compile">
+               <exec program="test.exe" managed="true" output="out" />
+               <fail if="${file::exists('out')}" />
+       </target>
+
+       <target name="rebuild" depends="clean, build" />
+</project>


Property changes on: trunk/gert/standalone/bug334740/default.build
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/gert/standalone/bug334740/test.cs
===================================================================
--- trunk/gert/standalone/bug334740/test.cs     2007-11-03 08:46:36 UTC (rev 
88776)
+++ trunk/gert/standalone/bug334740/test.cs     2007-11-03 10:02:22 UTC (rev 
88777)
@@ -0,0 +1,76 @@
+using System;
+using System.Timers;
+using ST = System.Threading;
+
+class Program
+{
+       static int Main ()
+       {
+               for (int i = 0; i < 10; i++) {
+                       if (!new RaceTest (true).Success)
+                               return 1;
+                       if (!new RaceTest (false).Success)
+                               return 2;
+               }
+               return 0;
+       }
+}
+
+class RaceTest
+{
+       const int Threads = 2;
+       const int Loops = 100;
+
+       object locker = new object ();
+       Timer timer;
+       int counter;
+
+       public bool Success
+       {
+               get { return counter > Loops * Threads; }
+       }
+
+       public RaceTest (bool autoReset)
+       {
+               timer = new Timer ();
+               timer.AutoReset = autoReset;
+               timer.Interval = 100;
+               timer.Elapsed += new ElapsedEventHandler (Tick);
+               timer.Start ();
+
+               ST.Thread [] tl = new ST.Thread [Threads];
+
+               for (int i = 0; i < Threads; i++) {
+                       tl [i] = new ST.Thread (new ST.ThreadStart (Run));
+                       tl [i].Start ();
+               }
+
+               for (int i = 0; i < Threads; i++) {
+                       tl [i].Join ();
+               }
+
+               ST.Thread.Sleep (1000);
+       }
+
+       void Restart ()
+       {
+               lock (locker) {
+                       timer.Stop ();
+                       timer.Start ();
+               }
+               ST.Interlocked.Increment (ref counter);
+       }
+
+       void Tick (object sender, ElapsedEventArgs e)
+       {
+               Restart ();
+       }
+
+       void Run ()
+       {
+               for (int i = 0; i < Loops; i++) {
+                       ST.Thread.Sleep (0);
+                       Restart ();
+               }
+       }
+}


Property changes on: trunk/gert/standalone/bug334740/test.cs
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/gert/standalone/known-issues
===================================================================
--- trunk/gert/standalone/known-issues  2007-11-03 08:46:36 UTC (rev 88776)
+++ trunk/gert/standalone/known-issues  2007-11-03 10:02:22 UTC (rev 88777)
@@ -99,6 +99,7 @@
 bug333741/**
 bug334453/**
 bug334465/**
+bug334740/**
 bug334931/**
 bug335011/**
 bug335329/**

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to