Skip to content

Commit 1407eaf

Browse files
committed
Tests: disable map use_inst property for test_timed_maps, check for correct instancing in testinstance and testinstance_no_cb.
1 parent 47f5b85 commit 1407eaf

4 files changed

Lines changed: 26 additions & 5 deletions

File tree

test/test_map_timed.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ void loop()
316316
if (sent % 3)
317317
mpr_sig_set_value(sendsig, 0, 1, MPR_INT32, &sent);
318318

319-
mpr_dev_poll(src, period);
319+
if (!shared_graph)
320+
mpr_dev_poll(src, period);
320321

321322
if (!verbose) {
322323
printf("\r Received: %4i", received);
@@ -332,7 +333,7 @@ int run_test(test_config *config)
332333
double period_sec = period * 0.001;
333334
mpr_time t_start;
334335
int result = 0;
335-
// int zero = 0;
336+
int use_inst = 0;
336337
mpr_map map;
337338
char expr[256];
338339

@@ -350,8 +351,10 @@ int run_test(test_config *config)
350351
/* set expression */
351352
mpr_obj_set_prop((mpr_obj)map, MPR_PROP_EXPR, NULL, 1, MPR_STR, expr, 1);
352353

353-
// TODO: ensure can set this with an int, etc
354-
// mpr_obj_set_prop((mpr_obj)map, MPR_PROP_USE_INST, NULL, 1, MPR_BOOL, &zero, 1);
354+
/* set use_inst property to False since the destination will claim an instance locally */
355+
/* TODO: test with multiple instances, instanced periods, etc. */
356+
/* also test setting boolean property with integer value */
357+
mpr_obj_set_prop((mpr_obj)map, MPR_PROP_USE_INST, NULL, 1, MPR_INT32, &use_inst, 1);
355358

356359
mpr_obj_push(map);
357360

@@ -384,6 +387,12 @@ int run_test(test_config *config)
384387
}
385388
} while (!done);
386389

390+
/* double-check that the map instancing is correct */
391+
if (mpr_obj_get_prop_as_int32((mpr_obj)map, MPR_PROP_USE_INST, NULL) != use_inst) {
392+
eprintf("error: map.use_inst=%d but should be %d\n", !use_inst, use_inst);
393+
return 1;
394+
}
395+
387396
/* activate a destination instance */
388397
// mpr_sig_activate_inst(recvsig, 0);
389398

test/testinstance.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,12 @@ int run_test(test_config *config)
711711
mpr_dev_poll(src, 10);
712712
mpr_dev_poll(dst, 10);
713713

714+
/* double-check that the map instancing is correct */
715+
if (mpr_obj_get_prop_as_int32((mpr_obj)map, MPR_PROP_USE_INST, NULL) != use_inst) {
716+
eprintf("error: map.use_inst=%d but should be %d\n", !use_inst, use_inst);
717+
return 1;
718+
}
719+
714720
/* remove any extra destination instances allocated by previous tests */
715721
while (5 <= mpr_sig_get_num_inst(multirecv, MPR_STATUS_ANY)) {
716722
mpr_id id;

test/testinstance_no_cb.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,12 @@ int run_test(test_config *config)
704704
mpr_dev_poll(src, 10);
705705
mpr_dev_poll(dst, 10);
706706

707+
/* double-check that the map instancing is correct */
708+
if (mpr_obj_get_prop_as_int32((mpr_obj)map, MPR_PROP_USE_INST, NULL) != use_inst) {
709+
eprintf("error: map.use_inst=%d but should be %d\n", !use_inst, use_inst);
710+
return 1;
711+
}
712+
707713
/* remove any extra destination instances allocated by previous tests */
708714
while (5 <= mpr_sig_get_num_inst(multirecv, MPR_STATUS_ANY)) {
709715
mpr_id id;

test/testthread.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ int main(int argc, char **argv)
355355
/* poll device in another thread */
356356
loop2();
357357

358-
if (autoconnect && (!received || sent > received)) {
358+
if (autoconnect && (!received || (sent - received) > 1)) {
359359
eprintf("Not all sent messages were received.\n");
360360
eprintf("Updated value %d time%s and received %d of them.\n",
361361
sent, sent == 1 ? "" : "s", received);

0 commit comments

Comments
 (0)