Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/ci-preemptive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ export RUST_BACKTRACE=1

# test open-coroutine-core mod
cd "${PROJECT_DIR}"/core
"${CARGO}" test --target "${TARGET}" --features preemptive
"${CARGO}" test --target "${TARGET}" --features preemptive --release
"${CARGO}" test --target "${TARGET}" --features preemptive,ci
"${CARGO}" test --target "${TARGET}" --features preemptive,ci --release

# test open-coroutine
cd "${PROJECT_DIR}"/open-coroutine
"${CARGO}" test --target "${TARGET}" --features preemptive
"${CARGO}" test --target "${TARGET}" --features preemptive --release
"${CARGO}" test --target "${TARGET}" --features preemptive,ci
"${CARGO}" test --target "${TARGET}" --features preemptive,ci --release

# test io_uring
if [ "${TARGET}" = "x86_64-unknown-linux-gnu" ]; then
cd "${PROJECT_DIR}"/core
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,preemptive
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,preemptive --release
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,preemptive,ci
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,preemptive,ci --release
cd "${PROJECT_DIR}"/open-coroutine
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,preemptive
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,preemptive --release
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,preemptive,ci
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,preemptive,ci --release
fi
16 changes: 8 additions & 8 deletions .github/workflows/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ export RUST_BACKTRACE=1

# test open-coroutine-core mod
cd "${PROJECT_DIR}"/core
"${CARGO}" test --target "${TARGET}"
"${CARGO}" test --target "${TARGET}" --release
"${CARGO}" test --target "${TARGET}" --features ci
"${CARGO}" test --target "${TARGET}" --features ci --release

# test open-coroutine
cd "${PROJECT_DIR}"/open-coroutine
"${CARGO}" test --target "${TARGET}"
"${CARGO}" test --target "${TARGET}" --release
"${CARGO}" test --target "${TARGET}" --features ci
"${CARGO}" test --target "${TARGET}" --features ci --release

# test io_uring
if [ "${TARGET}" = "x86_64-unknown-linux-gnu" ]; then
cd "${PROJECT_DIR}"/core
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring --release
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,ci
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,ci --release
cd "${PROJECT_DIR}"/open-coroutine
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring --release
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,ci
"${CARGO}" test --target "${TARGET}" --no-default-features --features io_uring,ci --release
fi
11 changes: 7 additions & 4 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ crossbeam-utils = { workspace = true, optional = true }
psm.workspace = true

[target.'cfg(unix)'.dependencies]
libc.workspace = true
nix = { workspace = true, features = ["signal"] }
mio = { workspace = true, features = [
"net",
"os-poll",
"os-ext",
], default-features = false, optional = true }
nix = { workspace = true, features = ["signal"] }
libc.workspace = true

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

[features]
default = ["log", "syscall"]

# Print some help log.
# Enable for default.
log = ["tracing", "tracing-subscriber", "time"]

# This feature only used in open-coroutine inner, don't use it in your project.
ci = []

# low-level raw coroutine
korosensei = ["corosensei", "uuid", "nix/pthread", "educe"]

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

# Provide syscall implementation.
syscall = ["net"]

default = ["log", "syscall"]
8 changes: 8 additions & 0 deletions core/src/common/ci.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/// just for CI
pub fn init() {
let _ = std::thread::spawn(|| {
// exit after 600 seconds, just for CI
std::thread::sleep(std::time::Duration::from_secs(600));
std::process::exit(-1);
});
}
4 changes: 4 additions & 0 deletions core/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ use std::ffi::c_int;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::time::{Duration, SystemTime, UNIX_EPOCH};

/// CI tools.
#[cfg(feature = "ci")]
pub mod ci;

/// Constants.
pub mod constants;

Expand Down
2 changes: 2 additions & 0 deletions core/src/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ impl EventLoops {
/// Init the `EventLoops`.
pub fn init(config: &Config) {
_ = INSTANCE.get_or_init(|| {
#[cfg(feature = "ci")]
crate::common::ci::init();
let loops = Self::new(
config.event_loop_size(),
config.stack_size(),
Expand Down
7 changes: 5 additions & 2 deletions hook/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@ windows-sys = { workspace = true, features = [
minhook.workspace = true

[features]
default = ["open-coroutine-core/default"]

# Print some help log.
# Enable for default.
log = ["open-coroutine-core/log"]

# This feature only used in open-coroutine inner, don't use it in your project.
ci = ["open-coroutine-core/ci"]

# Provide preemptive scheduling implementation.
# Enable for default.
preemptive = ["open-coroutine-core/preemptive"]
Expand All @@ -47,7 +52,5 @@ io_uring = ["open-coroutine-core/io_uring"]
# Provide syscall implementation.
syscall = ["open-coroutine-core/syscall"]

default = ["open-coroutine-core/default"]

[lib]
crate-type = ["cdylib"]
3 changes: 3 additions & 0 deletions open-coroutine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ default = ["open-coroutine-hook/default", "open-coroutine-core/default"]
# Enable for default.
log = ["open-coroutine-hook/log", "open-coroutine-core/log"]

# This feature only used in open-coroutine inner, don't use it in your project.
ci = ["open-coroutine-hook/ci", "open-coroutine-core/ci"]

# Provide preemptive scheduling implementation.
# Enable for default.
preemptive = ["open-coroutine-hook/preemptive", "open-coroutine-core/preemptive"]
Expand Down
2 changes: 2 additions & 0 deletions open-coroutine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ pub fn init(config: Config) {
unsafe { open_coroutine_init(config) },
"open-coroutine init failed !"
);
#[cfg(feature = "ci")]
open_coroutine_core::common::ci::init();
}

/// Shutdown the open-coroutine.
Expand Down
Loading