Exemplo n.º 1
0
END_TEST

START_TEST (test_check_add_var)
{
	ck_assert(check_enter_method("checkaddvar", parser_data) != NULL);

	Symbol *result;

	Attributes attrs = ATTRIBUTES_DEFAULT;

	attrs.t.std_type = INT;
	result = check_add_var("int", attrs, parser_data);
	ck_assert(result != NULL);
	ck_assert_str_eq("int", result->name);

	attrs.t.std_type = REAL;
	result = check_add_var("real", attrs, parser_data);
	ck_assert(result != NULL);
	ck_assert_str_eq("real", result->name);

	ck_assert(check_exit_method(parser_data) == 0);
}
Exemplo n.º 2
0
int main(int argc, char** argv)
{
    char filename[256];
    int  rank, nprocs, err, nerrs=0;

    MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &rank);
    MPI_Comm_size(MPI_COMM_WORLD, &nprocs);

    if (argc > 2) {
        if (!rank) printf("Usage: %s [filename]\n",argv[0]);
        MPI_Finalize();
        return 0;
    }
    strcpy(filename, "testfile.nc");
    if (argc == 2) strcpy(filename, argv[1]);
    MPI_Bcast(filename, 256, MPI_CHAR, 0, MPI_COMM_WORLD);

    if (rank == 0) {
        char cmd_str[256];
        sprintf(cmd_str, "*** TESTING C   %s for last large var in CDF-1/2", argv[0]);
        printf("%-66s ------ ", cmd_str); fflush(stdout);
    }

    nerrs += check_last_var(filename);
    nerrs += check_rec_var(filename);
    nerrs += check_not_last_var(filename);
    nerrs += check_add_var(filename);
    nerrs += check_var_offset(filename);

    /* check if PnetCDF freed all internal malloc */
    MPI_Offset malloc_size, sum_size;
    err = ncmpi_inq_malloc_size(&malloc_size);
    if (err == NC_NOERR) {
        MPI_Reduce(&malloc_size, &sum_size, 1, MPI_OFFSET, MPI_SUM, 0, MPI_COMM_WORLD);
        if (rank == 0 && sum_size > 0)
            printf("heap memory allocated by PnetCDF internally has %lld bytes yet to be freed\n",
                   sum_size);
    }

    MPI_Allreduce(MPI_IN_PLACE, &nerrs, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
    if (rank == 0) {
        if (nerrs) printf(FAIL_STR,nerrs);
        else       printf(PASS_STR);
    }

    MPI_Finalize();
    return 0;
}
Exemplo n.º 3
0
END_TEST

START_TEST (test_get_symbol)
{
	SymbolTable *result = get_symbol("notfound", parser_data, 1);
	ck_assert(result == NULL);

	// program
	ck_assert(check_enter_method("program", parser_data) != NULL);

	result = get_symbol("program", parser_data, 1);
	ck_assert_str_eq("program", result->symbol->name);
	ck_assert(result->symbol->type.std_type == PGNAME);

	// program.pvar
	Attributes attrs = ATTRIBUTES_DEFAULT;
	attrs.t.std_type = REAL;
	ck_assert(check_add_var("pvar", attrs, parser_data) != NULL);	

	// program.fun
	ck_assert(check_enter_method("fun", parser_data) != NULL);

	result = get_symbol("fun", parser_data, 1);
	ck_assert_str_eq("fun", result->symbol->name);
	ck_assert_int_eq(1, result->symbol->type.fun);
	ck_assert(result->symbol->type.std_type == NONE);

	// check global search
	ck_assert(get_symbol("pvar", parser_data, 0) == NULL);

	result = get_symbol("pvar", parser_data, 1);
	ck_assert_str_eq("pvar", result->symbol->name);
	ck_assert(result->symbol->type.std_type == REAL);

	// exit program.fun
	ck_assert(check_exit_method(parser_data) == 0);

	// exit program
	ck_assert(check_exit_method(parser_data) == 0);
}