@@ -4,11 +4,9 @@ use varlink::Connection;
4
4
5
5
pub type Result < T > = std:: result:: Result < T , Box < dyn std:: error:: Error > > ;
6
6
7
- fn run_self_test ( address : String ) -> Result < ( ) > {
8
- let client_address = address. clone ( ) ;
9
-
7
+ fn run_self_test ( address : & ' static str ) -> Result < ( ) > {
10
8
let child = thread:: spawn ( move || {
11
- if let Err ( e) = crate :: run_server ( & address, 4 ) {
9
+ if let Err ( e) = crate :: run_server ( address, 4 ) {
12
10
match e. kind ( ) {
13
11
:: varlink:: ErrorKind :: Timeout => { }
14
12
_ => panic ! ( "error: {:#?}" , e) ,
@@ -19,7 +17,7 @@ fn run_self_test(address: String) -> Result<()> {
19
17
// give server time to start
20
18
thread:: sleep ( time:: Duration :: from_secs ( 1 ) ) ;
21
19
22
- let ret = crate :: run_client ( Connection :: with_address ( & client_address ) ?) ;
20
+ let ret = crate :: run_client ( Connection :: with_address ( address ) ?) ;
23
21
if let Err ( e) = ret {
24
22
panic ! ( "error: {:?}" , e) ;
25
23
}
@@ -32,21 +30,21 @@ fn run_self_test(address: String) -> Result<()> {
32
30
33
31
#[ test]
34
32
fn test_unix ( ) -> crate :: Result < ( ) > {
35
- run_self_test ( "unix:org.varlink.certification" . into ( ) )
33
+ run_self_test ( "unix:org.varlink.certification" )
36
34
}
37
35
38
36
#[ test]
39
37
#[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
40
38
fn test_unix_abstract ( ) -> Result < ( ) > {
41
- run_self_test ( "unix:@org.varlink.certification_abs" . into ( ) )
39
+ run_self_test ( "unix:@org.varlink.certification_abs" )
42
40
}
43
41
44
42
#[ test]
45
43
fn test_tcp ( ) -> Result < ( ) > {
46
- run_self_test ( "tcp:127.0.0.1:23456" . into ( ) )
44
+ run_self_test ( "tcp:127.0.0.1:23456" )
47
45
}
48
46
49
47
#[ test]
50
48
fn test_wrong_address_1 ( ) {
51
- assert ! ( crate :: run_server( "tcpd:0.0.0.0:12345" , 1 ) . is_err ( ) ) ;
49
+ crate :: run_server ( "tcpd:0.0.0.0:12345" , 1 ) . unwrap_err ( ) ;
52
50
}
0 commit comments