Exemplo n.º 1
0
/*
 * Create a new macro: then create some random instances
 */
static void test_macro(const char *name, uint32_t n, type_t *vars, type_t body) {
    uint32_t i;
    int32_t id;

    printf("Test: create macro %s[", name);
    for (i=0; i<n; i++) {
        if (i > 0) fputs(", ", stdout);
        print_type(stdout, &types, vars[i]);
    }
    printf("] = ");
    print_type(stdout, &types, body);
    printf("\n");

    add_type_macro(&types, clone_string(name), n, vars, body);
    id = get_type_macro_by_name(&types, name);
    printf("Result: ");
    show_macro(stdout, &types, type_macro(&types, id));
    printf("\n");

    for (i=0; i<10; i++) {
        test_instance(id, n);
    }
    printf("----\n");
    show_macro_instances(stdout, &types, id);
    printf("\n");
}
Exemplo n.º 2
0
/*
 * Create a new type constructor + some instances
 */
static void test_constructor(const char *name, uint32_t n) {
    int32_t id;
    uint32_t i;

    printf("Test: create constructor %s, arity %"PRIu32"\n", name, n);
    add_type_constructor(&types, clone_string(name), n);
    id = get_type_macro_by_name(&types, name);
    printf("Result: ");
    show_macro(stdout, &types, type_macro(&types, id));
    printf("\n");

    for (i=0; i<10; i++) {
        test_instance(id, n);
    }
}
Exemplo n.º 3
0
/*
 * main
 */
int
main(int argc, char **argv)
{
    int	sts;

    set_proc_fmt();
    printf("pid=%" FMT_PID " ppid=%" FMT_PID "\n", getpid(), getppid());
    getargs(argc, argv);

    if (pmnsfile != PM_NS_DEFAULT) {
	if ((sts = pmLoadNameSpace(pmnsfile)) < 0) {
	    printf("%s: Cannot load pmnsfile from \"%s\": %s\n", 
		    pmProgname, pmnsfile, pmErrStr(sts));
	    exit(1);
	}
    }

    if ((sts = pmNewContext(PM_CONTEXT_HOST, host)) < 0) {
	printf("%s: Cannot connect to PMCD on host \"%s\": %s\n", 
		pmProgname, host, pmErrStr(sts));
	exit(1);
    }

    test_PMNS();
    test_desc();
    test_instance();
    test_prof_fetch();
    if (!is_hotproc)
        test_store();

    if ((sts = pmWhichContext()) < 0) {
	printf("%s: pmWhichContext: %s\n", pmProgname, pmErrStr(sts));
	exit(1);
    }
    pmDestroyContext(sts);

    exit(0);
}