PR162: Added regression test.
authorStefan Ring <stefan@complang.tuwien.ac.at>
Tue, 29 Nov 2011 23:24:30 +0000 (00:24 +0100)
committerStefan Ring <stefan@complang.tuwien.ac.at>
Tue, 29 Nov 2011 23:24:30 +0000 (00:24 +0100)
tests/regression/bugzilla/All.java
tests/regression/bugzilla/PR131.java
tests/regression/bugzilla/PR162.java [new file with mode: 0644]

index 937853d3466ac612e9280d9ec082802e69e7bd69..ad1c4d2faed14893230f052bd2b2a09d05736e80 100644 (file)
@@ -43,7 +43,8 @@ PR119.class,
 PR125.class,
 PR131.class,
 PR144.class,
-PR148.class
+PR148.class,
+PR162.class
 })
 
 public class All {
index 6ae256a22f400c8add60b21239c5e801d0bd8b4f..dafe228b38546d207f40aef9903bc0dcac429a6d 100644 (file)
@@ -1,6 +1,6 @@
-/* tests/regression/bugzilla/PR119.java
+/* tests/regression/bugzilla/PR131.java
 
-   Copyright (C) 2009
+   Copyright (C) 1996-2011
    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
diff --git a/tests/regression/bugzilla/PR162.java b/tests/regression/bugzilla/PR162.java
new file mode 100644 (file)
index 0000000..9541c4d
--- /dev/null
@@ -0,0 +1,76 @@
+/* tests/regression/bugzilla/PR162.java
+
+   Copyright (C) 1996-2011
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+// This test is not deterministic. It doesn't always fail, but it's very rare
+// that 5 consecutive runs succeed.
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import java.util.concurrent.Semaphore;
+
+class M {
+       public static Semaphore sem = new Semaphore(0);
+}
+
+class testglobal {
+       public static String the_string = initializeString();
+
+       static String initializeString() {
+               M.sem.release();
+               try {
+                       Thread.sleep(300);
+               } catch (InterruptedException e) {
+                       e.printStackTrace();
+               }
+               return "hullabaloo";
+       }
+}
+
+class testthread extends Thread {
+       public int the_length = 0;
+       public void run() {
+               try {
+                       M.sem.acquire();
+               } catch (InterruptedException e) {
+                       e.printStackTrace();
+               }
+               the_length = testglobal.the_string.length();
+       }
+}
+
+public class PR162 {
+       @Test
+       public void test() {
+               testthread t = new testthread();
+               t.start();
+               int length = testglobal.the_string.length();
+               try {
+                       t.join();
+               } catch (InterruptedException e) {
+                       e.printStackTrace();
+               }
+               assertEquals(t.the_length, length);
+       }
+}