@@ -203,6 +203,7 @@ mod tests {
203203 fn test_console_valid_configuration_nested ( ) {
204204 let args = ConsoleArgs {
205205 socket_path : String :: from ( "/tmp/vhost.sock" ) . into ( ) ,
206+ vm_sock : String :: from ( "/tmp/vm.sock" ) . into ( ) ,
206207 backend : BackendType :: Nested ,
207208 tcp_port : String :: from ( "12345" ) ,
208209 socket_count : 1 ,
@@ -216,6 +217,7 @@ mod tests {
216217 fn test_console_invalid_configuration_nested_1 ( ) {
217218 let args = ConsoleArgs {
218219 socket_path : String :: from ( "/tmp/vhost.sock" ) . into ( ) ,
220+ vm_sock : String :: from ( "/tmp/vm.sock" ) . into ( ) ,
219221 backend : BackendType :: Nested ,
220222 tcp_port : String :: from ( "12345" ) ,
221223 socket_count : 0 ,
@@ -232,6 +234,7 @@ mod tests {
232234 fn test_console_invalid_configuration_nested_2 ( ) {
233235 let args = ConsoleArgs {
234236 socket_path : String :: from ( "/tmp/vhost.sock" ) . into ( ) ,
237+ vm_sock : String :: from ( "/tmp/vm.sock" ) . into ( ) ,
235238 backend : BackendType :: Nested ,
236239 tcp_port : String :: from ( "12345" ) ,
237240 socket_count : 2 ,
@@ -248,6 +251,7 @@ mod tests {
248251 fn test_console_valid_configuration_network_1 ( ) {
249252 let args = ConsoleArgs {
250253 socket_path : String :: from ( "/tmp/vhost.sock" ) . into ( ) ,
254+ vm_sock : String :: from ( "/tmp/vm.sock" ) . into ( ) ,
251255 backend : BackendType :: Network ,
252256 tcp_port : String :: from ( "12345" ) ,
253257 socket_count : 1 ,
@@ -261,6 +265,7 @@ mod tests {
261265 fn test_console_valid_configuration_network_2 ( ) {
262266 let args = ConsoleArgs {
263267 socket_path : String :: from ( "/tmp/vhost.sock" ) . into ( ) ,
268+ vm_sock : String :: from ( "/tmp/vm.sock" ) . into ( ) ,
264269 backend : BackendType :: Network ,
265270 tcp_port : String :: from ( "12345" ) ,
266271 socket_count : 2 ,
@@ -291,6 +296,7 @@ mod tests {
291296 fn test_start_backend_server_success ( ) {
292297 let args = ConsoleArgs {
293298 socket_path : String :: from ( "/not_a_dir/vhost.sock" ) . into ( ) ,
299+ vm_sock : String :: from ( "/tmp/vm.sock" ) . into ( ) ,
294300 backend : BackendType :: Network ,
295301 tcp_port : String :: from ( "12345" ) ,
296302 socket_count : 1 ,
@@ -304,6 +310,7 @@ mod tests {
304310 fn test_start_backend_success ( ) {
305311 let config = VuConsoleConfig {
306312 socket_path : String :: from ( "/not_a_dir/vhost.sock" ) . into ( ) ,
313+ vm_sock : String :: from ( "/tmp/vm.sock" ) . into ( ) ,
307314 backend : BackendType :: Network ,
308315 tcp_port : String :: from ( "12346" ) ,
309316 socket_count : 1 ,
@@ -312,4 +319,55 @@ mod tests {
312319
313320 assert ! ( start_backend( config) . is_err( ) ) ;
314321 }
322+
323+ #[ test]
324+ fn test_console_invalid_uds_path ( ) {
325+ let args = ConsoleArgs {
326+ socket_path : PathBuf :: from ( "/tmp/vhost.sock" ) ,
327+ vm_sock : "/non_existing_dir/test.sock" . to_string ( ) ,
328+ backend : BackendType :: Uds ,
329+ tcp_port : String :: new ( ) ,
330+ socket_count : 1 ,
331+ max_queue_size : 128 ,
332+ } ;
333+
334+ assert_matches ! (
335+ VuConsoleConfig :: try_from( args) ,
336+ Err ( Error :: InvalidUdsFile )
337+ ) ;
338+ }
339+
340+ #[ test]
341+ fn test_generate_vm_sock_addrs_uds ( ) {
342+ let config = VuConsoleConfig {
343+ socket_path : PathBuf :: new ( ) ,
344+ vm_sock : "/tmp/vm.sock" . to_string ( ) ,
345+ backend : BackendType :: Uds ,
346+ tcp_port : String :: new ( ) ,
347+ socket_count : 3 ,
348+ max_queue_size : 128 ,
349+ } ;
350+
351+ let addrs = config. generate_vm_sock_addrs ( ) ;
352+ assert_eq ! ( addrs, vec![
353+ "/tmp/vm.sock0" ,
354+ "/tmp/vm.sock1" ,
355+ "/tmp/vm.sock2"
356+ ] ) ;
357+ }
358+
359+ #[ test]
360+ fn test_start_uds_backend_with_invalid_path ( ) {
361+ let config = VuConsoleConfig {
362+ socket_path : PathBuf :: from ( "/tmp/vhost.sock" ) ,
363+ vm_sock : "/invalid/path/uds.sock" . to_string ( ) ,
364+ backend : BackendType :: Uds ,
365+ tcp_port : String :: new ( ) ,
366+ socket_count : 1 ,
367+ max_queue_size : 128 ,
368+ } ;
369+
370+ let result = start_backend ( config) ;
371+ assert_matches ! ( result, Err ( Error :: CouldNotInitBackend ( _) ) ) ;
372+ }
315373}
0 commit comments