From f46806414a0ec69c2dce314e89ac02d4d70ae197 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Mon, 6 Sep 2021 17:00:26 +0200 Subject: [PATCH] tape/inventory: fix the tape tests as user, by mocking the lock locking during the tests as regular user failed because we try to chown to the backup user (which is not always possible). Instead, do not lock at all, by implementing 'open_backup_lockfile' with 'create_mocked_lock' Signed-off-by: Dominik Csapak Signed-off-by: Wolfgang Bumiller --- src/tape/inventory.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/tape/inventory.rs b/src/tape/inventory.rs index d56b2144..93d72057 100644 --- a/src/tape/inventory.rs +++ b/src/tape/inventory.rs @@ -40,7 +40,20 @@ use proxmox::tools::{ }; use pbs_systemd::time::compute_next_event; -use pbs_config::{open_backup_lockfile, BackupLockGuard}; +use pbs_config::BackupLockGuard; + +#[cfg(not(test))] +use pbs_config::open_backup_lockfile; + +#[cfg(test)] +fn open_backup_lockfile>( + _path: P, + _timeout: Option, + _exclusive: bool, +) -> Result { + Ok(unsafe { pbs_config::create_mocked_lock() }) +} + use crate::{ api2::types::{