From c296a3deb8b638d63ca9fab7a4fd1c4f237bfee6 Mon Sep 17 00:00:00 2001 From: edwardhartnett Date: Mon, 16 Sep 2019 11:38:48 -0600 Subject: [PATCH] porting tests --- unit_test/tst_nc4internal.c | 51 +++++++++++++++++++------------------ unit_test/tst_nclist.c | 31 ++++++++++++++++++++++ 2 files changed, 57 insertions(+), 25 deletions(-) diff --git a/unit_test/tst_nc4internal.c b/unit_test/tst_nc4internal.c index 323a47989f..4fbca4849e 100644 --- a/unit_test/tst_nc4internal.c +++ b/unit_test/tst_nc4internal.c @@ -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; } diff --git a/unit_test/tst_nclist.c b/unit_test/tst_nclist.c index 0daae16a9c..cdb56a9c5a 100644 --- a/unit_test/tst_nclist.c +++ b/unit_test/tst_nclist.c @@ -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...");