tests: relax the "version text" length check, accept longer strings
The version text length check fails for git setups that use more digits in abbreviated hashes, as is recommended by e.g. the Linux kernel project. Raise the upper limit for acceptable version strings, and add comments on how the limits were determined. The test still might fail in setups of slightly different configuration, but now it's easier to see why the test failed, and how to adjust the test. Signed-off-by: Gerhard Sittig <gerhard.sittig@gmx.net>
This commit is contained in:
parent
7c86d85372
commit
3cc2028382
tests
|
@ -60,21 +60,38 @@ END_TEST
|
||||||
/*
|
/*
|
||||||
* Check the version number API calls and macros.
|
* Check the version number API calls and macros.
|
||||||
*
|
*
|
||||||
* The string representations of the package/lib version must match the
|
* The string representations of the package/lib version must neither be
|
||||||
* version numbers, the string lengths must be >= 5 (e.g. "0.1.0"), and
|
* NULL nor empty, and the length shall be within an expected range.
|
||||||
* the strings length must be <= 20 characters, otherwise something is
|
*
|
||||||
* probably wrong.
|
* The lower limit assumes:
|
||||||
|
* - A version text consists of three parts (major, minor, micro),
|
||||||
|
* like "0.1.0".
|
||||||
|
* - Three numbers with at least one digit, and their separators,
|
||||||
|
* result in a minimum length of 5.
|
||||||
|
*
|
||||||
|
* The upper limit assumes:
|
||||||
|
* - The major, minor, and micro parts won't contain more than two
|
||||||
|
* digits each (this is an arbitrary choice).
|
||||||
|
* - An optional "-git-<hash>" 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.
|
||||||
*/
|
*/
|
||||||
START_TEST(test_version_strings)
|
START_TEST(test_version_strings)
|
||||||
{
|
{
|
||||||
const char *str;
|
const char *str;
|
||||||
|
const size_t len_min = 5;
|
||||||
|
const size_t len_max = 2 + 1 + 2 + 1 + 2 + 5 + 12;
|
||||||
|
|
||||||
str = sr_package_version_string_get();
|
str = sr_package_version_string_get();
|
||||||
fail_unless(str != NULL);
|
fail_unless(str != NULL);
|
||||||
fail_unless(strlen(str) >= 5 && strlen(str) <= 20);
|
fail_unless(strlen(str) >= len_min);
|
||||||
|
fail_unless(strlen(str) <= len_max);
|
||||||
str = sr_lib_version_string_get();
|
str = sr_lib_version_string_get();
|
||||||
fail_unless(str != NULL);
|
fail_unless(str != NULL);
|
||||||
fail_unless(strlen(str) >= 5 && strlen(str) <= 20);
|
fail_unless(strlen(str) >= len_min);
|
||||||
|
fail_unless(strlen(str) <= len_max);
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue