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

Vijay Kumar Banerjee vijay at rtems.org
Thu Jul 23 16:37:00 UTC 2020


---
 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):
+    print('TESTING WAF UNINSTALL\n')
+    print('CALCULATING HASH BEFORE INSTALL')
+    initial_hash = get_dir_hash(bld)
+    subprocess.call(['./waf', 'install'])
+    subprocess.call(['./waf', 'uninstall'])
+    print('CALCULATING HASH AFTER UNINSTALL')
+    final_hash = get_dir_hash(bld)
+
+    if (initial_hash == final_hash):
+        print("TEST PASSED")
+    else:
+        print("TEST FAILED")
+
 def load_cpuopts(conf):
     options = ['RTEMS_DEBUG',
                'RTEMS_MULTIPROCESSING',
-- 
2.21.1



More information about the devel mailing list