Update benchmarks to handle cog workflows
Test: run ./build/make/tools/benchmarks in a cog workspace
Change-Id: I421d1d08b4e90a79b8416486025229d4f3263fbe
diff --git a/tools/perf/benchmarks b/tools/perf/benchmarks
index 61bf888..06e0009 100755
--- a/tools/perf/benchmarks
+++ b/tools/perf/benchmarks
@@ -131,8 +131,14 @@
"""Remove the out directory."""
def remove_out():
out_dir = utils.get_out_dir()
+ #only remove actual contents, in case out is a symlink (as is the case for cog)
if os.path.exists(out_dir):
- shutil.rmtree(out_dir)
+ for filename in os.listdir(out_dir):
+ p = os.path.join(out_dir, filename)
+ if os.path.isfile(p) or os.path.islink(p):
+ os.remove(p)
+ elif os.path.isdir(p):
+ shutil.rmtree(p)
return Change(label="Remove out", change=remove_out, undo=lambda: None)