From c777c05125c0dc7cc07206ea130079c33f92602f Mon Sep 17 00:00:00 2001 From: Andres Beltran Date: Mon, 16 Jun 2025 23:44:35 +0000 Subject: [PATCH] test: add test for quotas on Exec directories --- mkosi/mkosi.repart/20-disk.conf | 5 ++ test/units/TEST-07-PID1.quota.sh | 95 ++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 mkosi/mkosi.repart/20-disk.conf create mode 100755 test/units/TEST-07-PID1.quota.sh diff --git a/mkosi/mkosi.repart/20-disk.conf b/mkosi/mkosi.repart/20-disk.conf new file mode 100644 index 00000000000..0090dc00da4 --- /dev/null +++ b/mkosi/mkosi.repart/20-disk.conf @@ -0,0 +1,5 @@ +[Partition] +Type=linux-generic +Format=ext4 +SizeMinBytes=498M +SizeMaxBytes=498M diff --git a/test/units/TEST-07-PID1.quota.sh b/test/units/TEST-07-PID1.quota.sh new file mode 100755 index 00000000000..748b5ee6589 --- /dev/null +++ b/test/units/TEST-07-PID1.quota.sh @@ -0,0 +1,95 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: LGPL-2.1-or-later +# shellcheck disable=SC2016 +set -eux +set -o pipefail + +systemd-analyze log-level debug + +test_quotas() { + + local directory="$1" + local exec_directory_directive="$2" + local exec_quota_directive="$3" + local mountpoint="/datadrive" + + dev_num=$(lsblk | grep "498M" | awk '{print $1}' | sed 's/[^a-zA-Z0-9]*//g') + + if ! tune2fs -Q prjquota "/dev/${dev_num}"; then + return + fi + mkdir -p "${mountpoint}" + mount "/dev/${dev_num}" "${mountpoint}" + + mv /var/lib/ "${mountpoint}" + rm -rf /var/lib/ && ln -s "${mountpoint}/lib/" /var/ + + rm -rf "${directory}/quotadir" + + cat >/run/systemd/system/testservice-07-check-quotas.service </run/systemd/system/testservice-07-check-quotas.service <