Skip to content

Commit

Permalink
Adjust test expectations
Browse files Browse the repository at this point in the history
  • Loading branch information
Pehrsons committed Apr 24, 2024
1 parent a75c5b2 commit a1f751d
Showing 1 changed file with 121 additions and 21 deletions.
142 changes: 121 additions & 21 deletions src/backend/tests/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,10 @@ fn test_ops_stereo_input_duplex_stream_drain() {
fn test_ops_input_voice_stream_init_and_destroy() {
test_default_input_voice_stream_operation("input voice stream: init and destroy", |stream| {
let stm = unsafe { &mut *(stream as *mut AudioUnitStream) };
assert!(stm.core_stream_data.using_voice_processing_unit());
assert_eq!(
stm.core_stream_data.using_voice_processing_unit(),
macos_kernel_major_version().unwrap() != MACOS_KERNEL_MAJOR_VERSION_MONTEREY
);
});
}

Expand All @@ -1244,7 +1247,10 @@ fn test_ops_input_voice_stream_start() {
test_default_input_voice_stream_operation("input voice stream: start", |stream| {
assert_eq!(unsafe { OPS.stream_start.unwrap()(stream) }, ffi::CUBEB_OK);
let stm = unsafe { &mut *(stream as *mut AudioUnitStream) };
assert!(stm.core_stream_data.using_voice_processing_unit());
assert_eq!(
stm.core_stream_data.using_voice_processing_unit(),
macos_kernel_major_version().unwrap() != MACOS_KERNEL_MAJOR_VERSION_MONTEREY
);
});
}

Expand All @@ -1253,15 +1259,21 @@ fn test_ops_input_voice_stream_stop() {
test_default_input_voice_stream_operation("input voice stream: stop", |stream| {
assert_eq!(unsafe { OPS.stream_stop.unwrap()(stream) }, ffi::CUBEB_OK);
let stm = unsafe { &mut *(stream as *mut AudioUnitStream) };
assert!(stm.core_stream_data.using_voice_processing_unit());
assert_eq!(
stm.core_stream_data.using_voice_processing_unit(),
macos_kernel_major_version().unwrap() != MACOS_KERNEL_MAJOR_VERSION_MONTEREY
);
});
}

#[test]
fn test_ops_duplex_voice_stream_init_and_destroy() {
test_default_duplex_voice_stream_operation("duplex voice stream: init and destroy", |stream| {
let stm = unsafe { &mut *(stream as *mut AudioUnitStream) };
assert!(stm.core_stream_data.using_voice_processing_unit());
assert_eq!(
stm.core_stream_data.using_voice_processing_unit(),
macos_kernel_major_version().unwrap() != MACOS_KERNEL_MAJOR_VERSION_MONTEREY
);
});
}

Expand All @@ -1270,7 +1282,10 @@ fn test_ops_duplex_voice_stream_start() {
test_default_duplex_voice_stream_operation("duplex voice stream: start", |stream| {
assert_eq!(unsafe { OPS.stream_start.unwrap()(stream) }, ffi::CUBEB_OK);
let stm = unsafe { &mut *(stream as *mut AudioUnitStream) };
assert!(stm.core_stream_data.using_voice_processing_unit());
assert_eq!(
stm.core_stream_data.using_voice_processing_unit(),
macos_kernel_major_version().unwrap() != MACOS_KERNEL_MAJOR_VERSION_MONTEREY
);
});
}

Expand All @@ -1279,7 +1294,10 @@ fn test_ops_duplex_voice_stream_stop() {
test_default_duplex_voice_stream_operation("duplex voice stream: stop", |stream| {
assert_eq!(unsafe { OPS.stream_stop.unwrap()(stream) }, ffi::CUBEB_OK);
let stm = unsafe { &mut *(stream as *mut AudioUnitStream) };
assert!(stm.core_stream_data.using_voice_processing_unit());
assert_eq!(
stm.core_stream_data.using_voice_processing_unit(),
macos_kernel_major_version().unwrap() != MACOS_KERNEL_MAJOR_VERSION_MONTEREY
);
});
}

Expand All @@ -1291,7 +1309,10 @@ fn test_ops_duplex_voice_stream_drain() {
|stream| {
assert_eq!(unsafe { OPS.stream_start.unwrap()(stream) }, ffi::CUBEB_OK);
let stm = unsafe { &mut *(stream as *mut AudioUnitStream) };
assert!(stm.core_stream_data.using_voice_processing_unit());
assert_eq!(
stm.core_stream_data.using_voice_processing_unit(),
macos_kernel_major_version().unwrap() != MACOS_KERNEL_MAJOR_VERSION_MONTEREY
);
thread::sleep(Duration::from_millis(10));
},
);
Expand All @@ -1318,23 +1339,34 @@ fn test_ops_timing_sensitive_multiple_voice_stream_init_and_destroy() {
context_ptr,
|stream| {
let stm = unsafe { &mut *(stream as *mut AudioUnitStream) };
assert!(stm.core_stream_data.using_voice_processing_unit());
assert_eq!(
stm.core_stream_data.using_voice_processing_unit(),
macos_kernel_major_version().unwrap() != MACOS_KERNEL_MAJOR_VERSION_MONTEREY
);

// Two concurrent vpio streams are supported.
test_default_input_voice_stream_operation_on_context(
"multiple voice streams: stream 2, input-only",
context_ptr,
|stream| {
let stm = unsafe { &mut *(stream as *mut AudioUnitStream) };
assert!(stm.core_stream_data.using_voice_processing_unit());
assert_eq!(
stm.core_stream_data.using_voice_processing_unit(),
macos_kernel_major_version().unwrap()
!= MACOS_KERNEL_MAJOR_VERSION_MONTEREY
);

// Three concurrent vpio streams are supported.
test_default_duplex_voice_stream_operation_on_context(
"multiple voice streams: stream 3, duplex",
context_ptr,
|stream| {
let stm = unsafe { &mut *(stream as *mut AudioUnitStream) };
assert!(stm.core_stream_data.using_voice_processing_unit());
assert_eq!(
stm.core_stream_data.using_voice_processing_unit(),
macos_kernel_major_version().unwrap()
!= MACOS_KERNEL_MAJOR_VERSION_MONTEREY
);
},
);
},
Expand All @@ -1348,7 +1380,10 @@ fn test_ops_timing_sensitive_multiple_voice_stream_init_and_destroy() {
context_ptr,
|stream| {
let stm = unsafe { &mut *(stream as *mut AudioUnitStream) };
assert!(stm.core_stream_data.using_voice_processing_unit());
assert_eq!(
stm.core_stream_data.using_voice_processing_unit(),
macos_kernel_major_version().unwrap() != MACOS_KERNEL_MAJOR_VERSION_MONTEREY
);
t2 = Instant::now();

// Fifth stream uses vpio, allows reuse of one already created.
Expand All @@ -1357,7 +1392,11 @@ fn test_ops_timing_sensitive_multiple_voice_stream_init_and_destroy() {
context_ptr,
|stream| {
let stm = unsafe { &mut *(stream as *mut AudioUnitStream) };
assert!(stm.core_stream_data.using_voice_processing_unit());
assert_eq!(
stm.core_stream_data.using_voice_processing_unit(),
macos_kernel_major_version().unwrap()
!= MACOS_KERNEL_MAJOR_VERSION_MONTEREY
);
t3 = Instant::now();

// Sixth stream uses vpio, allows reuse of one already created.
Expand All @@ -1366,7 +1405,11 @@ fn test_ops_timing_sensitive_multiple_voice_stream_init_and_destroy() {
context_ptr,
|stream| {
let stm = unsafe { &mut *(stream as *mut AudioUnitStream) };
assert!(stm.core_stream_data.using_voice_processing_unit());
assert_eq!(
stm.core_stream_data.using_voice_processing_unit(),
macos_kernel_major_version().unwrap()
!= MACOS_KERNEL_MAJOR_VERSION_MONTEREY
);
t4 = Instant::now();

// Seventh stream uses vpio, but is created anew.
Expand All @@ -1375,7 +1418,11 @@ fn test_ops_timing_sensitive_multiple_voice_stream_init_and_destroy() {
context_ptr,
|stream| {
let stm = unsafe { &mut *(stream as *mut AudioUnitStream) };
assert!(stm.core_stream_data.using_voice_processing_unit());
assert_eq!(
stm.core_stream_data.using_voice_processing_unit(),
macos_kernel_major_version().unwrap()
!= MACOS_KERNEL_MAJOR_VERSION_MONTEREY
);
t5 = Instant::now();
},
);
Expand Down Expand Up @@ -1457,7 +1504,10 @@ fn test_ops_timing_sensitive_multiple_duplex_voice_stream_start() {
context_ptr,
|stream| {
let stm = unsafe { &mut *(stream as *mut AudioUnitStream) };
assert!(stm.core_stream_data.using_voice_processing_unit());
assert_eq!(
stm.core_stream_data.using_voice_processing_unit(),
macos_kernel_major_version().unwrap() != MACOS_KERNEL_MAJOR_VERSION_MONTEREY
);
assert_eq!(unsafe { OPS.stream_start.unwrap()(stream) }, ffi::CUBEB_OK);
},
);
Expand All @@ -1468,7 +1518,10 @@ fn test_ops_timing_sensitive_multiple_duplex_voice_stream_start() {
context_ptr,
|stream| {
let stm = unsafe { &mut *(stream as *mut AudioUnitStream) };
assert!(stm.core_stream_data.using_voice_processing_unit());
assert_eq!(
stm.core_stream_data.using_voice_processing_unit(),
macos_kernel_major_version().unwrap() != MACOS_KERNEL_MAJOR_VERSION_MONTEREY
);
assert_eq!(unsafe { OPS.stream_start.unwrap()(stream) }, ffi::CUBEB_OK);
},
);
Expand All @@ -1494,7 +1547,10 @@ fn test_ops_timing_sensitive_multiple_duplex_voice_stream_params() {
context_ptr,
|stream| {
let stm = unsafe { &mut *(stream as *mut AudioUnitStream) };
assert!(stm.core_stream_data.using_voice_processing_unit());
assert_eq!(
stm.core_stream_data.using_voice_processing_unit(),
macos_kernel_major_version().unwrap() != MACOS_KERNEL_MAJOR_VERSION_MONTEREY
);
assert_eq!(
unsafe {
OPS.stream_set_input_processing_params.unwrap()(
Expand All @@ -1518,7 +1574,10 @@ fn test_ops_timing_sensitive_multiple_duplex_voice_stream_params() {
context_ptr,
|stream| {
let stm = unsafe { &mut *(stream as *mut AudioUnitStream) };
assert!(stm.core_stream_data.using_voice_processing_unit());
assert_eq!(
stm.core_stream_data.using_voice_processing_unit(),
macos_kernel_major_version().unwrap() != MACOS_KERNEL_MAJOR_VERSION_MONTEREY
);
let queue = stm.queue.clone();
// Test that input processing params does not carry over when reusing vpio.
let mut bypass: u32 = 0;
Expand Down Expand Up @@ -1568,6 +1627,10 @@ fn test_ops_timing_sensitive_multiple_duplex_voice_stream_params() {

#[test]
fn test_ops_duplex_voice_stream_set_input_mute() {
if macos_kernel_major_version().unwrap() == MACOS_KERNEL_MAJOR_VERSION_MONTEREY {
// We disable VPIO on Monterey.
return;
}
test_default_duplex_voice_stream_operation("duplex voice stream: mute", |stream| {
assert_eq!(
unsafe { OPS.stream_set_input_mute.unwrap()(stream, 1) },
Expand All @@ -1580,6 +1643,10 @@ fn test_ops_duplex_voice_stream_set_input_mute() {

#[test]
fn test_ops_duplex_voice_stream_set_input_mute_before_start() {
if macos_kernel_major_version().unwrap() == MACOS_KERNEL_MAJOR_VERSION_MONTEREY {
// We disable VPIO on Monterey.
return;
}
test_default_duplex_voice_stream_operation(
"duplex voice stream: mute before start",
|stream| {
Expand All @@ -1596,6 +1663,10 @@ fn test_ops_duplex_voice_stream_set_input_mute_before_start() {

#[test]
fn test_ops_duplex_voice_stream_set_input_mute_before_start_with_reinit() {
if macos_kernel_major_version().unwrap() == MACOS_KERNEL_MAJOR_VERSION_MONTEREY {
// We disable VPIO on Monterey.
return;
}
test_default_duplex_voice_stream_operation(
"duplex voice stream: mute before start with reinit",
|stream| {
Expand Down Expand Up @@ -1631,6 +1702,10 @@ fn test_ops_duplex_voice_stream_set_input_mute_before_start_with_reinit() {

#[test]
fn test_ops_duplex_voice_stream_set_input_mute_after_start() {
if macos_kernel_major_version().unwrap() == MACOS_KERNEL_MAJOR_VERSION_MONTEREY {
// We disable VPIO on Monterey.
return;
}
test_default_duplex_voice_stream_operation("duplex voice stream: mute after start", |stream| {
assert_eq!(unsafe { OPS.stream_start.unwrap()(stream) }, ffi::CUBEB_OK);
assert_eq!(
Expand All @@ -1644,6 +1719,10 @@ fn test_ops_duplex_voice_stream_set_input_mute_after_start() {

#[test]
fn test_ops_duplex_voice_stream_set_input_processing_params() {
if macos_kernel_major_version().unwrap() == MACOS_KERNEL_MAJOR_VERSION_MONTEREY {
// We disable VPIO on Monterey.
return;
}
test_default_duplex_voice_stream_operation("duplex voice stream: processing", |stream| {
let params: ffi::cubeb_input_processing_params =
ffi::CUBEB_INPUT_PROCESSING_PARAM_ECHO_CANCELLATION
Expand All @@ -1660,6 +1739,10 @@ fn test_ops_duplex_voice_stream_set_input_processing_params() {

#[test]
fn test_ops_duplex_voice_stream_set_input_processing_params_before_start() {
if macos_kernel_major_version().unwrap() == MACOS_KERNEL_MAJOR_VERSION_MONTEREY {
// We disable VPIO on Monterey.
return;
}
test_default_duplex_voice_stream_operation(
"duplex voice stream: processing before start",
|stream| {
Expand All @@ -1680,6 +1763,10 @@ fn test_ops_duplex_voice_stream_set_input_processing_params_before_start() {

#[test]
fn test_ops_duplex_voice_stream_set_input_processing_params_before_start_with_reinit() {
if macos_kernel_major_version().unwrap() == MACOS_KERNEL_MAJOR_VERSION_MONTEREY {
// We disable VPIO on Monterey.
return;
}
test_default_duplex_voice_stream_operation(
"duplex voice stream: processing before start with reinit",
|stream| {
Expand Down Expand Up @@ -1740,6 +1827,10 @@ fn test_ops_duplex_voice_stream_set_input_processing_params_before_start_with_re

#[test]
fn test_ops_duplex_voice_stream_set_input_processing_params_after_start() {
if macos_kernel_major_version().unwrap() == MACOS_KERNEL_MAJOR_VERSION_MONTEREY {
// We disable VPIO on Monterey.
return;
}
test_default_duplex_voice_stream_operation(
"duplex voice stream: processing after start",
|stream| {
Expand All @@ -1764,7 +1855,10 @@ fn test_ops_stereo_input_duplex_voice_stream_init_and_destroy() {
"stereo-input duplex voice stream: init and destroy",
|stream| {
let stm = unsafe { &mut *(stream as *mut AudioUnitStream) };
assert!(stm.core_stream_data.using_voice_processing_unit());
assert_eq!(
stm.core_stream_data.using_voice_processing_unit(),
macos_kernel_major_version().unwrap() != MACOS_KERNEL_MAJOR_VERSION_MONTEREY
);
},
);
}
Expand All @@ -1775,7 +1869,10 @@ fn test_ops_stereo_input_duplex_voice_stream_start() {
"stereo-input duplex voice stream: start",
|stream| {
let stm = unsafe { &mut *(stream as *mut AudioUnitStream) };
assert!(stm.core_stream_data.using_voice_processing_unit());
assert_eq!(
stm.core_stream_data.using_voice_processing_unit(),
macos_kernel_major_version().unwrap() != MACOS_KERNEL_MAJOR_VERSION_MONTEREY
);
assert_eq!(unsafe { OPS.stream_start.unwrap()(stream) }, ffi::CUBEB_OK);
},
);
Expand All @@ -1787,7 +1884,10 @@ fn test_ops_stereo_input_duplex_voice_stream_stop() {
"stereo-input duplex voice stream: stop",
|stream| {
let stm = unsafe { &mut *(stream as *mut AudioUnitStream) };
assert!(stm.core_stream_data.using_voice_processing_unit());
assert_eq!(
stm.core_stream_data.using_voice_processing_unit(),
macos_kernel_major_version().unwrap() != MACOS_KERNEL_MAJOR_VERSION_MONTEREY
);
assert_eq!(unsafe { OPS.stream_stop.unwrap()(stream) }, ffi::CUBEB_OK);
},
);
Expand Down

0 comments on commit a1f751d

Please sign in to comment.