library: Fix LINUX_VERSION macro

The previous commit did not take into account operator evaluation
order so always gave 0. Fixed the macro and added some checks for
the macro.

References:
 commit 9abf7d879d
This commit is contained in:
Craig Small
2016-05-01 17:46:25 +10:00
parent 9abf7d879d
commit 19a515e314
2 changed files with 30 additions and 1 deletions

View File

@@ -30,7 +30,36 @@ int check_linux_version(void *data)
return (procps_linux_version() > 0);
}
int check_conversion(void *data)
{
testname = "LINUX_VERSION macro";
struct testvals {
int retval;
int major, minor, patch;
};
struct testvals *tv;
struct testvals tvs[] = {
{ 132096, 2, 4, 0 },
{ 132635, 2, 6, 27 },
{ 199936, 3, 13, 0 },
{ 263426, 4, 5, 2 },
{ 0, 0, 0, 0}
};
for (tv=tvs; tv->major != 0; tv++)
{
if (LINUX_VERSION(tv->major, tv->minor, tv->patch) != tv->retval) {
fprintf(stderr, "Failed %d != %d\n", LINUX_VERSION(tv->major, tv->minor,
tv->patch), tv->retval);
return 0;
}
}
return 1;
}
TestFunction test_funcs[] = {
check_conversion,
check_linux_version,
NULL
};