Skip to content

Commit 252f04e

Browse files
committed
post-rebase fixes
1 parent 03e3c4d commit 252f04e

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

usertest/src/socket.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,36 @@
11
use libc::{AF_INET, AF_UNIX, SOCK_DGRAM, SOCK_STREAM};
22
use libc::{accept, bind, connect, listen, shutdown, socket};
3+
use crate::register_test;
34

45
pub fn test_tcp_socket_creation() {
5-
print!("Testing TCP socket creation ... ");
66
unsafe {
77
let sockfd = socket(AF_INET, SOCK_STREAM, 0);
88
if sockfd < 0 {
99
panic!("Failed to create TCP socket");
1010
}
1111
}
12-
println!("OK");
1312
}
1413

14+
register_test!(test_tcp_socket_creation);
15+
1516
pub fn test_unix_socket_creation() {
16-
print!("Testing UNIX stream socket creation ... ");
1717
unsafe {
1818
let sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
1919
if sockfd < 0 {
2020
panic!("Failed to create UNIX stream socket");
2121
}
2222
}
23-
println!("OK");
24-
25-
print!("Testing UNIX datagram socket creation ... ");
2623
unsafe {
2724
let sockfd = socket(AF_UNIX, SOCK_DGRAM, 0);
2825
if sockfd < 0 {
2926
panic!("Failed to create UNIX datagram socket");
3027
}
3128
}
32-
println!("OK");
3329
}
3430

31+
register_test!(test_unix_socket_creation);
32+
3533
pub fn test_unix_socket_basic_functions() {
36-
print!("Testing UNIX socket functions ... ");
3734
let sockfd = unsafe { socket(AF_UNIX, SOCK_STREAM, 0) };
3835
if sockfd < 0 {
3936
panic!("Failed to create UNIX stream socket for function tests");
@@ -67,14 +64,13 @@ pub fn test_unix_socket_basic_functions() {
6764
if shutdown_result < 0 {
6865
panic!("Failed to shutdown UNIX socket");
6966
}
70-
println!("OK");
7167
}
7268

69+
register_test!(test_unix_socket_basic_functions);
70+
7371
pub fn test_unix_socket_fork_msg_passing() {
7472
use std::ptr;
7573

76-
print!("Testing UNIX socket fork message passing ... ");
77-
7874
// Create server socket, bind and listen before fork
7975
let server_fd = unsafe { socket(AF_UNIX, SOCK_STREAM, 0) };
8076
if server_fd < 0 {
@@ -176,6 +172,7 @@ pub fn test_unix_socket_fork_msg_passing() {
176172

177173
unsafe { libc::close(conn_fd) };
178174
unsafe { libc::close(server_fd) };
179-
println!("OK");
180175
}
181176
}
177+
178+
register_test!(test_unix_socket_fork_msg_passing);

0 commit comments

Comments
 (0)