Seregon/zftpd

Zero-copy FTP/HTTP Daemon compatible with all POSIX systems

C/11.0 KB/No license
ffi/rust/tests/integration_tests.rs
zftpd / ffi / rust / tests / integration_tests.rs
1use zftpd::{EventLoop, FtpServer, HttpServer, PalAlloc};
2 
3#[test]
4fn test_allocator() {
5 assert!(PalAlloc::init_default().is_ok());
6 
7 let ptr = PalAlloc::malloc(1024);
8 assert!(!ptr.is_null());
9 
10 let free_approx = PalAlloc::get_arena_free_approx();
11 assert!(free_approx > 0);
12 
13 PalAlloc::free(ptr);
14}
15 
16#[test]
17fn test_ftp_server() {
18 let server = FtpServer::new("127.0.0.1", 2121, "/tmp").expect("Failed to create FtpServer");
19 assert!(server.start().is_ok());
20 assert!(server.is_running());
21 
22 let sessions = server.active_sessions();
23 assert_eq!(sessions, 0);
24 
25 server.stop();
26 assert!(!server.is_running());
27}
28 
29#[test]
30fn test_http_server() {
31 let _ = PalAlloc::init_default();
32 let loop_ctx = EventLoop::new().expect("Failed to create EventLoop");
33 let _http = HttpServer::new(&loop_ctx, 8888).expect("Failed to create HttpServer");
34 // Handle dropped automatically.
35}
36