[PATCH rtems_waf 2/2] rtems: Add function to test waf uninstall

Chris Johns chrisj at rtems.org
Fri Jul 24 04:52:41 UTC 2020


On 24/7/20 2:37 am, Vijay Kumar Banerjee wrote:
> ---
>  rtems.py | 40 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
> 
> diff --git a/rtems.py b/rtems.py
> index 067a213..ab6d03b 100644
> --- a/rtems.py
> +++ b/rtems.py
> @@ -303,6 +303,46 @@ def build(bld):
>      if bld.env.LONG_COMMANDS == 'yes':
>          long_command_line()
>  
> +def get_dir_hash(bld):
> +    from waflib import ConfigSet, Options
> +    import hashlib
> +
> +    env = ConfigSet.ConfigSet()
> +    env.load(Options.lockfile)
> +    prefix = env.options['prefix']
> +    shahash = hashlib.sha1()
> +
> +    for root, dirs, files in os.walk(prefix):
> +        for names in files:
> +            filepath = os.path.join(root, names)
> +            try:
> +                f1 = open(filepath, 'rb')
> +            except:
> +                f1.close()
> +                continue
> +
> +            while 1:
> +                buf = f1.read(4096)
> +                if not buf:
> +                    break
> +                shahash.update(hashlib.sha1(buf).hexdigest())
> +            f1.close()
> +    return shahash.hexdigest()
> +
> +def test_uninstall(bld):

Please move to the end of the file.

> +    print('TESTING WAF UNINSTALL\n')

I am not a fan of all caps...

 print('Test: uninstall')

Also please do not embed `\n'. If you want another line feed please add the
extra print().

> +    print('CALCULATING HASH BEFORE INSTALL')

What about ...

> +    initial_hash = get_dir_hash(bld)

 print('Preinstall hash: XXX') where XXX is the hash string?

> +    subprocess.call(['./waf', 'install'])
> +    subprocess.call(['./waf', 'uninstall'])

What happens if `waf` is in my $PATH and not in `./`?

> +    print('CALCULATING HASH AFTER UNINSTALL')
> +    final_hash = get_dir_hash(bld)

 print('Postinstall hash: XXX') ?

> +
> +    if (initial_hash == final_hash):
> +        print("TEST PASSED")
> +    else:
> +        print("TEST FAILED")
> +
>  def load_cpuopts(conf):
>      options = ['RTEMS_DEBUG',
>                 'RTEMS_MULTIPROCESSING',
> 

Chris


More information about the devel mailing list