[kaffe] CVS kaffe (inaba): Modify watchdog timeout value for ThreadState.java.
Kaffe CVS
cvs-commits at kaffe.org
Fri Jan 20 17:52:53 PST 2006
PatchSet 7099
Date: 2006/01/21 01:45:40
Author: inaba
Branch: HEAD
Tag: (none)
Log:
Modify watchdog timeout value for ThreadState.java.
Members:
ChangeLog:1.4619->1.4620
test/regression/ThreadState.java:INITIAL->1.7
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4619 kaffe/ChangeLog:1.4620
--- kaffe/ChangeLog:1.4619 Sat Jan 21 01:31:29 2006
+++ kaffe/ChangeLog Sat Jan 21 01:45:40 2006
@@ -1,8 +1,14 @@
2006-01-21 Kiyo Inaba <inaba at src.ricoh.co.jp>
+ * test/regression/ThreadState.java: Change timeout value for
+ this test from 60 * 1000 to 60 * 10000. This allows some
+ older machines to execute in enough time.
+
+2006-01-21 Kiyo Inaba <inaba at src.ricoh.co.jp>
+
* test/regression/RefTest.java: Change timeout value for
this test from 10000 to 100000. This allows some older
- machine to execute enough time.
+ machine to execute in enough time.
2006-01-19 Kiyo Inaba <inaba at src.ricoh.co.jp>
===================================================================
Checking out kaffe/test/regression/ThreadState.java
RCS: /home/cvs/kaffe/kaffe/test/regression/ThreadState.java,v
VERS: 1.7
***************
--- /dev/null Sun Aug 4 19:57:58 2002
+++ kaffe/test/regression/ThreadState.java Sat Jan 21 01:52:52 2006
@@ -0,0 +1,158 @@
+import java.util.*;
+import java.io.*;
+
+public class ThreadState extends Thread {
+ public final static int DEFAULT_NUMTHREADS = 10;
+ boolean childRunning;
+ static PrintStream p;
+
+ // Test thread states
+ public static void main(String args[]) throws Exception {
+ int numThreads;
+ int index = 0;
+
+ if (args.length > 0 && args[0].equals("-v")) {
+ p = System.out;
+ index = 1;
+ }
+
+ try {
+ numThreads = Integer.parseInt(args[index]);
+ } catch (Exception e) {
+ numThreads = DEFAULT_NUMTHREADS;
+ }
+
+ new Thread() {
+ public void run() {
+ try {
+ Thread.sleep(60 * 10000);
+ } catch (Exception _) { }
+ System.out.println("Time out. Failure.");
+ System.exit(-1);
+ }
+ }.start();
+
+ Thread[] threads = new Thread[numThreads];
+ for (int i = 0; i < numThreads; i++) {
+ threads[i] = new ThreadState();
+ verbose("main starting " + threads[i].getName());
+ threads[i].start();
+ }
+ for (int i = 0; i < numThreads; i++) {
+ try {
+ verbose("main joining " + threads[i].getName());
+ threads[i].join();
+ } catch (InterruptedException e) {
+ check(false, "main " + e);
+ }
+ }
+ System.exit(0);
+ }
+
+ public void run() {
+ try {
+ verbose(getName() + " running");
+
+ // Create child thread
+ Thread t = new Thread() {
+ public synchronized void run() {
+ try {
+ childRunning = true;
+ verbose(ThreadState.this.getName() + " child running [child]");
+ try {
+ this.wait(0);
+ } catch (InterruptedException e) {
+ check(false, "thread " + e);
+ }
+ verbose(ThreadState.this.getName() + " child thread exiting");
+ } catch (Throwable t) {
+ t.printStackTrace();
+ System.exit(-1);
+ }
+ }
+ };
+
+ // Check state
+ check(!t.isAlive(), "alive before start()");
+ verbose(getName() + " starting child thread");
+ t.start();
+ check(t.isAlive(), "dead after start()");
+
+ // Check setDaemon after start()
+ try {
+ t.setDaemon(false);
+ check(false, "setDaemon() after start");
+ } catch (IllegalThreadStateException e) {
+ }
+
+ // Check double start()
+ try {
+ t.start();
+ check(false, "start() while alive");
+ } catch (IllegalThreadStateException e) {
+ }
+
+ // Wait for thread to be running
+ while (!childRunning) {
+ Thread.yield();
+ }
+ verbose(getName() + " child thread running [parent]");
+
+ // Notify child he can exit
+ synchronized (t) {
+ t.notify();
+ }
+
+ verbose(getName() + " joining my child thread");
+ try {
+ t.join();
+ } catch (InterruptedException e) {
+ check(false, "join: " + e);
+ }
+ check(!t.isAlive(), "alive after join()");
+
+ // Check double start()
+ try {
+ t.start();
+ check(false, "start() after dead");
+ } catch (IllegalThreadStateException e) {
+ }
+
+ // OK
+ synchronized (ThreadState.class) {
+ System.out.println("Success.");
+ }
+ verbose(getName() + " exiting");
+ } catch (Throwable t) {
+ t.printStackTrace();
+ System.exit(-1);
+ }
+ }
+
+ public static void check(boolean that, String msg) {
+ if (!that) {
+ System.err.println("Failure: " + msg);
+ System.exit(1);
+ }
+ }
+
+ public static void verbose(String msg) {
+ if (p != null) {
+ p.println(msg);
+ p.flush();
+ }
+ }
+}
+
+/* Expected Output:
+Success.
+Success.
+Success.
+Success.
+Success.
+Success.
+Success.
+Success.
+Success.
+Success.
+*/
More information about the kaffe
mailing list