aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2025-10-15 15:30:06 +0200
committerKarel Zak <kzak@redhat.com>2025-10-15 15:30:06 +0200
commit001f3a6d69403db2ec8a375a3255e4b5d1369890 (patch)
treebb2b385b95149ae432903e4ed0433934ac3ab0ee
parent7609cb258d4975e49b020860f8ebba6feb5f2354 (diff)
downloadutil-linux-001f3a6d69403db2ec8a375a3255e4b5d1369890.tar.gz
tests: (configs) add sorting and masking test
Add a new test that verifies: - Main config file appears first - Drop-in files are sorted alphabetically - Files from /etc mask same-named files from /usr - Priority ordering is correct (etc > usr) The test creates mmm.conf in both /etc and /usr to verify that the /etc version takes precedence and /usr version is masked (not included in output). Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--tests/expected/misc/configs-sorting12
-rwxr-xr-xtests/ts/misc/configs20
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/expected/misc/configs-sorting b/tests/expected/misc/configs-sorting
new file mode 100644
index 0000000000..fe762e86fc
--- /dev/null
+++ b/tests/expected/misc/configs-sorting
@@ -0,0 +1,12 @@
+@TESTDIR@/etc/proj/example.conf
+@TESTDIR@/etc/proj/example.conf.d/bbb.conf
+@TESTDIR@/etc/proj/example.conf.d/mmm.conf
+@TESTDIR@/usr/proj/example.conf.d/aaa.conf
+@TESTDIR@/usr/proj/example.conf.d/mmm.conf
+@TESTDIR@/usr/proj/example.conf.d/zzz.conf
+Found 5 configuration file(s):
+ @TESTDIR@/etc/proj/example.conf
+ @TESTDIR@/usr/proj/example.conf.d/aaa.conf
+ @TESTDIR@/etc/proj/example.conf.d/bbb.conf
+ @TESTDIR@/etc/proj/example.conf.d/mmm.conf
+ @TESTDIR@/usr/proj/example.conf.d/zzz.conf
diff --git a/tests/ts/misc/configs b/tests/ts/misc/configs
index 2f7aacacce..1457d212c0 100755
--- a/tests/ts/misc/configs
+++ b/tests/ts/misc/configs
@@ -115,4 +115,24 @@ $TS_HELPER_CONFIGS --etc "$ETC_DIR" --run "$RUN_DIR" --usr "$USR_DIR" \
rm -f "$ETC_DIR/test.conf"
ts_finalize_subtest
+# Test 8: Alphabetical sorting order with main config and masking
+ts_init_subtest "sorting"
+echo "main config" > "$ETC_DIR/proj/example.conf"
+mkdir -p "$ETC_DIR/proj/example.conf.d"
+mkdir -p "$USR_DIR/proj/example.conf.d"
+# Create files with names that test sorting and masking
+echo "aaa from usr" > "$USR_DIR/proj/example.conf.d/aaa.conf"
+echo "zzz from usr" > "$USR_DIR/proj/example.conf.d/zzz.conf"
+echo "mmm from usr" > "$USR_DIR/proj/example.conf.d/mmm.conf"
+echo "bbb from etc" > "$ETC_DIR/proj/example.conf.d/bbb.conf"
+echo "mmm from etc" > "$ETC_DIR/proj/example.conf.d/mmm.conf" # masks usr/mmm.conf
+find "$TESTDIR" -type f | sed "s|$TESTDIR|@TESTDIR@|g" | sort >> $TS_OUTPUT
+$TS_HELPER_CONFIGS --etc "$ETC_DIR" --run "$RUN_DIR" --usr "$USR_DIR" \
+ --project "proj" --name "example" --suffix "conf" \
+ | sed "s|$TESTDIR|@TESTDIR@|g" >> $TS_OUTPUT 2>> $TS_ERRLOG
+rm -f "$ETC_DIR/proj/example.conf"
+rm -rf "$ETC_DIR/proj/example.conf.d"
+rm -rf "$USR_DIR/proj/example.conf.d"
+ts_finalize_subtest
+
ts_finalize