Skip to content

Commit

Permalink
Merge pull request #1061 from stlankes/mio
Browse files Browse the repository at this point in the history
add CI tests for the MIO support
  • Loading branch information
mkroening authored Feb 14, 2024
2 parents b24a802 + 6e2888c commit cbcae46
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
36 changes: 35 additions & 1 deletion xtask/src/ci/qemu.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -90,6 +92,8 @@ impl Qemu {
match self.build.package.as_str() {
"httpd" => test_httpd()?,
"testudp" => test_testudp()?,
"miotcp" => test_miotcp()?,
"mioudp" => test_mioudp()?,
_ => {}
}

Expand Down Expand Up @@ -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(())
}

Expand Down

0 comments on commit cbcae46

Please sign in to comment.