starting to add unit tests

This commit is contained in:
edwardhartnett 2019-08-09 09:31:24 -06:00
parent d558873c93
commit 298136a73a
4 changed files with 59 additions and 2 deletions

View File

@ -21,6 +21,11 @@ test-driver-verbose test_common.in
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = netcdf.pc
# Does the user want to build and run unit tests?
if BUILD_UNIT_TESTS
UNIT_TEST = unit_test
endif # BUILD_UNIT_TESTS
# Does the user want to build the V2 API?
if BUILD_V2
V2_TEST = nctest
@ -85,8 +90,8 @@ endif # BUILD_BENCHMARKS
# Define Test directories
if BUILD_TESTSETS
TESTDIRS = $(V2_TEST) nc_test $(NC_TEST4) $(BENCHMARKS_DIR) \
$(HDF4_TEST_DIR) $(NCDAP2TESTDIR) $(NCDAP4TESTDIR)
TESTDIRS = $(UNIT_TEST) $(V2_TEST) nc_test $(NC_TEST4) \
$(BENCHMARKS_DIR) $(HDF4_TEST_DIR) $(NCDAP2TESTDIR) $(NCDAP4TESTDIR)
endif
# This is the list of subdirs for which Makefiles will be constructed

View File

@ -184,6 +184,14 @@ if test "x$enable_jna" = xyes ; then
AC_DEFINE([JNA], [1], [if true, include jna bug workaround code])
fi
# Does the user want to turn off unit tests (useful for test coverage
# analysis).
AC_ARG_ENABLE([unit-tests],
[AS_HELP_STRING([--disable-unit-tests],
[Disable unit tests.])])
test "x$enable_unit_tests" = xno || enable_unit_tests=yes
AM_CONDITIONAL([BUILD_UNIT_TESTS], [test "x$enable_unit_tests" = xyes])
# Does the user want to build netcdf-4?
AC_MSG_CHECKING([whether we should build netCDF-4])
AC_ARG_ENABLE([netcdf-4], [AS_HELP_STRING([--disable-netcdf-4],
@ -1536,6 +1544,7 @@ AC_CONFIG_FILES([Makefile
ncdump/expected/Makefile
docs/Makefile
docs/images/Makefile
unit_test/Makefile
nctest/Makefile
nc_test4/Makefile
nc_perf/Makefile

17
unit_test/Makefile.am Normal file
View File

@ -0,0 +1,17 @@
## This is a automake file, part of Unidata's netCDF package.
# Copyright 2019, see the COPYRIGHT file for more information.
# This file builds and runs the unit tests.
# Ed Hartnett 8/9/19
# Put together AM_CPPFLAGS and AM_LDFLAGS.
include $(top_srcdir)/lib_flags.am
AM_LDFLAGS += ${top_builddir}/liblib/libnetcdf.la
#check_PROGRAMS = $(TESTPROGRAMS)
#TESTS = $(TESTPROGRAMS) compare_test_files.sh
# If valgrind is present, add valgrind targets.
@VALGRIND_CHECK_RULES@

26
unit_test/tst_nclist.c Normal file
View File

@ -0,0 +1,26 @@
/* This is part of the netCDF package. Copyright 2005-2019 University
Corporation for Atmospheric Research/Unidata. See COPYRIGHT file
for conditions of use.
Test list functions in nclistmgr.c.
Ed Hartnett, 8/10/19
*/
#include "config.h"
#include <nc_tests.h>
#include "err_macros.h"
int
main(int argc, char **argv)
{
printf("\n*** Testing netcdf internal NC list functions.\n");
{
printf("Testing NC list functions...");
{
}
SUMMARIZE_ERR;
}
FINAL_RESULTS;
}