Skip to content
Merged
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
13 changes: 13 additions & 0 deletions crates/tests-integration/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use indoc::indoc;
use scopeguard::defer;
use serde::Deserialize;
use std::process::{Command, Stdio};
use std::sync::RwLock;
use std::{fs, path::Path};

use anyhow::{Context, Result};
Expand Down Expand Up @@ -114,7 +115,16 @@ pub(crate) fn test_bootc_upgrade() -> Result<()> {
Ok(())
}

/// libtest runs the tests as threads of this one process, concurrently. Tests
/// that change the install config (under /run/bootc/install) take this for
/// writing and those that read it take it for reading, so no reader can see
/// a fragment being written or removed.
static INSTALL_CONFIG_LOCK: RwLock<()> = RwLock::new(());

pub(crate) fn test_bootc_install_config() -> Result<()> {
let _guard = INSTALL_CONFIG_LOCK
.read()
.unwrap_or_else(|e| e.into_inner());
let sh = &xshell::Shell::new()?;
let config = cmd!(sh, "bootc install print-configuration").read()?;
let config: serde_json::Value =
Expand All @@ -137,6 +147,9 @@ pub(crate) fn test_bootc_install_config_all() -> Result<()> {
ostree: Option<TestOstreeConfig>,
}

let _guard = INSTALL_CONFIG_LOCK
.write()
.unwrap_or_else(|e| e.into_inner());
let config_d = std::path::Path::new("/run/bootc/install/");
let test_toml_path = config_d.join("10-test.toml");
std::fs::create_dir_all(&config_d)?;
Expand Down
Loading