From: Karel Zak Date: Wed, 15 Oct 2025 13:30:06 +0000 (+0200) Subject: tests: (configs) add sorting and masking test X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=001f3a6d69403db2ec8a375a3255e4b5d1369890;p=thirdparty%2Futil-linux.git 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 --- diff --git a/tests/expected/misc/configs-sorting b/tests/expected/misc/configs-sorting new file mode 100644 index 000000000..fe762e86f --- /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 2f7aacacc..1457d212c 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