[gnome-continuous-yocto/gnomeostree-3.28-rocko: 1916/8267] oeqa.buildperf: use oe.path.remove()



commit 9800b4d9ffda22466066ab1d301e4730e61726e0
Author: Markus Lehtonen <markus lehtonen linux intel com>
Date:   Fri Aug 12 14:35:54 2016 +0300

    oeqa.buildperf: use oe.path.remove()
    
    Drop the self-baked force_rm() method.
    
    (From OE-Core rev: c86bf80abd87acb0da5860806822c64ec9dee089)
    
    Signed-off-by: Markus Lehtonen <markus lehtonen linux intel com>
    Signed-off-by: Ross Burton <ross burton intel com>
    Signed-off-by: Richard Purdie <richard purdie linuxfoundation org>

 meta/lib/oeqa/buildperf/base.py       |   15 ++++-----------
 meta/lib/oeqa/buildperf/test_basic.py |    5 +++--
 2 files changed, 7 insertions(+), 13 deletions(-)
---
diff --git a/meta/lib/oeqa/buildperf/base.py b/meta/lib/oeqa/buildperf/base.py
index fe18181..c1dc86e 100644
--- a/meta/lib/oeqa/buildperf/base.py
+++ b/meta/lib/oeqa/buildperf/base.py
@@ -23,6 +23,7 @@ import unittest
 from datetime import datetime, timedelta
 from functools import partial
 
+import oe.path
 from oeqa.utils.commands import CommandError, runCmd, get_bb_vars
 from oeqa.utils.git import GitError, GitRepo
 
@@ -297,29 +298,21 @@ class BuildPerfTestCase(unittest.TestCase):
         shutil.move(self.bb_vars['BUILDSTATS_BASE'],
                     os.path.join(self.out_dir, 'buildstats-' + self.name))
 
-    @staticmethod
-    def force_rm(path):
-        """Equivalent of 'rm -rf'"""
-        if os.path.isfile(path) or os.path.islink(path):
-            os.unlink(path)
-        elif os.path.isdir(path):
-            shutil.rmtree(path)
-
     def rm_tmp(self):
         """Cleanup temporary/intermediate files and directories"""
         log.debug("Removing temporary and cache files")
         for name in ['bitbake.lock', 'conf/sanity_info',
                      self.bb_vars['TMPDIR']]:
-            self.force_rm(name)
+            oe.path.remove(name, recurse=True)
 
     def rm_sstate(self):
         """Remove sstate directory"""
         log.debug("Removing sstate-cache")
-        self.force_rm(self.bb_vars['SSTATE_DIR'])
+        oe.path.remove(self.bb_vars['SSTATE_DIR'], recurse=True)
 
     def rm_cache(self):
         """Drop bitbake caches"""
-        self.force_rm(self.bb_vars['PERSISTENT_DIR'])
+        oe.path.remove(self.bb_vars['PERSISTENT_DIR'], recurse=True)
 
     @staticmethod
     def sync():
diff --git a/meta/lib/oeqa/buildperf/test_basic.py b/meta/lib/oeqa/buildperf/test_basic.py
index b8bec6d..9310f3d 100644
--- a/meta/lib/oeqa/buildperf/test_basic.py
+++ b/meta/lib/oeqa/buildperf/test_basic.py
@@ -13,6 +13,7 @@
 import os
 import shutil
 
+import oe.path
 from oeqa.buildperf import BuildPerfTestCase
 from oeqa.utils.commands import get_bb_vars
 
@@ -85,11 +86,11 @@ class Test3(BuildPerfTestCase):
         """Parsing time metrics (bitbake -p)"""
         # Drop all caches and parse
         self.rm_cache()
-        self.force_rm(os.path.join(self.bb_vars['TMPDIR'], 'cache'))
+        oe.path.remove(os.path.join(self.bb_vars['TMPDIR'], 'cache'), True)
         self.measure_cmd_resources(['bitbake', '-p'], 'parse_1',
                                    'bitbake -p (no caches)')
         # Drop tmp/cache
-        self.force_rm(os.path.join(self.bb_vars['TMPDIR'], 'cache'))
+        oe.path.remove(os.path.join(self.bb_vars['TMPDIR'], 'cache'), True)
         self.measure_cmd_resources(['bitbake', '-p'], 'parse_2',
                                    'bitbake -p (no tmp/cache)')
         # Parse with fully cached data


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]