about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorSeo Sanghyeon <sanxiyn@gmail.com>2016-08-02 00:12:40 +0900
committerGitHub <noreply@github.com>2016-08-02 00:12:40 +0900
commita790fbce23e823cde291d2c7452efdb7609303bb (patch)
treeabdbdce983bf62ca6a983951594cb0dcbb5b2bb9 /src
parent2effa8982e5b09351ed93a132a5b0962245ea68a (diff)
parent3ea293ddf2af66c9a2e720ce3139aed75787d890 (diff)
downloadrust-a790fbce23e823cde291d2c7452efdb7609303bb.tar.gz
rust-a790fbce23e823cde291d2c7452efdb7609303bb.zip
Rollup merge of #35140 - the-kenny:tcp-stress-test-const-thread-count, r=alexcrichton
tcp-stress-test: Pull out thread count as a constant

This PR factors out the number of concurrent threads used in `tcp-stress-test.rs` to a constant at the top of the file.

We at @NixOS had to lower our thread count as the chrooted-builds don't allow that many threads.

This change will make it easier to lower/increase the count in the future (I actually forgot to change the second `1000` when I was working on this). Another benefit is the removal of magic numbers in the test suite.

This is related to https://github.com/rust-lang/rust/issues/35107
Diffstat (limited to 'src')
-rw-r--r--src/test/run-pass/tcp-stress.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/test/run-pass/tcp-stress.rs b/src/test/run-pass/tcp-stress.rs
index dfc86497c96..0ba019c591c 100644
--- a/src/test/run-pass/tcp-stress.rs
+++ b/src/test/run-pass/tcp-stress.rs
@@ -21,6 +21,8 @@ use std::sync::mpsc::channel;
 use std::time::Duration;
 use std::thread::{self, Builder};
 
+const TARGET_CNT: usize = 200;
+
 fn main() {
     // This test has a chance to time out, try to not let it time out
     thread::spawn(move|| -> () {
@@ -42,8 +44,9 @@ fn main() {
     });
 
     let (tx, rx) = channel();
+
     let mut spawned_cnt = 0;
-    for _ in 0..1000 {
+    for _ in 0..TARGET_CNT {
         let tx = tx.clone();
         let res = Builder::new().stack_size(64 * 1024).spawn(move|| {
             match TcpStream::connect(addr) {
@@ -66,6 +69,6 @@ fn main() {
     for _ in 0..spawned_cnt {
         rx.recv().unwrap();
     }
-    assert_eq!(spawned_cnt, 1000);
+    assert_eq!(spawned_cnt, TARGET_CNT);
     process::exit(0);
 }