Skip to content

Commit

Permalink
Merge pull request #1474 from Unidata/gh1472.wif
Browse files Browse the repository at this point in the history
Unit tests plus cmake infrastructure
  • Loading branch information
WardF committed Aug 22, 2019
2 parents 207f2b5 + 842f520 commit 525eaeb
Show file tree
Hide file tree
Showing 10 changed files with 622 additions and 228 deletions.
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,13 @@ IF(ENABLE_TESTS)

OPTION(ENABLE_FAILING_TESTS "Run tests which are known to fail, check to see if any have been fixed." OFF)

###
# Option to turn on unit testing. See https://github.com/Unidata/netcdf-c/pull/1472 for more information.
# Currently (August 21, 2019): Will not work with Visual Studio
###
IF(NOT MSVC)
OPTION(ENABLE_UNIT_TESTS "Run Unit Tests." ON)
ENDIF(NOT MSVC)
###
# End known-failures.
###
Expand Down Expand Up @@ -1621,6 +1628,7 @@ MACRO(print_conf_summary)
MESSAGE(STATUS "Parallel Tests: ${ENABLE_PARALLEL_TESTS}")
MESSAGE(STATUS "Large File Tests: ${ENABLE_LARGE_FILE_TESTS}")
MESSAGE(STATUS "Extreme Numbers: ${ENABLE_EXTREME_NUMBERS}")
MESSAGE(STATUS "Unit Tests: ${ENABLE_UNIT_TESTS}")
ENDIF()

MESSAGE("")
Expand Down Expand Up @@ -1794,6 +1802,9 @@ IF(ENABLE_TESTS)
IF(ENABLE_EXAMPLES)
ADD_SUBDIRECTORY(examples)
ENDIF()
IF(ENABLE_UNIT_TESTS)
ADD_SUBDIRECTORY(unit_test)
ENDIF(ENABLE_UNIT_TESTS)
ENDIF()

# Code to generate an export header
Expand Down
10 changes: 8 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,24 @@ This file contains a high-level description of this package's evolution. Release

## 4.7.1 - TBD

* [Enhancement] Added unit_test directory, which contains unit tests
for the libdispatch and libsrc4 code (and any other directories that
want to put unit tests there). Use --disable-unit-tests to run without
unit tests (ex. for code coverage analysis).
See [GitHub #1458](https://github.com/Unidata/netcdf-c/issues/1458)

* [Bug Fix] Remove obsolete _CRAYMPP and LOCKNUMREC macros from
code. Also brought documentation up to date in man page. These macros
were used in ancient times, before modern parallel I/O systems were
developed. Programmers interested in parallel I/O should see
nc_open_par() and nc_create_par().
See [GitHub #1436](https://github.com/Unidata/netcdf-c/issues/1459)
See [GitHub #1459](https://github.com/Unidata/netcdf-c/issues/1459)

* [Enhancement] Remove obsolete and deprecated functions
nc_set_base_pe() and nc_inq_base_pe() from the dispatch table. (Both
functions are still supported in the library, this is an internal
change only.)
See [GitHub #1436](https://github.com/Unidata/netcdf-c/issues/1468)
See [GitHub #1468](https://github.com/Unidata/netcdf-c/issues/1468)

* [Bug Fix] Reverted nccopy behavior so that if no -c parameters
are given, then any default chunking is left to the netcdf-c library
Expand Down
437 changes: 228 additions & 209 deletions include/nc4internal.h

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions libdispatch/nc.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ free_NC(NC *ncp)
/**
* Create and initialize a new NC struct. The ncid is assigned later.
*
* @param dispatcher
* @param dispatcher An pointer to the NC_Dispatch table that should
* be used by this NC.
* @param path The name of the file.
* @param mode The open or create mode.
* @param model
* @param model An NCmodel instance, provided by NC_infermodel().
* @param ncpp A pointer that gets a pointer to the newlly allocacted
* and initialized NC struct.
*
Expand Down
35 changes: 30 additions & 5 deletions libsrc4/nc4internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ nc4_check_name(const char *name, char *norm_name)
* nc4_nc4f_list_add(), except it takes an ncid instead of an NC *,
* and also passes back the dispatchdata pointer.
*
* @param ncid The ncid of the file (aka ext_ncid).
* @param ncid The (already-assigned) ncid of the file (aka ext_ncid).
* @param path The file name of the new file.
* @param mode The mode flag.
* @param dispatchdata Void * that gets pointer to dispatch data,
Expand Down Expand Up @@ -125,10 +125,35 @@ nc4_file_list_add(int ncid, const char *path, int mode, void **dispatchdata)
return NC_NOERR;
}

/* /\** */
/* * @internal Change the ncid of an open file. This is needed for PIO */
/* * integration. */
/* * */
/* * @param ncid The ncid of the file (aka ext_ncid). */
/* * @param new_ncid The new ncid to use. */
/* * */
/* * @return ::NC_NOERR No error. */
/* * @return ::NC_EBADID No NC struct with this ext_ncid. */
/* * @return ::NC_ENOMEM Out of memory. */
/* * @author Ed Hartnett */
/* *\/ */
/* int */
/* nc4_file_change_ncid(int ncid, int new_ncid) */
/* { */
/* NC *nc; */
/* int ret; */

/* /\* Find NC pointer for this file. *\/ */
/* if ((ret = NC_check_id(ncid, &nc))) */
/* return ret; */

/* return NC_NOERR; */
/* } */

/**
* @internal Get info about a file on the list of libsrc4 open files. This is
* used by dispatch layers that wish to use the libsrc4 metadata
* model, but don't know about struct NC.
* @internal Get info about a file on the list of libsrc4 open
* files. This is used by dispatch layers that wish to use the libsrc4
* metadata model, but don't know about struct NC.
*
* @param ncid The ncid of the file (aka ext_ncid).
* @param path A pointer that gets file name (< NC_MAX_NAME). Igored
Expand Down Expand Up @@ -212,7 +237,7 @@ nc4_nc4f_list_add(NC *nc, const char *path, int mode)

/* There's always at least one open group - the root
* group. Allocate space for one group's worth of information. Set
* its hdf id, name, and a pointer to it's file structure. */
* its grp id, name, and allocate associated empty lists. */
if ((retval = nc4_grp_list_add(h5, NULL, NC_GROUP_NAME, &h5->root_grp)))
return retval;

Expand Down
2 changes: 0 additions & 2 deletions nc_test4/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,3 @@ IF(TEST_PARALLEL4)
build_bin_test(tst_simplerw_coll_r)
add_sh_test(nc_test4 run_par_test)
ENDIF()

ADD_EXTRA_DIST(findplugin.in run_par_test.sh.in)
21 changes: 21 additions & 0 deletions unit_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014,
# 2015, 2016, 2017, 2018, 2019
# University Corporation for Atmospheric Research/Unidata.

# See netcdf-c/COPYRIGHT file for more info.

# This is the cmake build file for unit_test/ directory.
# @author Ward Fisher

# Some unit testing

SET(UNIT_TESTS tst_nclist)

IF(ENABLE_NETCDF_4)
SET(UNIT_TESTS ${UNIT_TESTS} tst_nc4internal)
ENDIF(ENABLE_NETCDF_4)

FOREACH(CTEST ${UNIT_TESTS})
add_bin_test(unit_test ${CTEST})
ENDFOREACH()
10 changes: 8 additions & 2 deletions unit_test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ include $(top_srcdir)/lib_flags.am
# Find and link to the netcdf-c library.
LDADD = ${top_builddir}/liblib/libnetcdf.la

check_PROGRAMS = tst_nclist
TESTS = tst_nclist
if USE_NETCDF4
NC4_TESTS = tst_nc4internal
endif # USE_NETCDF4

check_PROGRAMS = tst_nclist $(NC4_TESTS)
TESTS = tst_nclist $(NC4_TESTS)

EXTRA_DIST = CMakeLists.txt

# If valgrind is present, add valgrind targets.
@VALGRIND_CHECK_RULES@
Loading

0 comments on commit 525eaeb

Please sign in to comment.