forked from aya-rs/aya
-
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: replace lo interface with dummy interface
Fixes: aya-rs#422 Signed-off-by: murex971 <nupur202000@gmail.com>
- Loading branch information
Showing
4 changed files
with
58 additions
and
9 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
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,30 @@ | ||
use std::process::Command; | ||
|
||
pub(crate) struct DummyInterface; | ||
|
||
impl DummyInterface { | ||
pub const TEST_DUMMY: &str = "aya-dummy"; | ||
|
||
pub fn new() -> Option<Self> { | ||
let output = Command::new("ip") | ||
.args(["link", "add", Self::TEST_DUMMY, "type", "dummy"]) | ||
.output() | ||
.expect("failed to run ip command"); | ||
|
||
if output.status.success() { | ||
None | ||
} else { | ||
Some(Self) | ||
} | ||
} | ||
} | ||
|
||
impl Drop for DummyInterface { | ||
fn drop(&mut self) { | ||
let output = Command::new("ip") | ||
.args(["link", "del", Self::TEST_DUMMY]) | ||
.output() | ||
.expect("failed to run ip command"); | ||
assert!(output.status.success()) | ||
} | ||
} |