Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,14 @@ def mock_value(self, file_path, value):
:param value: Value to write to sys fs file.
:return:
"""
out = self.dut.stat(path=file_path)
if not out['stat']['exists']:
raise SysfsNotExistError('{} not exist'.format(file_path))
if out['stat']['islnk']:
self._unlink(file_path)
else:
self._cache_file_value(file_path)
if file_path not in self.regular_file_list and file_path not in self.unlink_file_list:
out = self.dut.stat(path=file_path)
if not out['stat']['exists']:
raise SysfsNotExistError('{} not exist'.format(file_path))
if out['stat']['islnk']:
self._unlink(file_path)
else:
self._cache_file_value(file_path)
self.dut.shell('echo \'{}\' > {}'.format(value, file_path))

def read_thermal_value(self, file_path):
Expand Down Expand Up @@ -242,26 +243,24 @@ def _cache_file_value(self, file_path):
:param file_path: Regular file path.
:return:
"""
if file_path not in self.regular_file_list:
try:
output = self.dut.command("cat %s" % file_path)
value = output["stdout"]
self.regular_file_list[file_path] = value.strip()
except Exception as e:
assert 0, "Get content from %s failed, exception: %s" % (file_path, repr(e))
try:
output = self.dut.command("cat %s" % file_path)
value = output["stdout"]
self.regular_file_list[file_path] = value.strip()
except Exception as e:
assert 0, "Get content from %s failed, exception: %s" % (file_path, repr(e))

def _unlink(self, file_path):
"""
Unlink given sys fs file, record its soft link target.
:param file_path: Sys fs file path.
:return:
"""
if file_path not in self.unlink_file_list:
readlink_output = self.dut.command('readlink {}'.format(file_path))
self.unlink_file_list[file_path] = readlink_output["stdout"]
self.dut.command('unlink {}'.format(file_path))
self.dut.command('touch {}'.format(file_path))
self.dut.command('chown admin {}'.format(file_path))
readlink_output = self.dut.command('readlink {}'.format(file_path))
self.unlink_file_list[file_path] = readlink_output["stdout"]
self.dut.command('unlink {}'.format(file_path))
self.dut.command('touch {}'.format(file_path))
self.dut.command('chown admin {}'.format(file_path))

def deinit(self):
"""
Expand Down