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

ci: test everything with SMP #994

Merged
merged 2 commits into from
Dec 1, 2023
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
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ jobs:
package: [rusty_demo, httpd, testudp, hello_world]
netdev: [none, virtio-net-pci, rtl8139]
profile: [dev, release]
smp: [1, 4]
exclude:
- arch: riscv64
package: httpd
Expand All @@ -141,6 +142,12 @@ jobs:
arch: aarch64
- package: hello_world
arch: riscv64
# https://github.com/hermit-os/kernel/issues/995
- package: hello_world
smp: 4
# https://github.com/hermit-os/kernel/issues/737
- arch: aarch64
smp: 4
# rtl8139 support does not build on aarch64
- arch: aarch64
netdev: rtl8139
Expand Down Expand Up @@ -224,6 +231,7 @@ jobs:
cargo xtask ci qemu
--arch ${{ matrix.arch }}
--package ${{ matrix.package }}
--smp ${{ matrix.smp }}
${{ matrix.flags }}
${{ matrix.netdev == 'rtl8139' && '--features rtl8139' || '' }}
${{ matrix.netdev != 'none' && format('--netdev {0}', matrix.netdev) || '' }}
Expand Down
2 changes: 1 addition & 1 deletion xtask/src/cargo_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct CargoBuild {

/// Space or comma separated list of features to activate.
#[arg(long)]
features: Vec<String>,
pub features: Vec<String>,
}

pub trait CmdExt {
Expand Down
27 changes: 12 additions & 15 deletions xtask/src/ci/qemu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ pub struct Qemu {
netdev: Option<NetworkDevice>,

/// Create multiple vCPUs.
#[arg(long)]
smp: bool,
#[arg(long, default_value_t = 1)]
smp: usize,

/// Enable the `virtiofsd` virtio-fs vhost-user device daemon.
#[arg(long)]
Expand All @@ -46,7 +46,14 @@ pub enum NetworkDevice {
}

impl Qemu {
pub fn run(self) -> Result<()> {
pub fn run(mut self) -> Result<()> {
if self.smp > 1 {
self.build
.cargo_build
.features
.push("hermit/smp".to_string());
}

self.build.run()?;

let sh = crate::sh()?;
Expand All @@ -63,7 +70,7 @@ impl Qemu {
.args(&["-kernel", format!("../hermit-loader-{arch}").as_ref()])
.args(self.machine_args())
.args(self.cpu_args())
.args(self.smp_args())
.args(&["-smp", &self.smp.to_string()])
.args(self.memory_args())
.args(self.netdev_args())
.args(self.virtiofsd_args());
Expand Down Expand Up @@ -171,14 +178,6 @@ impl Qemu {
}
}

fn smp_args(&self) -> &'static [&'static str] {
if self.smp {
&["-smp", "4"]
} else {
&["-smp", "1"]
}
}

fn memory(&self) -> usize {
let mut memory = 32usize;
if self.build.cargo_build.artifact.arch == Arch::Riscv64 {
Expand All @@ -190,9 +189,7 @@ impl Qemu {
if self.netdev.is_some() {
memory *= 4;
}
if self.smp {
memory *= 4;
}
memory *= self.smp;
if self.build.cargo_build.artifact.arch == Arch::Aarch64 {
memory = memory.max(256);
}
Expand Down