Skip to content

Commit

Permalink
porting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed Sep 16, 2019
1 parent 2cd228b commit c296a3d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 25 deletions.
51 changes: 26 additions & 25 deletions unit_test/tst_nc4internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,36 +265,37 @@ main(int argc, char **argv)
free_NC(ncp);
}
SUMMARIZE_ERR;
/* printf("Testing changing ncid..."); */
/* { */
/* NC *ncp, *ncp2; */
/* int mode = 0; */
/* NCmodel model; */
/* int ret; */

/* /\* Create the NC* instance and insert its dispatcher and model. *\/ */
/* if ((ret = new_NC(NULL, FILE_NAME, mode, &model, &ncp))) ERR; */
printf("Testing changing ncid...");
{
NC *ncp;
NCmodel model;
NC_GRP_INFO_T *grp;
NC_FILE_INFO_T *h5;
int old_ncid;

/* /\* Add to list of known open files and define ext_ncid. *\/ */
/* add_to_NCList(ncp); */
/* Create the NC, add it to nc_filelist array, add and init
* NC_FILE_INFO_T. */
if (new_NC(NC3_dispatch_table, FILE_NAME, 0, &model, &ncp)) ERR;
add_to_NCList(ncp);
if (nc4_file_list_add(ncp->ext_ncid, FILE_NAME, 0, NULL)) ERR;
if (nc4_find_nc_grp_h5(ncp->ext_ncid, NULL, &grp, &h5)) ERR;

/* /\* Find it in the list. *\/ */
/* if (!(ncp2 = find_in_NCList(ncp->ext_ncid))) ERR; */
/* if (!(ncp2 = find_in_NCList_by_name(FILE_NAME))) ERR; */
/* if ((ret = iterate_NCList(1, &ncp2))) ERR; */
/* if (count_NCList() != 1) ERR; */
/* Change the ncid. */
old_ncid = ncp->ext_ncid;
if (nc4_file_change_ncid(ncp->ext_ncid, TEST_VAL_42)) ERR;

/* /\* Change the ncid. *\/ */
/* if (nc4_file_change_ncid(ncp->ext_ncid, TEST_VAL_42)) ERR; */
/* Can't find old ncid. */
if (nc4_find_nc_grp_h5(old_ncid, NULL, NULL, NULL) != NC_EBADID) ERR;

/* /\* Delete it. *\/ */
/* del_from_NCList(ncp); /\* Will free empty list. *\/ */
/* free_NC(ncp); */
/* Delete it. */
if (nc4_file_list_del(ncp->ext_ncid)) ERR;
del_from_NCList(ncp); /* Will free empty list. */
free_NC(ncp);

/* /\* Ensure it is no longer in list. *\/ */
/* /\* if (find_in_NCList(ncp->ext_ncid)) ERR; *\/ */
/* Ensure it is no longer in list. */
/* if (find_in_NCList(ncp->ext_ncid)) ERR; */

/* } */
/* SUMMARIZE_ERR; */
}
SUMMARIZE_ERR;
FINAL_RESULTS;
}
31 changes: 31 additions & 0 deletions unit_test/tst_nclist.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,37 @@ main(int argc, char **argv)
if (find_in_NCList(ncid)) ERR;
}
SUMMARIZE_ERR;
printf("Testing moving in NC list (needed for PIO)...");
{
int ncid;
NC *ncp, *ncp2;
int mode = 0;
NCmodel model;
int ret;

/* Create the NC* instance and add it to list. */
if ((ret = new_NC(NULL, FILE_NAME, mode, &model, &ncp))) ERR;
add_to_NCList(ncp);

/* Find it in the list. */
if (!(ncp2 = find_in_NCList(ncp->ext_ncid))) ERR;

/* Move it. */
ncid = ncp->ext_ncid;
if (move_in_NCList(ncp, TEST_VAL_42)) ERR;

/* Now we won't find old ncid in the list. */
if (find_in_NCList(ncid)) ERR;

/* Delete it. */
ncid = ncp->ext_ncid;
del_from_NCList(ncp); /* Will free empty list. */
free_NC(ncp);

/* Ensure it is no longer in list. */
if (find_in_NCList(ncid)) ERR;
}
SUMMARIZE_ERR;
#ifdef LARGE_FILE_TESTS
/* This test is slow, only run it on large file test builds. */
printf("Testing maxing out NC list...");
Expand Down

0 comments on commit c296a3d

Please sign in to comment.