For backport kernels where the functionality is more advanced than the base
kernel version implies, allow 'KVER' environment to override the results of
'uname -r'.
Signed-off-by: Dan Williams <dan.j.williams(a)intel.com>
---
test/core.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/test/core.c b/test/core.c
index b5703273fa76..c2d225d4921e 100644
--- a/test/core.c
+++ b/test/core.c
@@ -14,12 +14,16 @@ struct ndctl_test {
static unsigned int get_system_kver(void)
{
+ const char *kver = getenv("KVER");
struct utsname utsname;
int a, b, c;
- uname(&utsname);
+ if (!kver) {
+ uname(&utsname);
+ kver = utsname.release;
+ }
- if (sscanf(utsname.release, "%d.%d.%d", &a, &b, &c) != 3)
+ if (sscanf(kver, "%d.%d.%d", &a, &b, &c) != 3)
return LINUX_VERSION_CODE;
return KERNEL_VERSION(a,b,c);