Commit 694fab34 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Add julia tests

parent 9e6d5436
CTEST = test_start_stop test_io test_moberg4simulink
PYTEST=test_py
JULIATEST=test_jl
CCFLAGS += -Wall -Werror -I$(shell pwd) -g
LDFLAGS += -L$(shell pwd)/build/ -lmoberg
ENV_TEST = LD_LIBRARY_PATH=../build XDG_CONFIG_HOME=.config XDG_CONFIG_DIRS=.
ENV_TEST = LD_LIBRARY_PATH=../build \
XDG_CONFIG_HOME=.config \
XDG_CONFIG_DIRS=. \
JULIA_LOAD_PATH=../adaptors/julia
LDFLAGS_test_moberg4simulink = -lmoberg4simulink
CCFLAGS_test_moberg4simulink = -I../adaptors/matlab -Wall -Werror -I$(shell pwd) -g
PYTHON2PATH=$(shell realpath ../adaptors/python/install/usr/lib*/python2*/site-packages)
......@@ -10,7 +14,7 @@ PYTHON3PATH=$(shell realpath ../adaptors/python/install/usr/lib*/python3*/site-p
all:
.PHONY: test
test: $(PYTEST:%=run_py_%) $(CTEST:%=run_c_%)
test: $(PYTEST:%=run_py_%) $(JULIATEST:%=run_jl_%) $(CTEST:%=run_c_%)
echo Tests run
.PHONY: run_c_%
......@@ -22,6 +26,10 @@ run_py_%: %.py
$(ENV_TEST) PYTHONPATH=$(PYTHON2PATH) python2 $*.py
$(ENV_TEST) PYTHONPATH=$(PYTHON3PATH) python3 $*.py
.PHONY: run_jl_%
run_jl_%: %.jl
$(ENV_TEST) julia $*.jl
.PRECIOUS: build/%
build/%: %.c | build
......
#!/usr/bin/julia
push!(LOAD_PATH, ".")
using MobergIO
import MobergIO: read, write
function test()
m = MobergIO.Moberg()
println(m)
for v in -10.0:2.0:10
for i in 0:1
try
aout = MobergIO.AnalogOut(m, Unsigned(i))
value = v + i;
write(aout, value)
print("$value ")
catch ex
println("analog_out $i does not exist $(ex)")
end
end
println()
sleep(0.01)
for j in 0:3
try
ain = MobergIO.AnalogIn(m, Unsigned(j))
println(read(ain))
catch ex
println("analog_in $j does not exist $(ex)")
end
end
println()
# GC.gc()
end
for v in false:true
for i in 0:6
try
dout = MobergIO.DigitalOut(m, Unsigned(i))
value = xor(v, isodd(i))
write(dout, value)
print("$value ")
catch ex
println("digital_out $i does not exist $(ex)")
end
end
println()
for i in 0:6
try
din = MobergIO.DigitalIn(m, Unsigned(i))
print("$(read(din)) ")
catch ex
println("digital_out $i does not exist $(ex)")
end
end
println()
println()
sleep(0.01)
end
end
test()
println("DONE")
GC.gc()
println("Really DONE")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment