Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add CI tests for the MIO support #1061

Merged
merged 3 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
mkroening marked this conversation as resolved.
Show resolved Hide resolved
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
Loading