@@ -6,7 +6,7 @@ use vsock::VsockAddr;
66use crate :: uri:: { FirecrackerUri , UnixUri , VsockUri } ;
77
88#[ test]
9- fn unix_uri_should_be_constructed_correctly ( ) {
9+ fn unix_uri_with_pathname_should_be_constructed_correctly ( ) {
1010 let uri_str = format ! ( "unix://{}/route" , hex:: encode( "/tmp/socket.sock" ) ) ;
1111 assert_eq ! (
1212 Uri :: unix( "/tmp/socket.sock" , "/route" ) . unwrap( ) ,
@@ -15,14 +15,32 @@ fn unix_uri_should_be_constructed_correctly() {
1515}
1616
1717#[ test]
18- fn unix_uri_should_be_deconstructed_correctly ( ) {
18+ fn unix_uri_with_abstract_name_should_be_constructed_correctly ( ) {
19+ let uri_str = format ! ( "unix://00{}/route" , hex:: encode( "/tmp/socket.sock" ) ) ;
20+ assert_eq ! (
21+ Uri :: unix( "\0 /tmp/socket.sock" , "/route" ) . unwrap( ) ,
22+ uri_str. parse:: <Uri >( ) . unwrap( )
23+ ) ;
24+ }
25+
26+ #[ test]
27+ fn unix_uri_with_pathname_should_be_deconstructed_correctly ( ) {
1928 let uri = format ! ( "unix://{}/route" , hex:: encode( "/tmp/socket.sock" ) ) ;
2029 assert_eq ! (
2130 uri. parse:: <Uri >( ) . unwrap( ) . parse_unix( ) . unwrap( ) ,
2231 PathBuf :: from( "/tmp/socket.sock" )
2332 ) ;
2433}
2534
35+ #[ test]
36+ fn unix_uri_with_abstract_name_should_be_deconstructed_correctly ( ) {
37+ let uri = format ! ( "unix://00{}/route" , hex:: encode( "/tmp/socket.sock" ) ) ;
38+ assert_eq ! (
39+ uri. parse:: <Uri >( ) . unwrap( ) . parse_unix( ) . unwrap( ) ,
40+ PathBuf :: from( "\0 /tmp/socket.sock" )
41+ ) ;
42+ }
43+
2644#[ test]
2745fn vsock_uri_should_be_constructed_correctly ( ) {
2846 let uri = format ! ( "vsock://{}/route" , hex:: encode( "10.20" ) ) ;
@@ -41,7 +59,7 @@ fn vsock_uri_should_be_deconstructed_correctly() {
4159}
4260
4361#[ test]
44- fn firecracker_uri_should_be_constructed_correctly ( ) {
62+ fn firecracker_uri_with_pathname_should_be_constructed_correctly ( ) {
4563 let uri_str = format ! ( "fc://{}/route" , hex:: encode( "/tmp/socket.sock:1000" ) ) ;
4664 assert_eq ! (
4765 Uri :: firecracker( "/tmp/socket.sock" , 1000 , "/route" ) . unwrap( ) ,
@@ -50,11 +68,30 @@ fn firecracker_uri_should_be_constructed_correctly() {
5068}
5169
5270#[ test]
53- fn firecracker_uri_should_be_deconstructed_correctly ( ) {
71+ fn firecracker_uri_with_abstract_name_should_be_constructed_correctly ( ) {
72+ let uri_str = format ! ( "fc://00{}/route" , hex:: encode( "/tmp/socket.sock:1000" ) ) ;
73+ assert_eq ! (
74+ Uri :: firecracker( "\0 /tmp/socket.sock" , 1000 , "/route" ) . unwrap( ) ,
75+ uri_str. parse:: <Uri >( ) . unwrap( )
76+ ) ;
77+ }
78+
79+ #[ test]
80+ fn firecracker_uri_with_pathname_should_be_deconstructed_correctly ( ) {
5481 let uri = format ! ( "fc://{}/route" , hex:: encode( "/tmp/socket.sock:1000" ) )
5582 . parse :: < Uri > ( )
5683 . unwrap ( ) ;
5784 let ( socket_path, port) = uri. parse_firecracker ( ) . unwrap ( ) ;
5885 assert_eq ! ( socket_path, PathBuf :: from( "/tmp/socket.sock" ) ) ;
5986 assert_eq ! ( port, 1000 ) ;
6087}
88+
89+ #[ test]
90+ fn firecracker_uri_with_abstract_name_should_be_deconstructed_correctly ( ) {
91+ let uri = format ! ( "fc://00{}/route" , hex:: encode( "/tmp/socket.sock:1000" ) )
92+ . parse :: < Uri > ( )
93+ . unwrap ( ) ;
94+ let ( socket_path, port) = uri. parse_firecracker ( ) . unwrap ( ) ;
95+ assert_eq ! ( socket_path, PathBuf :: from( "\0 /tmp/socket.sock" ) ) ;
96+ assert_eq ! ( port, 1000 ) ;
97+ }
0 commit comments