mirror of
https://github.com/rust-vmm/vhost-device.git
synced 2025-12-29 00:41:19 +00:00
sound: test cli backend argument
Signed-off-by: Albert Esteve <aesteve@redhat.com>
This commit is contained in:
parent
6c5b2db7db
commit
4867edc009
@ -91,7 +91,7 @@ impl From<stream::Error> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(ValueEnum, Clone, Default, Debug)]
|
||||
#[derive(ValueEnum, Clone, Copy, Default, Debug, Eq, PartialEq)]
|
||||
pub enum BackendType {
|
||||
#[default]
|
||||
Null,
|
||||
@ -232,6 +232,10 @@ impl SoundConfig {
|
||||
pub fn get_socket_path(&self) -> String {
|
||||
String::from(&self.socket)
|
||||
}
|
||||
|
||||
pub fn get_audio_backend(&self) -> BackendType {
|
||||
self.audio_backend
|
||||
}
|
||||
}
|
||||
|
||||
pub struct IOMessage {
|
||||
|
||||
@ -55,7 +55,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_vsock_config_setup() {
|
||||
fn test_sound_config_setup() {
|
||||
let args = SoundArgs::from_args("/tmp/vhost-sound.socket");
|
||||
|
||||
let config = SoundConfig::try_from(args);
|
||||
@ -64,4 +64,22 @@ mod tests {
|
||||
let config = config.unwrap();
|
||||
assert_eq!(config.get_socket_path(), "/tmp/vhost-sound.socket");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn test_cli_backend_arg() {
|
||||
let args: SoundArgs = Parser::parse_from([
|
||||
"",
|
||||
"--socket",
|
||||
"/tmp/vhost-sound.socket ",
|
||||
"--backend",
|
||||
"null",
|
||||
]);
|
||||
|
||||
let config = SoundConfig::try_from(args);
|
||||
assert!(config.is_ok());
|
||||
|
||||
let config = config.unwrap();
|
||||
assert_eq!(config.get_audio_backend(), BackendType::Null);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user