From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH common v5 1/1] file: add exists and size helper
Date: Mon, 2 Mar 2026 15:46:34 +0100 [thread overview]
Message-ID: <20260302144642.3783463-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20260302144642.3783463-1-d.csapak@proxmox.com>
Can be used by other modules that need easy mocking in tests.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
new in v5 (split out from first qemu-server patch)
src/PVE/File.pm | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/PVE/File.pm b/src/PVE/File.pm
index abdf9d7..3fa8643 100644
--- a/src/PVE/File.pm
+++ b/src/PVE/File.pm
@@ -13,8 +13,10 @@ use POSIX qw(EEXIST EOPNOTSUPP);
use base 'Exporter';
our @EXPORT_OK = qw(
+ file_exists
file_set_contents
file_get_contents
+ file_get_size
file_read_first_line
file_read_last_line
dir_glob_regex
@@ -285,4 +287,16 @@ sub dir_glob_foreach($dir, $regex, $func) {
}
}
+# easier to mock for testing than '-f'.
+sub file_exists {
+ my ($path) = @_;
+ return -f $path;
+}
+
+# easier to mock for testing than '-s'.
+sub file_get_size {
+ my ($path) = @_;
+ return -s $path;
+}
+
1;
--
2.47.3
next prev parent reply other threads:[~2026-03-02 14:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-02 14:46 [PATCH common/qemu-server v5 0/5] improve multiarch build support Dominik Csapak
2026-03-02 14:46 ` Dominik Csapak [this message]
2026-03-03 21:23 ` applied: [PATCH common v5 1/1] file: add exists and size helper Thomas Lamprecht
2026-03-02 14:46 ` [PATCH qemu-server v5 1/4] ovmf: use helpers that can be mocked for tests Dominik Csapak
2026-03-02 14:46 ` [PATCH qemu-server v5 2/4] tests: improve multiarch build support by introducing local get_host_arch helper Dominik Csapak
2026-03-02 14:46 ` [PATCH qemu-server v5 3/4] tests: improve multiarch build support by allowing re-init of cpu models Dominik Csapak
2026-03-02 14:46 ` [PATCH qemu-server v5 4/4] tests: cfg2cmd: add some architecture tests Dominik Csapak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260302144642.3783463-2-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.