Skip to content

Commit 3486bcb

Browse files
committed
rtapi_app no autostart: Fix raster/test the proper way take 3
1 parent 3e1db68 commit 3486bcb

2 files changed

Lines changed: 6 additions & 29 deletions

File tree

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
import hal
33
import time
4-
import subprocess
4+
import os
55
from raster import *
66

77
theta = 0.005
@@ -193,19 +193,10 @@ def main():
193193

194194
prog = RasterProgrammer("programmer")
195195

196-
#instantiate the raster component
197-
#use interactive mode to be have the hal running
198-
#while needed and exit with writing "exit" at the end
199-
halrun = subprocess.Popen(["halrun", "-Is", "raster.hal"], stdin=subprocess.PIPE)
200-
#Test the last connection added in raster.hal
201-
#to determine if hal is up and running
202-
deadline = time.time() + 5
203-
while time.time() < deadline:
204-
if hal.pin_has_writer("test.fraction"):
205-
break
206-
time.sleep(0.01)
207-
else:
208-
raise RuntimeError("raster.hal did not come up within 5s")
196+
#instantiate the raster component,
197+
#add it to a thread and link all signals from
198+
#the test component here
199+
assert os.system('halcmd -f raster.hal') == 0, "raster.hal script failed"
209200

210201
testInvalidOffset(prog, pin)
211202
testInvalidBPP(prog, pin)
@@ -261,21 +252,6 @@ def main():
261252
finally:
262253
c.exit()
263254
prog.exit()
264-
try:
265-
try:
266-
halrun.communicate(input=b"exit\n", timeout=5)
267-
except subprocess.TimeoutExpired:
268-
halrun.kill()
269-
halrun.communicate()
270-
exit_status = halrun.returncode
271-
if exit_status == 0:
272-
return 0
273-
else:
274-
print("Halrun failed, exit status " + str(exit_status))
275-
return 1
276-
except Exception as e:
277-
print("error: Test failed: {}".format(traceback.format_exc()))
278-
return 1
279255
return 0
280256

281257
if __name__ == "__main__":

tests/raster/test.hal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
loadusr -w ./rastertest.py

0 commit comments

Comments
 (0)