From c1b5152790eca934130703997a15a1e631db4522 Mon Sep 17 00:00:00 2001 From: Brendan Jackman Date: Wed, 23 Nov 2016 13:44:00 +0000 Subject: [PATCH] target: Use root in file_exists check Use case: To check if a kernel supports function profiling we need to check for the presence of "/sys/kernel/debug/tracing/function_profiler_enabled", but "/sys/kernel/debug/"'s permissions are 700. --- devlib/target.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/devlib/target.py b/devlib/target.py index be77180..7623cd3 100644 --- a/devlib/target.py +++ b/devlib/target.py @@ -362,7 +362,8 @@ class Target(object): def file_exists(self, filepath): command = 'if [ -e \'{}\' ]; then echo 1; else echo 0; fi' - return boolean(self.execute(command.format(filepath)).strip()) + output = self.execute(command.format(filepath), as_root=self.is_rooted) + return boolean(output.strip()) def directory_exists(self, filepath): output = self.execute('if [ -d \'{}\' ]; then echo 1; else echo 0; fi'.format(filepath))