Skip to content

Commit

Permalink
target: Handle non-existing /sys/devices/system/node
Browse files Browse the repository at this point in the history
Some systems (ARM 32bits it seems) don't have this file in sysfs. Assume 1 node
in that case.
  • Loading branch information
douglas-raillard-arm authored and marcbonnici committed Jan 22, 2020
1 parent 0aeb5bc commit 9661c6b
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions devlib/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,18 @@ def number_of_cpus(self):
@property
@memoized
def number_of_nodes(self):
num_nodes = 0
nodere = re.compile(r'^\./node\d+\s*$')
cmd = 'cd /sys/devices/system/node && {busybox} find . -maxdepth 1'.format(busybox=quote(self.busybox))
output = self.execute(cmd, as_root=self.is_rooted)
for entry in output.splitlines():
if nodere.match(entry):
num_nodes += 1
return num_nodes
try:
output = self.execute(cmd, as_root=self.is_rooted)
except TargetStableError:
return 1
else:
nodere = re.compile(r'^\./node\d+\s*$')
num_nodes = 0
for entry in output.splitlines():
if nodere.match(entry):
num_nodes += 1
return num_nodes

@property
@memoized
Expand Down

0 comments on commit 9661c6b

Please sign in to comment.