Skip to content

Commit fcc05d0

Browse files
authored
CI add timeout (#330)
2 parents 6e7b2f7 + de0b105 commit fcc05d0

File tree

9 files changed

+47
-22
lines changed

9 files changed

+47
-22
lines changed

.github/workflows/ci-preemptive.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ export RUST_BACKTRACE=1
1717

1818
# test open-coroutine-core mod
1919
cd "${PROJECT_DIR}"/core
20-
"${CARGO}" test --target "${TARGET}" --features preemptive
21-
"${CARGO}" test --target "${TARGET}" --features preemptive --release
20+
"${CARGO}" test --target "${TARGET}" --features preemptive,ci
21+
"${CARGO}" test --target "${TARGET}" --features preemptive,ci --release
2222

2323
# test open-coroutine
2424
cd "${PROJECT_DIR}"/open-coroutine
25-
"${CARGO}" test --target "${TARGET}" --features preemptive
26-
"${CARGO}" test --target "${TARGET}" --features preemptive --release
25+
"${CARGO}" test --target "${TARGET}" --features preemptive,ci
26+
"${CARGO}" test --target "${TARGET}" --features preemptive,ci --release
2727

2828
# test io_uring
2929
if [ "${TARGET}" = "x86_64-unknown-linux-gnu" ]; then
3030
cd "${PROJECT_DIR}"/core
31-
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,preemptive
32-
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,preemptive --release
31+
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,preemptive,ci
32+
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,preemptive,ci --release
3333
cd "${PROJECT_DIR}"/open-coroutine
34-
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,preemptive
35-
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,preemptive --release
34+
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,preemptive,ci
35+
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,preemptive,ci --release
3636
fi

.github/workflows/ci.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ export RUST_BACKTRACE=1
1717

1818
# test open-coroutine-core mod
1919
cd "${PROJECT_DIR}"/core
20-
"${CARGO}" test --target "${TARGET}"
21-
"${CARGO}" test --target "${TARGET}" --release
20+
"${CARGO}" test --target "${TARGET}" --features ci
21+
"${CARGO}" test --target "${TARGET}" --features ci --release
2222

2323
# test open-coroutine
2424
cd "${PROJECT_DIR}"/open-coroutine
25-
"${CARGO}" test --target "${TARGET}"
26-
"${CARGO}" test --target "${TARGET}" --release
25+
"${CARGO}" test --target "${TARGET}" --features ci
26+
"${CARGO}" test --target "${TARGET}" --features ci --release
2727

2828
# test io_uring
2929
if [ "${TARGET}" = "x86_64-unknown-linux-gnu" ]; then
3030
cd "${PROJECT_DIR}"/core
31-
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring
32-
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring --release
31+
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,ci
32+
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,ci --release
3333
cd "${PROJECT_DIR}"/open-coroutine
34-
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring
35-
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring --release
34+
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,ci
35+
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,ci --release
3636
fi

core/Cargo.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ crossbeam-utils = { workspace = true, optional = true }
3535
psm.workspace = true
3636

3737
[target.'cfg(unix)'.dependencies]
38-
libc.workspace = true
39-
nix = { workspace = true, features = ["signal"] }
4038
mio = { workspace = true, features = [
4139
"net",
4240
"os-poll",
4341
"os-ext",
4442
], default-features = false, optional = true }
43+
nix = { workspace = true, features = ["signal"] }
44+
libc.workspace = true
4545

4646
[target.'cfg(target_os = "linux")'.dependencies]
4747
io-uring = { workspace = true, optional = true }
@@ -72,10 +72,15 @@ slab.workspace = true
7272
backtrace.workspace = true
7373

7474
[features]
75+
default = ["log", "syscall"]
76+
7577
# Print some help log.
7678
# Enable for default.
7779
log = ["tracing", "tracing-subscriber", "time"]
7880

81+
# This feature only used in open-coroutine inner, don't use it in your project.
82+
ci = []
83+
7984
# low-level raw coroutine
8085
korosensei = ["corosensei", "uuid", "nix/pthread", "educe"]
8186

@@ -91,5 +96,3 @@ io_uring = ["net", "io-uring"]
9196

9297
# Provide syscall implementation.
9398
syscall = ["net"]
94-
95-
default = ["log", "syscall"]

core/src/common/ci.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/// just for CI
2+
pub fn init() {
3+
let _ = std::thread::spawn(|| {
4+
// exit after 600 seconds, just for CI
5+
std::thread::sleep(std::time::Duration::from_secs(600));
6+
std::process::exit(-1);
7+
});
8+
}

core/src/common/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ use std::ffi::c_int;
33
use std::sync::atomic::{AtomicUsize, Ordering};
44
use std::time::{Duration, SystemTime, UNIX_EPOCH};
55

6+
/// CI tools.
7+
#[cfg(feature = "ci")]
8+
pub mod ci;
9+
610
/// Constants.
711
pub mod constants;
812

core/src/net/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ impl EventLoops {
6060
/// Init the `EventLoops`.
6161
pub fn init(config: &Config) {
6262
_ = INSTANCE.get_or_init(|| {
63+
#[cfg(feature = "ci")]
64+
crate::common::ci::init();
6365
let loops = Self::new(
6466
config.event_loop_size(),
6567
config.stack_size(),

hook/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@ windows-sys = { workspace = true, features = [
3030
minhook.workspace = true
3131

3232
[features]
33+
default = ["open-coroutine-core/default"]
34+
3335
# Print some help log.
3436
# Enable for default.
3537
log = ["open-coroutine-core/log"]
3638

39+
# This feature only used in open-coroutine inner, don't use it in your project.
40+
ci = ["open-coroutine-core/ci"]
41+
3742
# Provide preemptive scheduling implementation.
3843
# Enable for default.
3944
preemptive = ["open-coroutine-core/preemptive"]
@@ -47,7 +52,5 @@ io_uring = ["open-coroutine-core/io_uring"]
4752
# Provide syscall implementation.
4853
syscall = ["open-coroutine-core/syscall"]
4954

50-
default = ["open-coroutine-core/default"]
51-
5255
[lib]
5356
crate-type = ["cdylib"]

open-coroutine/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ default = ["open-coroutine-hook/default", "open-coroutine-core/default"]
4545
# Enable for default.
4646
log = ["open-coroutine-hook/log", "open-coroutine-core/log"]
4747

48+
# This feature only used in open-coroutine inner, don't use it in your project.
49+
ci = ["open-coroutine-hook/ci", "open-coroutine-core/ci"]
50+
4851
# Provide preemptive scheduling implementation.
4952
# Enable for default.
5053
preemptive = ["open-coroutine-hook/preemptive", "open-coroutine-core/preemptive"]

open-coroutine/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ pub fn init(config: Config) {
9292
unsafe { open_coroutine_init(config) },
9393
"open-coroutine init failed !"
9494
);
95+
#[cfg(feature = "ci")]
96+
open_coroutine_core::common::ci::init();
9597
}
9698

9799
/// Shutdown the open-coroutine.

0 commit comments

Comments
 (0)