Merge pull request #1596 from authmillenon/fix-expect
tests: Fix tests that were defect
This commit is contained in:
commit
ad70bb039c
@ -1,47 +0,0 @@
|
|||||||
#!/usr/bin/expect
|
|
||||||
|
|
||||||
set timeout 5
|
|
||||||
|
|
||||||
spawn pseudoterm $env(PORT)
|
|
||||||
|
|
||||||
expect {
|
|
||||||
"OK" {}
|
|
||||||
timeout { exit 1 }
|
|
||||||
}
|
|
||||||
|
|
||||||
expect {
|
|
||||||
"set callback 1" {}
|
|
||||||
timeout { exit 1 }
|
|
||||||
}
|
|
||||||
|
|
||||||
expect {
|
|
||||||
"set callback 2" {}
|
|
||||||
timeout { exit 1 }
|
|
||||||
}
|
|
||||||
|
|
||||||
expect {
|
|
||||||
"set callback 3" {}
|
|
||||||
timeout { exit 1 }
|
|
||||||
}
|
|
||||||
|
|
||||||
expect {
|
|
||||||
"callback 1" {}
|
|
||||||
timeout { exit 1 }
|
|
||||||
}
|
|
||||||
|
|
||||||
expect {
|
|
||||||
"callback 3" {}
|
|
||||||
timeout { exit 1 }
|
|
||||||
}
|
|
||||||
|
|
||||||
expect {
|
|
||||||
"callback 2" {}
|
|
||||||
timeout { exit 1 }
|
|
||||||
}
|
|
||||||
|
|
||||||
expect {
|
|
||||||
"hwtimer set." {}
|
|
||||||
timeout { exit 1 }
|
|
||||||
}
|
|
||||||
|
|
||||||
puts "\nTest successful!\n"
|
|
||||||
32
tests/hwtimer/tests/test_hwtimer.py
Executable file
32
tests/hwtimer/tests/test_hwtimer.py
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from pexpect import spawn, TIMEOUT
|
||||||
|
|
||||||
|
DEFAULT_TIMEOUT=5
|
||||||
|
hwtimers = 0
|
||||||
|
|
||||||
|
term = spawn("make term")
|
||||||
|
|
||||||
|
term.expect(r"Setting timers:", timeout=DEFAULT_TIMEOUT)
|
||||||
|
|
||||||
|
try:
|
||||||
|
while True:
|
||||||
|
term.expect(r"set callback\s+\d+", timeout=DEFAULT_TIMEOUT)
|
||||||
|
hwtimers += 1
|
||||||
|
except TIMEOUT:
|
||||||
|
pass
|
||||||
|
|
||||||
|
term.expect(r"All timers set.", timeout=DEFAULT_TIMEOUT)
|
||||||
|
term.expect(r"callback\s+1", timeout=DEFAULT_TIMEOUT)
|
||||||
|
print("Got callback 1")
|
||||||
|
|
||||||
|
while hwtimers > 1:
|
||||||
|
term.expect(r"callback\s+{:d}".format(hwtimers), timeout=DEFAULT_TIMEOUT)
|
||||||
|
print("Got callback {:d}".format(hwtimers))
|
||||||
|
hwtimers -= 1
|
||||||
|
|
||||||
|
# Setting timers:
|
||||||
|
# term.expect("OK")
|
||||||
|
if not term.terminate():
|
||||||
|
term.terminate(force=True)
|
||||||
|
|
||||||
@ -1,14 +1,8 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
import pexpect
|
import pexpect
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
child = pexpect.spawn("board/msba2/tools/bin/pseudoterm %s" % os.environ["PORT"])
|
term = pexpect.spawn("make term")
|
||||||
|
|
||||||
null = open('/dev/null', 'wb')
|
term.expect('first thread\r\n')
|
||||||
subprocess.call(['jam', 'reset'], stdout=null)
|
term.expect('second thread\r\n')
|
||||||
|
|
||||||
child.expect ('first thread\r\n')
|
|
||||||
child.expect ('second thread\r\n')
|
|
||||||
print("Test successful!")
|
|
||||||
|
|||||||
@ -1,12 +0,0 @@
|
|||||||
#!/usr/bin/expect
|
|
||||||
|
|
||||||
set timeout 5
|
|
||||||
|
|
||||||
spawn board/msba2/tools/bin/pseudoterm $env(PORT)
|
|
||||||
|
|
||||||
expect {
|
|
||||||
"Hello World!" {}
|
|
||||||
timeout { exit 1 }
|
|
||||||
}
|
|
||||||
|
|
||||||
puts "\nTest successful!\n"
|
|
||||||
Loading…
x
Reference in New Issue
Block a user