-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: omprakaash <omsuseela@gmail.com> Signed-off-by: om prakaash <omsuseela@gmail.com>
- Loading branch information
1 parent
7fa84ec
commit 6f7eaec
Showing
6 changed files
with
194 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
use crate::utils::test_inside_container; | ||
use anyhow::{Context, Ok, Result}; | ||
use oci_spec::runtime::{ | ||
LinuxBuilder, LinuxDeviceBuilder, LinuxDeviceType, ProcessBuilder, Spec, SpecBuilder, | ||
}; | ||
use test_framework::{test_result, Test, TestGroup, TestResult}; | ||
|
||
fn create_spec() -> Result<Spec> { | ||
let device1 = LinuxDeviceBuilder::default() | ||
.path("/dev/test1") | ||
.typ(LinuxDeviceType::C) | ||
.major(10) | ||
.minor(666) | ||
.file_mode(432u32) | ||
.uid(0u32) | ||
.gid(0u32) | ||
.build() | ||
.context("failed to create device 1")?; | ||
|
||
let device2 = LinuxDeviceBuilder::default() | ||
.path("/dev/test2") | ||
.typ(LinuxDeviceType::B) | ||
.major(8) | ||
.minor(666) | ||
.file_mode(432u32) | ||
.uid(0u32) | ||
.gid(0u32) | ||
.build() | ||
.context("failed to create device 2")?; | ||
|
||
let device3 = LinuxDeviceBuilder::default() | ||
.path("/dev/test3") | ||
.typ(LinuxDeviceType::P) | ||
.major(8) | ||
.minor(666) | ||
.file_mode(432u32) | ||
.build() | ||
.context("failed to create device 3")?; | ||
|
||
let spec = SpecBuilder::default() | ||
.process( | ||
ProcessBuilder::default() | ||
.args(vec!["runtimetest".to_string(), "devices".to_string()]) | ||
.build() | ||
.expect("error in creating process config"), | ||
) | ||
.linux( | ||
LinuxBuilder::default() | ||
.devices(vec![device1, device2, device3]) | ||
.build() | ||
.context("failed to build linux spec")?, | ||
) | ||
.build() | ||
.context("failed to build spec")?; | ||
|
||
Ok(spec) | ||
} | ||
|
||
fn devices_test() -> TestResult { | ||
let spec = test_result!(create_spec()); | ||
test_inside_container(spec, &|_| Ok(())) | ||
} | ||
|
||
pub fn get_devices_test() -> TestGroup { | ||
let mut device_test_group = TestGroup::new("devices"); | ||
|
||
let test = Test::new("device_test", Box::new(devices_test)); | ||
device_test_group.add(vec![Box::new(test)]); | ||
|
||
device_test_group | ||
} |
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,2 @@ | ||
mod devices_test; | ||
pub use devices_test::get_devices_test; |
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,4 +1,5 @@ | ||
pub mod cgroups; | ||
pub mod devices; | ||
pub mod domainname; | ||
pub mod example; | ||
pub mod hooks; | ||
|
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