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.

Files changed (84) hide show
  1. xcoll/general.py +1 -1
  2. {xcoll-0.6.1.dist-info → xcoll-0.6.2.dist-info}/METADATA +5 -4
  3. xcoll-0.6.2.dist-info/RECORD +61 -0
  4. {xcoll-0.6.1.dist-info → xcoll-0.6.2.dist-info}/WHEEL +1 -1
  5. xcoll/__init__.py.orig +0 -26
  6. xcoll/general.py.orig +0 -20
  7. xcoll/initial_distribution.py.orig +0 -256
  8. xcoll/scattering_routines/fluka/flukaio/.git +0 -1
  9. xcoll/scattering_routines/fluka/flukaio/.gitignore +0 -2
  10. xcoll/scattering_routines/fluka/flukaio/CMakeLists.txt +0 -18
  11. xcoll/scattering_routines/fluka/flukaio/ComponentMakefile +0 -192
  12. xcoll/scattering_routines/fluka/flukaio/Makefile +0 -144
  13. xcoll/scattering_routines/fluka/flukaio/README +0 -26
  14. xcoll/scattering_routines/fluka/flukaio/doc/Doxyfile +0 -1551
  15. xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO.asciidoc +0 -1054
  16. xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO.epub +0 -0
  17. xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO.html +0 -1607
  18. xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO.pdf +0 -0
  19. xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO__1.png +0 -0
  20. xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO__2.png +0 -0
  21. xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO__3.png +0 -0
  22. xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO__4.png +0 -0
  23. xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO__5.png +0 -0
  24. xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO__6.png +0 -0
  25. xcoll/scattering_routines/fluka/flukaio/doc/FlukaIO__7.png +0 -0
  26. xcoll/scattering_routines/fluka/flukaio/doc/Makefile +0 -8
  27. xcoll/scattering_routines/fluka/flukaio/doc/docbook.xsl +0 -1690
  28. xcoll/scattering_routines/fluka/flukaio/include/Connection.h +0 -79
  29. xcoll/scattering_routines/fluka/flukaio/include/FlukaIO.h +0 -58
  30. xcoll/scattering_routines/fluka/flukaio/include/FlukaIOServer.h +0 -33
  31. xcoll/scattering_routines/fluka/flukaio/include/FortranFlukaIO.h +0 -277
  32. xcoll/scattering_routines/fluka/flukaio/include/Message.h +0 -89
  33. xcoll/scattering_routines/fluka/flukaio/include/ParticleInfo.h +0 -76
  34. xcoll/scattering_routines/fluka/flukaio/lib/libFlukaIO64.a +0 -0
  35. xcoll/scattering_routines/fluka/flukaio/lib/libFlukaIO64.so +0 -0
  36. xcoll/scattering_routines/fluka/flukaio/samples/ClientTest.c +0 -156
  37. xcoll/scattering_routines/fluka/flukaio/samples/ServerTest.c +0 -123
  38. xcoll/scattering_routines/fluka/flukaio/samples/fclient.f +0 -149
  39. xcoll/scattering_routines/fluka/flukaio/samples/fserver.f +0 -118
  40. xcoll/scattering_routines/fluka/flukaio/src/Connection.c +0 -264
  41. xcoll/scattering_routines/fluka/flukaio/src/Connection.d +0 -69
  42. xcoll/scattering_routines/fluka/flukaio/src/Connection.o +0 -0
  43. xcoll/scattering_routines/fluka/flukaio/src/FlukaIO.c +0 -211
  44. xcoll/scattering_routines/fluka/flukaio/src/FlukaIO.d +0 -46
  45. xcoll/scattering_routines/fluka/flukaio/src/FlukaIO.o +0 -0
  46. xcoll/scattering_routines/fluka/flukaio/src/FlukaIOHandshake.c +0 -45
  47. xcoll/scattering_routines/fluka/flukaio/src/FlukaIOHandshake.d +0 -29
  48. xcoll/scattering_routines/fluka/flukaio/src/FlukaIOHandshake.h +0 -17
  49. xcoll/scattering_routines/fluka/flukaio/src/FlukaIOHandshake.o +0 -0
  50. xcoll/scattering_routines/fluka/flukaio/src/FlukaIOServer.c +0 -84
  51. xcoll/scattering_routines/fluka/flukaio/src/FlukaIOServer.d +0 -70
  52. xcoll/scattering_routines/fluka/flukaio/src/FlukaIOServer.o +0 -0
  53. xcoll/scattering_routines/fluka/flukaio/src/FlukaIOServer_private.h +0 -22
  54. xcoll/scattering_routines/fluka/flukaio/src/FlukaIO_private.h +0 -16
  55. xcoll/scattering_routines/fluka/flukaio/src/FortranFlukaIO.c +0 -533
  56. xcoll/scattering_routines/fluka/flukaio/src/FortranFlukaIO.d +0 -40
  57. xcoll/scattering_routines/fluka/flukaio/src/FortranFlukaIO.o +0 -0
  58. xcoll/scattering_routines/fluka/flukaio/src/NetIO.c +0 -304
  59. xcoll/scattering_routines/fluka/flukaio/src/NetIO.d +0 -66
  60. xcoll/scattering_routines/fluka/flukaio/src/NetIO.h +0 -30
  61. xcoll/scattering_routines/fluka/flukaio/src/NetIO.o +0 -0
  62. xcoll/scattering_routines/fluka/flukaio/src/tags +0 -167
  63. xcoll/scattering_routines/fluka/flukaio/tests/AllTests.cpp +0 -8
  64. xcoll/scattering_routines/fluka/flukaio/tests/CommonTest.h +0 -10
  65. xcoll/scattering_routines/fluka/flukaio/tests/ConnectionTest.cpp +0 -99
  66. xcoll/scattering_routines/fluka/flukaio/tests/FlukaIOServerTest.cpp +0 -104
  67. xcoll/scattering_routines/fluka/flukaio/tests/FlukaIOTest.cpp +0 -439
  68. xcoll/scattering_routines/fluka/flukaio/tests/FortranFlukaIOTest.cpp +0 -682
  69. xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeConnection.c +0 -19
  70. xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeConnection.h +0 -16
  71. xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeFlukaIO.c +0 -74
  72. xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeFlukaIO.h +0 -50
  73. xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeFlukaIOHandshake.c +0 -16
  74. xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeFlukaIOHandshake.h +0 -20
  75. xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeFlukaIOServer.c +0 -12
  76. xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeFlukaIOServer.h +0 -18
  77. xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeFortranFlukaIO.h +0 -19
  78. xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeNetIO.c +0 -80
  79. xcoll/scattering_routines/fluka/flukaio/tests/fakes/FakeNetIO.h +0 -35
  80. xcoll-0.6.1.dist-info/LICENSE +0 -201
  81. xcoll-0.6.1.dist-info/NOTICE +0 -2
  82. xcoll-0.6.1.dist-info/RECORD +0 -138
  83. /LICENSE → /xcoll-0.6.2.dist-info/LICENSE +0 -0
  84. /NOTICE → /xcoll-0.6.2.dist-info/NOTICE +0 -0
@@ -1,99 +0,0 @@
1
- #include "Connection.h"
2
- #include "fakes/FakeNetIO.h"
3
- #include "fakes/FakeConnection.h"
4
-
5
- #include "CommonTest.h"
6
-
7
- TEST_GROUP(Connection)
8
- {
9
- static const int fd = -1;
10
- flukaio_connection_t *conn;
11
- ssize_t oldretval;
12
-
13
- void setup()
14
- {
15
- oldretval = connection_read(NULL);
16
-
17
- conn = fakeconnection_create(fd);
18
-
19
- if (conn == NULL)
20
- FAIL("Connection should not be NULL now");
21
- }
22
-
23
- void teardown()
24
- {
25
- connection_destroy(conn);
26
- conn = NULL;
27
- fakenetio_set_read_retval(oldretval);
28
- }
29
-
30
- };
31
-
32
- TEST(Connection, ConnectionCreate)
33
- {
34
- CHECK(conn != NULL);
35
- LONGS_EQUAL(fd, conn->fd);
36
- CHECK(conn->in_buffer != NULL);
37
- CHECK(conn->out_buffer != NULL);
38
- LONGS_EQUAL(0, conn->in_buffer_len);
39
- LONGS_EQUAL(0, conn->out_buffer_len);
40
- CHECK(conn->in_buffer_size != 0);
41
- CHECK(conn->out_buffer_size != 0);
42
- LONGS_EQUAL(DEFAULT_READ_TIMEOUT, conn->read_timeout);
43
- LONGS_EQUAL(DEFAULT_WRITE_TIMEOUT, conn->write_timeout);
44
- }
45
-
46
- TEST(Connection, connection_read_update_buffer_len)
47
- {
48
- size_t prevlen = conn->in_buffer_len;
49
- fakenetio_set_read_retval(1);
50
- connection_read(conn);
51
- LONGS_EQUAL(prevlen + 1, conn->in_buffer_len);
52
-
53
- }
54
-
55
- TEST(Connection, connection_read_doesnt_update_buffer_len_if_error)
56
- {
57
- size_t prevlen = conn->in_buffer_len;
58
- fakenetio_set_read_retval(-1);
59
- connection_read(conn);
60
- LONGS_EQUAL(prevlen, conn->in_buffer_len);
61
-
62
- }
63
-
64
- TEST(Connection, connection_set_read_timeout)
65
- {
66
- connection_set_read_timeout(conn, 137);
67
- LONGS_EQUAL(conn->read_timeout, 137);
68
- }
69
-
70
- // Write message bin
71
- //
72
- TEST(Connection, write_message_bin_just_buffer)
73
- {
74
- uint8_t data[8] = { 230, 123, 234, 54, 1, 2, 3, 4 };
75
- uint8_t buffer[MSG_HEADER_LEN+sizeof(data)];
76
- uint8_t type = 2;
77
- int n = connection_write_message_bin(type, data, sizeof(data), buffer, sizeof(buffer));
78
-
79
- LONGS_EQUAL(MSG_HEADER_LEN+8, n);
80
- }
81
- TEST(Connection, write_message_bin_big_buffer)
82
- {
83
- uint8_t data[8] = { 230, 123, 234, 54, 1, 2, 3, 4 };
84
- uint8_t buffer[1024];
85
- uint8_t type = 2;
86
- int n = connection_write_message_bin(type, data, sizeof(data), buffer, sizeof(buffer));
87
-
88
- LONGS_EQUAL(MSG_HEADER_LEN+8, n);
89
- }
90
- TEST(Connection, write_message_bin_small_buffer)
91
- {
92
- uint8_t data[8] = { 230, 123, 234, 54, 1, 2, 3, 4 };
93
- uint8_t buffer[MSG_HEADER_LEN];
94
- uint8_t type = 2;
95
- int n = connection_write_message_bin(type, data, sizeof(data), buffer, sizeof(buffer));
96
-
97
- LONGS_EQUAL(-1, n);
98
- }
99
-
@@ -1,104 +0,0 @@
1
- #include "FlukaIO.h"
2
- #include "FlukaIOServer.h"
3
- #include "fakes/FakeNetIO.h"
4
- #include "fakes/FakeFlukaIO.h"
5
- #include "fakes/FakeFlukaIOServer.h"
6
- #include "fakes/FakeFlukaIOHandshake.h"
7
-
8
- #include "CommonTest.h"
9
-
10
- static flukaio_server_t* server;
11
-
12
- TEST_GROUP(FlukaIOServer)
13
- {
14
-
15
- int n;
16
-
17
- void setup()
18
- {
19
- server = fakeflukaio_server_create();
20
- if (!server) {
21
- FAIL("Server should be valid here");
22
- }
23
- }
24
-
25
- void teardown()
26
- {
27
- if (server) {
28
- n = flukaio_server_shutdown(server);
29
- server = NULL;
30
- CHECK(n != -1);
31
- }
32
- }
33
-
34
- };
35
-
36
- TEST(FlukaIOServer, flukaio_server_create)
37
- {
38
- LONGS_EQUAL(-1, server->port);
39
- LONGS_EQUAL(-1, server->fd);
40
- }
41
-
42
- TEST(FlukaIOServer, flukaio_server_start_random_port)
43
- {
44
- int port = 234;
45
- fakenetio_set_next_port(port);
46
-
47
- n = flukaio_server_start(server, 0);
48
-
49
- LONGS_EQUAL(port, n);
50
- }
51
-
52
- TEST(FlukaIOServer, flukaio_server_start_given_port)
53
- {
54
- int port = 236;
55
-
56
- n = flukaio_server_start(server, port);
57
-
58
- LONGS_EQUAL(port, n);
59
- }
60
-
61
- TEST(FlukaIOServer, flukaio_server_get_port_stopped)
62
- {
63
- n = flukaio_server_get_port(server);
64
-
65
- LONGS_EQUAL(-1, n);
66
- }
67
-
68
- TEST(FlukaIOServer, flukaio_server_get_port)
69
- {
70
- int port = 235;
71
- fakenetio_set_next_port(port);
72
-
73
- flukaio_server_start(server, 0);
74
- n = flukaio_server_get_port(server);
75
-
76
- LONGS_EQUAL(port, n);
77
- }
78
-
79
- TEST(FlukaIOServer, flukaio_server_start_twice)
80
- {
81
- n = flukaio_server_start(server, 0);
82
- CHECK(n != -1);
83
-
84
- n = flukaio_server_start(server, 0);
85
- CHECK(n == -1);
86
- }
87
-
88
- TEST(FlukaIOServer, flukaio_server_accept)
89
- {
90
- flukaio_server_start(server, 0);
91
- int hsk_count = fakeflukaio_handshake_server_called;
92
-
93
- flukaio_connection_t* conn = flukaio_server_accept(server);
94
- CHECK(conn != NULL);
95
-
96
- CHECK(fakeflukaio_handshake_server_called > hsk_count);
97
- flukaio_disconnect(conn);
98
- }
99
-
100
- TEST(FlukaIOServer, flukaio_server_shutdown_stops_the_server_if_initialized)
101
- {
102
- flukaio_server_start(server, 0);
103
- }
104
-
@@ -1,439 +0,0 @@
1
- #include <stdio.h>
2
- #include <math.h>
3
- #include <stdint.h>
4
- #include <stddef.h>
5
- #include <inttypes.h>
6
- #include <string.h>
7
-
8
- #include "Message.h"
9
- #include "Connection.h"
10
- #include "fakes/FakeNetIO.h"
11
- #include "fakes/FakeFlukaIO.h"
12
- #include "fakes/FakeConnection.h"
13
- #include "fakes/FakeFlukaIOHandshake.h"
14
-
15
- #include "CommonTest.h"
16
-
17
- TEST_GROUP(FlukaIO)
18
- {
19
-
20
- flukaio_connection_t *conn;
21
-
22
- particle_info_t result;
23
- particle_info_t expected;
24
- flukaio_message_t msg;
25
-
26
- char buf[1024];
27
-
28
- ssize_t n;
29
-
30
- void setup()
31
- {
32
-
33
- // create connection
34
- conn = fakeconnection_create(-1);
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
- }
56
-
57
- void teardown()
58
- {
59
- // Check no messages are left
60
- n = flukaio_receive_message(conn, NULL);
61
- LONGS_EQUAL(-1, n);
62
-
63
- // Cleanup
64
- flukaio_disconnect(conn);
65
- }
66
-
67
- void PARTICLES_EQUAL(const particle_info_t *expected, const particle_info_t *result)
68
- {
69
- LONGS_EQUAL(expected->id, result->id);
70
- LONGS_EQUAL(expected->gen, result->gen);
71
- DOUBLES_EQUAL(expected->weight, result->weight, DOUBLE_TOL);
72
- DOUBLES_EQUAL(expected->x, result->x, DOUBLE_TOL);
73
- DOUBLES_EQUAL(expected->y, result->y, DOUBLE_TOL);
74
- DOUBLES_EQUAL(expected->z, result->z, DOUBLE_TOL);
75
- DOUBLES_EQUAL(expected->tx, result->tx, DOUBLE_TOL);
76
- DOUBLES_EQUAL(expected->ty, result->ty, DOUBLE_TOL);
77
- DOUBLES_EQUAL(expected->tz, result->tz, DOUBLE_TOL);
78
- LONGS_EQUAL(expected->aa, result->aa);
79
- LONGS_EQUAL(expected->zz, result->zz);
80
- DOUBLES_EQUAL(expected->m, result->m, DOUBLE_TOL);
81
- DOUBLES_EQUAL(expected->pc, result->pc, DOUBLE_TOL);
82
- DOUBLES_EQUAL(expected->t, result->t, DOUBLE_TOL);
83
- }
84
-
85
- void MESSAGE_HEADER_EQUAL(flukaio_message_t *msg, flukaio_message_type_t type, size_t len) {
86
- LONGS_EQUAL(type, msg->type);
87
- LONGS_EQUAL(MSG_HEADER_LEN + len, msg->size);
88
- }
89
-
90
- };
91
-
92
- /* connect */
93
- TEST(FlukaIO, connect)
94
- {
95
- conn = flukaio_connect(conn, "htest", 0);
96
- CHECK(conn != NULL);
97
- CHECK(fakeflukaio_handshake_client_called == 1);
98
- }
99
-
100
- /* Read operations */
101
- TEST(FlukaIO, read_message_empty_buffer)
102
- {
103
- n = flukaio_receive_message(conn, &msg);
104
-
105
- LONGS_EQUAL(-1, n);
106
- }
107
-
108
- TEST(FlukaIO, read_NULL_message_particle)
109
- {
110
- // Read in NULL buffer skips next message
111
- fakeflukaio_insert_particle_message(conn, &expected);
112
-
113
- n = flukaio_receive_message(conn, NULL);
114
- LONGS_EQUAL(MSG_PART_LEN, n);
115
- }
116
-
117
- TEST(FlukaIO, read_message_particle)
118
- {
119
- // Read particle message
120
- fakeflukaio_insert_particle_message(conn, &expected);
121
-
122
- n = flukaio_receive_message(conn, &msg);
123
- CHECK(n != -1);
124
-
125
- MESSAGE_HEADER_EQUAL(&msg, N_PART, sizeof(expected));
126
- PARTICLES_EQUAL(&expected, &msg.data.particle);
127
- }
128
-
129
- TEST(FlukaIO, read_message_particle_twice)
130
- {
131
- // Insert two messages and check they are read correctly
132
- fakeflukaio_insert_particle_message(conn, &expected);
133
- fakeflukaio_insert_particle_message(conn, &expected);
134
-
135
- n = flukaio_receive_message(conn, &msg);
136
- CHECK(n != -1);
137
-
138
- MESSAGE_HEADER_EQUAL(&msg, N_PART, sizeof(expected));
139
- PARTICLES_EQUAL(&expected, &msg.data.particle);
140
-
141
- memset(&msg, 0xff, sizeof(msg));
142
- n = flukaio_receive_message(conn, &msg);
143
- CHECK(n != -1);
144
-
145
- MESSAGE_HEADER_EQUAL(&msg, N_PART, sizeof(expected));
146
- PARTICLES_EQUAL(&expected, &msg.data.particle);
147
- }
148
-
149
- TEST(FlukaIO, read_message_eob)
150
- {
151
- // Insert end of turn and check
152
- fakeflukaio_insert_eob_message(conn);
153
-
154
- n = flukaio_receive_message(conn, &msg);
155
- CHECK(n != -1);
156
-
157
- MESSAGE_HEADER_EQUAL(&msg, N_EOB, 0);
158
- }
159
-
160
- TEST(FlukaIO, read_message_insertion_point)
161
- {
162
- // Insert end of turn and check
163
- uint32_t turn = 7;
164
- uint16_t ipt = 2;
165
- fakeflukaio_insert_ipt_message(conn, turn, ipt);
166
-
167
- n = flukaio_receive_message(conn, &msg);
168
- CHECK(n != -1);
169
-
170
- MESSAGE_HEADER_EQUAL(&msg, N_IPT, sizeof(flukaio_ipt_data_t));
171
- LONGS_EQUAL(ipt, msg.data.ipt.ipt);
172
- }
173
-
174
- TEST(FlukaIO, read_message_insertion_point_last)
175
- {
176
- // Insert end of turn and check
177
- uint32_t turn = -1;
178
- uint16_t ipt = 2;
179
- fakeflukaio_insert_ipt_message(conn, turn, ipt);
180
-
181
- n = flukaio_receive_message(conn, &msg);
182
- CHECK(n != -1);
183
-
184
- MESSAGE_HEADER_EQUAL(&msg, N_IPT, sizeof(flukaio_ipt_data_t));
185
- LONGS_EQUAL(turn, msg.data.ipt.turn);
186
- LONGS_EQUAL(ipt, msg.data.ipt.ipt);
187
- }
188
-
189
- TEST(FlukaIO, read_message_particle_and_end_of_turn)
190
- {
191
- // Insert particle and end of turn, check
192
- fakeflukaio_insert_particle_message(conn, &expected);
193
- fakeflukaio_insert_eob_message(conn);
194
-
195
- // read the particle
196
- n = flukaio_receive_message(conn, &msg);
197
- CHECK(n != -1);
198
-
199
- MESSAGE_HEADER_EQUAL(&msg, N_PART, sizeof(expected));
200
- PARTICLES_EQUAL(&expected, &msg.data.particle);
201
-
202
- // read the turn
203
- n = flukaio_receive_message(conn, &msg);
204
- CHECK(n != -1);
205
-
206
- MESSAGE_HEADER_EQUAL(&msg, N_EOB, 0);
207
- }
208
-
209
- TEST(FlukaIO, read_message_end_of_computation)
210
- {
211
- // Insert end of computation and check
212
- fakeflukaio_insert_eoc_message(conn);
213
-
214
- n = flukaio_receive_message(conn, &msg);
215
- CHECK(n != -1);
216
-
217
- MESSAGE_HEADER_EQUAL(&msg, N_END, 0);
218
- }
219
-
220
- TEST(FlukaIO, read_message_configuration)
221
- {
222
- // Insert configuration message and check
223
- fakeflukaio_insert_config_message(conn);
224
-
225
- n = flukaio_receive_message(conn, &msg);
226
- CHECK(n != -1);
227
-
228
- MESSAGE_HEADER_EQUAL(&msg, N_CONF, 0);
229
- }
230
-
231
- TEST(FlukaIO, read_message_other)
232
- {
233
- // Insert other message and check error is read
234
- fakeflukaio_insert_unknown_message(conn);
235
-
236
- n = flukaio_receive_message(conn, &msg);
237
- LONGS_EQUAL(-1, n);
238
- CHECK(n == -1);
239
-
240
- MESSAGE_HEADER_EQUAL(&msg, N_ERR, 0);
241
- }
242
-
243
- TEST(FlukaIO, read_message_handshake)
244
- {
245
- // Insert end of turn and check
246
- uint16_t major = 3;
247
- uint16_t minor = 1;
248
- uint32_t key = 123;
249
- fakeflukaio_insert_hsk_message(conn, major, minor, key);
250
-
251
- n = flukaio_receive_message(conn, &msg);
252
- CHECK(n != -1);
253
-
254
- MESSAGE_HEADER_EQUAL(&msg, N_HSK, sizeof(flukaio_hsk_data_t));
255
- LONGS_EQUAL(major, msg.data.hsk.major);
256
- LONGS_EQUAL(minor, msg.data.hsk.minor);
257
- LONGS_EQUAL(key, msg.data.hsk.key);
258
- }
259
-
260
- /* Send operations */
261
- /* Send end of turn */
262
- TEST(FlukaIO, send_eob)
263
- {
264
- n = flukaio_send_eob(conn);
265
- LONGS_EQUAL(MSG_EOB_LEN, fakenetio_get_last_sent_size());
266
-
267
- fakeflukaio_get_last_sent_message(conn, &msg);
268
- MESSAGE_HEADER_EQUAL(&msg, N_EOB, 0);
269
- }
270
-
271
- /* Send end of insertion point */
272
- TEST(FlukaIO, send_insertion_point)
273
- {
274
- uint32_t turn = 32;
275
- uint16_t ipt = 55;
276
- n = flukaio_send_ipt(conn, turn, ipt);
277
-
278
- connection_flush(conn); // Force flush
279
- LONGS_EQUAL(MSG_IPT_LEN, fakenetio_get_last_sent_size());
280
-
281
- fakeflukaio_get_last_sent_message(conn, &msg);
282
- MESSAGE_HEADER_EQUAL(&msg, N_IPT, sizeof(flukaio_ipt_data_t));
283
- LONGS_EQUAL(turn, msg.data.ipt.turn);
284
- LONGS_EQUAL(ipt, msg.data.ipt.ipt);
285
-
286
- }
287
-
288
- /* Send Particle */
289
- TEST(FlukaIO, send_particle)
290
- {
291
- n = flukaio_send_particle(conn, &expected);
292
- CHECK(n != -1);
293
-
294
- connection_flush(conn);// Force flush
295
- LONGS_EQUAL(MSG_PART_LEN, fakenetio_get_last_sent_size());
296
-
297
- fakeflukaio_get_last_sent_message(conn, &msg);
298
- MESSAGE_HEADER_EQUAL(&msg, N_PART, sizeof(expected));
299
- PARTICLES_EQUAL(&expected, &msg.data.particle);
300
- }
301
- /* Send Particle n times */
302
- TEST(FlukaIO, send_particle_n_times)
303
- {
304
- int times = 25;
305
- for(int i = 0; i < times; ++i) {
306
- expected.id = i;
307
- n = flukaio_send_particle(conn, &expected);
308
- CHECK(n != -1);
309
- }
310
-
311
- connection_flush(conn);
312
- LONGS_EQUAL(MSG_PART_LEN * times, fakenetio_get_last_sent_size());
313
-
314
- for(int i = 0; i < times; ++i) {
315
- expected.id = i;
316
- fakeflukaio_get_last_sent_message(conn, &msg);
317
- MESSAGE_HEADER_EQUAL(&msg, N_PART, sizeof(expected));
318
- PARTICLES_EQUAL(&expected, &msg.data.particle);
319
- }
320
- }
321
-
322
-
323
- /* End Computation */
324
- TEST(FlukaIO, send_end_comp)
325
- {
326
- n = flukaio_send_eoc(conn);
327
- CHECK(n != -1);
328
- LONGS_EQUAL(MSG_EOC_LEN, fakenetio_get_last_sent_size());
329
-
330
- fakeflukaio_get_last_sent_message(conn, &msg);
331
- MESSAGE_HEADER_EQUAL(&msg, N_END, 0);
332
- }
333
-
334
- /* Send handshake */
335
- TEST(FlukaIO, send_handshake)
336
- {
337
- uint16_t major = 32;
338
- uint16_t minor = 55;
339
- uint32_t key = 45668;
340
- n = flukaio_send_hsk(conn, major, minor, key);
341
- LONGS_EQUAL(MSG_HSK_LEN, fakenetio_get_last_sent_size());
342
-
343
- fakeflukaio_get_last_sent_message(conn, &msg);
344
- MESSAGE_HEADER_EQUAL(&msg, N_HSK, sizeof(flukaio_hsk_data_t));
345
- LONGS_EQUAL(major, msg.data.hsk.major);
346
- LONGS_EQUAL(minor, msg.data.hsk.minor);
347
- LONGS_EQUAL(key, msg.data.hsk.key);
348
-
349
- }
350
-
351
- /* Sync reads */
352
- TEST(FlukaIO, wait_message_empty_buffer)
353
- {
354
- n = flukaio_wait_message(conn, &msg);
355
-
356
- LONGS_EQUAL(-1, n);
357
- }
358
-
359
- TEST(FlukaIO, wait_with_empty_buffer_delay)
360
- {
361
-
362
- // TODO: Add delay
363
- n = flukaio_wait_message(conn, &msg);
364
-
365
- LONGS_EQUAL(-1, n);
366
- }
367
-
368
- TEST(FlukaIO, wait_until_somethig_is_read)
369
- {
370
- fakeflukaio_insert_particle_message(conn, &expected);
371
-
372
- n = flukaio_wait_message(conn, &msg);
373
- CHECK(n != -1);
374
- }
375
-
376
- TEST(FlukaIO, wait_message_particle)
377
- {
378
- // wait particle message
379
- fakeflukaio_insert_particle_message(conn, &expected);
380
-
381
- n = flukaio_wait_message(conn, &msg);
382
- CHECK(n != -1);
383
-
384
- MESSAGE_HEADER_EQUAL(&msg, N_PART, sizeof(expected));
385
- PARTICLES_EQUAL(&expected, &msg.data.particle);
386
- }
387
-
388
-
389
- TEST(FlukaIO, wait_NULL_message_particle)
390
- {
391
- // wait in NULL buffer skips next message
392
- fakeflukaio_insert_particle_message(conn, &expected);
393
-
394
- n = flukaio_wait_message(conn, NULL);
395
- CHECK(n != -1);
396
- }
397
-
398
- TEST(FlukaIO, wait_message_particle_twice)
399
- {
400
- // Insert two messages and check they are read correctly
401
- fakeflukaio_insert_particle_message(conn, &expected);
402
- fakeflukaio_insert_particle_message(conn, &expected);
403
-
404
- n = flukaio_wait_message(conn, &msg);
405
- CHECK(n != -1);
406
-
407
- MESSAGE_HEADER_EQUAL(&msg, N_PART, sizeof(expected));
408
- PARTICLES_EQUAL(&expected, &msg.data.particle);
409
-
410
- memset(&msg, 0, sizeof(msg));
411
- n = flukaio_wait_message(conn, &msg);
412
- CHECK(n != -1);
413
-
414
- MESSAGE_HEADER_EQUAL(&msg, N_PART, sizeof(expected));
415
- PARTICLES_EQUAL(&expected, &msg.data.particle);
416
- }
417
-
418
- // Insert particle
419
- TEST(FlukaIO, insert_particle)
420
- {
421
- n = fakeflukaio_insert_particle_message(conn, &expected);
422
-
423
- LONGS_EQUAL(MSG_PART_LEN, n);
424
- LONGS_EQUAL(conn->in_buffer_len, n);
425
- fakeflukaio_clean_buffers(conn);
426
- }
427
-
428
- TEST(FlukaIO, insert_two_particles)
429
- {
430
- n = fakeflukaio_insert_particle_message(conn, &expected);
431
- LONGS_EQUAL(MSG_PART_LEN, n);
432
- LONGS_EQUAL(conn->in_buffer_len, n);
433
-
434
- n = fakeflukaio_insert_particle_message(conn, &expected);
435
- LONGS_EQUAL(MSG_PART_LEN, n);
436
- LONGS_EQUAL(conn->in_buffer_len, n+n);
437
-
438
- fakeflukaio_clean_buffers(conn);
439
- }