diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3d0453135..93b04d6863 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -126,7 +126,7 @@ jobs: strategy: matrix: arch: [x86_64, aarch64, riscv64] - package: [rusty_demo, httpd, testudp, hello_world] + package: [rusty_demo, httpd, testudp, hello_world, miotcp, mioudp] netdev: [none, virtio-net-pci, rtl8139] profile: [dev, release] smp: [1, 4] @@ -135,6 +135,10 @@ jobs: package: httpd - arch: riscv64 package: testudp + - arch: riscv64 + package: mioudp + - arch: riscv64 + package: miotcp # microvm (Firecracker) test does not run on aarch64 or riscv64 - package: hello_world arch: aarch64 @@ -163,6 +167,10 @@ jobs: netdev: none - package: testudp netdev: none + - package: miotcp + netdev: none + - package: mioudp + netdev: none include: - arch: x86_64 packages: qemu-system-x86 libcap-ng-dev libseccomp-dev socat @@ -182,6 +190,10 @@ jobs: flags: --features ci,dhcpv4 - package: testudp flags: --features udp,dhcpv4 + - package: miotcp + flags: --features dhcpv4 + - package: mioudp + flags: --features udp,dhcpv4 - package: hello_world flags: --no-default-features --microvm diff --git a/xtask/src/ci/qemu.rs b/xtask/src/ci/qemu.rs index 0962112129..8c774bf531 100644 --- a/xtask/src/ci/qemu.rs +++ b/xtask/src/ci/qemu.rs @@ -1,5 +1,7 @@ -use std::net::UdpSocket; +use std::io::{Read, Write}; +use std::net::{TcpStream, UdpSocket}; use std::process::{Child, Command, ExitStatus}; +use std::str::from_utf8; use std::time::Duration; use std::{env, thread}; @@ -90,6 +92,8 @@ impl Qemu { match self.build.package.as_str() { "httpd" => test_httpd()?, "testudp" => test_testudp()?, + "miotcp" => test_miotcp()?, + "mioudp" => test_mioudp()?, _ => {} } @@ -279,6 +283,36 @@ fn test_testudp() -> Result<()> { let socket = UdpSocket::bind("127.0.0.1:0")?; socket.connect("127.0.0.1:9975")?; socket.send(buf.as_bytes())?; + + Ok(()) +} + +fn test_miotcp() -> Result<()> { + thread::sleep(Duration::from_secs(10)); + let buf = "exit"; + eprintln!("[CI] send {buf:?} via TCP to 127.0.0.1:9975"); + let mut stream = TcpStream::connect("127.0.0.1:9975")?; + stream.write_all(buf.as_bytes())?; + + let mut buf = vec![]; + let received = stream.read_to_end(&mut buf)?; + eprintln!("[CI] receive: {}", from_utf8(&buf[..received])?); + + Ok(()) +} + +fn test_mioudp() -> Result<()> { + thread::sleep(Duration::from_secs(10)); + let buf = "exit"; + eprintln!("[CI] send {buf:?} via UDP to 127.0.0.1:9975"); + let socket = UdpSocket::bind("127.0.0.1:0")?; + socket.connect("127.0.0.1:9975")?; + socket.send(buf.as_bytes())?; + + let mut buf = [0; 128]; + let received = socket.recv(&mut buf)?; + eprintln!("[CI] receive: {}", from_utf8(&buf[..received])?); + Ok(()) }