|
|
@ -6,21 +6,21 @@
|
|
|
|
// option. All files in the project carrying such notice may not be copied,
|
|
|
|
// option. All files in the project carrying such notice may not be copied,
|
|
|
|
// modified, or distributed except according to those terms.
|
|
|
|
// modified, or distributed except according to those terms.
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(not(feature = "metal-io"))]
|
|
|
|
#[cfg(not(feature = "async-mio"))]
|
|
|
|
use ssip_client::*;
|
|
|
|
use ssip_client::*;
|
|
|
|
#[cfg(not(feature = "metal-io"))]
|
|
|
|
#[cfg(not(feature = "async-mio"))]
|
|
|
|
use std::{io, os::unix::net::UnixStream};
|
|
|
|
use std::{io, os::unix::net::UnixStream};
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(not(feature = "metal-io"))]
|
|
|
|
#[cfg(not(feature = "async-mio"))]
|
|
|
|
mod server;
|
|
|
|
mod server;
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(not(feature = "metal-io"))]
|
|
|
|
#[cfg(not(feature = "async-mio"))]
|
|
|
|
use server::Server;
|
|
|
|
use server::Server;
|
|
|
|
|
|
|
|
|
|
|
|
/// Create a server and run the client
|
|
|
|
/// Create a server and run the client
|
|
|
|
///
|
|
|
|
///
|
|
|
|
/// The communication is an array of (["question", ...], "response")
|
|
|
|
/// The communication is an array of (["question", ...], "response")
|
|
|
|
#[cfg(not(feature = "metal-io"))]
|
|
|
|
#[cfg(not(feature = "async-mio"))]
|
|
|
|
fn test_client<F>(
|
|
|
|
fn test_client<F>(
|
|
|
|
communication: &'static [(&'static str, &'static str)],
|
|
|
|
communication: &'static [(&'static str, &'static str)],
|
|
|
|
process: F,
|
|
|
|
process: F,
|
|
|
@ -51,14 +51,14 @@ where
|
|
|
|
Ok(())
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(not(feature = "metal-io"))]
|
|
|
|
#[cfg(not(feature = "async-mio"))]
|
|
|
|
const SET_CLIENT_COMMUNICATION: (&str, &str) = (
|
|
|
|
const SET_CLIENT_COMMUNICATION: (&str, &str) = (
|
|
|
|
"SET self CLIENT_NAME test:test:main\r\n",
|
|
|
|
"SET self CLIENT_NAME test:test:main\r\n",
|
|
|
|
"208 OK CLIENT NAME SET\r\n",
|
|
|
|
"208 OK CLIENT NAME SET\r\n",
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
#[cfg(not(feature = "metal-io"))]
|
|
|
|
#[cfg(not(feature = "async-mio"))]
|
|
|
|
fn connect_and_quit() -> io::Result<()> {
|
|
|
|
fn connect_and_quit() -> io::Result<()> {
|
|
|
|
test_client(
|
|
|
|
test_client(
|
|
|
|
&[
|
|
|
|
&[
|
|
|
@ -73,7 +73,7 @@ fn connect_and_quit() -> io::Result<()> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
#[cfg(not(feature = "metal-io"))]
|
|
|
|
#[cfg(not(feature = "async-mio"))]
|
|
|
|
fn say_one_line() -> io::Result<()> {
|
|
|
|
fn say_one_line() -> io::Result<()> {
|
|
|
|
test_client(
|
|
|
|
test_client(
|
|
|
|
&[
|
|
|
|
&[
|
|
|
@ -105,7 +105,7 @@ fn say_one_line() -> io::Result<()> {
|
|
|
|
macro_rules! test_setter {
|
|
|
|
macro_rules! test_setter {
|
|
|
|
($setter:ident, $question:expr, $answer:expr, $code:expr, $($arg:tt)*) => {
|
|
|
|
($setter:ident, $question:expr, $answer:expr, $code:expr, $($arg:tt)*) => {
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
#[cfg(not(feature = "metal-io"))]
|
|
|
|
#[cfg(not(feature = "async-mio"))]
|
|
|
|
fn $setter() -> io::Result<()> {
|
|
|
|
fn $setter() -> io::Result<()> {
|
|
|
|
test_client(
|
|
|
|
test_client(
|
|
|
|
&[SET_CLIENT_COMMUNICATION, ($question, $answer)],
|
|
|
|
&[SET_CLIENT_COMMUNICATION, ($question, $answer)],
|
|
|
@ -119,14 +119,14 @@ macro_rules! test_setter {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
macro_rules! test_getter {
|
|
|
|
macro_rules! test_getter {
|
|
|
|
($getter:ident, $receive:ident, $question:expr, $answer:expr, $value:expr) => {
|
|
|
|
($getter:ident, $receive:ident, $arg:tt, $question:expr, $answer:expr, $value:expr) => {
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
#[cfg(not(feature = "metal-io"))]
|
|
|
|
#[cfg(not(feature = "async-mio"))]
|
|
|
|
fn $getter() -> io::Result<()> {
|
|
|
|
fn $getter() -> io::Result<()> {
|
|
|
|
test_client(
|
|
|
|
test_client(
|
|
|
|
&[SET_CLIENT_COMMUNICATION, ($question, $answer)],
|
|
|
|
&[SET_CLIENT_COMMUNICATION, ($question, $answer)],
|
|
|
|
|client| {
|
|
|
|
|client| {
|
|
|
|
let value = client.$getter().unwrap().$receive(251).unwrap();
|
|
|
|
let value = client.$getter().unwrap().$receive $arg.unwrap();
|
|
|
|
assert_eq!($value, value);
|
|
|
|
assert_eq!($value, value);
|
|
|
|
Ok(())
|
|
|
|
Ok(())
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -134,14 +134,14 @@ macro_rules! test_getter {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
($getter:ident, $question:expr, $answer:expr, $value:expr) => {
|
|
|
|
($getter:ident, $question:expr, $answer:expr, $value:expr) => {
|
|
|
|
test_getter!($getter, receive_string, $question, $answer, $value);
|
|
|
|
test_getter!($getter, receive_string, (OK_GET), $question, $answer, $value);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
macro_rules! test_list {
|
|
|
|
macro_rules! test_list {
|
|
|
|
($getter:ident, $question:expr, $answer:expr, $code:expr, $values:expr) => {
|
|
|
|
($getter:ident, $question:expr, $answer:expr, $code:expr, $values:expr) => {
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
#[cfg(not(feature = "metal-io"))]
|
|
|
|
#[cfg(not(feature = "async-mio"))]
|
|
|
|
fn $getter() -> io::Result<()> {
|
|
|
|
fn $getter() -> io::Result<()> {
|
|
|
|
test_client(
|
|
|
|
test_client(
|
|
|
|
&[SET_CLIENT_COMMUNICATION, ($question, $answer)],
|
|
|
|
&[SET_CLIENT_COMMUNICATION, ($question, $answer)],
|
|
|
@ -164,7 +164,7 @@ test_setter!(
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
#[cfg(not(feature = "metal-io"))]
|
|
|
|
#[cfg(not(feature = "async-mio"))]
|
|
|
|
fn set_debug() -> io::Result<()> {
|
|
|
|
fn set_debug() -> io::Result<()> {
|
|
|
|
test_client(
|
|
|
|
test_client(
|
|
|
|
&[
|
|
|
|
&[
|
|
|
@ -238,6 +238,7 @@ test_setter!(
|
|
|
|
test_getter!(
|
|
|
|
test_getter!(
|
|
|
|
get_rate,
|
|
|
|
get_rate,
|
|
|
|
receive_u8,
|
|
|
|
receive_u8,
|
|
|
|
|
|
|
|
(),
|
|
|
|
"GET RATE\r\n",
|
|
|
|
"GET RATE\r\n",
|
|
|
|
"251-0\r\n251 OK GET RETURNED\r\n",
|
|
|
|
"251-0\r\n251 OK GET RETURNED\r\n",
|
|
|
|
0
|
|
|
|
0
|
|
|
@ -255,6 +256,7 @@ test_setter!(
|
|
|
|
test_getter!(
|
|
|
|
test_getter!(
|
|
|
|
get_volume,
|
|
|
|
get_volume,
|
|
|
|
receive_u8,
|
|
|
|
receive_u8,
|
|
|
|
|
|
|
|
(),
|
|
|
|
"GET VOLUME\r\n",
|
|
|
|
"GET VOLUME\r\n",
|
|
|
|
"251-100\r\n251 OK GET RETURNED\r\n",
|
|
|
|
"251-100\r\n251 OK GET RETURNED\r\n",
|
|
|
|
100
|
|
|
|
100
|
|
|
@ -263,6 +265,7 @@ test_getter!(
|
|
|
|
test_getter!(
|
|
|
|
test_getter!(
|
|
|
|
get_pitch,
|
|
|
|
get_pitch,
|
|
|
|
receive_u8,
|
|
|
|
receive_u8,
|
|
|
|
|
|
|
|
(),
|
|
|
|
"GET PITCH\r\n",
|
|
|
|
"GET PITCH\r\n",
|
|
|
|
"251-0\r\n251 OK GET RETURNED\r\n",
|
|
|
|
"251-0\r\n251 OK GET RETURNED\r\n",
|
|
|
|
0
|
|
|
|
0
|
|
|
@ -337,7 +340,7 @@ test_list!(
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
#[cfg(not(feature = "metal-io"))]
|
|
|
|
#[cfg(not(feature = "async-mio"))]
|
|
|
|
fn list_synthesis_voices() -> io::Result<()> {
|
|
|
|
fn list_synthesis_voices() -> io::Result<()> {
|
|
|
|
test_client(
|
|
|
|
test_client(
|
|
|
|
&[
|
|
|
|
&[
|
|
|
@ -363,7 +366,7 @@ fn list_synthesis_voices() -> io::Result<()> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[test]
|
|
|
|
#[cfg(not(feature = "metal-io"))]
|
|
|
|
#[cfg(not(feature = "async-mio"))]
|
|
|
|
fn receive_notification() -> io::Result<()> {
|
|
|
|
fn receive_notification() -> io::Result<()> {
|
|
|
|
test_client(
|
|
|
|
test_client(
|
|
|
|
&[
|
|
|
|
&[
|
|
|
|