Skip to content

Commit

Permalink
Use sysfs to check can state in test
Browse files Browse the repository at this point in the history
The output of `ip addr` might lead to different results depending on the
time it takes for pexpect to send the command after the `ip link`
command. For this reason, sysfs is used to check the state.

Signed-off-by: Nils Bosbach <bosbach@ice.rwth-aachen.de>
  • Loading branch information
nbosb committed Aug 2, 2024
1 parent 73d0422 commit 3eca2e8
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tests/linux_boot.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,22 @@ p.expect('can0:')
p.expect('# ')
p.sendline('ip link set can0 up type can bitrate 1000000')

# can we bringup the can controller?
# is the can if up?
p.expect('# ')
p.sendline('ip addr')
p.expect('can0: <NOARP,UP,LOWER_UP,ECHO>')
p.sendline('sleep 2 && cat /sys/class/net/can0/operstate')
p.expect('up')

# can we send a package?
p.expect('# ')
p.sendline('cansend can0 123#deadbeef')
p.sendline('cansend can0 123#deadbeef && sleep 2')
p.expect('# ')

# test ok - shut down simulation
p.sendline('devmem 0x10008000 32 1')
p.expect(pexpect.EOF)

# check if can packed arrived
with open('system.canbridge.tx', 'r') as f:
line = f.readline()
assert('frame #1 CAN 123 [00] de ad be ef' in line)

# test ok - shut down simulation
p.sendline('devmem 0x10008000 32 1')
p.expect(pexpect.EOF)

0 comments on commit 3eca2e8

Please sign in to comment.