1+ module DockerRuntime
2+ include (joinpath (@__DIR__ , " .." , " .." , " concoredocker.jl" ))
3+ end
4+
5+ const DockerConcore = DockerRuntime. Concore
6+
7+ @testset " Concore Docker runtime" begin
8+
9+ function reset_docker_state! ()
10+ DockerConcore. _backend = DockerConcore. FileBackend ()
11+ DockerConcore. inpath = " /in"
12+ DockerConcore. outpath = " /out"
13+ DockerConcore. simtime = 0.0
14+ DockerConcore. delay = 0.0
15+ DockerConcore. s = " "
16+ DockerConcore. olds = " "
17+ DockerConcore. retrycount = 0
18+ DockerConcore. params = Dict {String,Any} ()
19+ end
20+
21+ @testset " default paths" begin
22+ reset_docker_state! ()
23+ @test DockerConcore. inpath == " /in"
24+ @test DockerConcore. outpath == " /out"
25+ @test DockerConcore. _backend_inpath (DockerConcore. FileBackend ()) == " /in"
26+ @test DockerConcore. _backend_outpath (DockerConcore. FileBackend ()) == " /out"
27+ @test DockerConcore. _input_dir (1 ) == " /in1"
28+ @test DockerConcore. _output_dir (2 ) == " /out2"
29+ end
30+
31+ @testset " basic API" begin
32+ reset_docker_state! ()
33+ @test DockerConcore. initval (" [3.0, 10.0, 20.0]" ) == [10.0 , 20.0 ]
34+ @test DockerConcore. simtime == 3.0
35+
36+ DockerConcore. params = Dict {String,Any} (" gain" => 2.5 )
37+ @test DockerConcore. tryparam (" gain" , 1.0 ) == 2.5
38+ @test DockerConcore. tryparam (" missing" , 7.0 ) == 7.0
39+ end
40+
41+ @testset " read and write" begin
42+ mktempdir () do dir
43+ reset_docker_state! ()
44+ DockerConcore. inpath = joinpath (dir, " in" )
45+ DockerConcore. outpath = joinpath (dir, " out" )
46+ DockerConcore. simtime = 5.0
47+
48+ DockerConcore. concore_write (1 , " signal" , [42.0 ])
49+ path = joinpath (DockerConcore. outpath * " 1" , " signal" )
50+ @test read (path, String) == " [5.0, 42.0]"
51+
52+ DockerConcore. inpath = DockerConcore. outpath
53+ DockerConcore. simtime = 0.0
54+ @test DockerConcore. concore_read (1 , " signal" , " [0.0, 0.0]" ) == [42.0 ]
55+ @test DockerConcore. simtime == 5.0
56+ end
57+ end
58+
59+ @testset " aliases" begin
60+ mktempdir () do dir
61+ reset_docker_state! ()
62+ DockerConcore. inpath = joinpath (dir, " io" )
63+ DockerConcore. outpath = joinpath (dir, " io" )
64+ DockerConcore. simtime = 9.0
65+
66+ DockerConcore. write (1 , " alias_signal" , [1.5 , 2.5 ])
67+ DockerConcore. simtime = 0.0
68+ @test DockerConcore. read (1 , " alias_signal" , " [0.0, 0.0, 0.0]" ) == [1.5 , 2.5 ]
69+ @test DockerConcore. simtime == 9.0
70+ end
71+ end
72+
73+ @testset " maxtime" begin
74+ mktempdir () do dir
75+ reset_docker_state! ()
76+ DockerConcore. inpath = joinpath (dir, " in" )
77+ mkpath (DockerConcore. inpath * " 1" )
78+ write (joinpath (DockerConcore. inpath * " 1" , " concore.maxtime" ), " 75" )
79+
80+ @test DockerConcore. default_maxtime (100 ) == 75
81+ @test DockerConcore. maxtime == 75
82+ end
83+ end
84+
85+ end
0 commit comments