working tests including warmup
This commit is contained in:
parent
4d527e152c
commit
1b2ef60bbe
@ -188,7 +188,6 @@ fn implement_dispatch_arm_invoke_stmt(
|
|||||||
) -> ast::Stmt
|
) -> ast::Stmt
|
||||||
{
|
{
|
||||||
let function_name = builder.id(dispatch.function_name.as_str());
|
let function_name = builder.id(dispatch.function_name.as_str());
|
||||||
let output_type_id = builder.id(dispatch.return_type_name.clone().unwrap().as_str());
|
|
||||||
|
|
||||||
let input_args_exprs = dispatch.input_arg_names.iter().enumerate().map(|(arg_index, arg_name)| {
|
let input_args_exprs = dispatch.input_arg_names.iter().enumerate().map(|(arg_index, arg_name)| {
|
||||||
let arg_ident = builder.id(arg_name);
|
let arg_ident = builder.id(arg_name);
|
||||||
@ -216,10 +215,6 @@ fn implement_dispatch_arm_invoke_stmt(
|
|||||||
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Ident(ext_cx.ident_of("serialize"), ::syntax::parse::token::Plain)));
|
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Ident(ext_cx.ident_of("serialize"), ::syntax::parse::token::Plain)));
|
||||||
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::OpenDelim(::syntax::parse::token::Paren)));
|
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::OpenDelim(::syntax::parse::token::Paren)));
|
||||||
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::BinOp(::syntax::parse::token::And)));
|
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::BinOp(::syntax::parse::token::And)));
|
||||||
tt.extend(::quasi::ToTokens::to_tokens(&output_type_id, ext_cx).into_iter());
|
|
||||||
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::OpenDelim(::syntax::parse::token::Brace)));
|
|
||||||
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Ident(ext_cx.ident_of("payload"), ::syntax::parse::token::Plain)));
|
|
||||||
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Colon));
|
|
||||||
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Ident(ext_cx.ident_of("self"), ::syntax::parse::token::Plain)));
|
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Ident(ext_cx.ident_of("self"), ::syntax::parse::token::Plain)));
|
||||||
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Dot));
|
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Dot));
|
||||||
tt.extend(::quasi::ToTokens::to_tokens(&function_name, ext_cx).into_iter());
|
tt.extend(::quasi::ToTokens::to_tokens(&function_name, ext_cx).into_iter());
|
||||||
@ -231,7 +226,6 @@ fn implement_dispatch_arm_invoke_stmt(
|
|||||||
}
|
}
|
||||||
|
|
||||||
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::CloseDelim(::syntax::parse::token::Paren)));
|
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::CloseDelim(::syntax::parse::token::Paren)));
|
||||||
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::CloseDelim(::syntax::parse::token::Brace)));
|
|
||||||
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Comma));
|
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Comma));
|
||||||
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::ModSep));
|
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::ModSep));
|
||||||
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Ident(ext_cx.ident_of("bincode"), ::syntax::parse::token::ModName)));
|
tt.push(::syntax::ast::TokenTree::Token(_sp, ::syntax::parse::token::Ident(ext_cx.ident_of("bincode"), ::syntax::parse::token::ModName)));
|
||||||
@ -729,6 +723,7 @@ fn implement_interface(
|
|||||||
Err(e) => { panic!("ipc read error: {:?}, aborting", e); }
|
Err(e) => { panic!("ipc read error: {:?}, aborting", e); }
|
||||||
_ => { }
|
_ => { }
|
||||||
}
|
}
|
||||||
|
|
||||||
// method_num is a 16-bit little-endian unsigned number
|
// method_num is a 16-bit little-endian unsigned number
|
||||||
match method_num[1] as u16 + (method_num[0] as u16)*256 {
|
match method_num[1] as u16 + (method_num[0] as u16)*256 {
|
||||||
// handshake
|
// handshake
|
||||||
|
@ -125,7 +125,7 @@ impl<S> Worker<S> where S: IpcInterface<S> {
|
|||||||
if method_sign_len >= 2 {
|
if method_sign_len >= 2 {
|
||||||
|
|
||||||
// method_num
|
// method_num
|
||||||
let method_num = self.buf[1] as u16 * 256 + self.buf[0] as u16;
|
let method_num = self.buf[0] as u16 * 256 + self.buf[1] as u16;
|
||||||
// payload
|
// payload
|
||||||
let payload = &self.buf[2..];
|
let payload = &self.buf[2..];
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ mod tests {
|
|||||||
|
|
||||||
|
|
||||||
fn init_worker(addr: &str) -> nanoipc::Worker<Service> {
|
fn init_worker(addr: &str) -> nanoipc::Worker<Service> {
|
||||||
let mut worker = nanoipc::Worker::<Service>::new(Arc::new(Service::new()));
|
let mut worker = nanoipc::Worker::<Service>::new(&Arc::new(Service::new()));
|
||||||
worker.add_duplex(addr).unwrap();
|
worker.add_duplex(addr).unwrap();
|
||||||
worker
|
worker
|
||||||
}
|
}
|
||||||
@ -105,5 +105,4 @@ mod tests {
|
|||||||
|
|
||||||
worker_should_exit.store(true, Ordering::Relaxed);
|
worker_should_exit.store(true, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_init() {
|
fn can_init() {
|
||||||
let url = "ipc:///tmp/test-parity-hypervisor-10";
|
let url = "ipc:///tmp/test-parity-hypervisor-10.ipc";
|
||||||
|
|
||||||
let hypervisor = Hypervisor::with_url(url);
|
let hypervisor = Hypervisor::with_url(url);
|
||||||
assert_eq!(false, hypervisor.modules_ready());
|
assert_eq!(false, hypervisor.modules_ready());
|
||||||
@ -80,7 +80,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_wait_for_startup() {
|
fn can_wait_for_startup() {
|
||||||
let url = "ipc:///tmp/test-parity-hypervisor-20";
|
let url = "ipc:///tmp/test-parity-hypervisor-20.ipc";
|
||||||
let test_module_id = 8080u64;
|
let test_module_id = 8080u64;
|
||||||
|
|
||||||
let hypervisor_ready = Arc::new(AtomicBool::new(false));
|
let hypervisor_ready = Arc::new(AtomicBool::new(false));
|
||||||
@ -90,6 +90,7 @@ mod tests {
|
|||||||
while !hypervisor_ready.load(Ordering::Relaxed) { }
|
while !hypervisor_ready.load(Ordering::Relaxed) { }
|
||||||
|
|
||||||
let client = nanoipc::init_client::<HypervisorServiceClient<_>>(url).unwrap();
|
let client = nanoipc::init_client::<HypervisorServiceClient<_>>(url).unwrap();
|
||||||
|
client.handshake().unwrap();
|
||||||
client.module_ready(test_module_id);
|
client.module_ready(test_module_id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user