xcoll 0.6.1__py3-none-any.whl → 0.6.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of xcoll might be problematic. Click here for more details.
- xcoll/general.py +1 -1
- {xcoll-0.6.1.dist-info → xcoll-0.6.2.dist-info}/METADATA +5 -4
- xcoll-0.6.2.dist-info/RECORD +61 -0
- {xcoll-0.6.1.dist-info → xcoll-0.6.2.dist-info}/WHEEL +1 -1
- xcoll/__init__.py.orig +0 -26
- xcoll/general.py.orig +0 -20
- xcoll/initial_distribution.py.orig +0 -256
- xcoll/scattering_routines/fluka/flukaio/.git +0 -1
- xcoll/scattering_routines/fluka/flukaio/.gitignore +0 -2
- xcoll/scattering_routines/fluka/flukaio/CMakeLists.txt +0 -18
- xcoll/scattering_routines/fluka/flukaio/ComponentMakefile +0 -192
- xcoll/scattering_routines/fluka/flukaio/Makefile +0 -144
- xcoll/scattering_routines/fluka/flukaio/README +0 -26
- xcoll/scattering_routines/fluka/flukaio/doc/Doxyfile +0 -1551
- xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO.asciidoc +0 -1054
- xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO.epub +0 -0
- xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO.html +0 -1607
- xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO.pdf +0 -0
- xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO__1.png +0 -0
- xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO__2.png +0 -0
- xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO__3.png +0 -0
- xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO__4.png +0 -0
- xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO__5.png +0 -0
- xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO__6.png +0 -0
- xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO__7.png +0 -0
- xcoll/scattering_routines/fluka/flukaio/doc/Makefile +0 -8
- xcoll/scattering_routines/fluka/flukaio/doc/docbook.xsl +0 -1690
- xcoll/scattering_routines/fluka/flukaio/include/Connection.h +0 -79
- xcoll/scattering_routines/fluka/flukaio/include/FlukaIO.h +0 -58
- xcoll/scattering_routines/fluka/flukaio/include/FlukaIOServer.h +0 -33
- xcoll/scattering_routines/fluka/flukaio/include/FortranFlukaIO.h +0 -277
- xcoll/scattering_routines/fluka/flukaio/include/Message.h +0 -89
- xcoll/scattering_routines/fluka/flukaio/include/ParticleInfo.h +0 -76
- xcoll/scattering_routines/fluka/flukaio/lib/libFlukaIO64.a +0 -0
- xcoll/scattering_routines/fluka/flukaio/lib/libFlukaIO64.so +0 -0
- xcoll/scattering_routines/fluka/flukaio/samples/ClientTest.c +0 -156
- xcoll/scattering_routines/fluka/flukaio/samples/ServerTest.c +0 -123
- xcoll/scattering_routines/fluka/flukaio/samples/fclient.f +0 -149
- xcoll/scattering_routines/fluka/flukaio/samples/fserver.f +0 -118
- xcoll/scattering_routines/fluka/flukaio/src/Connection.c +0 -264
- xcoll/scattering_routines/fluka/flukaio/src/Connection.d +0 -69
- xcoll/scattering_routines/fluka/flukaio/src/Connection.o +0 -0
- xcoll/scattering_routines/fluka/flukaio/src/FlukaIO.c +0 -211
- xcoll/scattering_routines/fluka/flukaio/src/FlukaIO.d +0 -46
- xcoll/scattering_routines/fluka/flukaio/src/FlukaIO.o +0 -0
- xcoll/scattering_routines/fluka/flukaio/src/FlukaIOHandshake.c +0 -45
- xcoll/scattering_routines/fluka/flukaio/src/FlukaIOHandshake.d +0 -29
- xcoll/scattering_routines/fluka/flukaio/src/FlukaIOHandshake.h +0 -17
- xcoll/scattering_routines/fluka/flukaio/src/FlukaIOHandshake.o +0 -0
- xcoll/scattering_routines/fluka/flukaio/src/FlukaIOServer.c +0 -84
- xcoll/scattering_routines/fluka/flukaio/src/FlukaIOServer.d +0 -70
- xcoll/scattering_routines/fluka/flukaio/src/FlukaIOServer.o +0 -0
- xcoll/scattering_routines/fluka/flukaio/src/FlukaIOServer_private.h +0 -22
- xcoll/scattering_routines/fluka/flukaio/src/FlukaIO_private.h +0 -16
- xcoll/scattering_routines/fluka/flukaio/src/FortranFlukaIO.c +0 -533
- xcoll/scattering_routines/fluka/flukaio/src/FortranFlukaIO.d +0 -40
- xcoll/scattering_routines/fluka/flukaio/src/FortranFlukaIO.o +0 -0
- xcoll/scattering_routines/fluka/flukaio/src/NetIO.c +0 -304
- xcoll/scattering_routines/fluka/flukaio/src/NetIO.d +0 -66
- xcoll/scattering_routines/fluka/flukaio/src/NetIO.h +0 -30
- xcoll/scattering_routines/fluka/flukaio/src/NetIO.o +0 -0
- xcoll/scattering_routines/fluka/flukaio/src/tags +0 -167
- xcoll/scattering_routines/fluka/flukaio/tests/AllTests.cpp +0 -8
- xcoll/scattering_routines/fluka/flukaio/tests/CommonTest.h +0 -10
- xcoll/scattering_routines/fluka/flukaio/tests/ConnectionTest.cpp +0 -99
- xcoll/scattering_routines/fluka/flukaio/tests/FlukaIOServerTest.cpp +0 -104
- xcoll/scattering_routines/fluka/flukaio/tests/FlukaIOTest.cpp +0 -439
- xcoll/scattering_routines/fluka/flukaio/tests/FortranFlukaIOTest.cpp +0 -682
- xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeConnection.c +0 -19
- xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeConnection.h +0 -16
- xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeFlukaIO.c +0 -74
- xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeFlukaIO.h +0 -50
- xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeFlukaIOHandshake.c +0 -16
- xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeFlukaIOHandshake.h +0 -20
- xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeFlukaIOServer.c +0 -12
- xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeFlukaIOServer.h +0 -18
- xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeFortranFlukaIO.h +0 -19
- xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeNetIO.c +0 -80
- xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeNetIO.h +0 -35
- xcoll-0.6.1.dist-info/LICENSE +0 -201
- xcoll-0.6.1.dist-info/NOTICE +0 -2
- xcoll-0.6.1.dist-info/RECORD +0 -138
- /LICENSE → /xcoll-0.6.2.dist-info/LICENSE +0 -0
- /NOTICE → /xcoll-0.6.2.dist-info/NOTICE +0 -0
|
@@ -1,682 +0,0 @@
|
|
|
1
|
-
#include <stdio.h>
|
|
2
|
-
#include <stdint.h>
|
|
3
|
-
#include <stddef.h>
|
|
4
|
-
#include <math.h>
|
|
5
|
-
#include <inttypes.h>
|
|
6
|
-
#include <string.h>
|
|
7
|
-
|
|
8
|
-
#include "Message.h"
|
|
9
|
-
#include "Connection.h"
|
|
10
|
-
#include "FlukaIOServer.h"
|
|
11
|
-
#include "fakes/FakeConnection.h"
|
|
12
|
-
#include "fakes/FakeFortranFlukaIO.h"
|
|
13
|
-
#include "fakes/FakeNetIO.h"
|
|
14
|
-
#include "fakes/FakeFlukaIO.h"
|
|
15
|
-
#include "fakes/FakeFlukaIOServer.h"
|
|
16
|
-
#include "fakes/FakeFlukaIOHandshake.h"
|
|
17
|
-
|
|
18
|
-
#include "CommonTest.h"
|
|
19
|
-
|
|
20
|
-
TEST_GROUP(FortranFlukaIO)
|
|
21
|
-
{
|
|
22
|
-
|
|
23
|
-
flukaio_connection_t *conn;
|
|
24
|
-
int cid;
|
|
25
|
-
|
|
26
|
-
particle_info_t result;
|
|
27
|
-
particle_info_t expected;
|
|
28
|
-
flukaio_message_t msg;
|
|
29
|
-
|
|
30
|
-
char buf[1024];
|
|
31
|
-
|
|
32
|
-
ssize_t n;
|
|
33
|
-
|
|
34
|
-
void setup()
|
|
35
|
-
{
|
|
36
|
-
memset(&result, 0x00, sizeof(result));
|
|
37
|
-
memset(&expected, 0x00, sizeof(expected));
|
|
38
|
-
memset(&msg, 0x00, sizeof(msg));
|
|
39
|
-
|
|
40
|
-
expected.id = 456;
|
|
41
|
-
expected.gen = 7;
|
|
42
|
-
expected.weight = 1.0;
|
|
43
|
-
expected.x = 1.11e2;
|
|
44
|
-
expected.y = 2.22e2;
|
|
45
|
-
expected.z = 3.33e3;
|
|
46
|
-
expected.tx = 11e-1;
|
|
47
|
-
expected.ty = 22e-1;
|
|
48
|
-
expected.tz = 33e-1;
|
|
49
|
-
expected.aa = 3;
|
|
50
|
-
expected.zz = 4;
|
|
51
|
-
expected.m = 450e0;
|
|
52
|
-
expected.pc = 4520e-1;
|
|
53
|
-
expected.t = 5e-3;
|
|
54
|
-
|
|
55
|
-
// create connection
|
|
56
|
-
conn = fakeconnection_create(-1);
|
|
57
|
-
ntinit_();
|
|
58
|
-
cid = store_connection(conn);
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
void teardown()
|
|
63
|
-
{
|
|
64
|
-
// Check no messages are left
|
|
65
|
-
n = ntrecv_(
|
|
66
|
-
&cid,
|
|
67
|
-
NULL,
|
|
68
|
-
NULL, NULL,
|
|
69
|
-
NULL,
|
|
70
|
-
NULL, NULL, NULL,
|
|
71
|
-
NULL, NULL, NULL,
|
|
72
|
-
NULL, NULL,
|
|
73
|
-
NULL, NULL,
|
|
74
|
-
NULL
|
|
75
|
-
);
|
|
76
|
-
LONGS_EQUAL(-1, n);
|
|
77
|
-
|
|
78
|
-
// Cleanup
|
|
79
|
-
ntend_(&cid);
|
|
80
|
-
conn = NULL;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
void PARTICLES_EQUAL(const particle_info_t *expected, const particle_info_t *result)
|
|
84
|
-
{
|
|
85
|
-
LONGS_EQUAL(expected->id, result->id);
|
|
86
|
-
LONGS_EQUAL(expected->gen, result->gen);
|
|
87
|
-
DOUBLES_EQUAL(expected->weight, result->weight, DOUBLE_TOL);
|
|
88
|
-
DOUBLES_EQUAL(expected->x, result->x, DOUBLE_TOL);
|
|
89
|
-
DOUBLES_EQUAL(expected->y, result->y, DOUBLE_TOL);
|
|
90
|
-
DOUBLES_EQUAL(expected->z, result->z, DOUBLE_TOL);
|
|
91
|
-
DOUBLES_EQUAL(expected->tx, result->tx, DOUBLE_TOL);
|
|
92
|
-
DOUBLES_EQUAL(expected->ty, result->ty, DOUBLE_TOL);
|
|
93
|
-
DOUBLES_EQUAL(expected->tz, result->tz, DOUBLE_TOL);
|
|
94
|
-
LONGS_EQUAL(expected->aa, result->aa);
|
|
95
|
-
LONGS_EQUAL(expected->zz, result->zz);
|
|
96
|
-
DOUBLES_EQUAL(expected->m, result->m, DOUBLE_TOL);
|
|
97
|
-
DOUBLES_EQUAL(expected->pc, result->pc, DOUBLE_TOL);
|
|
98
|
-
DOUBLES_EQUAL(expected->t, result->t, DOUBLE_TOL);
|
|
99
|
-
}
|
|
100
|
-
void MESSAGE_HEADER_EQUAL(flukaio_message_t *msg, flukaio_message_type_t type, size_t len) {
|
|
101
|
-
LONGS_EQUAL(type, msg->type);
|
|
102
|
-
LONGS_EQUAL(MSG_HEADER_LEN + len, msg->size);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
/* Async Read operations */
|
|
108
|
-
TEST(FortranFlukaIO, read_message_empty_buffer)
|
|
109
|
-
{
|
|
110
|
-
uint8_t type;
|
|
111
|
-
n = ntrecv_(
|
|
112
|
-
&cid,
|
|
113
|
-
&type,
|
|
114
|
-
&result.id, &result.gen,
|
|
115
|
-
&result.weight,
|
|
116
|
-
&result.x, &result.y, &result.z,
|
|
117
|
-
&result.tx, &result.ty, &result.tz,
|
|
118
|
-
&result.aa, &result.zz,
|
|
119
|
-
&result.m, &result.pc, &result.t);
|
|
120
|
-
|
|
121
|
-
LONGS_EQUAL(-1, n);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
TEST(FortranFlukaIO, read_NULL_message_particle)
|
|
125
|
-
{
|
|
126
|
-
// Read in NULL buffer skips next message
|
|
127
|
-
fakeflukaio_insert_particle_message(conn, &expected);
|
|
128
|
-
|
|
129
|
-
n = ntrecv_(
|
|
130
|
-
&cid,
|
|
131
|
-
NULL,
|
|
132
|
-
NULL, NULL,
|
|
133
|
-
NULL,
|
|
134
|
-
NULL, NULL, NULL,
|
|
135
|
-
NULL, NULL, NULL,
|
|
136
|
-
NULL, NULL,
|
|
137
|
-
NULL, NULL,
|
|
138
|
-
NULL
|
|
139
|
-
);
|
|
140
|
-
LONGS_EQUAL(MSG_PART_LEN, n);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
TEST(FortranFlukaIO, read_message_particle)
|
|
145
|
-
{
|
|
146
|
-
fakeflukaio_insert_particle_message(conn, &expected);
|
|
147
|
-
|
|
148
|
-
uint8_t type;
|
|
149
|
-
n = ntrecv_(
|
|
150
|
-
&cid,
|
|
151
|
-
&type,
|
|
152
|
-
&result.id, &result.gen,
|
|
153
|
-
&result.weight,
|
|
154
|
-
&result.x, &result.y, &result.z,
|
|
155
|
-
&result.tx, &result.ty, &result.tz,
|
|
156
|
-
&result.aa, &result.zz,
|
|
157
|
-
&result.m, &result.pc, &result.t);
|
|
158
|
-
|
|
159
|
-
CHECK(n != -1);
|
|
160
|
-
LONGS_EQUAL(N_PART, type);
|
|
161
|
-
PARTICLES_EQUAL(&expected, &result);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
TEST(FortranFlukaIO, read_message_eob)
|
|
165
|
-
{
|
|
166
|
-
fakeflukaio_insert_eob_message(conn);
|
|
167
|
-
|
|
168
|
-
uint8_t type;
|
|
169
|
-
n = ntrecv_(
|
|
170
|
-
&cid,
|
|
171
|
-
&type,
|
|
172
|
-
&result.id, &result.gen,
|
|
173
|
-
&result.weight,
|
|
174
|
-
&result.x, &result.y, &result.z,
|
|
175
|
-
&result.tx, &result.ty, &result.tz,
|
|
176
|
-
&result.aa, &result.zz,
|
|
177
|
-
&result.m, &result.pc, &result.t);
|
|
178
|
-
CHECK(n != -1);
|
|
179
|
-
|
|
180
|
-
LONGS_EQUAL(N_EOB, type);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
TEST(FortranFlukaIO, read_message_insertion_point)
|
|
184
|
-
{
|
|
185
|
-
uint32_t turn = 5694;
|
|
186
|
-
uint16_t ipt = 8;
|
|
187
|
-
fakeflukaio_insert_ipt_message(conn, turn, ipt);
|
|
188
|
-
|
|
189
|
-
uint8_t type;
|
|
190
|
-
n = ntrecv_(
|
|
191
|
-
&cid,
|
|
192
|
-
&type,
|
|
193
|
-
&result.id, &result.gen,
|
|
194
|
-
&result.weight,
|
|
195
|
-
&result.x, &result.y, &result.z,
|
|
196
|
-
&result.tx, &result.ty, &result.tz,
|
|
197
|
-
&result.aa, &result.zz,
|
|
198
|
-
&result.m, &result.pc, &result.t);
|
|
199
|
-
CHECK(n != -1);
|
|
200
|
-
|
|
201
|
-
LONGS_EQUAL(N_IPT, type);
|
|
202
|
-
LONGS_EQUAL(turn, result.gen);
|
|
203
|
-
LONGS_EQUAL(ipt, result.id);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
TEST(FortranFlukaIO, ntrecv_with_eoc)
|
|
207
|
-
{
|
|
208
|
-
fakeflukaio_insert_eoc_message(conn);
|
|
209
|
-
|
|
210
|
-
uint8_t type;
|
|
211
|
-
n = ntrecv_(
|
|
212
|
-
&cid,
|
|
213
|
-
&type,
|
|
214
|
-
&result.id, &result.gen,
|
|
215
|
-
&result.weight,
|
|
216
|
-
&result.x, &result.y, &result.z,
|
|
217
|
-
&result.tx, &result.ty, &result.tz,
|
|
218
|
-
&result.aa, &result.zz,
|
|
219
|
-
&result.m, &result.pc, &result.t);
|
|
220
|
-
CHECK(n != -1);
|
|
221
|
-
|
|
222
|
-
LONGS_EQUAL(N_END, type);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
TEST(FortranFlukaIO, ntrecv_with_particle_and_end_of_turn)
|
|
226
|
-
{
|
|
227
|
-
fakeflukaio_insert_particle_message(conn, &expected);
|
|
228
|
-
fakeflukaio_insert_eob_message(conn);
|
|
229
|
-
|
|
230
|
-
uint8_t type;
|
|
231
|
-
n = ntrecv_(
|
|
232
|
-
&cid,
|
|
233
|
-
&type,
|
|
234
|
-
&result.id, &result.gen,
|
|
235
|
-
&result.weight,
|
|
236
|
-
&result.x, &result.y, &result.z,
|
|
237
|
-
&result.tx, &result.ty, &result.tz,
|
|
238
|
-
&result.aa, &result.zz,
|
|
239
|
-
&result.m, &result.pc, &result.t);
|
|
240
|
-
CHECK(n != -1);
|
|
241
|
-
LONGS_EQUAL(N_PART, type);
|
|
242
|
-
PARTICLES_EQUAL(&expected, &result);
|
|
243
|
-
|
|
244
|
-
n = ntrecv_(
|
|
245
|
-
&cid,
|
|
246
|
-
&type,
|
|
247
|
-
&result.id, &result.gen,
|
|
248
|
-
&result.weight,
|
|
249
|
-
&result.x, &result.y, &result.z,
|
|
250
|
-
&result.tx, &result.ty, &result.tz,
|
|
251
|
-
&result.aa, &result.zz,
|
|
252
|
-
&result.m, &result.pc, &result.t);
|
|
253
|
-
|
|
254
|
-
CHECK(n != -1);
|
|
255
|
-
LONGS_EQUAL(N_EOB, type);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
TEST(FortranFlukaIO, ntrecv_with_other_message)
|
|
259
|
-
{
|
|
260
|
-
fakeflukaio_insert_unknown_message(conn);
|
|
261
|
-
uint8_t type;
|
|
262
|
-
n = ntrecv_(
|
|
263
|
-
&cid,
|
|
264
|
-
&type,
|
|
265
|
-
&result.id, &result.gen,
|
|
266
|
-
&result.weight,
|
|
267
|
-
&result.x, &result.y, &result.z,
|
|
268
|
-
&result.tx, &result.ty, &result.tz,
|
|
269
|
-
&result.aa, &result.zz,
|
|
270
|
-
&result.m, &result.pc, &result.t);
|
|
271
|
-
|
|
272
|
-
LONGS_EQUAL(-1, n);
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/* Send operations */
|
|
276
|
-
// Send end of batch
|
|
277
|
-
TEST(FortranFlukaIO, ntsend_eob)
|
|
278
|
-
{
|
|
279
|
-
n = ntsendeob_(&cid);
|
|
280
|
-
LONGS_EQUAL(MSG_EOB_LEN, fakenetio_get_last_sent_size());
|
|
281
|
-
|
|
282
|
-
fakeflukaio_get_last_sent_message(conn, &msg);
|
|
283
|
-
MESSAGE_HEADER_EQUAL(&msg, N_EOB, 0);
|
|
284
|
-
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// Send iot
|
|
288
|
-
TEST(FortranFlukaIO, ntsend_insertion_point)
|
|
289
|
-
{
|
|
290
|
-
uint32_t turn = 1354;
|
|
291
|
-
uint16_t ipt = 7;
|
|
292
|
-
n = ntsendipt_(&cid, &turn, &ipt);
|
|
293
|
-
|
|
294
|
-
connection_flush(conn);
|
|
295
|
-
LONGS_EQUAL(MSG_IPT_LEN, fakenetio_get_last_sent_size());
|
|
296
|
-
|
|
297
|
-
fakeflukaio_get_last_sent_message(conn, &msg);
|
|
298
|
-
MESSAGE_HEADER_EQUAL(&msg, N_IPT, sizeof(flukaio_ipt_data_t));
|
|
299
|
-
LONGS_EQUAL(turn, msg.data.ipt.turn);
|
|
300
|
-
LONGS_EQUAL(ipt, msg.data.ipt.ipt);
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// Send Particle
|
|
305
|
-
TEST(FortranFlukaIO, send_particle)
|
|
306
|
-
{
|
|
307
|
-
n = ntsendp_(
|
|
308
|
-
&cid,
|
|
309
|
-
&expected.id, &expected.gen,
|
|
310
|
-
&expected.weight,
|
|
311
|
-
&expected.x, &expected.y, &expected.z,
|
|
312
|
-
&expected.tx, &expected.ty, &expected.tz,
|
|
313
|
-
&expected.aa, &expected.zz,
|
|
314
|
-
&expected.m, &expected.pc,
|
|
315
|
-
&expected.t
|
|
316
|
-
);
|
|
317
|
-
|
|
318
|
-
connection_flush(conn);
|
|
319
|
-
LONGS_EQUAL(MSG_PART_LEN, fakenetio_get_last_sent_size());
|
|
320
|
-
|
|
321
|
-
fakeflukaio_get_last_sent_message(conn, &msg);
|
|
322
|
-
MESSAGE_HEADER_EQUAL(&msg, N_PART, sizeof(expected));
|
|
323
|
-
PARTICLES_EQUAL(&expected, &msg.data.particle);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
// Send Particle n times
|
|
327
|
-
TEST(FortranFlukaIO, send_particle_n_times)
|
|
328
|
-
{
|
|
329
|
-
int times = 25;
|
|
330
|
-
for(int i = 0; i < times; ++i) {
|
|
331
|
-
expected.id = i;
|
|
332
|
-
n = ntsendp_(
|
|
333
|
-
&cid,
|
|
334
|
-
&expected.id, &expected.gen,
|
|
335
|
-
&expected.weight,
|
|
336
|
-
&expected.x, &expected.y, &expected.z,
|
|
337
|
-
&expected.tx, &expected.ty, &expected.tz,
|
|
338
|
-
&expected.aa, &expected.zz,
|
|
339
|
-
&expected.m, &expected.pc,
|
|
340
|
-
&expected.t
|
|
341
|
-
);
|
|
342
|
-
LONGS_EQUAL(MSG_PART_LEN, n);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
connection_flush(conn);
|
|
346
|
-
LONGS_EQUAL(MSG_PART_LEN * times, fakenetio_get_last_sent_size());
|
|
347
|
-
|
|
348
|
-
for(int i = 0; i < times; ++i) {
|
|
349
|
-
expected.id = i;
|
|
350
|
-
fakeflukaio_get_last_sent_message(conn, &msg);
|
|
351
|
-
MESSAGE_HEADER_EQUAL(&msg, N_PART, sizeof(expected));
|
|
352
|
-
PARTICLES_EQUAL(&expected, &msg.data.particle);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
// End Computation
|
|
358
|
-
TEST(FortranFlukaIO, send_end_comp)
|
|
359
|
-
{
|
|
360
|
-
n = ntsendeoc_(&cid);
|
|
361
|
-
LONGS_EQUAL(MSG_EOC_LEN, fakenetio_get_last_sent_size());
|
|
362
|
-
|
|
363
|
-
fakeflukaio_get_last_sent_message(conn, &msg);
|
|
364
|
-
MESSAGE_HEADER_EQUAL(&msg, N_END, 0);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
/* Sync Read operations */
|
|
368
|
-
|
|
369
|
-
TEST(FortranFlukaIO, ntwait_with_empty_buffer)
|
|
370
|
-
{
|
|
371
|
-
uint8_t type;
|
|
372
|
-
n = ntwait_(
|
|
373
|
-
&cid,
|
|
374
|
-
&type,
|
|
375
|
-
&result.id, &result.gen,
|
|
376
|
-
&result.weight,
|
|
377
|
-
&result.x, &result.y, &result.z,
|
|
378
|
-
&result.tx, &result.ty, &result.tz,
|
|
379
|
-
&result.aa, &result.zz,
|
|
380
|
-
&result.m, &result.pc,
|
|
381
|
-
&result.t);
|
|
382
|
-
|
|
383
|
-
LONGS_EQUAL(-1, n);
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
TEST(FortranFlukaIO, ntwait_with_one_particle)
|
|
387
|
-
{
|
|
388
|
-
fakeflukaio_insert_particle_message(conn, &expected);
|
|
389
|
-
|
|
390
|
-
uint8_t type;
|
|
391
|
-
n = ntwait_(
|
|
392
|
-
&cid,
|
|
393
|
-
&type,
|
|
394
|
-
&result.id, &result.gen,
|
|
395
|
-
&result.weight,
|
|
396
|
-
&result.x, &result.y, &result.z,
|
|
397
|
-
&result.tx, &result.ty, &result.tz,
|
|
398
|
-
&result.aa, &result.zz,
|
|
399
|
-
&result.m, &result.pc,
|
|
400
|
-
&result.t);
|
|
401
|
-
|
|
402
|
-
LONGS_EQUAL(MSG_PART_LEN, n);
|
|
403
|
-
LONGS_EQUAL(N_PART, type);
|
|
404
|
-
PARTICLES_EQUAL(&expected, &result);
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
TEST(FortranFlukaIO, ntwait_with_eob)
|
|
408
|
-
{
|
|
409
|
-
fakeflukaio_insert_eob_message(conn);
|
|
410
|
-
|
|
411
|
-
uint8_t type;
|
|
412
|
-
n = ntwait_(
|
|
413
|
-
&cid,
|
|
414
|
-
&type,
|
|
415
|
-
&result.id, &result.gen,
|
|
416
|
-
&result.weight,
|
|
417
|
-
&result.x, &result.y, &result.z,
|
|
418
|
-
&result.tx, &result.ty, &result.tz,
|
|
419
|
-
&result.aa, &result.zz,
|
|
420
|
-
&result.m, &result.pc,
|
|
421
|
-
&result.t);
|
|
422
|
-
|
|
423
|
-
LONGS_EQUAL(MSG_EOB_LEN, n);
|
|
424
|
-
LONGS_EQUAL(N_EOB, type);
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
TEST(FortranFlukaIO, ntwait_with_ipt)
|
|
428
|
-
{
|
|
429
|
-
fakeflukaio_insert_ipt_message(conn, 12, 9);
|
|
430
|
-
|
|
431
|
-
uint8_t type;
|
|
432
|
-
n = ntwait_(
|
|
433
|
-
&cid,
|
|
434
|
-
&type,
|
|
435
|
-
&result.id, &result.gen,
|
|
436
|
-
&result.weight,
|
|
437
|
-
&result.x, &result.y, &result.z,
|
|
438
|
-
&result.tx, &result.ty, &result.tz,
|
|
439
|
-
&result.aa, &result.zz,
|
|
440
|
-
&result.m, &result.pc,
|
|
441
|
-
&result.t);
|
|
442
|
-
|
|
443
|
-
LONGS_EQUAL(MSG_IPT_LEN, n);
|
|
444
|
-
LONGS_EQUAL(N_IPT, type);
|
|
445
|
-
LONGS_EQUAL(12, result.gen);
|
|
446
|
-
LONGS_EQUAL(9, result.id);
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
TEST(FortranFlukaIO, ntwait_with_eoc)
|
|
450
|
-
{
|
|
451
|
-
fakeflukaio_insert_eoc_message(conn);
|
|
452
|
-
|
|
453
|
-
uint8_t type;
|
|
454
|
-
n = ntwait_(
|
|
455
|
-
&cid,
|
|
456
|
-
&type,
|
|
457
|
-
&result.id, &result.gen,
|
|
458
|
-
&result.weight,
|
|
459
|
-
&result.x, &result.y, &result.z,
|
|
460
|
-
&result.tx, &result.ty, &result.tz,
|
|
461
|
-
&result.aa, &result.zz,
|
|
462
|
-
&result.m, &result.pc,
|
|
463
|
-
&result.t);
|
|
464
|
-
|
|
465
|
-
LONGS_EQUAL(MSG_EOC_LEN, n);
|
|
466
|
-
LONGS_EQUAL(N_END, type);
|
|
467
|
-
LONGS_EQUAL(N_END, type);
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
TEST(FortranFlukaIO, ntwait_with_ipt_part_and_end_of_turn)
|
|
471
|
-
{
|
|
472
|
-
fakeflukaio_insert_ipt_message(conn, 66, 3);
|
|
473
|
-
fakeflukaio_insert_particle_message(conn, &expected);
|
|
474
|
-
fakeflukaio_insert_eob_message(conn);
|
|
475
|
-
|
|
476
|
-
uint8_t type;
|
|
477
|
-
|
|
478
|
-
n = ntwait_(
|
|
479
|
-
&cid,
|
|
480
|
-
&type,
|
|
481
|
-
&result.id, &result.gen,
|
|
482
|
-
&result.weight,
|
|
483
|
-
&result.x, &result.y, &result.z,
|
|
484
|
-
&result.tx, &result.ty, &result.tz,
|
|
485
|
-
&result.aa, &result.zz,
|
|
486
|
-
&result.m, &result.pc,
|
|
487
|
-
&result.t);
|
|
488
|
-
LONGS_EQUAL(MSG_IPT_LEN, n);
|
|
489
|
-
LONGS_EQUAL(N_IPT, type);
|
|
490
|
-
LONGS_EQUAL(3, result.id);
|
|
491
|
-
LONGS_EQUAL(66, result.gen);
|
|
492
|
-
|
|
493
|
-
n = ntwait_(
|
|
494
|
-
&cid,
|
|
495
|
-
&type,
|
|
496
|
-
&result.id, &result.gen,
|
|
497
|
-
&result.weight,
|
|
498
|
-
&result.x, &result.y, &result.z,
|
|
499
|
-
&result.tx, &result.ty, &result.tz,
|
|
500
|
-
&result.aa, &result.zz,
|
|
501
|
-
&result.m, &result.pc,
|
|
502
|
-
&result.t);
|
|
503
|
-
LONGS_EQUAL(MSG_PART_LEN, n);
|
|
504
|
-
LONGS_EQUAL(N_PART, type);
|
|
505
|
-
PARTICLES_EQUAL(&expected, &result);
|
|
506
|
-
|
|
507
|
-
n = ntwait_(
|
|
508
|
-
&cid,
|
|
509
|
-
&type,
|
|
510
|
-
&result.id, &result.gen,
|
|
511
|
-
&result.weight,
|
|
512
|
-
&result.x, &result.y, &result.z,
|
|
513
|
-
&result.tx, &result.ty, &result.tz,
|
|
514
|
-
&result.aa, &result.zz,
|
|
515
|
-
&result.m, &result.pc,
|
|
516
|
-
&result.t);
|
|
517
|
-
|
|
518
|
-
LONGS_EQUAL(MSG_EOB_LEN, n);
|
|
519
|
-
LONGS_EQUAL(N_EOB, type);
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
TEST(FortranFlukaIO, ntwait_with_other_message)
|
|
523
|
-
{
|
|
524
|
-
fakeflukaio_insert_unknown_message(conn);
|
|
525
|
-
uint8_t type;
|
|
526
|
-
n = ntwait_(
|
|
527
|
-
&cid,
|
|
528
|
-
&type,
|
|
529
|
-
&result.id, &result.gen,
|
|
530
|
-
&result.weight,
|
|
531
|
-
&result.x, &result.y, &result.z,
|
|
532
|
-
&result.tx, &result.ty, &result.tz,
|
|
533
|
-
&result.aa, &result.zz,
|
|
534
|
-
&result.m, &result.pc,
|
|
535
|
-
&result.t);
|
|
536
|
-
|
|
537
|
-
LONGS_EQUAL(-1, n);
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
static flukaio_server_t* server;
|
|
541
|
-
|
|
542
|
-
TEST_GROUP(FortranFlukaIOServer)
|
|
543
|
-
{
|
|
544
|
-
ssize_t n;
|
|
545
|
-
int serverid;
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
void setup()
|
|
549
|
-
{
|
|
550
|
-
server = fakeflukaio_server_create();
|
|
551
|
-
if (!server) {
|
|
552
|
-
FAIL("Server should be valid here");
|
|
553
|
-
}
|
|
554
|
-
serverid = store_server(server);
|
|
555
|
-
if (serverid < 0) {
|
|
556
|
-
FAIL("Serverid should be valid here");
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
void teardown()
|
|
561
|
-
{
|
|
562
|
-
if (serverid > -1) {
|
|
563
|
-
ntshdwn_(&serverid);
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
};
|
|
567
|
-
/* FlukaIOServer interface */
|
|
568
|
-
TEST(FortranFlukaIOServer, flukaio_server_create)
|
|
569
|
-
{
|
|
570
|
-
LONGS_EQUAL(-1, ntgetport_(&serverid));
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
TEST(FortranFlukaIOServer, flukaio_server_start_random_port)
|
|
574
|
-
{
|
|
575
|
-
int port = 234;
|
|
576
|
-
int sport = 0;
|
|
577
|
-
fakenetio_set_next_port(port);
|
|
578
|
-
|
|
579
|
-
n = ntstart_(&serverid, &sport);
|
|
580
|
-
|
|
581
|
-
LONGS_EQUAL(port, n);
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
TEST(FortranFlukaIOServer, flukaio_server_start_given_port)
|
|
585
|
-
{
|
|
586
|
-
int port = 236;
|
|
587
|
-
|
|
588
|
-
n = ntstart_(&serverid, &port);
|
|
589
|
-
|
|
590
|
-
LONGS_EQUAL(port, n);
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
TEST(FortranFlukaIOServer, flukaio_server_get_port_stopped)
|
|
594
|
-
{
|
|
595
|
-
n = ntgetport_(&serverid);
|
|
596
|
-
|
|
597
|
-
LONGS_EQUAL(-1, n);
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
TEST(FortranFlukaIOServer, flukaio_server_get_port)
|
|
601
|
-
{
|
|
602
|
-
int port = 235;
|
|
603
|
-
int sport = 0;
|
|
604
|
-
fakenetio_set_next_port(port);
|
|
605
|
-
|
|
606
|
-
ntstart_(&serverid, &sport);
|
|
607
|
-
n = ntgetport_(&serverid);
|
|
608
|
-
|
|
609
|
-
LONGS_EQUAL(port, n);
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
TEST(FortranFlukaIOServer, flukaio_server_start_twice)
|
|
613
|
-
{
|
|
614
|
-
int sport = 0;
|
|
615
|
-
n = ntstart_(&serverid, &sport);
|
|
616
|
-
CHECK(n != -1);
|
|
617
|
-
|
|
618
|
-
sport = 0;
|
|
619
|
-
n = ntstart_(&serverid, &sport);
|
|
620
|
-
CHECK(n == -1);
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
TEST(FortranFlukaIOServer, flukaio_server_accept)
|
|
624
|
-
{
|
|
625
|
-
int sport = 0;
|
|
626
|
-
int cid;
|
|
627
|
-
n = ntstart_(&serverid, &sport);
|
|
628
|
-
int hsk_count = fakeflukaio_handshake_server_called;
|
|
629
|
-
|
|
630
|
-
cid = ntaccept_(&serverid);
|
|
631
|
-
CHECK(cid != -1);
|
|
632
|
-
|
|
633
|
-
CHECK(fakeflukaio_handshake_server_called > hsk_count);
|
|
634
|
-
ntend_(&cid);
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
TEST(FortranFlukaIOServer, flukaio_server_shutdown_fails_if_not_initialized)
|
|
638
|
-
{
|
|
639
|
-
n = ntshdwn_(&serverid);
|
|
640
|
-
serverid = -1;
|
|
641
|
-
|
|
642
|
-
CHECK(n != -1);
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
TEST(FortranFlukaIOServer, flukaio_server_shutdown_stops_the_server_if_initialized)
|
|
646
|
-
{
|
|
647
|
-
int sport = 0;
|
|
648
|
-
n = ntstart_(&serverid, &sport);
|
|
649
|
-
CHECK(n != -1);
|
|
650
|
-
|
|
651
|
-
n = ntshdwn_(&serverid);
|
|
652
|
-
serverid = -1;
|
|
653
|
-
|
|
654
|
-
CHECK(n != -1);
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
TEST(FortranFlukaIOServer, fortran_string_conversion_spaces_at_end)
|
|
658
|
-
{
|
|
659
|
-
const char *fortran_string = "localhost ";
|
|
660
|
-
char *new_string = NULL;
|
|
661
|
-
new_string = create_fortran_string(fortran_string, strlen(fortran_string));
|
|
662
|
-
|
|
663
|
-
CHECK(new_string != NULL);
|
|
664
|
-
LONGS_EQUAL(9, strlen(new_string));
|
|
665
|
-
CHECK(strcmp(new_string, "localhost") == 0);
|
|
666
|
-
free(new_string);
|
|
667
|
-
new_string = NULL;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
TEST(FortranFlukaIOServer, fortran_string_conversion_empty_string)
|
|
671
|
-
{
|
|
672
|
-
const char *fortran_string = "";
|
|
673
|
-
char *new_string = NULL;
|
|
674
|
-
new_string = create_fortran_string(fortran_string, strlen(fortran_string));
|
|
675
|
-
|
|
676
|
-
CHECK(new_string != NULL);
|
|
677
|
-
LONGS_EQUAL(0, strlen(new_string));
|
|
678
|
-
CHECK(strcmp(new_string, "") == 0);
|
|
679
|
-
free(new_string);
|
|
680
|
-
new_string = NULL;
|
|
681
|
-
}
|
|
682
|
-
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
#include "FakeConnection.h"
|
|
2
|
-
#include "FakeNetIO.h"
|
|
3
|
-
#include "FakeFlukaIO.h"
|
|
4
|
-
|
|
5
|
-
flukaio_connection_t* fakeconnection_create(int fd) {
|
|
6
|
-
flukaio_connection_t *conn = connection_create(fd);
|
|
7
|
-
if (!conn) return NULL;
|
|
8
|
-
|
|
9
|
-
// Fake connection
|
|
10
|
-
conn->connect = &fakenetio_connect;
|
|
11
|
-
conn->read = &fakenetio_read;
|
|
12
|
-
conn->write = &fakenetio_write;
|
|
13
|
-
conn->can_read = &fakenetio_can_read;
|
|
14
|
-
conn->can_write = &fakenetio_can_write;
|
|
15
|
-
conn->set_nonblocking = &fakenetio_set_nonblocking;
|
|
16
|
-
conn->set_nodelay = &fakenetio_set_nodelay;
|
|
17
|
-
|
|
18
|
-
return conn;
|
|
19
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#ifndef FLUKAIO_FAKECONNECTION_H__
|
|
2
|
-
#define FLUKAIO_FAKECONNECTION_H__
|
|
3
|
-
|
|
4
|
-
#include "Connection.h"
|
|
5
|
-
|
|
6
|
-
#ifdef __cplusplus
|
|
7
|
-
extern "C" {
|
|
8
|
-
#endif
|
|
9
|
-
|
|
10
|
-
flukaio_connection_t* fakeconnection_create(int fd);
|
|
11
|
-
|
|
12
|
-
#ifdef __cplusplus
|
|
13
|
-
}
|
|
14
|
-
#endif
|
|
15
|
-
|
|
16
|
-
#endif
|