-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(rsjudge-runner): 🚚 normalize test names
- Loading branch information
1 parent
2869e4d
commit fbbdce6
Showing
9 changed files
with
69 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use capctl::FullCapState; | ||
use capctl::CapState; | ||
|
||
fn main() { | ||
eprintln!("Start normal binary"); | ||
dbg!(FullCapState::get_current().unwrap()); | ||
dbg!(CapState::get_current().unwrap()); | ||
eprintln!("End normal binary"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use std::{path::PathBuf, time::Duration}; | ||
|
||
use rsjudge_runner::utils::resources::{rusage::WaitForResourceUsage, RunWithResourceLimit}; | ||
use rsjudge_traits::resource::ResourceLimit; | ||
use tokio::{process::Command, time::Instant}; | ||
|
||
#[tokio::main] | ||
async fn main() -> anyhow::Result<()> { | ||
let examples = PathBuf::from(env!("CARGO_MANIFEST_DIR")) | ||
.parent() | ||
.and_then(|p| p.parent()) | ||
.ok_or_else(|| anyhow::anyhow!("cannot find crate root"))? | ||
.join("target/debug/examples"); | ||
let spin_lock = examples.join("spin_lock"); | ||
eprintln!("Starting spin_lock with CPU time limit of 1s, wall time limit 2s:"); | ||
let start_time = Instant::now(); | ||
let _ = Command::new(spin_lock) | ||
.spawn_with_resource_limit(ResourceLimit::new( | ||
Some(Duration::from_secs(1)), | ||
Some(Duration::from_secs(2)), | ||
None, | ||
None, | ||
))? | ||
.wait_for_resource_usage() | ||
.await; | ||
|
||
dbg!(start_time.elapsed()); | ||
let sleep = examples.join("sleep"); | ||
eprintln!("Starting sleep with CPU time limit of 1s, wall time limit 2s:"); | ||
let start_time = Instant::now(); | ||
let _ = Command::new(sleep) | ||
.spawn_with_resource_limit(ResourceLimit::new( | ||
Some(Duration::from_secs(1)), | ||
Some(Duration::from_secs(2)), | ||
None, | ||
None, | ||
))? | ||
.wait_for_resource_usage() | ||
.await; | ||
|
||
dbg!(start_time.elapsed()); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,6 @@ | ||
use std::{path::PathBuf, time::Duration}; | ||
use std::{thread::sleep, time::Duration}; | ||
|
||
use capctl::{Cap, CapState}; | ||
use rsjudge_runner::{ | ||
use_caps, | ||
utils::resources::{rusage::WaitForResourceUsage, RunWithResourceLimit}, | ||
}; | ||
use rsjudge_traits::resource::ResourceLimit; | ||
use tokio::process::Command; | ||
|
||
#[tokio::main] | ||
async fn main() -> anyhow::Result<()> { | ||
use_caps!(Cap::DAC_READ_SEARCH); | ||
dbg!(CapState::get_current().unwrap()); | ||
|
||
let examples = PathBuf::from(env!("CARGO_MANIFEST_DIR")) | ||
.parent() | ||
.and_then(|p| p.parent()) | ||
.ok_or_else(|| anyhow::anyhow!("cannot find crate root"))? | ||
.join("target/debug/examples"); | ||
let sleep_inner = examples.join("sleep_inner"); | ||
dbg!(&sleep_inner); | ||
let status = Command::new(sleep_inner) | ||
.spawn_with_resource_limit(ResourceLimit::new( | ||
Some(Duration::from_secs(1)), | ||
Some(Duration::from_secs(2)), | ||
None, | ||
None, | ||
))? | ||
.wait_for_resource_usage() | ||
.await?; | ||
dbg!(status); | ||
Ok(()) | ||
fn main() { | ||
println!("Trying to sleep for 10s."); | ||
sleep(Duration::from_secs(10)); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use std::time::{Duration, Instant}; | ||
|
||
fn main() { | ||
println!("Trying to spin for 10s."); | ||
let start_time = Instant::now(); | ||
while start_time.elapsed() < Duration::from_secs(10) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters