aboutsummaryrefslogtreecommitdiffstats
path: root/tests/common
diff options
context:
space:
mode:
Diffstat (limited to 'tests/common')
-rw-r--r--tests/common/mod.rs24
1 files changed, 20 insertions, 4 deletions
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index 751d809..f1f3f74 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -73,17 +73,33 @@ impl Host {
pub fn apply(&self, schema: &(Schema, Vec<u8>), dir: &Path) -> Plan {
let submission = Submission::load(dir).unwrap();
let store = self.store();
- let _lock = store.lock().unwrap();
+ let lock = store.lock().unwrap();
plan::plan(&schema.0, &store, &submission)
.unwrap()
- .apply(&store, &schema.1, &self.systemctl())
+ .apply(&store, &schema.1, &self.systemctl(), lock)
.unwrap()
}
- /// A systemctl that writes down what it was asked.
+ /// A systemctl that writes down what it was asked, and whether the store's lock
+ /// was free then.
pub fn systemctl(&self) -> PathBuf {
let log = self.root.join("systemctl.log");
- PathBuf::from(self.program("systemctl", &format!("echo \"$*\" >> {}", log.display())))
+ let lock = self.root.join("state/lock");
+ let locks = self.root.join("locks.log");
+ PathBuf::from(self.program(
+ "systemctl",
+ &format!(
+ "echo \"$*\" >> {log}\nif flock -n {lock} true; then echo free; else echo held; fi >> {locks}",
+ log = log.display(),
+ lock = lock.display(),
+ locks = locks.display(),
+ ),
+ ))
+ }
+
+ /// Whether the lock was free each time systemctl ran.
+ pub fn locks(&self) -> String {
+ std::fs::read_to_string(self.root.join("locks.log")).unwrap_or_default()
}
pub fn reactions(&self) -> String {