Updating and unXFAILing somet communication tests.

This commit is contained in:
Eric Holk 2011-07-12 15:27:17 -07:00
parent 598b50e10a
commit 1ea449e2f6
12 changed files with 80 additions and 105 deletions

View file

@ -1,6 +1,10 @@
// xfail-stage0
// xfail-stage1
// xfail-stage2
use std;
import std::task;
fn start(chan[chan[str]] c) {
let port[str] p = port();
c <| chan(p);
@ -10,9 +14,9 @@ fn start(chan[chan[str]] c) {
fn main() {
let port[chan[str]] p = port();
auto child = spawn "start" start(chan(p));
auto child = spawn start(chan(p));
auto c; p |> c;
c <| "A";
c <| "B";
yield;
task::yield();
}

View file

@ -1,6 +1,7 @@
// xfail-stage0
// xfail-stage1
// xfail-stage2
fn start(chan[chan[str]] c) {
let port[str] p = port();
c <| chan(p);
@ -8,6 +9,6 @@ fn start(chan[chan[str]] c) {
fn main() {
let port[chan[str]] p = port();
auto child = spawn "child" start(chan(p));
auto child = spawn start(chan(p));
auto c; p |> c;
}

View file

@ -1,8 +1,7 @@
// xfail-stage0
// xfail-stage1
// xfail-stage2
use std;
import std::_task;
import std::task;
fn main() -> () {
test00();
@ -14,13 +13,13 @@ fn start(int task_number) {
fn test00() {
let int i = 0;
let task t = spawn thread "child" start(i);
let task t = spawn start(i);
// Sleep long enough for the task to finish.
_task::sleep(10000u);
task::sleep(10000u);
// Try joining tasks that have already finished.
join t;
task::join(t);
log "Joined task.";
}

View file

@ -1,21 +0,0 @@
// xfail-stage0
// xfail-stage1
// xfail-stage2
use std;
import std::_task;
fn start(chan[int] c, int start, int number_of_messages) {
let int i = 0;
while (i < number_of_messages) {
c <| start + i;
i += 1;
}
}
fn main() -> () {
log "Check that we don't deadlock.";
let port[int] p = port();
let task a = spawn thread "start" start(chan(p), 0, 10);
join a;
log "Joined task";
}

View file

@ -1,8 +1,7 @@
// xfail-stage0
// xfail-stage1
// xfail-stage2
use std;
import std::_task;
import std::task;
fn start(chan[int] c, int start, int number_of_messages) {
let int i = 0;
@ -15,7 +14,7 @@ fn start(chan[int] c, int start, int number_of_messages) {
fn main() -> () {
log "Check that we don't deadlock.";
let port[int] p = port();
let task a = spawn "start" start(chan(p), 0, 10);
join a;
let task a = spawn start(chan(p), 0, 10);
task::join(a);
log "Joined task";
}

View file

@ -1,6 +1,5 @@
// xfail-stage0
// xfail-stage1
// xfail-stage2
fn start(chan[int] c, int n) {
let int i = n;
@ -16,6 +15,6 @@ fn main() {
// is likely to terminate before the child completes, so from
// the child's point of view the receiver may die. We should
// drop messages on the floor in this case, and not crash!
auto child = spawn thread "child" start(chan(p), 10);
auto child = spawn start(chan(p), 10);
auto c; p |> c;
}

View file

@ -1,11 +1,12 @@
// xfail-stage0
// xfail-stage1
// xfail-stage2
use std;
import std::task;
fn main() -> () {
log "===== SPAWNING and JOINING TASKS =====";
test00(false);
log "===== SPAWNING and JOINING THREAD TASKS =====";
test00(true);
test00();
}
fn start(int task_number) {
@ -17,22 +18,18 @@ fn start(int task_number) {
log "Finished task.";
}
fn test00(bool create_threads) {
fn test00() {
let int number_of_tasks = 8;
let int i = 0;
let vec[task] tasks = [];
while (i < number_of_tasks) {
i = i + 1;
if (create_threads) {
tasks += [spawn thread start(i)];
} else {
tasks += [spawn start(i)];
}
}
for (task t in tasks) {
join t;
task::join(t);
}
log "Joined all task.";

View file

@ -1,11 +1,11 @@
// xfail-stage0
// xfail-stage1
// xfail-stage2
use std;
import std::task;
fn main() -> () {
log "===== WITHOUT THREADS =====";
test00(false);
log "====== WITH THREADS ======";
test00(true);
test00();
}
fn test00_start(chan[int] ch, int message, int count) {
@ -19,7 +19,7 @@ fn test00_start(chan[int] ch, int message, int count) {
log "Ending test00_start";
}
fn test00(bool is_multithreaded) {
fn test00() {
let int number_of_tasks = 16;
let int number_of_messages = 4;
@ -33,12 +33,7 @@ fn test00(bool is_multithreaded) {
// Create and spawn tasks...
let vec[task] tasks = [];
while (i < number_of_tasks) {
if (is_multithreaded) {
tasks += [
spawn thread test00_start(ch, i, number_of_messages)];
} else {
tasks += [spawn test00_start(ch, i, number_of_messages)];
}
i = i + 1;
}
@ -55,7 +50,7 @@ fn test00(bool is_multithreaded) {
// Join spawned tasks...
for (task t in tasks) {
join t;
task::join(t);
}
log "Completed: Final number is: ";

View file

@ -1,6 +1,8 @@
// xfail-stage0
// xfail-stage1
// xfail-stage2
use std;
import std::task;
fn main() -> () {
test00();
}
@ -37,10 +39,10 @@ fn test00() {
i += 1;
}
join t0;
join t1;
join t2;
join t3;
task::join(t0);
task::join(t1);
task::join(t2);
task::join(t3);
assert (sum == (((number_of_messages * 4) *
((number_of_messages * 4) - 1)) / 2));

View file

@ -1,6 +1,8 @@
// xfail-stage0
// xfail-stage1
// xfail-stage2
use std;
import std::task;
fn main() -> () {
test00();
}
@ -19,13 +21,13 @@ fn test00() {
let port[int] p = port();
let int number_of_messages = 10;
let task t0 = spawn thread test00_start(chan(p),
let task t0 = spawn test00_start(chan(p),
number_of_messages * 0, number_of_messages);
let task t1 = spawn thread test00_start(chan(p),
let task t1 = spawn test00_start(chan(p),
number_of_messages * 1, number_of_messages);
let task t2 = spawn thread test00_start(chan(p),
let task t2 = spawn test00_start(chan(p),
number_of_messages * 2, number_of_messages);
let task t3 = spawn thread test00_start(chan(p),
let task t3 = spawn test00_start(chan(p),
number_of_messages * 3, number_of_messages);
let int i = 0;
@ -37,10 +39,10 @@ fn test00() {
i += 1;
}
join t0;
join t1;
join t2;
join t3;
task::join(t0);
task::join(t1);
task::join(t2);
task::join(t3);
assert (sum == (((number_of_messages * 4) *
((number_of_messages * 4) - 1)) / 2));

View file

@ -1,6 +1,8 @@
// xfail-stage0
// xfail-stage1
// xfail-stage2
use std;
import std::task;
fn main() -> () {
test00();
}
@ -19,7 +21,7 @@ fn test00() {
let port[int] p = port();
let int number_of_messages = 10;
let task t0 = spawn thread "child"
let task t0 = spawn
test00_start(chan(p), number_of_messages);
let int i = 0;
@ -28,7 +30,7 @@ fn test00() {
i += 1;
}
join t0;
task::join(t0);
assert (sum == (number_of_messages * (number_of_messages - 1)) / 2);
}

View file

@ -1,9 +1,11 @@
// xfail-stage0
// xfail-stage1
// xfail-stage2
use std;
import std::task;
fn main() -> () {
test00(true);
test00();
// test01();
test02();
test03();
@ -23,7 +25,7 @@ fn test00_start(chan[int] ch, int message, int count) {
log "Ending test00_start";
}
fn test00(bool is_multithreaded) {
fn test00() {
let int number_of_tasks = 1;
let int number_of_messages = 4;
log "Creating tasks";
@ -36,13 +38,8 @@ fn test00(bool is_multithreaded) {
let vec[task] tasks = [];
while (i < number_of_tasks) {
i = i + 1;
if (is_multithreaded) {
tasks += [
spawn thread test00_start(ch, i, number_of_messages)];
} else {
tasks += [spawn test00_start(ch, i, number_of_messages)];
}
}
let int sum = 0;
for (task t in tasks) {
@ -55,7 +52,7 @@ fn test00(bool is_multithreaded) {
}
for (task t in tasks) {
join t;
task::join(t);
}
log "Completed: Final number is: ";
@ -89,9 +86,9 @@ obj vector(mutable int x, int y) {
fn test03() {
log "Creating object ...";
let mutable vector v = vector(1, 2);
let vector v = vector(1, 2);
log "created object ...";
let mutable vector t = v;
let vector t = v;
log v.length();
}
@ -109,7 +106,7 @@ fn test04() {
let int i = 4;
while (i > 0) {
i = i - 1;
spawn thread test04_start();
spawn test04_start();
}
log "Finishing up.";
}
@ -125,7 +122,7 @@ fn test05_start(chan[int] ch) {
fn test05() {
let port[int] po = port();
let chan[int] ch = chan(po);
spawn thread test05_start(ch);
spawn test05_start(ch);
let int value; po |> value;
po |> value;
po |> value;
@ -150,12 +147,11 @@ fn test06() {
let vec[task] tasks = [];
while (i < number_of_tasks) {
i = i + 1;
tasks += [spawn thread test06_start(i)];
// tasks += [spawn test06_start(i)];
tasks += [spawn test06_start(i)];
}
for (task t in tasks) {
join t;
task::join(t);
}
}