From: Gerhard Sittig Date: Sun, 2 Jul 2023 07:20:49 +0000 (+0200) Subject: tests: raise maximum version text length (dirty flag) X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=f3bca6d9cec6fea8c3dc3754eabe8d8d7c684788;p=libsigrok.git tests: raise maximum version text length (dirty flag) The previous implementation of the version text length check accounted for the major, minor, micro numbers and the git hash. Raise the upper limit of the accepted text length range to also account for the optional "dirty" flag. Update comments to keep awareness of the magic numbers in the length calculation. --- diff --git a/tests/version.c b/tests/version.c index fa3a63cb..2b0faff3 100644 --- a/tests/version.c +++ b/tests/version.c @@ -70,27 +70,31 @@ END_TEST * * The upper limit assumes: * - The major, minor, and micro parts won't contain more than two - * digits each (this is an arbitrary choice). + * digits each (this is an arbitrary choice). The three numbers + * are separated by a period character. * - An optional "-git-" suffix might follow. While git(1) * defaults to 7 hex digits for abbreviated hashes, projects of * larger scale might recommend to use more digits to avoid * potential ambiguity (e.g. Linux recommends core.abbrev=12). * Again, this is an arbitrary choice. + * - An optional "-dirty" suffix might follow. */ START_TEST(test_version_strings) { const char *str; const size_t len_min = 5; - const size_t len_max = 2 + 1 + 2 + 1 + 2 + 5 + 12; + const size_t len_max = 2 + 1 + 2 + 1 + 2 + 5 + 12 + 6; str = sr_package_version_string_get(); fail_unless(str != NULL); fail_unless(strlen(str) >= len_min); - fail_unless(strlen(str) <= len_max); + fail_unless(strlen(str) <= len_max, + "Max len exceeded, max %zu, text %s", len_max, str); str = sr_lib_version_string_get(); fail_unless(str != NULL); fail_unless(strlen(str) >= len_min); - fail_unless(strlen(str) <= len_max); + fail_unless(strlen(str) <= len_max, + "Max len exceeded, max %zu, text %s", len_max, str); } END_TEST