xref: /aosp_15_r20/external/ltp/include/tst_kvercmp.h (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1*49cdfc7eSAndroid Build Coastguard Worker /* SPDX-License-Identifier: GPL-2.0-or-later
2*49cdfc7eSAndroid Build Coastguard Worker  * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
3*49cdfc7eSAndroid Build Coastguard Worker  * Copyright (c) 2009-2016 Cyril Hrubis [email protected]
4*49cdfc7eSAndroid Build Coastguard Worker  */
5*49cdfc7eSAndroid Build Coastguard Worker 
6*49cdfc7eSAndroid Build Coastguard Worker #ifndef TST_KVERCMP_H__
7*49cdfc7eSAndroid Build Coastguard Worker #define TST_KVERCMP_H__
8*49cdfc7eSAndroid Build Coastguard Worker 
9*49cdfc7eSAndroid Build Coastguard Worker /*
10*49cdfc7eSAndroid Build Coastguard Worker  * The same as tst_kvercmp() but running kernel version is passed as parameter
11*49cdfc7eSAndroid Build Coastguard Worker  * instead of utilizing uname().
12*49cdfc7eSAndroid Build Coastguard Worker  */
13*49cdfc7eSAndroid Build Coastguard Worker int tst_kvcmp(const char *cur_kver, int r1, int r2, int r3);
14*49cdfc7eSAndroid Build Coastguard Worker 
15*49cdfc7eSAndroid Build Coastguard Worker /*
16*49cdfc7eSAndroid Build Coastguard Worker  * Parsers string into three integer version.
17*49cdfc7eSAndroid Build Coastguard Worker  */
18*49cdfc7eSAndroid Build Coastguard Worker int tst_parse_kver(const char *str_kver, int *v1, int *v2, int *v3);
19*49cdfc7eSAndroid Build Coastguard Worker 
20*49cdfc7eSAndroid Build Coastguard Worker /*
21*49cdfc7eSAndroid Build Coastguard Worker  * Returns distribution name parsed from kernel version string or NULL.
22*49cdfc7eSAndroid Build Coastguard Worker  */
23*49cdfc7eSAndroid Build Coastguard Worker const char *tst_kvcmp_distname(const char *cur_kver);
24*49cdfc7eSAndroid Build Coastguard Worker 
25*49cdfc7eSAndroid Build Coastguard Worker /*
26*49cdfc7eSAndroid Build Coastguard Worker  * Compares versions up to five version numbers long.
27*49cdfc7eSAndroid Build Coastguard Worker  */
28*49cdfc7eSAndroid Build Coastguard Worker int tst_kvexcmp(const char *tst_exv, const char *cur_kver);
29*49cdfc7eSAndroid Build Coastguard Worker 
30*49cdfc7eSAndroid Build Coastguard Worker /*
31*49cdfc7eSAndroid Build Coastguard Worker  * Compare given kernel version with currently running kernel.
32*49cdfc7eSAndroid Build Coastguard Worker  *
33*49cdfc7eSAndroid Build Coastguard Worker  * Returns negative if older, 0 if the same and positive if newer.
34*49cdfc7eSAndroid Build Coastguard Worker  */
35*49cdfc7eSAndroid Build Coastguard Worker int tst_kvercmp(int r1, int r2, int r3);
36*49cdfc7eSAndroid Build Coastguard Worker 
37*49cdfc7eSAndroid Build Coastguard Worker struct tst_kern_exv {
38*49cdfc7eSAndroid Build Coastguard Worker 	char *dist_name;
39*49cdfc7eSAndroid Build Coastguard Worker 	char *extra_ver;
40*49cdfc7eSAndroid Build Coastguard Worker };
41*49cdfc7eSAndroid Build Coastguard Worker 
42*49cdfc7eSAndroid Build Coastguard Worker int tst_kvercmp2(int r1, int r2, int r3, struct tst_kern_exv *vers);
43*49cdfc7eSAndroid Build Coastguard Worker 
44*49cdfc7eSAndroid Build Coastguard Worker #endif	/* TST_KVERCMP_H__ */
45