[rtems_waf commit] rtems: Add function to test waf uninstall

Chris Johns chrisj at rtems.org
Mon Jul 27 02:44:22 UTC 2020


Module:    rtems_waf
Branch:    master
Commit:    945b0b9c069959266c698eeda51cedd2a055b9fe
Changeset: http://git.rtems.org/rtems_waf/commit/?id=945b0b9c069959266c698eeda51cedd2a055b9fe

Author:    Vijay Kumar Banerjee <vijay at rtems.org>
Date:      Fri Jul 24 21:02:13 2020 +0530

rtems: Add function to test waf uninstall

---

 rtems.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/rtems.py b/rtems.py
index 067a213..7ee3653 100644
--- a/rtems.py
+++ b/rtems.py
@@ -897,6 +897,52 @@ def _strip_cflags(cflags):
 def _log_header(conf):
     conf.to_log('-----------------------------------------')
 
+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):
+    from os import sys
+
+    print('Test: uninstall')
+    initial_hash = _get_dir_hash(bld)
+    print('Preinstall hash: %s' % (initial_hash))
+    try:
+        subprocess.call(['waf', 'install'])
+        subprocess.call(['waf', 'uninstall'])
+    except:
+        subprocess.call(['./waf', 'install'])
+        subprocess.call(['./waf', 'uninstall'])
+    final_hash = _get_dir_hash(bld)
+    print('Post install hash: %s' % (final_hash))
+
+    if (initial_hash == final_hash):
+        print("Test successful")
+    else:
+        print("Test failed")
+
 from waflib import Task
 from waflib import TaskGen
 from waflib import Utils



More information about the vc mailing list