Esempio n. 1
0
int main()
{
    int result = 0;

    signal(SIGINT, ctrlc);

    if (setup_destination()) {
        printf("Error initializing destination.\n");
        result = 1;
        goto done;
    }

    if (setup_source()) {
        printf("Done initializing source.\n");
        result = 1;
        goto done;
    }

    wait_local_devices();

    loop();

  done:
    cleanup_destination();
    cleanup_source();
    return result;
}
Esempio n. 2
0
int main()
{
    int result = 0;

    value = (float)rand();

    signal(SIGINT, ctrlc);

    if (setup_destination()) {
        printf("Error initializing destination.\n");
        result = 1;
        goto done;
    }

    if (setup_source()) {
        printf("Done initializing source.\n");
        result = 1;
        goto done;
    }

    wait_local_devices();

    if (automate)
        connect_signals();

    // start things off
    printf("STARTING TEST...\n");
    times[0] = get_current_time();
    msig_update_instance(sendsig, counter++, &value, 0, MAPPER_TIMETAG_NOW);
    while (!done) {
        mdev_poll(destination, 0);
        mdev_poll(source, 0);
    }
    goto done;

  done:
    cleanup_destination();
    cleanup_source();
    print_results();
    return result;
}
Esempio n. 3
0
int main(int argc, char **argv)
{
    int i, j, result = 0;

    // process flags for -v verbose, -t terminate, -h help
    for (i = 1; i < argc; i++) {
        if (argv[i] && argv[i][0] == '-') {
            int len = strlen(argv[i]);
            for (j = 1; j < len; j++) {
                switch (argv[i][j]) {
                    case 'h':
                        eprintf("testselect.c: possible arguments"
                                "-q quiet (suppress output), "
                                "-t terminate automatically, "
                                "-h help\n");
                        return 1;
                        break;
                    case 'q':
                        verbose = 0;
                        break;
                    case 't':
                        terminate = 1;
                        break;
                    default:
                        break;
                }
            }
        }
    }

    signal(SIGINT, ctrlc);

    if (setup_destination()) {
        eprintf("Error initializing destination.\n");
        result = 1;
        goto done;
    }

    if (setup_source()) {
        eprintf("Error initializing source.\n");
        result = 1;
        goto done;
    }

    wait_local_devices();

    if (autoconnect && setup_connection()) {
        eprintf("Error initializing connection.\n");
        result = 1;
        goto done;
    }

    loop();

    if (sent != received) {
        result = 1;
        eprintf("Error: sent %i messages but received %i messages.\n",
                sent, received);
    }

  done:
    cleanup_destination();
    cleanup_source();
    printf("Test %s.\n", result ? "FAILED" : "PASSED");
    return result;
}
Esempio n. 4
0
int main()
{
    int result = 0;
    int stats[6], i;

    signal(SIGINT, ctrlc);

    if (setup_destination()) {
        printf("Error initializing destination.\n");
        result = 1;
        goto done;
    }

    if (setup_source()) {
        printf("Done initializing source.\n");
        result = 1;
        goto done;
    }

    wait_local_devices();

    if (automate)
        connect_signals();

    printf("\n**********************************************\n");
    printf("************ NO INSTANCE STEALING ************\n");
    loop(100);

    stats[0] = sent;
    stats[1] = received;

    for (i=0; i<10; i++)
        msig_release_instance(sendsig, sendinst[i], MAPPER_TIMETAG_NOW);
    sent = received = 0;

    msig_set_instance_allocation_mode(recvsig, IN_STEAL_OLDEST);
    printf("\n**********************************************\n");
    printf("*************** IN_STEAL_OLDEST **************\n");
    loop(100);

    stats[2] = sent;
    stats[3] = received;

    sent = received = 0;

    msig_set_instance_allocation_mode(recvsig, IN_UNDEFINED);
    msig_set_instance_management_callback(recvsig, overflow_handler);
    printf("\n**********************************************\n");
    printf("*********** CALLBACK > ADD INSTANCE **********\n");
    loop(100);

    stats[4] = sent;
    stats[5] = received;

    printf("NO STEALING: sent %i updates, received %i updates (mismatch is OK).\n", stats[0], stats[1]);
    printf("STEAL OLDEST: sent %i updates, received %i updates (mismatch is OK).\n", stats[2], stats[3]);
    printf("ADD INSTANCE: sent %i updates, received %i updates.\n", stats[4], stats[5]);

    result = (stats[4] != stats[5]);

  done:
    cleanup_destination();
    cleanup_source();
    printf("Test %s.\n", result ? "FAILED" : "PASSED");
    return result;
}
Esempio n. 5
0
int main(int argc, char *argv[])
{
    double now = get_current_time();
    int result = 0;
    int do_loop = 1;

    if (argc > 1) {
        if (strcmp(argv[1], "-h")==0
            || strcmp(argv[1], "--help")==0)
        {
            printf("Usage: testmany [num_sources=5] [num_dests=5] "
                   "[max_num_signals=4] [loop=1]\n");
            exit(0);
        }
        else
            num_sources = atoi(argv[1]);
    }

    if (argc > 2)
        num_dests = atoi(argv[2]);

    if (argc > 3)
        max_num_signals = atoi(argv[3]);

    if (argc > 4)
        do_loop = atoi(argv[4]);

    source_device_list = (mapper_device*)malloc(
        sizeof(mapper_device)*num_sources);

    dest_device_list = (mapper_device*)malloc(
        sizeof(mapper_device)*num_dests);

    num_signals = (int*)malloc(sizeof(int)*(num_sources + num_dests));

    signal(SIGINT, ctrlc);
	srand( time(NULL) );

	for (int i=0; i<num_sources+num_dests; i++) {

		num_signals[i] = (rand() % max_num_signals) + 1;

	}

    if (setup_sources()) {
        printf("Error initializing sources.\n");
        result = 1;
        goto done;
    }
    if (setup_destinations()) {
        printf("Error initializing destinations.\n");
        result = 1;
        goto done;
    }

    wait_local_devices(&done);
    now = get_current_time() - now;
    printf("Allocated %d devices in %f seconds.\n", num_sources + num_dests, now);

    if (do_loop)
        loop();

  done:
    cleanup_destinations();
    cleanup_sources();

    free(source_device_list);
    free(dest_device_list);
    free(num_signals);

    return result;
}
Esempio n. 6
0
int main(int argc, char **argv)
{
    int i, j, result = 0, stats[6];

    // process flags for -v verbose, -t terminate, -h help
    for (i = 1; i < argc; i++) {
        if (argv[i] && argv[i][0] == '-') {
            int len = strlen(argv[i]);
            for (j = 1; j < len; j++) {
                switch (argv[i][j]) {
                    case 'h':
                        printf("testinstance.c: possible arguments "
                               "-q quiet (suppress output), "
                               "-h help\n");
                        return 1;
                        break;
                    case 'q':
                        verbose = 0;
                        break;
                    default:
                        break;
                }
            }
        }
    }

    signal(SIGINT, ctrlc);

    if (setup_destination()) {
        eprintf("Error initializing destination.\n");
        result = 1;
        goto done;
    }

    if (setup_source()) {
        eprintf("Done initializing source.\n");
        result = 1;
        goto done;
    }

    wait_local_devices();

    if (automate)
        map_signals();

    eprintf("\n**********************************************\n");
    eprintf("************ NO INSTANCE STEALING ************\n");
    loop();

    stats[0] = sent;
    stats[1] = received;

    for (i=0; i<10; i++)
        mapper_signal_instance_release(sendsig, i, MAPPER_NOW);
    sent = received = 0;

    mapper_signal_set_instance_stealing_mode(recvsig, MAPPER_STEAL_OLDEST);
    eprintf("\n**********************************************\n");
    eprintf("************ STEAL OLDEST INSTANCE ***********\n");
    if (!verbose)
        printf("\n");
    loop();

    stats[2] = sent;
    stats[3] = received;
    sent = received = 0;

    for (i=0; i<10; i++)
        mapper_signal_instance_release(sendsig, i, MAPPER_NOW);
    sent = received = 0;

    mapper_signal_set_instance_event_callback(recvsig, more_handler,
                                              MAPPER_INSTANCE_OVERFLOW
                                              | MAPPER_UPSTREAM_RELEASE);
    eprintf("\n**********************************************\n");
    eprintf("*********** CALLBACK -> ADD INSTANCE *********\n");
    if (!verbose)
        printf("\n");
    loop();

    stats[4] = sent;
    stats[5] = received;

    eprintf("NO STEALING: sent %i updates, received %i updates (mismatch is OK).\n",
            stats[0], stats[1]);
    eprintf("STEAL OLDEST: sent %i updates, received %i updates (mismatch is OK).\n",
            stats[2], stats[3]);
    eprintf("ADD INSTANCE: sent %i updates, received %i updates.\n",
            stats[4], stats[5]);

    result = (stats[4] != stats[5]);

  done:
    cleanup_destination();
    cleanup_source();
    printf("Test %s.\n", result ? "FAILED" : "PASSED");
    return result;
}