Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions TestConcoreHpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ static void test_load_params_semicolon_format() {

static void test_tryparam_comma_in_value() {
setup_dirs();
write_file("in/1/concore.params", "{'channels': [1, 2], 'gain': '0.5'}");
write_file("in1/concore.params", "{'channels': [1, 2], 'gain': '0.5'}");

Concore c;
c.delay = 0;
Expand All @@ -342,7 +342,7 @@ static void test_tryparam_comma_in_value() {
check("tryparam preserves list with comma", c.tryparam("channels", "") == "[1, 2]");
check("tryparam preserves subsequent key", c.tryparam("gain", "") == "0.5");

rm("in/1/concore.params");
rm("in1/concore.params");
}

// ------------- main -------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion concore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,11 @@ function _zmq_read(port_name::AbstractString, initstr::AbstractString)::Vector{F
port = get(zmq_ports, String(port_name), nothing)
port === nothing && error("ZMQ port '$port_name' not registered")

global simtime
global s, simtime
_apply_write()
try
msg = _zmq_recv(port.socket)
s = _cap_s(s, msg)
vals = safe_parse_list(msg)
simtime = max(simtime, vals[1])
return vals[2:end]
Expand Down
3 changes: 2 additions & 1 deletion concoredocker.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,11 @@ function _zmq_read(port_name::AbstractString, initstr::AbstractString)::Vector{F
port = get(zmq_ports, String(port_name), nothing)
port === nothing && error("ZMQ port '$port_name' not registered")

global simtime
global s, simtime
_apply_write()
try
msg = _zmq_recv(port.socket)
s = _cap_s(s, msg)
vals = safe_parse_list(msg)
simtime = max(simtime, vals[1])
return vals[2:end]
Expand Down
22 changes: 22 additions & 0 deletions tests/julia/test_concoredocker.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,26 @@ const DockerConcore = DockerRuntime.Concore
end
end

if DockerConcore.HAS_ZMQ
@testset "ZMQ read updates unchanged" begin
using Sockets

reset_docker_state!()
server = Sockets.listen(Sockets.localhost, 0)
tcp_port = Sockets.getsockname(server)[2]
close(server)
address = "tcp://127.0.0.1:$tcp_port"

DockerConcore.init_zmq_port("out", "bind", address, "PAIR")
DockerConcore.init_zmq_port("in", "connect", address, "PAIR")
sleep(0.1)

DockerConcore.concore_write("out", "signal", [10.0])
@test DockerConcore.unchanged()
@test DockerConcore.concore_read("in", "signal", "[0.0, 0.0]") == [10.0]
@test !DockerConcore.unchanged()
DockerConcore.terminate_zmq()
end
end

end
18 changes: 18 additions & 0 deletions tests/julia/test_zmq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,24 @@
@test Concore.simtime == 4.0
reset_zmq_state!()
end

@testset "ZMQ read updates unchanged" begin
reset_zmq_state!()
server = Sockets.listen(Sockets.localhost, 0)
tcp_port = Sockets.getsockname(server)[2]
close(server)
address = "tcp://127.0.0.1:$tcp_port"

Concore.init_zmq_port("out", "bind", address, "PAIR")
Concore.init_zmq_port("in", "connect", address, "PAIR")
sleep(0.1)

Concore.concore_write("out", "signal", [10.0])
@test Concore.unchanged()
@test Concore.concore_read("in", "signal", "[0.0, 0.0]") == [10.0]
@test !Concore.unchanged()
reset_zmq_state!()
end
else
@testset "live ZMQ skipped" begin
@test_skip "ZMQ.jl not installed"
Expand Down
Loading