Rather than adding yet another version comparison function is there some way
you could make use of the compare_versions function in
client/common_lib/utils.py?

-- John

On Tue, May 11, 2010 at 5:06 AM, Jason Wang <[email protected]> wrote:

> Previous version comparsion in check_glibc_ver() and
> check_kernel_ver() may think 2.11 is older than 2.5 so this patch
> compare the versions by converting them into digit numbers through a
> helper function.
> ---
>  client/bin/base_utils.py |   20 ++++++++++++++++++--
>  1 files changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/client/bin/base_utils.py b/client/bin/base_utils.py
> index a3e989c..e0ffb9f 100644
> --- a/client/bin/base_utils.py
> +++ b/client/bin/base_utils.py
> @@ -520,18 +520,34 @@ def cpu_online_map():
>             cpus.append(line.split()[2]) # grab cpu number
>     return cpus
>
> +def check_ver(v1, v2):
> +    """
> +    Check whether version v1 is less or equal than version v2
> +    """
> +    v1s = v1.split('.')
> +    v2s = v2.split('.')
> +    while v1s:
> +        v1 = int(v1s.pop(0))
> +        if not v2s:
> +            return False
> +        v2 = int(v2s.pop(0))
> +        if v1 < v2:
> +            return True
> +        elif v1 > v2:
> +            return False
> +    return True
>
>  def check_glibc_ver(ver):
>     glibc_ver = commands.getoutput('ldd --version').splitlines()[0]
>     glibc_ver = re.search(r'(\d+\.\d+(\.\d+)?)', glibc_ver).group()
> -    if glibc_ver.split('.') < ver.split('.'):
> +    if not check_ver(ver, glibc_ver):
>         raise error.TestError("Glibc too old (%s). Glibc >= %s is needed."
> % \
>                                                 (glibc_ver, ver))
>
>  def check_kernel_ver(ver):
>     kernel_ver = utils.system_output('uname -r')
>     kv_tmp = re.split(r'[-]', kernel_ver)[0:3]
> -    if kv_tmp[0].split('.') < ver.split('.'):
> +    if not check_ver(ver, kv_tmp[0]):
>         raise error.TestError("Kernel too old (%s). Kernel > %s is needed."
> % \
>                                                 (kernel_ver, ver))
>
>
> _______________________________________________
> Autotest mailing list
> [email protected]
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
>
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to