From: Martin Schwenke Date: Wed, 25 Jun 2025 12:14:05 +0000 (+1000) Subject: ctdb-tests: Allow tunables unit test to process a second file X-Git-Tag: tdb-1.4.14~87 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=de069d6b950531b3c2ad4584ae661980bd25a982;p=thirdparty%2Fsamba.git ctdb-tests: Allow tunables unit test to process a second file The second file is optional. Make $tfile the default to avoid having to update all of the single file testcases. Add test cases for second file. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/tests/UNIT/cunit/tunable_test_001.sh b/ctdb/tests/UNIT/cunit/tunable_test_001.sh index 1b67cc83189..caac08bd245 100755 --- a/ctdb/tests/UNIT/cunit/tunable_test_001.sh +++ b/ctdb/tests/UNIT/cunit/tunable_test_001.sh @@ -3,10 +3,11 @@ . "${TEST_SCRIPTS_DIR}/unit.sh" tfile="${CTDB_TEST_TMP_DIR}/tunable.$$" +tfile2="${CTDB_TEST_TMP_DIR}/tunable2.$$" remove_files() { - rm -f "$tfile" + rm -f "$tfile" "$tfile2" } test_cleanup remove_files @@ -111,9 +112,12 @@ ok_tunable_1() } # Set required output to a version of $defaults where values for -# tunables specified in $tfile replace the default values +# tunables specified in the given file(s) replace the default values ok_tunable() { + _f1="${1:-"${tfile}"}" + _f2="${2:-""}" + # Construct a version of $defaults prepended with a lowercase # version of the tunable variable, to allow case-insensitive # matching. This would be easier with the GNU sed @@ -125,7 +129,15 @@ ok_tunable() log="" - ok_tunable_1 "$tfile" + # + # Replace values for tunables that are set in each file + # + + ok_tunable_1 "$_f1" + + if [ -n "$_f2" ]; then + ok_tunable_1 "$_f2" + fi # Set result, stripping off lowercase tunable prefix ok "${log}$(echo "$_map" | awk -F: '{ print $2 }')" @@ -359,3 +371,42 @@ ReCoVerInTeRvAl = 10 EOF ok_tunable unit_test tunable_test "$tfile" + +# +# Subsequent tests will use the same 1st file, to reduce clutter +# + +cat >"$tfile" <"$tfile2" +ok_tunable "$tfile" "$tfile2" +unit_test tunable_test "$tfile" "$tfile2" + +test_case "OK, several tunables, 2nd file disjoint" +cat >"$tfile2" <"$tfile2" <\n", argv[0]); + if (argc != 2 && argc != 3) { + fprintf(stderr, "Usage: %s []\n", argv[0]); return 1; } @@ -54,6 +54,14 @@ int main(int argc, const char **argv) goto done; } + if (argc == 3) { + status = ctdb_tunable_load_file(mem_ctx, &tun_list, argv[2]); + if (!status) { + ret = EINVAL; + goto done; + } + } + list = ctdb_tunable_names(mem_ctx); assert(list != NULL);