new upstream 2.8.0

This commit is contained in:
lagertonne 2022-06-29 12:37:36 +02:00
parent fc7f4b43c1
commit b2b0c9995a
836 changed files with 137090 additions and 30018 deletions

View file

@ -1,21 +1,117 @@
# Network UPS Tools: tests
if HAVE_CPPUNIT
SUBDIRS = . NIT
TESTS = cppunittest
all: $(TESTS)
EXTRA_DIST = nut-driver-enumerator-test.sh nut-driver-enumerator-test--ups.conf
TESTS = nutlogtest
CLEANFILES = *.trs *.log
AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/drivers
AM_CXXFLAGS = -I$(top_srcdir)/include
check_PROGRAMS = $(TESTS)
cppunittest_CXXFLAGS = $(CPPUNIT_CFLAGS)
cppunittest_LDFLAGS = $(CPPUNIT_LIBS)
# NUT Integration Testing suite
check-NIT check-NIT-devel:
cd "$(builddir)/NIT" && $(MAKE) $@
nutlogtest_SOURCES = nutlogtest.c
nutlogtest_LDADD = $(top_builddir)/common/libcommon.la
# Separate the .deps of other dirs from this one
LINKED_SOURCE_FILES = hidparser.c
# NOTE: Not using "$<" due to a legacy Sun/illumos dmake bug with resolver
# of dynamic vars, see e.g. https://man.omnios.org/man1/make#BUGS
hidparser.c: $(top_srcdir)/drivers/hidparser.c
test -s "$@" || ln -s -f "$(top_srcdir)/drivers/hidparser.c" "$@"
if WITH_USB
TESTS += getvaluetest
getvaluetest_SOURCES = getvaluetest.c
nodist_getvaluetest_SOURCES = hidparser.c
# Pull the right include path for chosen libusb version:
getvaluetest_CFLAGS = $(AM_CFLAGS) $(LIBUSB_CFLAGS)
getvaluetest_LDADD = $(top_builddir)/common/libcommon.la
endif
# Make sure out-of-dir dependencies exist (especially when dev-building parts):
$(top_builddir)/common/libcommon.la: dummy
@cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F)
### Optional tests which can not be built everywhere
# List of src files for CppUnit tests
CPPUNITTESTSRC = example.cpp
CPPUNITTESTSRC = example.cpp nutclienttest.cpp
# The test driver which orchestrates running those tests above
CPPUNITTESTERSRC = cpputest.cpp
cppunittest_SOURCES = $(CPPUNITTESTSRC) cpputest.cpp
CPPCLIENTTESTSRC = cpputest-client.cpp
TESTS_CXX11 = cppunittest
if HAVE_CXX11
if HAVE_CPPUNIT
# Note: per configure script this "SHOULD" also assume
# that we HAVE_CXX11 - but better have it explicit
TESTS += $(TESTS_CXX11)
# Note: we only build it, but do not run directly (NIT prepares the sandbox)
check_PROGRAMS += cppnit
if WITH_VALGRIND
check-local: $(check_PROGRAMS)
RES=0; for P in $^ ; do $(VALGRIND) ./$$P || { RES=$$? ; echo "FAILED: $(VALGRIND) ./$$P" >&2; }; done; exit $$RES
endif
cppunittest_CXXFLAGS = $(AM_CXXFLAGS) $(CPPUNIT_CFLAGS) $(CPPUNIT_CXXFLAGS) $(CPPUNIT_NUT_CXXFLAGS) $(CXXFLAGS)
cppunittest_LDFLAGS = $(CPPUNIT_LDFLAGS) $(CPPUNIT_LIBS)
cppunittest_LDADD = $(top_builddir)/clients/libnutclient.la $(top_builddir)/clients/libnutclientstub.la
cppunittest_SOURCES = $(CPPUNITTESTSRC) $(CPPUNITTESTERSRC)
cppnit_CXXFLAGS = $(AM_CXXFLAGS) $(CPPUNIT_CFLAGS) $(CPPUNIT_CXXFLAGS) $(CPPUNIT_NUT_CXXFLAGS) $(CXXFLAGS)
cppnit_LDFLAGS = $(CPPUNIT_LDFLAGS) $(CPPUNIT_LIBS)
cppnit_LDADD = $(top_builddir)/clients/libnutclient.la $(top_builddir)/clients/libnutclientstub.la
cppnit_SOURCES = $(CPPCLIENTTESTSRC) $(CPPUNITTESTERSRC)
# Make sure out-of-dir C++ dependencies exist (especially when dev-building
# only some parts of NUT):
$(top_builddir)/clients/libnutclient.la \
$(top_builddir)/clients/libnutclientstub.la: dummy
@cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F)
else !HAVE_CPPUNIT
# Just redistribute test source into tarball if not building tests
EXTRA_DIST = example.cpp cpputest.cpp
EXTRA_DIST += $(CPPUNITTESTSRC) $(CPPCLIENTTESTSRC) $(CPPUNITTESTERSRC)
cppnit:
@echo "SKIP: $@ not implemented without C++11 and CPPUNIT enabled" >&2 ; exit 1
endif !HAVE_CPPUNIT
else !HAVE_CXX11
# Just redistribute test source into tarball if not building C++ at all
EXTRA_DIST += $(CPPUNITTESTSRC) $(CPPCLIENTTESTSRC) $(CPPUNITTESTERSRC)
cppnit:
@echo "SKIP: $@ not implemented without C++11 and CPPUNIT enabled" >&2 ; exit 1
endif !HAVE_CXX11
dummy:
BUILT_SOURCES = $(LINKED_SOURCE_FILES)
CLEANFILES += $(LINKED_SOURCE_FILES)
CLEANFILES += $(TESTS) $(TESTS_CXX11)
MAINTAINERCLEANFILES = Makefile.in .dirstamp
# NOTE: Do not clean ".deps" in SUBDIRS of the main project,
# the root Makefile.am takes care of that!
#clean-local:
# rm -rf $(builddir)/.deps

View file

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.14.1 from Makefile.am.
# Makefile.in generated by automake 1.16.3 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -16,7 +16,17 @@
# Network UPS Tools: tests
VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
@ -80,22 +90,41 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
@HAVE_CPPUNIT_TRUE@TESTS = cppunittest$(EXEEXT)
@HAVE_CPPUNIT_TRUE@check_PROGRAMS = $(am__EXEEXT_1)
TESTS = nutlogtest$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_3)
check_PROGRAMS = $(am__EXEEXT_4) $(am__EXEEXT_5)
@WITH_USB_TRUE@am__append_1 = getvaluetest
# Note: per configure script this "SHOULD" also assume
# that we HAVE_CXX11 - but better have it explicit
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@am__append_2 = $(TESTS_CXX11)
# Note: we only build it, but do not run directly (NIT prepares the sandbox)
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@am__append_3 = cppnit
# Just redistribute test source into tarball if not building tests
@HAVE_CPPUNIT_FALSE@@HAVE_CXX11_TRUE@am__append_4 = $(CPPUNITTESTSRC) $(CPPCLIENTTESTSRC) $(CPPUNITTESTERSRC)
# Just redistribute test source into tarball if not building C++ at all
@HAVE_CXX11_FALSE@am__append_5 = $(CPPUNITTESTSRC) $(CPPCLIENTTESTSRC) $(CPPUNITTESTERSRC)
subdir = tests
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/depcomp $(top_srcdir)/test-driver
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \
$(top_srcdir)/m4/ax_c_pragmas.m4 \
$(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/m4/ax_compare_version.m4 \
$(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/nut_arg_with.m4 \
$(top_srcdir)/m4/nut_check_asciidoc.m4 \
$(top_srcdir)/m4/nut_check_cppcheck.m4 \
$(top_srcdir)/m4/nut_check_headers_windows.m4 \
$(top_srcdir)/m4/nut_check_libavahi.m4 \
$(top_srcdir)/m4/nut_check_libfreeipmi.m4 \
$(top_srcdir)/m4/nut_check_libgd.m4 \
$(top_srcdir)/m4/nut_check_libltdl.m4 \
$(top_srcdir)/m4/nut_check_libmodbus.m4 \
$(top_srcdir)/m4/nut_check_libneon.m4 \
$(top_srcdir)/m4/nut_check_libnetsnmp.m4 \
$(top_srcdir)/m4/nut_check_libnss.m4 \
@ -104,29 +133,71 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_compare_version.m4 \
$(top_srcdir)/m4/nut_check_libusb.m4 \
$(top_srcdir)/m4/nut_check_libwrap.m4 \
$(top_srcdir)/m4/nut_check_os.m4 \
$(top_srcdir)/m4/nut_check_pkgconfig.m4 \
$(top_srcdir)/m4/nut_check_python.m4 \
$(top_srcdir)/m4/nut_compiler_family.m4 \
$(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \
$(top_srcdir)/m4/nut_report_feature.m4 \
$(top_srcdir)/m4/nut_stash_warnings.m4 \
$(top_srcdir)/m4/nut_type_socklen_t.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/include/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
@HAVE_CPPUNIT_TRUE@am__EXEEXT_1 = cppunittest$(EXEEXT)
am__cppunittest_SOURCES_DIST = example.cpp cpputest.cpp
@HAVE_CPPUNIT_TRUE@am__objects_1 = cppunittest-example.$(OBJEXT)
@HAVE_CPPUNIT_TRUE@am_cppunittest_OBJECTS = $(am__objects_1) \
@HAVE_CPPUNIT_TRUE@ cppunittest-cpputest.$(OBJEXT)
cppunittest_OBJECTS = $(am_cppunittest_OBJECTS)
cppunittest_LDADD = $(LDADD)
@WITH_USB_TRUE@am__EXEEXT_1 = getvaluetest$(EXEEXT)
am__EXEEXT_2 = cppunittest$(EXEEXT)
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@am__EXEEXT_3 = $(am__EXEEXT_2)
am__EXEEXT_4 = nutlogtest$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_3)
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@am__EXEEXT_5 = cppnit$(EXEEXT)
am__cppnit_SOURCES_DIST = cpputest-client.cpp cpputest.cpp
am__objects_1 = cppnit-cpputest-client.$(OBJEXT)
am__objects_2 = cppnit-cpputest.$(OBJEXT)
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@am_cppnit_OBJECTS = \
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@ $(am__objects_1) \
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@ $(am__objects_2)
cppnit_OBJECTS = $(am_cppnit_OBJECTS)
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppnit_DEPENDENCIES = $(top_builddir)/clients/libnutclient.la \
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@ $(top_builddir)/clients/libnutclientstub.la
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
cppnit_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(cppnit_CXXFLAGS) \
$(CXXFLAGS) $(cppnit_LDFLAGS) $(LDFLAGS) -o $@
am__cppunittest_SOURCES_DIST = example.cpp nutclienttest.cpp \
cpputest.cpp
am__objects_3 = cppunittest-example.$(OBJEXT) \
cppunittest-nutclienttest.$(OBJEXT)
am__objects_4 = cppunittest-cpputest.$(OBJEXT)
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@am_cppunittest_OBJECTS = \
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@ $(am__objects_3) \
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@ $(am__objects_4)
cppunittest_OBJECTS = $(am_cppunittest_OBJECTS)
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppunittest_DEPENDENCIES = $(top_builddir)/clients/libnutclient.la \
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@ $(top_builddir)/clients/libnutclientstub.la
cppunittest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(cppunittest_CXXFLAGS) \
$(CXXFLAGS) $(cppunittest_LDFLAGS) $(LDFLAGS) -o $@
am__getvaluetest_SOURCES_DIST = getvaluetest.c
@WITH_USB_TRUE@am_getvaluetest_OBJECTS = \
@WITH_USB_TRUE@ getvaluetest-getvaluetest.$(OBJEXT)
@WITH_USB_TRUE@nodist_getvaluetest_OBJECTS = \
@WITH_USB_TRUE@ getvaluetest-hidparser.$(OBJEXT)
getvaluetest_OBJECTS = $(am_getvaluetest_OBJECTS) \
$(nodist_getvaluetest_OBJECTS)
@WITH_USB_TRUE@getvaluetest_DEPENDENCIES = \
@WITH_USB_TRUE@ $(top_builddir)/common/libcommon.la
getvaluetest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(getvaluetest_CFLAGS) \
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
am_nutlogtest_OBJECTS = nutlogtest.$(OBJEXT)
nutlogtest_OBJECTS = $(am_nutlogtest_OBJECTS)
nutlogtest_DEPENDENCIES = $(top_builddir)/common/libcommon.la
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
@ -141,8 +212,34 @@ am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__maybe_remake_depfiles = depfiles
am__depfiles_remade = ./$(DEPDIR)/cppnit-cpputest-client.Po \
./$(DEPDIR)/cppnit-cpputest.Po \
./$(DEPDIR)/cppunittest-cpputest.Po \
./$(DEPDIR)/cppunittest-example.Po \
./$(DEPDIR)/cppunittest-nutclienttest.Po \
./$(DEPDIR)/getvaluetest-getvaluetest.Po \
./$(DEPDIR)/getvaluetest-hidparser.Po \
./$(DEPDIR)/nutlogtest.Po
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
am__v_CC_0 = @echo " CC " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
@ -161,13 +258,33 @@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
am__v_CXXLD_0 = @echo " CXXLD " $@;
am__v_CXXLD_1 =
SOURCES = $(cppunittest_SOURCES)
DIST_SOURCES = $(am__cppunittest_SOURCES_DIST)
SOURCES = $(cppnit_SOURCES) $(cppunittest_SOURCES) \
$(getvaluetest_SOURCES) $(nodist_getvaluetest_SOURCES) \
$(nutlogtest_SOURCES)
DIST_SOURCES = $(am__cppnit_SOURCES_DIST) \
$(am__cppunittest_SOURCES_DIST) \
$(am__getvaluetest_SOURCES_DIST) $(nutlogtest_SOURCES)
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-recursive dvi-recursive html-recursive info-recursive \
install-data-recursive install-dvi-recursive \
install-exec-recursive install-html-recursive \
install-info-recursive install-pdf-recursive \
install-ps-recursive install-recursive installcheck-recursive \
installdirs-recursive pdf-recursive ps-recursive \
tags-recursive uninstall-recursive
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
am__recursive_targets = \
$(RECURSIVE_TARGETS) \
$(RECURSIVE_CLEAN_TARGETS) \
$(am__extra_recursive_targets)
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
check recheck distdir distdir-am
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
@ -369,8 +486,8 @@ am__set_TESTS_bases = \
bases='$(TEST_LOGS)'; \
bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
bases=`echo $$bases`
AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)'
RECHECK_LOGS = $(TEST_LOGS)
AM_RECURSIVE_TARGETS = check recheck
TEST_SUITE_LOG = test-suite.log
TEST_EXTENSIONS = @EXEEXT@ .test
LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver
@ -391,7 +508,35 @@ TEST_LOGS = $(am__test_logs2:.test.log=.log)
TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver
TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
$(TEST_LOG_FLAGS)
DIST_SUBDIRS = $(SUBDIRS)
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \
$(top_srcdir)/test-driver
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
am__relativize = \
dir0=`pwd`; \
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
sed_rest='s,^[^/]*/*,,'; \
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
sed_butlast='s,/*[^/]*$$,,'; \
while test -n "$$dir1"; do \
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
if test "$$first" != "."; then \
if test "$$first" = ".."; then \
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
else \
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
if test "$$first2" = "$$first"; then \
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
else \
dir2="../$$dir2"; \
fi; \
dir0="$$dir0"/"$$first"; \
fi; \
fi; \
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
done; \
reldir="$$dir2"
A2X = @A2X@
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
@ -399,6 +544,7 @@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
ASCIIDOC = @ASCIIDOC@
ASPELL = @ASPELL@
AUGPARSE = @AUGPARSE@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
@ -409,6 +555,7 @@ CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CONFPATH = @CONFPATH@
CPP = @CPP@
CPPCHECK = @CPPCHECK@
CPPFLAGS = @CPPFLAGS@
CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@
CPPUNIT_LIBS = @CPPUNIT_LIBS@
@ -422,6 +569,7 @@ DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DOC_BUILD_LIST = @DOC_BUILD_LIST@
DOC_CHECK_LIST = @DOC_CHECK_LIST@
DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@
DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@
DRIVER_MAN_LIST = @DRIVER_MAN_LIST@
@ -434,6 +582,7 @@ ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GDLIB_CONFIG = @GDLIB_CONFIG@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
@ -451,6 +600,8 @@ LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@
LIBIPMI_LIBS = @LIBIPMI_LIBS@
LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@
LIBLTDL_LIBS = @LIBLTDL_LIBS@
LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@
LIBMODBUS_LIBS = @LIBMODBUS_LIBS@
LIBNEON_CFLAGS = @LIBNEON_CFLAGS@
LIBNEON_LIBS = @LIBNEON_LIBS@
LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@
@ -461,21 +612,29 @@ LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@
LIBS = @LIBS@
LIBSSL_CFLAGS = @LIBSSL_CFLAGS@
LIBSSL_LIBS = @LIBSSL_LIBS@
LIBSSL_REQUIRES = @LIBSSL_REQUIRES@
LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIBUSB_CFLAGS = @LIBUSB_CFLAGS@
LIBUSB_CONFIG = @LIBUSB_CONFIG@
LIBUSB_LIBS = @LIBUSB_LIBS@
LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@
LIBWRAP_LIBS = @LIBWRAP_LIBS@
LIPO = @LIPO@
LN_S = @LN_S@
LN_S_R = @LN_S_R@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NETLIBS = @NETLIBS@
NET_SNMP_CONFIG = @NET_SNMP_CONFIG@
NM = @NM@
NMEDIT = @NMEDIT@
NUT_DATADIR = @NUT_DATADIR@
NUT_LIBEXECDIR = @NUT_LIBEXECDIR@
NUT_NETVERSION = @NUT_NETVERSION@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
@ -495,6 +654,9 @@ PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PORT = @PORT@
PYTHON = @PYTHON@
PYTHON2 = @PYTHON2@
PYTHON3 = @PYTHON3@
RANLIB = @RANLIB@
RUN_AS_GROUP = @RUN_AS_GROUP@
RUN_AS_USER = @RUN_AS_USER@
@ -508,6 +670,7 @@ STATEPATH = @STATEPATH@
STRIP = @STRIP@
SUN_LIBUSB = @SUN_LIBUSB@
TREE_VERSION = @TREE_VERSION@
VALGRIND = @VALGRIND@
VERSION = @VERSION@
WORDS_BIGENDIAN = @WORDS_BIGENDIAN@
XMLLINT = @XMLLINT@
@ -525,6 +688,7 @@ am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
auglensdir = @auglensdir@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
@ -538,6 +702,9 @@ datarootdir = @datarootdir@
devddir = @devddir@
docdir = @docdir@
driverexecdir = @driverexecdir@
dummy_PKG_CONFIG = @dummy_PKG_CONFIG@
dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@
dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
@ -563,12 +730,14 @@ pkgconfigdir = @pkgconfigdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
systemdsystemshutdowndir = @systemdsystemshutdowndir@
systemdshutdowndir = @systemdshutdowndir@
systemdsystemunitdir = @systemdsystemunitdir@
systemdtmpfilesdir = @systemdtmpfilesdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
@ -578,17 +747,47 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
udevdir = @udevdir@
@HAVE_CPPUNIT_TRUE@cppunittest_CXXFLAGS = $(CPPUNIT_CFLAGS)
@HAVE_CPPUNIT_TRUE@cppunittest_LDFLAGS = $(CPPUNIT_LIBS)
SUBDIRS = . NIT
EXTRA_DIST = nut-driver-enumerator-test.sh \
nut-driver-enumerator-test--ups.conf $(am__append_4) \
$(am__append_5)
CLEANFILES = *.trs *.log $(LINKED_SOURCE_FILES) $(TESTS) \
$(TESTS_CXX11)
AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/drivers
AM_CXXFLAGS = -I$(top_srcdir)/include
nutlogtest_SOURCES = nutlogtest.c
nutlogtest_LDADD = $(top_builddir)/common/libcommon.la
# Separate the .deps of other dirs from this one
LINKED_SOURCE_FILES = hidparser.c
@WITH_USB_TRUE@getvaluetest_SOURCES = getvaluetest.c
@WITH_USB_TRUE@nodist_getvaluetest_SOURCES = hidparser.c
# Pull the right include path for chosen libusb version:
@WITH_USB_TRUE@getvaluetest_CFLAGS = $(AM_CFLAGS) $(LIBUSB_CFLAGS)
@WITH_USB_TRUE@getvaluetest_LDADD = $(top_builddir)/common/libcommon.la
### Optional tests which can not be built everywhere
# List of src files for CppUnit tests
@HAVE_CPPUNIT_TRUE@CPPUNITTESTSRC = example.cpp
@HAVE_CPPUNIT_TRUE@cppunittest_SOURCES = $(CPPUNITTESTSRC) cpputest.cpp
@HAVE_CPPUNIT_FALSE@EXTRA_DIST = example.cpp cpputest.cpp
all: all-am
CPPUNITTESTSRC = example.cpp nutclienttest.cpp
# The test driver which orchestrates running those tests above
CPPUNITTESTERSRC = cpputest.cpp
CPPCLIENTTESTSRC = cpputest-client.cpp
TESTS_CXX11 = cppunittest
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppunittest_CXXFLAGS = $(AM_CXXFLAGS) $(CPPUNIT_CFLAGS) $(CPPUNIT_CXXFLAGS) $(CPPUNIT_NUT_CXXFLAGS) $(CXXFLAGS)
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppunittest_LDFLAGS = $(CPPUNIT_LDFLAGS) $(CPPUNIT_LIBS)
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppunittest_LDADD = $(top_builddir)/clients/libnutclient.la $(top_builddir)/clients/libnutclientstub.la
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppunittest_SOURCES = $(CPPUNITTESTSRC) $(CPPUNITTESTERSRC)
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppnit_CXXFLAGS = $(AM_CXXFLAGS) $(CPPUNIT_CFLAGS) $(CPPUNIT_CXXFLAGS) $(CPPUNIT_NUT_CXXFLAGS) $(CXXFLAGS)
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppnit_LDFLAGS = $(CPPUNIT_LDFLAGS) $(CPPUNIT_LIBS)
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppnit_LDADD = $(top_builddir)/clients/libnutclient.la $(top_builddir)/clients/libnutclientstub.la
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppnit_SOURCES = $(CPPCLIENTTESTSRC) $(CPPUNITTESTERSRC)
BUILT_SOURCES = $(LINKED_SOURCE_FILES)
MAINTAINERCLEANFILES = Makefile.in .dirstamp
all: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) all-recursive
.SUFFIXES:
.SUFFIXES: .cpp .lo .log .o .obj .test .test$(EXEEXT) .trs
.SUFFIXES: .c .cpp .lo .log .o .obj .test .test$(EXEEXT) .trs
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
@ -601,14 +800,13 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu tests/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@ -629,18 +827,94 @@ clean-checkPROGRAMS:
echo " rm -f" $$list; \
rm -f $$list
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@cppnit$(EXEEXT): $(cppnit_OBJECTS) $(cppnit_DEPENDENCIES) $(EXTRA_cppnit_DEPENDENCIES)
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@ @rm -f cppnit$(EXEEXT)
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@ $(AM_V_CXXLD)$(cppnit_LINK) $(cppnit_OBJECTS) $(cppnit_LDADD) $(LIBS)
cppunittest$(EXEEXT): $(cppunittest_OBJECTS) $(cppunittest_DEPENDENCIES) $(EXTRA_cppunittest_DEPENDENCIES)
@rm -f cppunittest$(EXEEXT)
$(AM_V_CXXLD)$(cppunittest_LINK) $(cppunittest_OBJECTS) $(cppunittest_LDADD) $(LIBS)
getvaluetest$(EXEEXT): $(getvaluetest_OBJECTS) $(getvaluetest_DEPENDENCIES) $(EXTRA_getvaluetest_DEPENDENCIES)
@rm -f getvaluetest$(EXEEXT)
$(AM_V_CCLD)$(getvaluetest_LINK) $(getvaluetest_OBJECTS) $(getvaluetest_LDADD) $(LIBS)
nutlogtest$(EXEEXT): $(nutlogtest_OBJECTS) $(nutlogtest_DEPENDENCIES) $(EXTRA_nutlogtest_DEPENDENCIES)
@rm -f nutlogtest$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(nutlogtest_OBJECTS) $(nutlogtest_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cppunittest-cpputest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cppunittest-example.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cppnit-cpputest-client.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cppnit-cpputest.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cppunittest-cpputest.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cppunittest-example.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cppunittest-nutclienttest.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getvaluetest-getvaluetest.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getvaluetest-hidparser.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nutlogtest.Po@am__quote@ # am--include-marker
$(am__depfiles_remade):
@$(MKDIR_P) $(@D)
@echo '# dummy' >$@-t && $(am__mv) $@-t $@
am--depfiles: $(am__depfiles_remade)
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
getvaluetest-getvaluetest.o: getvaluetest.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(getvaluetest_CFLAGS) $(CFLAGS) -MT getvaluetest-getvaluetest.o -MD -MP -MF $(DEPDIR)/getvaluetest-getvaluetest.Tpo -c -o getvaluetest-getvaluetest.o `test -f 'getvaluetest.c' || echo '$(srcdir)/'`getvaluetest.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/getvaluetest-getvaluetest.Tpo $(DEPDIR)/getvaluetest-getvaluetest.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='getvaluetest.c' object='getvaluetest-getvaluetest.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(getvaluetest_CFLAGS) $(CFLAGS) -c -o getvaluetest-getvaluetest.o `test -f 'getvaluetest.c' || echo '$(srcdir)/'`getvaluetest.c
getvaluetest-getvaluetest.obj: getvaluetest.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(getvaluetest_CFLAGS) $(CFLAGS) -MT getvaluetest-getvaluetest.obj -MD -MP -MF $(DEPDIR)/getvaluetest-getvaluetest.Tpo -c -o getvaluetest-getvaluetest.obj `if test -f 'getvaluetest.c'; then $(CYGPATH_W) 'getvaluetest.c'; else $(CYGPATH_W) '$(srcdir)/getvaluetest.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/getvaluetest-getvaluetest.Tpo $(DEPDIR)/getvaluetest-getvaluetest.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='getvaluetest.c' object='getvaluetest-getvaluetest.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(getvaluetest_CFLAGS) $(CFLAGS) -c -o getvaluetest-getvaluetest.obj `if test -f 'getvaluetest.c'; then $(CYGPATH_W) 'getvaluetest.c'; else $(CYGPATH_W) '$(srcdir)/getvaluetest.c'; fi`
getvaluetest-hidparser.o: hidparser.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(getvaluetest_CFLAGS) $(CFLAGS) -MT getvaluetest-hidparser.o -MD -MP -MF $(DEPDIR)/getvaluetest-hidparser.Tpo -c -o getvaluetest-hidparser.o `test -f 'hidparser.c' || echo '$(srcdir)/'`hidparser.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/getvaluetest-hidparser.Tpo $(DEPDIR)/getvaluetest-hidparser.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hidparser.c' object='getvaluetest-hidparser.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(getvaluetest_CFLAGS) $(CFLAGS) -c -o getvaluetest-hidparser.o `test -f 'hidparser.c' || echo '$(srcdir)/'`hidparser.c
getvaluetest-hidparser.obj: hidparser.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(getvaluetest_CFLAGS) $(CFLAGS) -MT getvaluetest-hidparser.obj -MD -MP -MF $(DEPDIR)/getvaluetest-hidparser.Tpo -c -o getvaluetest-hidparser.obj `if test -f 'hidparser.c'; then $(CYGPATH_W) 'hidparser.c'; else $(CYGPATH_W) '$(srcdir)/hidparser.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/getvaluetest-hidparser.Tpo $(DEPDIR)/getvaluetest-hidparser.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='hidparser.c' object='getvaluetest-hidparser.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(getvaluetest_CFLAGS) $(CFLAGS) -c -o getvaluetest-hidparser.obj `if test -f 'hidparser.c'; then $(CYGPATH_W) 'hidparser.c'; else $(CYGPATH_W) '$(srcdir)/hidparser.c'; fi`
.cpp.o:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@ -666,6 +940,34 @@ distclean-compile:
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
cppnit-cpputest-client.o: cpputest-client.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppnit_CXXFLAGS) $(CXXFLAGS) -MT cppnit-cpputest-client.o -MD -MP -MF $(DEPDIR)/cppnit-cpputest-client.Tpo -c -o cppnit-cpputest-client.o `test -f 'cpputest-client.cpp' || echo '$(srcdir)/'`cpputest-client.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cppnit-cpputest-client.Tpo $(DEPDIR)/cppnit-cpputest-client.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='cpputest-client.cpp' object='cppnit-cpputest-client.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppnit_CXXFLAGS) $(CXXFLAGS) -c -o cppnit-cpputest-client.o `test -f 'cpputest-client.cpp' || echo '$(srcdir)/'`cpputest-client.cpp
cppnit-cpputest-client.obj: cpputest-client.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppnit_CXXFLAGS) $(CXXFLAGS) -MT cppnit-cpputest-client.obj -MD -MP -MF $(DEPDIR)/cppnit-cpputest-client.Tpo -c -o cppnit-cpputest-client.obj `if test -f 'cpputest-client.cpp'; then $(CYGPATH_W) 'cpputest-client.cpp'; else $(CYGPATH_W) '$(srcdir)/cpputest-client.cpp'; fi`
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cppnit-cpputest-client.Tpo $(DEPDIR)/cppnit-cpputest-client.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='cpputest-client.cpp' object='cppnit-cpputest-client.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppnit_CXXFLAGS) $(CXXFLAGS) -c -o cppnit-cpputest-client.obj `if test -f 'cpputest-client.cpp'; then $(CYGPATH_W) 'cpputest-client.cpp'; else $(CYGPATH_W) '$(srcdir)/cpputest-client.cpp'; fi`
cppnit-cpputest.o: cpputest.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppnit_CXXFLAGS) $(CXXFLAGS) -MT cppnit-cpputest.o -MD -MP -MF $(DEPDIR)/cppnit-cpputest.Tpo -c -o cppnit-cpputest.o `test -f 'cpputest.cpp' || echo '$(srcdir)/'`cpputest.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cppnit-cpputest.Tpo $(DEPDIR)/cppnit-cpputest.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='cpputest.cpp' object='cppnit-cpputest.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppnit_CXXFLAGS) $(CXXFLAGS) -c -o cppnit-cpputest.o `test -f 'cpputest.cpp' || echo '$(srcdir)/'`cpputest.cpp
cppnit-cpputest.obj: cpputest.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppnit_CXXFLAGS) $(CXXFLAGS) -MT cppnit-cpputest.obj -MD -MP -MF $(DEPDIR)/cppnit-cpputest.Tpo -c -o cppnit-cpputest.obj `if test -f 'cpputest.cpp'; then $(CYGPATH_W) 'cpputest.cpp'; else $(CYGPATH_W) '$(srcdir)/cpputest.cpp'; fi`
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cppnit-cpputest.Tpo $(DEPDIR)/cppnit-cpputest.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='cpputest.cpp' object='cppnit-cpputest.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppnit_CXXFLAGS) $(CXXFLAGS) -c -o cppnit-cpputest.obj `if test -f 'cpputest.cpp'; then $(CYGPATH_W) 'cpputest.cpp'; else $(CYGPATH_W) '$(srcdir)/cpputest.cpp'; fi`
cppunittest-example.o: example.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppunittest_CXXFLAGS) $(CXXFLAGS) -MT cppunittest-example.o -MD -MP -MF $(DEPDIR)/cppunittest-example.Tpo -c -o cppunittest-example.o `test -f 'example.cpp' || echo '$(srcdir)/'`example.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cppunittest-example.Tpo $(DEPDIR)/cppunittest-example.Po
@ -680,6 +982,20 @@ cppunittest-example.obj: example.cpp
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppunittest_CXXFLAGS) $(CXXFLAGS) -c -o cppunittest-example.obj `if test -f 'example.cpp'; then $(CYGPATH_W) 'example.cpp'; else $(CYGPATH_W) '$(srcdir)/example.cpp'; fi`
cppunittest-nutclienttest.o: nutclienttest.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppunittest_CXXFLAGS) $(CXXFLAGS) -MT cppunittest-nutclienttest.o -MD -MP -MF $(DEPDIR)/cppunittest-nutclienttest.Tpo -c -o cppunittest-nutclienttest.o `test -f 'nutclienttest.cpp' || echo '$(srcdir)/'`nutclienttest.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cppunittest-nutclienttest.Tpo $(DEPDIR)/cppunittest-nutclienttest.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='nutclienttest.cpp' object='cppunittest-nutclienttest.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppunittest_CXXFLAGS) $(CXXFLAGS) -c -o cppunittest-nutclienttest.o `test -f 'nutclienttest.cpp' || echo '$(srcdir)/'`nutclienttest.cpp
cppunittest-nutclienttest.obj: nutclienttest.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppunittest_CXXFLAGS) $(CXXFLAGS) -MT cppunittest-nutclienttest.obj -MD -MP -MF $(DEPDIR)/cppunittest-nutclienttest.Tpo -c -o cppunittest-nutclienttest.obj `if test -f 'nutclienttest.cpp'; then $(CYGPATH_W) 'nutclienttest.cpp'; else $(CYGPATH_W) '$(srcdir)/nutclienttest.cpp'; fi`
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cppunittest-nutclienttest.Tpo $(DEPDIR)/cppunittest-nutclienttest.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='nutclienttest.cpp' object='cppunittest-nutclienttest.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppunittest_CXXFLAGS) $(CXXFLAGS) -c -o cppunittest-nutclienttest.obj `if test -f 'nutclienttest.cpp'; then $(CYGPATH_W) 'nutclienttest.cpp'; else $(CYGPATH_W) '$(srcdir)/nutclienttest.cpp'; fi`
cppunittest-cpputest.o: cpputest.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(cppunittest_CXXFLAGS) $(CXXFLAGS) -MT cppunittest-cpputest.o -MD -MP -MF $(DEPDIR)/cppunittest-cpputest.Tpo -c -o cppunittest-cpputest.o `test -f 'cpputest.cpp' || echo '$(srcdir)/'`cpputest.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/cppunittest-cpputest.Tpo $(DEPDIR)/cppunittest-cpputest.Po
@ -700,14 +1016,61 @@ mostlyclean-libtool:
clean-libtool:
-rm -rf .libs _libs
# This directory's subdirectories are mostly independent; you can cd
# into them and run 'make' without going through this Makefile.
# To change the values of 'make' variables: instead of editing Makefiles,
# (1) if the variable is set in 'config.status', edit 'config.status'
# (which will cause the Makefiles to be regenerated when you run 'make');
# (2) otherwise, pass the desired values on the 'make' command line.
$(am__recursive_targets):
@fail=; \
if $(am__make_keepgoing); then \
failcom='fail=yes'; \
else \
failcom='exit 1'; \
fi; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
tags: tags-recursive
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
@ -720,7 +1083,7 @@ tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$$unique; \
fi; \
fi
ctags: ctags-am
ctags: ctags-recursive
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
@ -733,7 +1096,7 @@ GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist: cscopelist-recursive
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
@ -782,7 +1145,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
if test -n "$$am__remaking_logs"; then \
echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
"recursion detected" >&2; \
else \
elif test -n "$$redo_logs"; then \
am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
fi; \
if $(am__make_dryrun); then :; else \
@ -859,7 +1222,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
fi; \
echo "$${col}$$br$${std}"; \
echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \
echo "$${col}Testsuite summary"$(AM_TESTSUITE_SUMMARY_HEADER)"$${std}"; \
echo "$${col}$$br$${std}"; \
create_testsuite_report --maybe-color; \
echo "$$col$$br$$std"; \
@ -872,7 +1235,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
fi; \
$$success || exit 1
check-TESTS:
check-TESTS: $(check_PROGRAMS)
@list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
@list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
@test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
@ -893,6 +1256,20 @@ recheck: all $(check_PROGRAMS)
am__force_recheck=am--force-recheck \
TEST_LOGS="$$log_list"; \
exit $$?
nutlogtest.log: nutlogtest$(EXEEXT)
@p='nutlogtest$(EXEEXT)'; \
b='nutlogtest'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
getvaluetest.log: getvaluetest$(EXEEXT)
@p='getvaluetest$(EXEEXT)'; \
b='getvaluetest'; \
$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
cppunittest.log: cppunittest$(EXEEXT)
@p='cppunittest$(EXEEXT)'; \
b='cppunittest'; \
@ -915,7 +1292,10 @@ cppunittest.log: cppunittest$(EXEEXT)
@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
distdir: $(DISTFILES)
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
@ -945,21 +1325,53 @@ distdir: $(DISTFILES)
|| exit 1; \
fi; \
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
$(am__make_dryrun) \
|| test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
$(am__relativize); \
new_distdir=$$reldir; \
dir1=$$subdir; dir2="$(top_distdir)"; \
$(am__relativize); \
new_top_distdir=$$reldir; \
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
($(am__cd) $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$new_top_distdir" \
distdir="$$new_distdir" \
am__remove_distdir=: \
am__skip_length_check=: \
am__skip_mode_fix=: \
distdir) \
|| exit 1; \
fi; \
done
@HAVE_CPPUNIT_FALSE@check-local:
@HAVE_CXX11_FALSE@check-local:
@WITH_VALGRIND_FALSE@check-local:
check-am: all-am
$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
$(MAKE) $(AM_MAKEFLAGS) check-TESTS
check: check-am
$(MAKE) $(AM_MAKEFLAGS) check-TESTS check-local
check: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) check-recursive
all-am: Makefile
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
installdirs: installdirs-recursive
installdirs-am:
install: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) install-recursive
install-exec: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
installcheck: installcheck-recursive
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
@ -976,6 +1388,7 @@ mostlyclean-generic:
-test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
@ -984,80 +1397,98 @@ distclean-generic:
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
clean: clean-recursive
clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
distclean: distclean-recursive
-rm -f ./$(DEPDIR)/cppnit-cpputest-client.Po
-rm -f ./$(DEPDIR)/cppnit-cpputest.Po
-rm -f ./$(DEPDIR)/cppunittest-cpputest.Po
-rm -f ./$(DEPDIR)/cppunittest-example.Po
-rm -f ./$(DEPDIR)/cppunittest-nutclienttest.Po
-rm -f ./$(DEPDIR)/getvaluetest-getvaluetest.Po
-rm -f ./$(DEPDIR)/getvaluetest-hidparser.Po
-rm -f ./$(DEPDIR)/nutlogtest.Po
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi: dvi-recursive
dvi-am:
html: html-am
html: html-recursive
html-am:
info: info-am
info: info-recursive
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi: install-dvi-recursive
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html: install-html-recursive
install-html-am:
install-info: install-info-am
install-info: install-info-recursive
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf: install-pdf-recursive
install-pdf-am:
install-ps: install-ps-am
install-ps: install-ps-recursive
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
maintainer-clean: maintainer-clean-recursive
-rm -f ./$(DEPDIR)/cppnit-cpputest-client.Po
-rm -f ./$(DEPDIR)/cppnit-cpputest.Po
-rm -f ./$(DEPDIR)/cppunittest-cpputest.Po
-rm -f ./$(DEPDIR)/cppunittest-example.Po
-rm -f ./$(DEPDIR)/cppunittest-nutclienttest.Po
-rm -f ./$(DEPDIR)/getvaluetest-getvaluetest.Po
-rm -f ./$(DEPDIR)/getvaluetest-hidparser.Po
-rm -f ./$(DEPDIR)/nutlogtest.Po
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf: pdf-recursive
pdf-am:
ps: ps-am
ps: ps-recursive
ps-am:
uninstall-am:
.MAKE: check-am install-am install-strip
.MAKE: $(am__recursive_targets) all check check-am install install-am \
install-exec install-strip
.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
am--depfiles check check-TESTS check-am check-local clean \
clean-checkPROGRAMS clean-generic clean-libtool cscopelist-am \
ctags ctags-am distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
@ -1066,11 +1497,50 @@ uninstall-am:
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs maintainer-clean \
installcheck-am installdirs installdirs-am maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
recheck tags tags-am uninstall uninstall-am
.PRECIOUS: Makefile
all: $(TESTS)
# NUT Integration Testing suite
check-NIT check-NIT-devel:
cd "$(builddir)/NIT" && $(MAKE) $@
# NOTE: Not using "$<" due to a legacy Sun/illumos dmake bug with resolver
# of dynamic vars, see e.g. https://man.omnios.org/man1/make#BUGS
hidparser.c: $(top_srcdir)/drivers/hidparser.c
test -s "$@" || ln -s -f "$(top_srcdir)/drivers/hidparser.c" "$@"
# Make sure out-of-dir dependencies exist (especially when dev-building parts):
$(top_builddir)/common/libcommon.la: dummy
@cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F)
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@@WITH_VALGRIND_TRUE@check-local: $(check_PROGRAMS)
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@@WITH_VALGRIND_TRUE@ RES=0; for P in $^ ; do $(VALGRIND) ./$$P || { RES=$$? ; echo "FAILED: $(VALGRIND) ./$$P" >&2; }; done; exit $$RES
# Make sure out-of-dir C++ dependencies exist (especially when dev-building
# only some parts of NUT):
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@$(top_builddir)/clients/libnutclient.la \
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@$(top_builddir)/clients/libnutclientstub.la: dummy
@HAVE_CPPUNIT_TRUE@@HAVE_CXX11_TRUE@ @cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F)
@HAVE_CPPUNIT_FALSE@@HAVE_CXX11_TRUE@cppnit:
@HAVE_CPPUNIT_FALSE@@HAVE_CXX11_TRUE@ @echo "SKIP: $@ not implemented without C++11 and CPPUNIT enabled" >&2 ; exit 1
@HAVE_CXX11_FALSE@cppnit:
@HAVE_CXX11_FALSE@ @echo "SKIP: $@ not implemented without C++11 and CPPUNIT enabled" >&2 ; exit 1
dummy:
# NOTE: Do not clean ".deps" in SUBDIRS of the main project,
# the root Makefile.am takes care of that!
#clean-local:
# rm -rf $(builddir)/.deps
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.

26
tests/NIT/Makefile.am Normal file
View file

@ -0,0 +1,26 @@
EXTRA_DIST = nit.sh README
if WITH_CHECK_NIT
check: check-NIT
else
check:
@echo "NO-OP: $@ in `pwd` is inactive by default. Run 'configure --enable-check-NIT' or 'make check-NIT' explicitly" >&2
endif
# Run in builddir, use script from srcdir
# Avoid running "$<" - not all make implementations handle that
check-NIT: $(abs_srcdir)/nit.sh
"$(abs_srcdir)/nit.sh"
# Make sure pre-requisites for NIT are fresh as we iterate
check-NIT-devel: $(abs_srcdir)/nit.sh
@cd .. && ( $(MAKE) -s cppnit || echo "OPTIONAL C++ test client test will be skipped" )
@cd "$(top_builddir)/clients" && $(MAKE) -s upsc upsrw upsmon
@cd "$(top_builddir)/server" && $(MAKE) -s upsd
@cd "$(top_builddir)/drivers" && $(MAKE) -s dummy-ups
@$(MAKE) check-NIT
MAINTAINERCLEANFILES = Makefile.in .dirstamp
clean-local:
rm -rf tmp

585
tests/NIT/Makefile.in Normal file
View file

@ -0,0 +1,585 @@
# Makefile.in generated by automake 1.16.3 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
subdir = tests/NIT
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_c___attribute__.m4 \
$(top_srcdir)/m4/ax_c_pragmas.m4 \
$(top_srcdir)/m4/ax_check_compile_flag.m4 \
$(top_srcdir)/m4/ax_compare_version.m4 \
$(top_srcdir)/m4/ax_run_or_link_ifelse.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/m4/nut_arg_with.m4 \
$(top_srcdir)/m4/nut_check_asciidoc.m4 \
$(top_srcdir)/m4/nut_check_cppcheck.m4 \
$(top_srcdir)/m4/nut_check_headers_windows.m4 \
$(top_srcdir)/m4/nut_check_libavahi.m4 \
$(top_srcdir)/m4/nut_check_libfreeipmi.m4 \
$(top_srcdir)/m4/nut_check_libgd.m4 \
$(top_srcdir)/m4/nut_check_libltdl.m4 \
$(top_srcdir)/m4/nut_check_libmodbus.m4 \
$(top_srcdir)/m4/nut_check_libneon.m4 \
$(top_srcdir)/m4/nut_check_libnetsnmp.m4 \
$(top_srcdir)/m4/nut_check_libnss.m4 \
$(top_srcdir)/m4/nut_check_libopenssl.m4 \
$(top_srcdir)/m4/nut_check_libpowerman.m4 \
$(top_srcdir)/m4/nut_check_libusb.m4 \
$(top_srcdir)/m4/nut_check_libwrap.m4 \
$(top_srcdir)/m4/nut_check_os.m4 \
$(top_srcdir)/m4/nut_check_pkgconfig.m4 \
$(top_srcdir)/m4/nut_check_python.m4 \
$(top_srcdir)/m4/nut_compiler_family.m4 \
$(top_srcdir)/m4/nut_func_getnameinfo_argtypes.m4 \
$(top_srcdir)/m4/nut_report_feature.m4 \
$(top_srcdir)/m4/nut_stash_warnings.m4 \
$(top_srcdir)/m4/nut_type_socklen_t.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/include/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES =
DIST_SOURCES =
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
am__DIST_COMMON = $(srcdir)/Makefile.in README
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
A2X = @A2X@
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
ASCIIDOC = @ASCIIDOC@
ASPELL = @ASPELL@
AUGPARSE = @AUGPARSE@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BINDIR = @BINDIR@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CONFPATH = @CONFPATH@
CPP = @CPP@
CPPCHECK = @CPPCHECK@
CPPFLAGS = @CPPFLAGS@
CPPUNIT_CFLAGS = @CPPUNIT_CFLAGS@
CPPUNIT_LIBS = @CPPUNIT_LIBS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DBLATEX = @DBLATEX@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DOC_BUILD_LIST = @DOC_BUILD_LIST@
DOC_CHECK_LIST = @DOC_CHECK_LIST@
DRIVER_BUILD_LIST = @DRIVER_BUILD_LIST@
DRIVER_INSTALL_TARGET = @DRIVER_INSTALL_TARGET@
DRIVER_MAN_LIST = @DRIVER_MAN_LIST@
DRVPATH = @DRVPATH@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GDLIB_CONFIG = @GDLIB_CONFIG@
GREP = @GREP@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBAVAHI_CFLAGS = @LIBAVAHI_CFLAGS@
LIBAVAHI_LIBS = @LIBAVAHI_LIBS@
LIBDIR = @LIBDIR@
LIBGD_CFLAGS = @LIBGD_CFLAGS@
LIBGD_LDFLAGS = @LIBGD_LDFLAGS@
LIBIPMI_CFLAGS = @LIBIPMI_CFLAGS@
LIBIPMI_LIBS = @LIBIPMI_LIBS@
LIBLTDL_CFLAGS = @LIBLTDL_CFLAGS@
LIBLTDL_LIBS = @LIBLTDL_LIBS@
LIBMODBUS_CFLAGS = @LIBMODBUS_CFLAGS@
LIBMODBUS_LIBS = @LIBMODBUS_LIBS@
LIBNEON_CFLAGS = @LIBNEON_CFLAGS@
LIBNEON_LIBS = @LIBNEON_LIBS@
LIBNETSNMP_CFLAGS = @LIBNETSNMP_CFLAGS@
LIBNETSNMP_LIBS = @LIBNETSNMP_LIBS@
LIBOBJS = @LIBOBJS@
LIBPOWERMAN_CFLAGS = @LIBPOWERMAN_CFLAGS@
LIBPOWERMAN_LIBS = @LIBPOWERMAN_LIBS@
LIBS = @LIBS@
LIBSSL_CFLAGS = @LIBSSL_CFLAGS@
LIBSSL_LIBS = @LIBSSL_LIBS@
LIBSSL_REQUIRES = @LIBSSL_REQUIRES@
LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIBUSB_CFLAGS = @LIBUSB_CFLAGS@
LIBUSB_CONFIG = @LIBUSB_CONFIG@
LIBUSB_LIBS = @LIBUSB_LIBS@
LIBWRAP_CFLAGS = @LIBWRAP_CFLAGS@
LIBWRAP_LIBS = @LIBWRAP_LIBS@
LIPO = @LIPO@
LN_S = @LN_S@
LN_S_R = @LN_S_R@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
NETLIBS = @NETLIBS@
NET_SNMP_CONFIG = @NET_SNMP_CONFIG@
NM = @NM@
NMEDIT = @NMEDIT@
NUT_DATADIR = @NUT_DATADIR@
NUT_LIBEXECDIR = @NUT_LIBEXECDIR@
NUT_NETVERSION = @NUT_NETVERSION@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OS_NAME = @OS_NAME@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PIDPATH = @PIDPATH@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
PORT = @PORT@
PYTHON = @PYTHON@
PYTHON2 = @PYTHON2@
PYTHON3 = @PYTHON3@
RANLIB = @RANLIB@
RUN_AS_GROUP = @RUN_AS_GROUP@
RUN_AS_USER = @RUN_AS_USER@
SBINDIR = @SBINDIR@
SED = @SED@
SERLIBS = @SERLIBS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOURCE_HIGHLIGHT = @SOURCE_HIGHLIGHT@
STATEPATH = @STATEPATH@
STRIP = @STRIP@
SUN_LIBUSB = @SUN_LIBUSB@
TREE_VERSION = @TREE_VERSION@
VALGRIND = @VALGRIND@
VERSION = @VERSION@
WORDS_BIGENDIAN = @WORDS_BIGENDIAN@
XMLLINT = @XMLLINT@
XSLTPROC = @XSLTPROC@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
auglensdir = @auglensdir@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
cgiexecdir = @cgiexecdir@
datadir = @datadir@
datarootdir = @datarootdir@
devddir = @devddir@
docdir = @docdir@
driverexecdir = @driverexecdir@
dummy_PKG_CONFIG = @dummy_PKG_CONFIG@
dummy_PKG_CONFIG_CFLAGS = @dummy_PKG_CONFIG_CFLAGS@
dummy_PKG_CONFIG_LIBS = @dummy_PKG_CONFIG_LIBS@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
hotplugdir = @hotplugdir@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
now = @now@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
pkgconfigdir = @pkgconfigdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
systemdshutdowndir = @systemdshutdowndir@
systemdsystemunitdir = @systemdsystemunitdir@
systemdtmpfilesdir = @systemdtmpfilesdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
udevdir = @udevdir@
EXTRA_DIST = nit.sh README
MAINTAINERCLEANFILES = Makefile.in .dirstamp
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/NIT/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu tests/NIT/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
tags TAGS:
ctags CTAGS:
cscope cscopelist:
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
clean: clean-am
clean-am: clean-generic clean-libtool clean-local mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am:
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am:
.MAKE: install-am install-strip
.PHONY: all all-am check check-am clean clean-generic clean-libtool \
clean-local cscopelist-am ctags-am distclean distclean-generic \
distclean-libtool distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags-am uninstall uninstall-am
.PRECIOUS: Makefile
@WITH_CHECK_NIT_TRUE@check: check-NIT
@WITH_CHECK_NIT_FALSE@check:
@WITH_CHECK_NIT_FALSE@ @echo "NO-OP: $@ in `pwd` is inactive by default. Run 'configure --enable-check-NIT' or 'make check-NIT' explicitly" >&2
# Run in builddir, use script from srcdir
# Avoid running "$<" - not all make implementations handle that
check-NIT: $(abs_srcdir)/nit.sh
"$(abs_srcdir)/nit.sh"
# Make sure pre-requisites for NIT are fresh as we iterate
check-NIT-devel: $(abs_srcdir)/nit.sh
@cd .. && ( $(MAKE) -s cppnit || echo "OPTIONAL C++ test client test will be skipped" )
@cd "$(top_builddir)/clients" && $(MAKE) -s upsc upsrw upsmon
@cd "$(top_builddir)/server" && $(MAKE) -s upsd
@cd "$(top_builddir)/drivers" && $(MAKE) -s dummy-ups
@$(MAKE) check-NIT
clean-local:
rm -rf tmp
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

17
tests/NIT/README Normal file
View file

@ -0,0 +1,17 @@
NUT Integration Testing suite
=============================
This suite aims to simplify running `upsd`, a `dummy-ups` driver and
a few clients to query them, as part of regular `make check` routine
or separately with existing binaries (should not impact any existing
installation data, processes or communications).
WARNING: Current working directory when starting the script should be
the location where it may create temporary data (e.g. the BUILDDIR).
See also
link:https://git.launchpad.net/ubuntu/+source/nut/tree/debian/tests/test-nut.py[The NUT testing script]
available in the
link:https://code.edge.launchpad.net/qa-regression-testing[Ubuntu QA Regression Testing suite]
doing a similar job with NUT installed from packages and configuring
it via files in standard path names.

853
tests/NIT/nit.sh Executable file
View file

@ -0,0 +1,853 @@
#!/bin/sh
# NUT Integration Testing suite, assumes the codebase was built and
# arranges running of the binaries to test driver-client-server
# ability to start and their interactions.
#
# Note: currently it is a PoC-quality mess that gets the job done
# but could be refactored for better maintainability and generic
# approach. Part of the goal was to let this script set up the
# sandbox to run tests which could be defined in other files.
#
# WARNING: Current working directory when starting the script should be
# the location where it may create temporary data (e.g. the BUILDDIR).
# Caller can export envvars to impact the script behavior, e.g.:
# DEBUG=true to print debug messages, running processes, etc.
# DEBUG_SLEEP=60 to sleep after tests, with driver+server running
# NUT_DEBUG_MIN=3 to set (minimum) debug level for drivers, upsd...
# NUT_PORT=12345 custom port for upsd to listen and clients to query
#
# Design note: written with dumbed-down POSIX shell syntax, to
# properly work in whatever different OSes have (bash, dash,
# ksh, busybox sh...)
#
# Copyright
# 2022 Jim Klimov <jimklimov+nut@gmail.com>
#
# License: GPLv2+
TZ=UTC
LANG=C
LC_ALL=C
export TZ LANG LC_ALL
log_separator() {
echo "" >&2
echo "================================" >&2
}
shouldDebug() {
[ -n "$DEBUG" ] || [ -n "$DEBUG_SLEEP" ]
}
log_debug() {
if shouldDebug ; then
echo "[DEBUG] $@" >&2
fi
}
log_info() {
echo "[INFO] $@" >&2
}
log_error() {
echo "[ERROR] $@" >&2
}
die() {
echo "[FATAL] $@" >&2
exit 1
}
# Note: current directory is assumed to be writeable for temporary
# data, e.g. the $(builddir) from the Makefile. Static resources
# from the source codebase are where the script resides, e.g.
# the $(srcdir) from the Makefile. If we are not in the source
# tree, tests would use binaries in PATH (e.g. packaged install).
BUILDDIR="`pwd`"
TOP_BUILDDIR=""
case "${BUILDDIR}" in
*/tests/NIT)
TOP_BUILDDIR="`cd "${BUILDDIR}"/../.. && pwd`" ;;
*) log_info "Current directory '${BUILDDIR}' is not a .../tests/NIT" ;;
esac
if ! test -w "${BUILDDIR}" ; then
log_error "BUILDDIR='${BUILDDIR}' is not writeable, tests may fail below"
fi
SRCDIR="`dirname "$0"`"
SRCDIR="`cd "$SRCDIR" && pwd`"
TOP_SRCDIR=""
case "${SRCDIR}" in
*/tests/NIT)
TOP_SRCDIR="`cd "${SRCDIR}"/../.. && pwd`" ;;
*) log_info "Script source directory '${SRCDIR}' is not a .../tests/NIT" ;;
esac
# No fuss about LD_LIBRARY_PATH: for binaries that need it,
# PATH entries below would contain libtool wrapper scripts;
# for other builds we use system default or caller's env.
PATH_ADD="${BUILDDIR}"
if [ x"${SRCDIR}" != x"${BUILDDIR}" ]; then
PATH_ADD="${PATH_ADD}:${SRCDIR}"
fi
if [ x"${TOP_BUILDDIR}" != x ]; then
PATH_ADD="${PATH_ADD}:${TOP_BUILDDIR}/clients:${TOP_BUILDDIR}/drivers:${TOP_BUILDDIR}/server:${TOP_BUILDDIR}/tools:${TOP_BUILDDIR}/tools/nut-scanner"
fi
if [ x"${TOP_SRCDIR}" != x ]; then
PATH_ADD="${PATH_ADD}:${TOP_SRCDIR}/clients:${TOP_SRCDIR}/drivers:${TOP_SRCDIR}/server:${TOP_SRCDIR}/tools:${TOP_SRCDIR}/tools/nut-scanner"
fi
PATH="${PATH_ADD}:${PATH}"
export PATH
unset PATH_ADD
log_debug "Using PATH='$PATH'"
for PROG in upsd upsc dummy-ups upsmon ; do
(command -v ${PROG}) || die "Useless setup: ${PROG} not found in PATH: ${PATH}"
done
PID_UPSD=""
PID_DUMMYUPS=""
PID_DUMMYUPS1=""
PID_DUMMYUPS2=""
TESTDIR="$BUILDDIR/tmp"
# Technically the limit is sizeof(sockaddr.sun_path) for complete socket
# pathname, which varies 104-108 chars max on systems seen in CI farm;
# we reserve 17 chars for "/dummy-ups-dummy" longest filename.
if [ `echo "$TESTDIR" | wc -c` -gt 80 ]; then
log_info "'$TESTDIR' is too long to store AF_UNIX socket files, will mktemp"
if ! ( [ -n "${TMPDIR-}" ] && [ -d "${TMPDIR-}" ] && [ -w "${TMPDIR-}" ] ) ; then
if [ -d /dev/shm ] && [ -w /dev/shm ]; then TMPDIR=/dev/shm ; else TMPDIR=/tmp ; fi
fi
TESTDIR="`mktemp -d "${TMPDIR}/nit-tmp.$$.XXXXXX"`" || die "Failed to mktemp"
else
rm -rf "${TESTDIR}" || true
fi
log_info "Using '$TESTDIR' for generated configs and state files"
mkdir -p "${TESTDIR}/etc" "${TESTDIR}/run" && chmod 750 "${TESTDIR}/run" \
|| die "Failed to create temporary FS structure for the NIT"
stop_daemons() {
if [ -n "$PID_UPSD$PID_DUMMYUPS$PID_DUMMYUPS1$PID_DUMMYUPS2" ] ; then
log_info "Stopping test daemons"
kill -15 $PID_UPSD $PID_DUMMYUPS $PID_DUMMYUPS1 $PID_DUMMYUPS2 2>/dev/null
fi
}
trap 'RES=$?; stop_daemons; if [ "${TESTDIR}" != "${BUILDDIR}/tmp" ] ; then rm -rf "${TESTDIR}" ; fi; exit $RES;' 0 1 2 3 15
NUT_STATEPATH="${TESTDIR}/run"
NUT_ALTPIDPATH="${TESTDIR}/run"
NUT_CONFPATH="${TESTDIR}/etc"
export NUT_STATEPATH NUT_ALTPIDPATH NUT_CONFPATH
# TODO: Find a portable way to (check and) grab a random unprivileged port?
[ -n "${NUT_PORT-}" ] && [ "$NUT_PORT" -gt 0 ] && [ "$NUT_PORT" -lt 65536 ] \
|| {
DELTA1="`date +%S`" || DELTA1=0
DELTA2="`expr $$ % 99`" || DELTA2=0
NUT_PORT="`expr 34931 + $DELTA1 + $DELTA2`" \
&& [ "$NUT_PORT" -gt 0 ] && [ "$NUT_PORT" -lt 65536 ] \
|| NUT_PORT=34931
}
export NUT_PORT
### upsd.conf: ##################################################
generatecfg_upsd_trivial() {
# Populate the configs for the run
cat > "$NUT_CONFPATH/upsd.conf" << EOF
STATEPATH "$NUT_STATEPATH"
LISTEN localhost $NUT_PORT
EOF
[ $? = 0 ] || die "Failed to populate temporary FS structure for the NIT: upsd.conf"
chmod 640 "$NUT_CONFPATH/upsd.conf"
# Some systems listining on symbolic "localhost" actually
# only bind to IPv6, and Python telnetlib resolves IPv4
# and fails its connection tests. Others fare well with
# both addresses in one command.
for LH in 127.0.0.1 '::1' ; do
if (
( cat /etc/hosts || getent hosts ) | grep "$LH" \
|| ping -c 1 "$LH"
) 2>/dev/null >/dev/null ; then
echo "LISTEN $LH $NUT_PORT" >> "$NUT_CONFPATH/upsd.conf"
fi
done
if [ -n "${NUT_DEBUG_MIN-}" ] ; then
echo "DEBUG_MIN ${NUT_DEBUG_MIN}" >> "$NUT_CONFPATH/upsd.conf" || exit
fi
}
generatecfg_upsd_nodev() {
generatecfg_upsd_trivial
echo "ALLOW_NO_DEVICE true" >> "$NUT_CONFPATH/upsd.conf" \
|| die "Failed to populate temporary FS structure for the NIT: upsd.conf"
}
### upsd.users: ##################################################
TESTPASS_ADMIN='mypass'
TESTPASS_TESTER='pass words'
TESTPASS_UPSMON_PRIMARY='P@ssW0rdAdm'
TESTPASS_UPSMON_SECONDARY='P@ssW0rd'
generatecfg_upsdusers_trivial() {
cat > "$NUT_CONFPATH/upsd.users" << EOF
[admin]
password = $TESTPASS_ADMIN
actions = SET
instcmds = ALL
[tester]
password = "${TESTPASS_TESTER}"
instcmds = test.battery.start
instcmds = test.battery.stop
[dummy-admin-m]
password = "${TESTPASS_UPSMON_PRIMARY}"
upsmon master
[dummy-admin]
password = "${TESTPASS_UPSMON_PRIMARY}"
upsmon primary
[dummy-user-s]
password = "${TESTPASS_UPSMON_SECONDARY}"
upsmon slave
[dummy-user]
password = "${TESTPASS_UPSMON_SECONDARY}"
upsmon secondary
EOF
[ $? = 0 ] || die "Failed to populate temporary FS structure for the NIT: upsd.users"
chmod 640 "$NUT_CONFPATH/upsd.users"
}
### upsmon.conf: ##################################################
generatecfg_upsmon_trivial() {
# Populate the configs for the run
( echo 'MINSUPPLIES 0' > "$NUT_CONFPATH/upsmon.conf" || exit
echo 'SHUTDOWNCMD "echo TESTING_DUMMY_SHUTDOWN_NOW"' >> "$NUT_CONFPATH/upsmon.conf" || exit
if [ -n "${NUT_DEBUG_MIN-}" ] ; then
echo "DEBUG_MIN ${NUT_DEBUG_MIN}" >> "$NUT_CONFPATH/upsmon.conf" || exit
fi
) || die "Failed to populate temporary FS structure for the NIT: upsmon.conf"
chmod 640 "$NUT_CONFPATH/upsmon.conf"
}
generatecfg_upsmon_master() {
generatecfg_upsmon_trivial
echo "MONITOR 'dummy@localhost:$NUT_PORT' 0 'dummy-admin-m' '${TESTPASS_UPSMON_PRIMARY}' master" >> "$NUT_CONFPATH/upsmon.conf" \
|| die "Failed to populate temporary FS structure for the NIT: upsmon.conf"
}
generatecfg_upsmon_primary() {
generatecfg_upsmon_trivial
echo "MONITOR 'dummy@localhost:$NUT_PORT' 0 'dummy-admin' '${TESTPASS_UPSMON_PRIMARY}' primary" >> "$NUT_CONFPATH/upsmon.conf" \
|| die "Failed to populate temporary FS structure for the NIT: upsmon.conf"
}
generatecfg_upsmon_slave() {
generatecfg_upsmon_trivial
echo "MONITOR 'dummy@localhost:$NUT_PORT' 0 'dummy-user-s' '${TESTPASS_UPSMON_SECONDARY}' slave" >> "$NUT_CONFPATH/upsmon.conf" \
|| die "Failed to populate temporary FS structure for the NIT: upsmon.conf"
}
generatecfg_upsmon_secondary() {
generatecfg_upsmon_trivial
echo "MONITOR 'dummy@localhost:$NUT_PORT' 0 'dummy-user' '${TESTPASS_UPSMON_SECONDARY}' secondary" >> "$NUT_CONFPATH/upsmon.conf" \
|| die "Failed to populate temporary FS structure for the NIT: upsmon.conf"
}
### ups.conf: ##################################################
generatecfg_ups_trivial() {
# Populate the configs for the run
( echo 'maxretry = 3' > "$NUT_CONFPATH/ups.conf" || exit
if [ x"${TOP_BUILDDIR}" != x ]; then
echo "driverpath = '${TOP_BUILDDIR}/drivers'" >> "$NUT_CONFPATH/ups.conf" || exit
fi
if [ -n "${NUT_DEBUG_MIN-}" ] ; then
echo "debug_min = ${NUT_DEBUG_MIN}" >> "$NUT_CONFPATH/ups.conf" || exit
fi
) || die "Failed to populate temporary FS structure for the NIT: ups.conf"
chmod 640 "$NUT_CONFPATH/ups.conf"
}
generatecfg_ups_dummy() {
generatecfg_ups_trivial
cat > "$NUT_CONFPATH/dummy.seq" << EOF
ups.status: OB
TIMER 5
ups.status: OL
TIMER 5
EOF
[ $? = 0 ] || die "Failed to populate temporary FS structure for the NIT: dummy.seq"
cat >> "$NUT_CONFPATH/ups.conf" << EOF
[dummy]
driver = dummy-ups
desc = "Crash Dummy"
port = dummy.seq
#mode = dummy-loop
EOF
[ $? = 0 ] || die "Failed to populate temporary FS structure for the NIT: ups.conf"
if [ x"${TOP_SRCDIR}" != x ]; then
cp "${TOP_SRCDIR}/data/evolution500.seq" "${TOP_SRCDIR}/data/epdu-managed.dev" "$NUT_CONFPATH/"
cat >> "$NUT_CONFPATH/ups.conf" << EOF
[UPS1]
driver = dummy-ups
desc = "Example event sequence"
port = evolution500.seq
[UPS2]
driver = dummy-ups
desc = "Example ePDU data dump"
port = epdu-managed.dev
mode = dummy-once
EOF
[ $? = 0 ] || die "Failed to populate temporary FS structure for the NIT: ups.conf"
# HACK: Avoid empty ups.status that may be present in example docs
# FIXME: Might we actually want that value (un-)set for tests?..
# TODO: Check if the problem was with dummy-ups looping? [#1385]
for F in "$NUT_CONFPATH/"*.dev "$NUT_CONFPATH/"*.seq ; do
sed -e 's,^ups.status: *$,ups.status: OL BOOST,' -i'.bak' "$F"
grep -E '^ups.status:' "$F" >/dev/null || { echo "ups.status: OL BOOST" >> "$F"; }
done
fi
}
#####################################################
isPidAlive() {
[ -n "$1" ] && [ "$1" -gt 0 ] || return
[ -d "/proc/$1" ] || kill -0 "$1" 2>/dev/null
}
FAILED=0
PASSED=0
testcase_upsd_no_configs_at_all() {
log_separator
log_info "Test UPSD without configs at all"
upsd -F
if [ "$?" = 0 ]; then
log_error "upsd should fail without configs"
FAILED="`expr $FAILED + 1`"
else
log_info "OK, upsd failed to start in wrong conditions"
PASSED="`expr $PASSED + 1`"
fi
}
testcase_upsd_no_configs_driver_file() {
log_separator
log_info "Test UPSD without driver config file"
generatecfg_upsd_trivial
upsd -F
if [ "$?" = 0 ]; then
log_error "upsd should fail without driver config file"
FAILED="`expr $FAILED + 1`"
else
log_info "OK, upsd failed to start in wrong conditions"
PASSED="`expr $PASSED + 1`"
fi
}
testcase_upsd_no_configs_in_driver_file() {
log_separator
log_info "Test UPSD without drivers defined in config file"
generatecfg_upsd_trivial
generatecfg_ups_trivial
upsd -F
if [ "$?" = 0 ]; then
log_error "upsd should fail without drivers defined in config file"
FAILED="`expr $FAILED + 1`"
else
log_info "OK, upsd failed to start in wrong conditions"
PASSED="`expr $PASSED + 1`"
fi
}
testcase_upsd_allow_no_device() {
log_separator
log_info "Test UPSD allowed to run without driver configs"
generatecfg_upsd_nodev
generatecfg_upsdusers_trivial
generatecfg_ups_trivial
upsd -F &
PID_UPSD="$!"
sleep 2
if isPidAlive "$PID_UPSD"; then
log_info "OK, upsd is running"
PASSED="`expr $PASSED + 1`"
log_separator
log_info "Test that UPSD responds to UPSC"
OUT="`upsc -l localhost:$NUT_PORT`" || die "upsd does not respond: $OUT"
if [ -n "$OUT" ] ; then
log_error "got reply for upsc listing when none was expected: $OUT"
FAILED="`expr $FAILED + 1`"
else
log_info "OK, empty response as expected"
PASSED="`expr $PASSED + 1`"
fi
else
log_error "upsd was expected to be running although no devices are defined"
FAILED="`expr $FAILED + 1`"
fi
kill -15 $PID_UPSD
wait $PID_UPSD
}
testgroup_upsd_invalid_configs() {
testcase_upsd_no_configs_at_all
testcase_upsd_no_configs_driver_file
testcase_upsd_no_configs_in_driver_file
}
testgroup_upsd_questionable_configs() {
testcase_upsd_allow_no_device
}
#########################################################
### Tests in a common sandbox with driver(s) + server ###
#########################################################
SANDBOX_CONFIG_GENERATED=false
sandbox_generate_configs() {
if $SANDBOX_CONFIG_GENERATED ; then return ; fi
log_info "Generating configs for sandbox"
generatecfg_upsd_nodev
generatecfg_upsdusers_trivial
generatecfg_ups_dummy
SANDBOX_CONFIG_GENERATED=true
}
sandbox_forget_configs() {
SANDBOX_CONFIG_GENERATED=false
if [ -z "${DEBUG_SLEEP-}" ] ; then
stop_daemons
fi
}
sandbox_start_upsd() {
if isPidAlive "$PID_UPSD" ; then
return 0
fi
sandbox_generate_configs
log_info "Starting UPSD for sandbox"
upsd -F &
PID_UPSD="$!"
sleep 5
}
sandbox_start_drivers() {
if isPidAlive "$PID_DUMMYUPS" \
&& { [ x"${TOP_SRCDIR}" != x ] && isPidAlive "$PID_DUMMYUPS1" && isPidAlive "$PID_DUMMYUPS2" \
|| [ x"${TOP_SRCDIR}" = x ] ; } \
; then
# All drivers expected for this environment are already running
return 0
fi
sandbox_generate_configs
log_info "Starting dummy-ups driver(s) for sandbox"
#upsdrvctl -F start dummy &
dummy-ups -a dummy -F &
PID_DUMMYUPS="$!"
if [ x"${TOP_SRCDIR}" != x ]; then
dummy-ups -a UPS1 -F &
PID_DUMMYUPS1="$!"
dummy-ups -a UPS2 -F &
PID_DUMMYUPS2="$!"
fi
sleep 5
if shouldDebug ; then
(ps -ef || ps -xawwu) 2>/dev/null | grep -E '(ups|nut|dummy)' || true
fi
}
testcase_sandbox_start_upsd_alone() {
log_separator
log_info "Test starting UPSD but not a driver before it"
sandbox_start_upsd
EXPECTED_UPSLIST='dummy'
if [ x"${TOP_SRCDIR}" != x ]; then
EXPECTED_UPSLIST="$EXPECTED_UPSLIST
UPS1
UPS2"
fi
log_info "Query listing from UPSD by UPSC (driver not running yet)"
OUT="`upsc -l localhost:$NUT_PORT`" || die "upsd does not respond: $OUT"
if [ x"$OUT" != x"$EXPECTED_UPSLIST" ] ; then
log_error "got this reply for upsc listing when '$EXPECTED_UPSLIST' was expected: $OUT"
FAILED="`expr $FAILED + 1`"
else
PASSED="`expr $PASSED + 1`"
fi
log_info "Query driver state from UPSD by UPSC (driver not running yet)"
OUT="`upsc dummy@localhost:$NUT_PORT 2>&1`" && {
log_error "upsc was supposed to answer with error exit code: $OUT"
FAILED="`expr $FAILED + 1`"
}
if ! echo "$OUT" | grep 'Error: Driver not connected' ; then
log_error "got reply for upsc query when 'Error: Driver not connected' was expected: '$OUT'"
FAILED="`expr $FAILED + 1`"
else
PASSED="`expr $PASSED + 1`"
fi
}
testcase_sandbox_start_upsd_after_drivers() {
# Historically this is a fallback from testcase_sandbox_start_drivers_after_upsd
kill -15 $PID_UPSD 2>/dev/null
wait $PID_UPSD
upsd -F &
PID_UPSD="$!"
sandbox_start_drivers
sandbox_start_upsd
sleep 5
upsc dummy@localhost:$NUT_PORT || die "upsd does not respond"
}
testcase_sandbox_start_drivers_after_upsd() {
#sandbox_start_upsd
testcase_sandbox_start_upsd_alone
sandbox_start_drivers
log_info "Query driver state from UPSD by UPSC after driver startup"
upsc dummy@localhost:$NUT_PORT || {
# Should not get to this, except on very laggy systems maybe
log_error "Query failed, retrying with UPSD started after drivers"
testcase_sandbox_start_upsd_after_drivers
}
if [ x"${TOP_SRCDIR}" != x ]; then
log_info "Wait for dummy UPSes with larger data sets to initialize"
for U in UPS1 UPS2 ; do
COUNTDOWN=60
while ! upsc $U@localhost:$NUT_PORT ups.status ; do
sleep 1
COUNTDOWN="`expr $COUNTDOWN - 1`"
# Systemic error, e.g. could not create socket file?
[ "$COUNTDOWN" -lt 1 ] && die "Dummy driver did not start or respond in time"
done
done
fi
log_info "Expected drivers are now responding via UPSD"
}
testcase_sandbox_upsc_query_model() {
OUT="`upsc dummy@localhost:$NUT_PORT device.model`" || die "upsd does not respond: $OUT"
if [ x"$OUT" != x"Dummy UPS" ] ; then
log_error "got this reply for upsc query when 'Dummy UPS' was expected: $OUT"
FAILED="`expr $FAILED + 1`"
else
PASSED="`expr $PASSED + 1`"
fi
}
testcase_sandbox_upsc_query_bogus() {
log_info "Query driver state from UPSD by UPSC for bogus info"
OUT="`upsc dummy@localhost:$NUT_PORT ups.bogus.value 2>&1`" && {
log_error "upsc was supposed to answer with error exit code: $OUT"
FAILED="`expr $FAILED + 1`"
}
if ! echo "$OUT" | grep 'Error: Variable not supported by UPS' ; then
log_error "got reply for upsc query when 'Error: Variable not supported by UPS' was expected: $OUT"
FAILED="`expr $FAILED + 1`"
else
PASSED="`expr $PASSED + 1`"
fi
}
testcase_sandbox_upsc_query_timer() {
log_separator
log_info "Test that dummy-ups TIMER action changes the reported state"
# Driver is set up to flip ups.status every 5 sec, so check every 3
OUT1="`upsc dummy@localhost:$NUT_PORT ups.status`" || die "upsd does not respond: $OUT1" ; sleep 3
OUT2="`upsc dummy@localhost:$NUT_PORT ups.status`" || die "upsd does not respond: $OUT2"
OUT3=""
OUT4=""
if [ x"$OUT1" = x"$OUT2" ]; then
sleep 3
OUT3="`upsc dummy@localhost:$NUT_PORT ups.status`" || die "upsd does not respond: $OUT3"
if [ x"$OUT2" = x"$OUT3" ]; then
sleep 3
OUT4="`upsc dummy@localhost:$NUT_PORT ups.status`" || die "upsd does not respond: $OUT4"
fi
fi
if echo "$OUT1$OUT2$OUT3$OUT4" | grep "OB" && echo "$OUT1$OUT2$OUT3$OUT4" | grep "OL" ; then
log_info "OK, ups.status flips over time"
PASSED="`expr $PASSED + 1`"
else
log_error "ups.status did not flip over time"
FAILED="`expr $FAILED + 1`"
fi
}
isTestablePython() {
# We optionally make python module (if interpreter is found):
if [ x"${TOP_BUILDDIR}" = x ] \
|| [ ! -x "${TOP_BUILDDIR}/scripts/python/module/test_nutclient.py" ] \
; then
return 1
fi
return 0
}
testcase_sandbox_python_without_credentials() {
isTestablePython || return 0
log_separator
log_info "Call Python module test suite: PyNUT (NUT Python bindings) without login credentials"
if ( unset NUT_USER || true
unset NUT_PASS || true
"${TOP_BUILDDIR}/scripts/python/module/test_nutclient.py"
) ; then
log_info "OK, PyNUT did not complain"
PASSED="`expr $PASSED + 1`"
else
log_error "PyNUT complained, check above"
FAILED="`expr $FAILED + 1`"
fi
}
testcase_sandbox_python_with_credentials() {
isTestablePython || return 0
# That script says it expects data/evolution500.seq (as the UPS1 dummy)
# but the dummy data does not currently let issue the commands and
# setvars tested from python script.
log_separator
log_info "Call Python module test suite: PyNUT (NUT Python bindings) with login credentials"
if (
NUT_USER='admin'
NUT_PASS="${TESTPASS_ADMIN}"
export NUT_USER NUT_PASS
"${TOP_BUILDDIR}/scripts/python/module/test_nutclient.py"
) ; then
log_info "OK, PyNUT did not complain"
PASSED="`expr $PASSED + 1`"
else
log_error "PyNUT complained, check above"
FAILED="`expr $FAILED + 1`"
fi
}
testcases_sandbox_python() {
isTestablePython || return 0
testcase_sandbox_python_without_credentials
testcase_sandbox_python_with_credentials
}
####################################
isTestableCppNIT() {
# We optionally make and here can run C++ client tests:
if [ x"${TOP_BUILDDIR}" = x ] \
|| [ ! -x "${TOP_BUILDDIR}/tests/cppnit" ] \
; then
return 1
fi
return 0
}
testcase_sandbox_cppnit_without_creds() {
isTestableCppNIT || return 0
log_separator
log_info "Call libnutclient test suite: cppnit without login credentials"
if ( unset NUT_USER || true
unset NUT_PASS || true
"${TOP_BUILDDIR}/tests/cppnit"
) ; then
log_info "OK, cppnit did not complain"
PASSED="`expr $PASSED + 1`"
else
log_error "cppnit complained, check above"
FAILED="`expr $FAILED + 1`"
fi
}
testcase_sandbox_cppnit_simple_admin() {
isTestableCppNIT || return 0
log_separator
log_info "Call libnutclient test suite: cppnit with login credentials: simple admin"
if (
NUT_USER='admin'
NUT_PASS="${TESTPASS_ADMIN}"
if [ x"${TOP_SRCDIR}" != x ]; then
# Avoid dummies with TIMER flip-flops
NUT_SETVAR_DEVICE='UPS2'
else
# Risks failure when lauching sub-test at the wrong second
NUT_SETVAR_DEVICE='dummy'
fi
unset NUT_PRIMARY_DEVICE
export NUT_USER NUT_PASS NUT_SETVAR_DEVICE
"${TOP_BUILDDIR}/tests/cppnit"
) ; then
log_info "OK, cppnit did not complain"
PASSED="`expr $PASSED + 1`"
else
log_error "cppnit complained, check above"
FAILED="`expr $FAILED + 1`"
fi
}
testcase_sandbox_cppnit_upsmon_primary() {
isTestableCppNIT || return 0
log_separator
log_info "Call libnutclient test suite: cppnit with login credentials: upsmon-primary"
if (
NUT_USER='dummy-admin'
NUT_PASS="${TESTPASS_UPSMON_PRIMARY}"
NUT_PRIMARY_DEVICE='dummy'
unset NUT_SETVAR_DEVICE
export NUT_USER NUT_PASS NUT_PRIMARY_DEVICE
"${TOP_BUILDDIR}/tests/cppnit"
) ; then
log_info "OK, cppnit did not complain"
PASSED="`expr $PASSED + 1`"
else
log_error "cppnit complained, check above"
FAILED="`expr $FAILED + 1`"
fi
}
testcase_sandbox_cppnit_upsmon_master() {
isTestableCppNIT || return 0
log_separator
log_info "Call libnutclient test suite: cppnit with login credentials: upsmon-master"
if (
NUT_USER='dummy-admin-m'
NUT_PASS="${TESTPASS_UPSMON_PRIMARY}"
NUT_PRIMARY_DEVICE='dummy'
unset NUT_SETVAR_DEVICE
export NUT_USER NUT_PASS NUT_PRIMARY_DEVICE
"${TOP_BUILDDIR}/tests/cppnit"
) ; then
log_info "OK, cppnit did not complain"
PASSED="`expr $PASSED + 1`"
else
log_error "cppnit complained, check above"
FAILED="`expr $FAILED + 1`"
fi
}
testcases_sandbox_cppnit() {
isTestableCppNIT || return 0
testcase_sandbox_cppnit_without_creds
testcase_sandbox_cppnit_upsmon_primary
testcase_sandbox_cppnit_upsmon_master
testcase_sandbox_cppnit_simple_admin
}
# TODO: Some upsmon tests?
testgroup_sandbox() {
testcase_sandbox_start_drivers_after_upsd
testcase_sandbox_upsc_query_model
testcase_sandbox_upsc_query_bogus
testcase_sandbox_upsc_query_timer
testcases_sandbox_python
testcases_sandbox_cppnit
sandbox_forget_configs
}
testgroup_sandbox_python() {
# Arrange for quick test iterations
testcase_sandbox_start_drivers_after_upsd
testcases_sandbox_python
sandbox_forget_configs
}
testgroup_sandbox_cppnit() {
# Arrange for quick test iterations
testcase_sandbox_start_drivers_after_upsd
testcases_sandbox_cppnit
sandbox_forget_configs
}
testgroup_sandbox_cppnit_simple_admin() {
# Arrange for quick test iterations
testcase_sandbox_start_drivers_after_upsd
testcase_sandbox_cppnit_simple_admin
sandbox_forget_configs
}
################################################################
case "${NIT_CASE}" in
cppnit) testgroup_sandbox_cppnit ;;
python) testgroup_sandbox_python ;;
testcase_*|testgroup_*|testcases_*|testgroups_*)
"${NIT_CASE}" ;;
"") # Default test groups:
testgroup_upsd_invalid_configs
testgroup_upsd_questionable_configs
testgroup_sandbox
;;
*) die "Unsupported NIT_CASE='$NIT_CASE' was requested" ;;
esac
log_separator
log_info "OVERALL: PASSED=$PASSED FAILED=$FAILED"
# Allow to leave the sandbox daemons running for a while,
# to experiment with them interactively:
if [ -n "${DEBUG_SLEEP-}" ] ; then
log_separator
log_info "Sleeping now as asked, so you can play with the driver and server running; hint: export NUT_PORT=$NUT_PORT"
log_separator
if [ "${DEBUG_SLEEP-}" -gt 0 ] ; then
sleep "${DEBUG_SLEEP}"
else
sleep 60
fi
log_info "Sleep finished"
log_separator
fi
if [ "$PASSED" = 0 ] || [ "$FAILED" != 0 ] ; then
die "Some test scenarios failed!"
else
log_info "SUCCESS"
fi

415
tests/cpputest-client.cpp Normal file
View file

@ -0,0 +1,415 @@
/* cpputest-client - CppUnit libnutclient active test
Module for NUT `cpputest` runner, to check client-server interactions
as part of NIT (NUT Integration Testing) suite and similar scenarios.
This is an "active" NUT client talking to an `upsd` on $NUT_PORT,
as opposed to nutclienttest.cpp which unit-tests the class API etc.
in isolated-binary fashion.
Copyright (C) 2022 Jim Klimov <jimklimov@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "common.h"
/* Current CPPUnit offends the honor of C++98 */
#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS || defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS)
#pragma GCC diagnostic push
# ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS
# pragma GCC diagnostic ignored "-Wglobal-constructors"
# endif
# ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS
# pragma GCC diagnostic ignored "-Wexit-time-destructors"
# endif
#endif
#include <cppunit/extensions/HelperMacros.h>
#include <stdexcept>
#include <cstdint>
#include <cstdlib>
#include <stdlib.h>
namespace nut {
class NutActiveClientTest : public CppUnit::TestFixture
{
/* Note: is "friend" of nut::TcpClient class
* to test a few of its protected methods */
CPPUNIT_TEST_SUITE( NutActiveClientTest );
CPPUNIT_TEST( test_query_ver );
CPPUNIT_TEST( test_list_ups );
CPPUNIT_TEST( test_auth_user );
CPPUNIT_TEST( test_auth_primary );
CPPUNIT_TEST_SUITE_END();
private:
/* Fed by caller via envvars: */
uint16_t NUT_PORT = 0;
std::string NUT_USER = "";
std::string NUT_PASS = "";
std::string NUT_PRIMARY_DEVICE = "";
std::string NUT_SETVAR_DEVICE = "";
public:
void setUp() override;
void tearDown() override;
void test_query_ver();
void test_list_ups();
void test_auth_user();
void test_auth_primary();
};
// Registers the fixture into the 'registry'
CPPUNIT_TEST_SUITE_REGISTRATION( NutActiveClientTest );
} // namespace nut {}
#ifndef _NUTCLIENTTEST_BUILD
# define _NUTCLIENTTEST_BUILD 1
#endif
#include "../clients/nutclient.h"
#include "../clients/nutclientmem.h"
namespace nut {
extern "C" {
strarr stringset_to_strarr(const std::set<std::string>& strset);
strarr stringvector_to_strarr(const std::vector<std::string>& strset);
} // extern "C"
void NutActiveClientTest::setUp()
{
/* NUT_PORT etc. are provided by external test suite driver */
char * s;
s = std::getenv("NUT_PORT");
if (s) {
long l = atol(s);
if (l < 1 || l > 65535) {
throw std::runtime_error("NUT_PORT specified by caller is out of range");
}
NUT_PORT = static_cast<uint16_t>(l);
} else {
throw std::runtime_error("NUT_PORT not specified by caller, NIT should call this test");
}
s = std::getenv("NUT_USER");
if (s) {
NUT_USER = s;
} // else stays empty
s = std::getenv("NUT_PASS");
if (s) {
NUT_PASS = s;
} // else stays empty
s = std::getenv("NUT_PRIMARY_DEVICE");
if (s) {
NUT_PRIMARY_DEVICE = s;
} // else stays empty
s = std::getenv("NUT_SETVAR_DEVICE");
if (s) {
NUT_SETVAR_DEVICE = s;
} // else stays empty
}
void NutActiveClientTest::tearDown()
{
}
void NutActiveClientTest::test_query_ver() {
nut::TcpClient c("localhost", NUT_PORT);
std::string s;
std::cerr << "[D] C++ NUT Client lib test running against Data Server at: "
<< c.getHost() << ':' << c.getPort() << std::endl;
CPPUNIT_ASSERT_MESSAGE(
"TcpClient is not connected after constructor",
c.isConnected());
/* Note: generic client code can not use protected methods
* like low-level sendQuery(), list(), get() and some more,
* but this NutActiveClientTest is a friend of TcpClient:
*/
s = c.sendQuery("VER");
std::cerr << "[D] Got Data Server VER: " << s << std::endl;
try {
s = c.sendQuery("PROTVER");
std::cerr << "[D] Got PROTVER: " << s << std::endl;
}
catch(nut::NutException& ex)
{
std::cerr << "[D] Did not get PROTVER: " << ex.what() << std::endl;
}
try {
s = c.sendQuery("NETVER");
std::cerr << "[D] Got NETVER (obsolete): " << s << std::endl;
}
catch(nut::NutException& ex)
{
std::cerr << "[D] Did not get NETVER (obsolete): " << ex.what() << std::endl;
}
try {
c.logout();
}
catch(nut::NutException& ex)
{
std::cerr << "[D] Could not get LOGOUT: " << ex.what() << std::endl;
}
try {
c.disconnect();
}
catch(nut::NutException& ex)
{
/* NUT_UNUSED_VARIABLE(ex); */
std::cerr << "[D] Could not get disconnect(): " << ex.what() << std::endl;
}
}
void NutActiveClientTest::test_list_ups() {
nut::TcpClient c("localhost", NUT_PORT);
std::set<std::string> devs;
bool noException = true;
try {
devs = c.getDeviceNames();
std::cerr << "[D] Got device list (" << devs.size() << "): [";
for (std::set<std::string>::iterator it = devs.begin();
it != devs.end(); it++
) {
if (it != devs.begin()) {
std::cerr << ", ";
}
std::cerr << '"' << *it << '"';
}
std::cerr << "]" << std::endl;
}
catch(nut::NutException& ex)
{
std::cerr << "[D] Could not device list: " << ex.what() << std::endl;
noException = false;
}
c.logout();
c.disconnect();
CPPUNIT_ASSERT_MESSAGE(
"Failed to list UPS with TcpClient: threw NutException",
noException);
}
void NutActiveClientTest::test_auth_user() {
if (NUT_USER.empty()) {
std::cerr << "[D] SKIPPING test_auth_user()" << std::endl;
return;
}
nut::TcpClient c("localhost", NUT_PORT);
bool noException = true;
try {
c.authenticate(NUT_USER, NUT_PASS);
std::cerr << "[D] Authenticated without exceptions" << std::endl;
/* Note: no high hopes here, credentials are checked by server
* when running critical commands, not at auth request itself */
}
catch(nut::NutException& ex)
{
std::cerr << "[D] Could not authenticate as a simple user: " << ex.what() << std::endl;
noException = false;
}
if (!NUT_SETVAR_DEVICE.empty()) {
try {
TrackingResult tres;
TrackingID tid;
int i;
std::string nutVar = "ups.status"; /* Has a risk of flip-flop with NIT dummy setup */
std::string s1 = c.getDeviceVariableValue(NUT_SETVAR_DEVICE, nutVar)[0];
std::string sTest = s1 + "-test";
std::cerr << "[D] Got initial device '" << NUT_SETVAR_DEVICE
<< "' variable '" << nutVar << "' value: " << s1 << std::endl;
CPPUNIT_ASSERT_MESSAGE(
"Did not expect empty value here",
!s1.empty());
tid = c.setDeviceVariable(NUT_SETVAR_DEVICE, nutVar, sTest);
while ( (tres = c.getTrackingResult(tid)) == PENDING) {
usleep(100);
}
if (tres != SUCCESS) {
std::cerr << "[D] Failed to set device variable: "
<< "tracking result is " << tres << std::endl;
noException = false;
}
/* Check what we got after set */
/* Note that above we told the server to tell the driver
* to set a dstate entry; below we ask the server to ask
* the driver and relay the answer to us. The dummy-ups
* driver may also be in a sleeping state between cycles.
* Data propagation may be not instantaneous, so we loop
* for a while to see the expected value (or give up).
*/
std::string s2;
for (i = 0; i < 100 ; i++) {
s2 = c.getDeviceVariableValue(NUT_SETVAR_DEVICE, nutVar)[0];
if (s2 == sTest)
break;
usleep(100000);
}
std::cerr << "[D] Read back: " << s2
<< " after " << (100 * i) << "msec"
<< std::endl;
/* Fix it back */
tid = c.setDeviceVariable(NUT_SETVAR_DEVICE, nutVar, s1);
while ( (tres = c.getTrackingResult(tid)) == PENDING) {
usleep(100);
}
if (tres != SUCCESS) {
std::cerr << "[D] Failed to set device variable: "
<< "tracking result is " << tres << std::endl;
noException = false;
}
std::string s3;
for (i = 0; i < 100 ; i++) {
s3 = c.getDeviceVariableValue(NUT_SETVAR_DEVICE, nutVar)[0];
if (s3 == s1)
break;
usleep(100000);
}
std::cerr << "[D] Read back: " << s3
<< " after " << (100 * i) << "msec"
<< std::endl;
if (s3 != s1) {
std::cerr << "[D] Final device variable value '" << s3
<< "' differs from original '" << s1
<< "'" << std::endl;
noException = false;
}
if (s2 == s1) {
std::cerr << "[D] Tweaked device variable value '" << s2
<< "' does not differ from original '" << s1
<< "'" << std::endl;
noException = false;
}
if (noException) {
std::cerr << "[D] Tweaked device variable value OK" << std::endl;
}
}
catch(nut::NutException& ex)
{
std::cerr << "[D] Failed to set device variable: "
<< ex.what() << std::endl;
noException = false;
}
} else {
std::cerr << "[D] SKIPPING test_auth_user() active test "
<< "(got no NUT_SETVAR_DEVICE to poke)" << std::endl;
}
c.logout();
c.disconnect();
CPPUNIT_ASSERT_MESSAGE(
"Failed to auth as user with TcpClient or tweak device variable",
noException);
}
void NutActiveClientTest::test_auth_primary() {
if (NUT_USER.empty() || NUT_PRIMARY_DEVICE.empty()) {
std::cerr << "[D] SKIPPING test_auth_primary()" << std::endl;
return;
}
nut::TcpClient c("localhost", NUT_PORT);
bool noException = true;
try {
c.authenticate(NUT_USER, NUT_PASS);
std::cerr << "[D] Authenticated without exceptions" << std::endl;
}
catch(nut::NutException& ex)
{
std::cerr << "[D] Could not authenticate as an upsmon primary user: "
<< ex.what() << std::endl;
noException = false;
}
try {
Device d = c.getDevice(NUT_PRIMARY_DEVICE);
bool gotPrimary = false;
bool gotMaster = false;
try {
c.deviceMaster(NUT_PRIMARY_DEVICE);
gotMaster = true;
std::cerr << "[D] Elevated as MASTER without exceptions" << std::endl;
}
catch(nut::NutException& ex)
{
std::cerr << "[D] Could not elevate as MASTER for "
<< "NUT_PRIMARY_DEVICE " << NUT_PRIMARY_DEVICE << ": "
<< ex.what() << std::endl;
}
try {
c.devicePrimary(NUT_PRIMARY_DEVICE);
gotPrimary = true;
std::cerr << "[D] Elevated as PRIMARY without exceptions" << std::endl;
}
catch(nut::NutException& ex)
{
std::cerr << "[D] Could not elevate as PRIMARY for "
<< "NUT_PRIMARY_DEVICE " << NUT_PRIMARY_DEVICE << ": "
<< ex.what() << std::endl;
}
if (!gotMaster && !gotPrimary)
noException = false;
}
catch(nut::NutException& ex)
{
std::cerr << "[D] NUT_PRIMARY_DEVICE " << NUT_PRIMARY_DEVICE
<< " not found on Data Server: "
<< ex.what() << std::endl;
noException = false;
}
c.logout();
c.disconnect();
CPPUNIT_ASSERT_MESSAGE(
"Failed to auth as user with TcpClient: threw NutException",
noException);
}
} // namespace nut {}
#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS || defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS)
#pragma GCC diagnostic pop
#endif

View file

@ -2,6 +2,7 @@
Copyright (C)
2012 Emilien Kia <emilienkia-guest@alioth.debian.org>
2020 Jim Klimov <jimklimov@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -18,27 +19,75 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdexcept>
#include <cppunit/TestResult.h>
#include <cppunit/CompilerOutputter.h>
#include <cppunit/TextTestProgressListener.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/ui/text/TestRunner.h>
#include "common.h"
// Inspired by https://stackoverflow.com/a/66702001
class MyCustomProgressTestListener : public CppUnit::TextTestProgressListener {
public:
virtual void startTest(CppUnit::Test *test) override;
};
// Implement out of class declaration to avoid
// error: 'MyCustomProgressTestListener' has no out-of-line virtual method
// definitions; its vtable will be emitted in every translation unit
// [-Werror,-Wweak-vtables]
void MyCustomProgressTestListener::startTest(CppUnit::Test *test) {
//fprintf(stderr, "starting test %s\n", test->getName().c_str());
std::cerr << "starting test " << test->getName() << std::endl;
}
int main(int argc, char* argv[])
{
bool verbose = false;
if (argc > 1) {
if (strcmp("-v", argv[1]) == 0 || strcmp("--verbose", argv[1]) == 0 ) {
verbose = true;
}
}
/* Get the top level suite from the registry */
std::cerr << "D: Getting test suite..." << std::endl;
CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
/* Adds the test to the list of test to run */
std::cerr << "D: Preparing test runner..." << std::endl;
CppUnit::TextUi::TestRunner runner;
runner.addTest( suite );
/* Change the default outputter to a compiler error format outputter */
std::cerr << "D: Setting test runner outputter..." << std::endl;
runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
std::cerr ) );
if (verbose) {
/* Add a listener to report test names */
std::cerr << "D: Setting test runner listener for test names..." << std::endl;
MyCustomProgressTestListener progress;
runner.eventManager().addListener(&progress);
}
/* Run the tests. */
bool wasSucessful = runner.run();
bool wasSucessful = false;
try {
std::cerr << "D: Launching the test run..." << std::endl;
wasSucessful = runner.run();
}
catch ( std::invalid_argument &e ) // Test path not resolved
{
std::cerr << std::endl
<< "ERROR: " << e.what()
<< std::endl;
wasSucessful = false;
}
/* Return error code 1 if the one of test failed. */
std::cerr << "D: Got to the end of test suite with code " <<
"'" << ( wasSucessful ? "true" : "false" ) << "'" << std::endl;
return wasSucessful ? 0 : 1;
}

View file

@ -2,6 +2,7 @@
Copyright (C)
2012 Emilien Kia <emilienkia-guest@alioth.debian.org>
2020 Jim Klimov <jimklimov@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -17,6 +18,20 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "common.h"
/* Current CPPUnit offends the honor of C++98 */
#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS || defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS)
#pragma GCC diagnostic push
# ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS
# pragma GCC diagnostic ignored "-Wglobal-constructors"
# endif
# ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS
# pragma GCC diagnostic ignored "-Wexit-time-destructors"
# endif
#endif
#include <cppunit/extensions/HelperMacros.h>
class ExampleTest : public CppUnit::TestFixture
@ -26,8 +41,8 @@ class ExampleTest : public CppUnit::TestFixture
CPPUNIT_TEST_SUITE_END();
public:
void setUp();
void tearDown();
void setUp() override;
void tearDown() override;
void testOne();
};
@ -53,10 +68,12 @@ void ExampleTest::testOne()
float f = 1.0;
// Process
int cast = (int)f;
int cast = static_cast<int>(f);
// Check
CPPUNIT_ASSERT_EQUAL( i, cast );
}
#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS || defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS)
#pragma GCC diagnostic pop
#endif

282
tests/getvaluetest.c Normal file
View file

@ -0,0 +1,282 @@
/* getvaluetest - check that the bitness/endianness dependent conversions
* of representation of numeric types between wire protocols and different
* CPU computations produce expected results.
*
* See also:
* https://github.com/networkupstools/nut/pull/1055
* https://github.com/networkupstools/nut/pull/1040
* https://github.com/networkupstools/nut/pull/1024
* https://github.com/networkupstools/nut/issues/1023
*
* Copyright (C)
* 2021 Nick Briggs <nicholas.h.briggs@gmail.com>
* 2022 Jim Klimov <jimklimov+nut@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include <stdint.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hidtypes.h"
#include "usb-common.h"
#include "common.h"
void GetValue(const unsigned char *Buf, HIDData_t *pData, long *pValue);
static void Usage(char *name) {
printf("%s [<buf> <offset> <size> <min> <max> <expect>]\n", name);
printf(" <buf> - string of hex digit pairs, space separated\n");
printf(" <offset> - offset of the report item value in bits, typically 0..31\n");
printf(" <size> - size of the report item value in bits: typically 1..32\n");
printf(" <min> - logical minimum value for report item\n");
printf(" <max> - logical maximum value for report item\n");
printf(" <expect> - expected value\n");
printf("\n");
printf("%s \"0c 64 11 0d\" 8 16 0 65535 3345\n", name);
printf("\nIf no arguments are given a builtin set of tests are run.\n");
}
static void PrintBufAndData(uint8_t *buf, size_t bufSize, HIDData_t *pData) {
size_t i;
printf("buf \"");
for (i = 0; i < bufSize - 1; i++) {
printf("%02x ", buf[i]);
}
printf("%02x\"", buf[bufSize - 1]);
printf(" offset %u size %u logmin %ld (0x%lx) logmax %ld (0x%lx)",
pData->Offset, pData->Size, pData->LogMin, pData->LogMin, pData->LogMax, pData->LogMax);
}
static int RunBuiltInTests(char *argv[]) {
NUT_UNUSED_VARIABLE(argv);
int exitStatus = 0;
size_t i;
char *next;
uint8_t reportBuf[64];
size_t bufSize;
HIDData_t data;
long value;
static struct {
char *buf; /* item data, starts with report id byte, then remaining report bytes */
uint8_t Offset; /* item offset in bits, typically 0..31 */
uint8_t Size; /* item size in bits, typically 1..32 */
long LogMin, LogMax; /* logical minimum and maximum values */
long expectedValue; /* the expected result of decoding the value in the buffer */
} testData[] = {
{.buf = "00 ff ff ff ff", .Offset = 0, .Size = 32, .LogMin = -1, .LogMax = 2147483647, .expectedValue = -1},
{.buf = "00 ff", .Offset = 0, .Size = 8, .LogMin = -1, .LogMax = 127, .expectedValue = -1},
{.buf = "00 ff", .Offset = 0, .Size = 8, .LogMin = 0, .LogMax = 127, .expectedValue = 127},
{.buf = "00 ff", .Offset = 0, .Size = 8, .LogMin = 0, .LogMax = 255, .expectedValue = 255},
{.buf = "33 00 0a 08 80", .Offset = 0, .Size = 32, .LogMin = 0, .LogMax = 65535, .expectedValue = 2560},
{.buf = "00 00 08 00 00", .Offset = 0, .Size = 32, .LogMin = 0, .LogMax = 65535, .expectedValue = 2048},
{.buf = "06 00 00 08", .Offset = 0, .Size = 8, .LogMin = 0, .LogMax = 255, .expectedValue = 0},
{.buf = "06 00 00 08", .Offset = 8, .Size = 8, .LogMin = 0, .LogMax = 255, .expectedValue = 0},
{.buf = "06 00 00 08", .Offset = 16, .Size = 8, .LogMin = 0, .LogMax = 255, .expectedValue = 8},
{.buf = "16 0c 00 00 00", .Offset = 0, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 0},
{.buf = "16 0c 00 00 00", .Offset = 1, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 0},
{.buf = "16 0c 00 00 00", .Offset = 2, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 1},
{.buf = "16 0c 00 00 00", .Offset = 3, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 1},
{.buf = "16 0c 00 00 00", .Offset = 4, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 0},
{.buf = "16 0c 00 00 00", .Offset = 5, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 0},
{.buf = "16 0c 00 00 00", .Offset = 6, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 0},
{.buf = "16 0c 00 00 00", .Offset = 7, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 0},
{.buf = "16 0c 00 00 00", .Offset = 8, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 0},
{.buf = "16 0c 00 00 00", .Offset = 9, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 0},
{.buf = "16 0c 00 00 00", .Offset = 10, .Size = 1, .LogMin = 0, .LogMax = 1, .expectedValue = 0}
};
for (i = 0; i < sizeof(testData)/sizeof(testData[0]); i++) {
next = testData[i].buf;
for (bufSize = 0; *next != 0; bufSize++) {
reportBuf[bufSize] = (uint8_t) strtol(next, (char **)&next, 16);
}
memset((void *)&data, 0, sizeof(data));
data.Offset = testData[i].Offset;
data.Size = testData[i].Size;
data.LogMin = testData[i].LogMin;
data.LogMax = testData[i].LogMax;
GetValue(reportBuf, &data, &value);
printf("Test #%zd ", i + 1);
PrintBufAndData(reportBuf, bufSize, &data);
if (value == testData[i].expectedValue) {
printf(" value %ld PASS\n", value);
} else {
printf(" value %ld FAIL expected %ld\n", value, testData[i].expectedValue);
exitStatus = 1;
}
}
/* Emulate rdlen calculations in libusb{0,1}.c or
* langid calculations in nutdrv_qx.c; in these
* cases we take two bytes (cast from usb_ctrl_char
* type, may be signed depending on used API version)
* from the protocol buffer, and build a platform
* dependent representation of a two-byte word.
*/
usb_ctrl_char bufC[2];
signed char bufS[2];
unsigned char bufU[2];
int rdlen;
/* Example from issue https://github.com/networkupstools/nut/issues/1261
* where resulting length 0x01a9 should be "425" but ended up "-87" */
bufC[0] = (usb_ctrl_char)0xa9;
bufC[1] = (usb_ctrl_char)0x01;
bufS[0] = (signed char)0xa9;
bufS[1] = (signed char)0x01;
bufU[0] = (unsigned char)0xa9;
bufU[1] = (unsigned char)0x01;
/* Check different conversion methods and hope current build CPU,
* C implementation etc. do not mess up bit-shifting vs rotation,
* zeroing high bits, int type width extension et al. If something
* is mismatched below, the production NUT code may need adaptations
* for that platform to count stuff correctly!
*/
printf("\nTesting bit-shifting approaches used in codebase to get 2-byte int lengths from wire bytes:\n");
printf("(Expected correct value is '425', incorrect '-87' or other)\n");
#define REPORT_VERDICT(expected) { if (expected) { printf(" - PASS\n"); } else { printf(" - FAIL\n"); exitStatus = 1; } }
rdlen = bufC[0] | (bufC[1] << 8);
printf(" * reference: no casting, usb_ctrl_char :\t%d\t(depends on libusb API built against)", rdlen);
REPORT_VERDICT (rdlen == 425 || rdlen == -87)
rdlen = bufS[0] | (bufS[1] << 8);
printf(" * reference: no casting, signed char :\t%d\t(expected '-87' here)", rdlen);
REPORT_VERDICT (rdlen == -87)
rdlen = bufU[0] | (bufU[1] << 8);
printf(" * reference: no casting, unsigned char :\t%d\t(expected '425')", rdlen);
REPORT_VERDICT (rdlen == 425)
rdlen = (uint8_t)bufC[0] | ((uint8_t)bufC[1] << 8);
printf(" * uint8_t casting, usb_ctrl_char :\t%d", rdlen);
REPORT_VERDICT (rdlen == 425)
rdlen = (uint8_t)bufS[0] | ((uint8_t)bufS[1] << 8);
printf(" * uint8_t casting, signed char :\t%d", rdlen);
REPORT_VERDICT (rdlen == 425)
rdlen = (uint8_t)bufU[0] | ((uint8_t)bufU[1] << 8);
printf(" * uint8_t casting, unsigned char :\t%d", rdlen);
REPORT_VERDICT (rdlen == 425)
rdlen = ((uint8_t)bufC[0]) | (((uint8_t)bufC[1]) << 8);
printf(" * uint8_t casting with parentheses, usb_ctrl_char :\t%d", rdlen);
REPORT_VERDICT (rdlen == 425)
rdlen = ((uint8_t)bufS[0]) | (((uint8_t)bufS[1]) << 8);
printf(" * uint8_t casting with parentheses, signed char :\t%d", rdlen);
REPORT_VERDICT (rdlen == 425)
rdlen = ((uint8_t)bufU[0]) | (((uint8_t)bufU[1]) << 8);
printf(" * uint8_t casting with parentheses, unsigned char :\t%d", rdlen);
REPORT_VERDICT (rdlen == 425)
rdlen = ((uint16_t)(bufC[0]) & 0x00FF) | (((uint16_t)(bufC[1]) & 0x00FF) << 8);
printf(" * uint16_t casting with 8-bit mask, usb_ctrl_char :\t%d", rdlen);
REPORT_VERDICT (rdlen == 425)
rdlen = ((uint16_t)(bufS[0]) & 0x00FF) | (((uint16_t)(bufS[1]) & 0x00FF) << 8);
printf(" * uint16_t casting with 8-bit mask, signed char :\t%d", rdlen);
REPORT_VERDICT (rdlen == 425)
rdlen = ((uint16_t)(bufU[0]) & 0x00FF) | (((uint16_t)(bufU[1]) & 0x00FF) << 8);
printf(" * uint16_t casting with 8-bit mask, unsigned char :\t%d", rdlen);
REPORT_VERDICT (rdlen == 425)
rdlen = 256 * (uint8_t)(bufC[1]) + (uint8_t)(bufC[0]);
printf(" * uint8_t casting with multiplication, usb_ctrl_char :\t%d", rdlen);
REPORT_VERDICT (rdlen == 425)
rdlen = 256 * (uint8_t)(bufS[1]) + (uint8_t)(bufS[0]);
printf(" * uint8_t casting with multiplication, signed char :\t%d", rdlen);
REPORT_VERDICT (rdlen == 425)
rdlen = 256 * (uint8_t)(bufU[1]) + (uint8_t)(bufU[0]);
printf(" * uint8_t casting with multiplication, unsigned char :\t%d", rdlen);
REPORT_VERDICT (rdlen == 425)
return (exitStatus);
}
static int RunCommandLineTest(char *argv[]) {
uint8_t reportBuf[64];
size_t bufSize;
char *start, *end;
HIDData_t data;
long value, expectedValue;
start = argv[1];
end = NULL;
for (bufSize = 0; *start != 0; bufSize++) {
reportBuf[bufSize] = (uint8_t) strtol(start, (char **)&end, 16);
if (start == end) break;
start = end;
}
memset((void *)&data, 0, sizeof(data));
data.Offset = (uint8_t) atoi(argv[2]);
data.Size = (uint8_t) atoi(argv[3]);
data.LogMin = strtol(argv[4], 0, 0);
data.LogMax = strtol(argv[5], 0, 0);
expectedValue = strtol(argv[6], 0, 0);
GetValue(reportBuf, &data, &value);
printf("Test #0 ");
PrintBufAndData(reportBuf, bufSize, &data);
if (value == expectedValue) {
printf(" value %ld PASS\n", value);
return (0);
} else {
printf(" value %ld FAIL expected %ld\n", value, expectedValue);
return (1);
}
}
int main (int argc, char *argv[]) {
int status;
switch (argc) {
case 1:
status = RunBuiltInTests(argv);
break;
case 7:
status = RunCommandLineTest(argv);
break;
default:
Usage(argv[0]);
status = 2;
}
return(status);
}

View file

@ -0,0 +1,71 @@
# This is an ups.conf file for nut-driver-enumerator-test.sh
# It is intentionally written in different samples of markup,
# do not clean it up ;)
maxstartdelay=180
globalflag
[dummy1]
driver = dummy-ups
port = file1.dev
desc = "This is ups-1"
[epdu-2]
# This is an ePDU
driver=netxml-ups
port="http://172.16.1.2"
synchronous=yes
[epdu-2-snmp]
driver=snmp-ups
port=172.16.1.2
synchronous=no
[usb_3]
driver = "usbhid-ups"
port = "auto"
[serial.4]
driver = serial-ups
driverflag
port = /dev/ttyS1 # some path
[dummy-proxy]
driver = "dummy-ups "
port = remoteUPS@RemoteHost.local
[dummy-proxy-localhost]
driver = 'dummy-ups '
port = "localUPS@127.0.0.1"
[valueHasEquals]
driver = dummy=ups
port = file1.dev # key = val, right?
[valueHasHashtag]
driver = dummy-ups
port = file#1.dev
[valueHasQuotedHashtag]
driver = dummy-ups
port = "file#1.dev"
[qx-serial]
driver=nutdrv_qx
port = /dev/ttyb
[qx-usb1]
driver=nutdrv_qx
port = auto
[qx-usb2]
driver=nutdrv_qx
port = /dev/usb/8
[sectionWithComment]# Some comment
driver=nutdrv_qx#comment
port = /dev/usb/8
desc="value with [brackets]"
[brackets with spaces are not sections] # but rather an invalid mess as binary parser may think
[sectionWithCommentWhitespace] # Some comment with a space and tab
driver=nutdrv_qx # comment
port = /dev/usb/8 # comment
commentedDriverFlag # This flag gotta mean something

View file

@ -0,0 +1,314 @@
#!/bin/sh
# Copyright (C) 2018 Eaton
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
#! \file nut-driver-enumerator-test.sh
# \author Jim Klimov <EvgenyKlimov@eaton.com>
# \brief Self-test for nut-driver-enumerator.sh utility
# \details Automated sanity test for nut-driver-enumerator.sh(.in)
# using different shells (per $SHELL_PROGS) and CLI requests
# for regression and compatibility tests as well as for TDD
# fueled by pre-decided expected outcomes.
### Use a standard locale setup so sorting in expected results is not confused
LANG=C
LC_ALL=C
TZ=UTC
export LANG LC_ALL TZ
### Note: These are relative to where the selftest script lives,
### not the NUT top_srcdir etc. They can be exported by a Makefile.
[ -n "${BUILDDIR-}" ] || BUILDDIR="`dirname $0`"
[ -n "${SRCDIR-}" ] || SRCDIR="`dirname $0`"
[ -n "${SHELL_PROGS-}" ] || SHELL_PROGS="/bin/sh"
case "${DEBUG-}" in
[Yy]|[Yy][Ee][Ss]) DEBUG=yes ;;
[Tt][Rr][Aa][Cc][Ee]) DEBUG=trace ;;
*) DEBUG="" ;;
esac
SYSTEMD_CONFPATH="${BUILDDIR}/selftest-rw/systemd-units"
export SYSTEMD_CONFPATH
NUT_CONFPATH="${BUILDDIR}/selftest-rw/nut"
export NUT_CONFPATH
[ -n "${UPSCONF-}" ] || UPSCONF="${SRCDIR}/nut-driver-enumerator-test--ups.conf"
[ ! -s "${UPSCONF-}" ] && echo "FATAL : testing ups.conf not found as '$UPSCONF'" >&2 && exit 1
export UPSCONF
if [ ! -n "${NDE-}" ] ; then
for NDE in \
"${BUILDDIR}/../scripts/upsdrvsvcctl/nut-driver-enumerator.sh" \
"${SRCDIR}/../scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in" \
; do [ -s "$NDE" ] && break ; done
fi
[ ! -s "${NDE-}" ] && echo "FATAL : testing nut-driver-enumerator.sh implementation not found as '$NDE'" >&2 && exit 1
# TODO : Add tests that generate configuration files for units
#mkdir -p "${NUT_CONFPATH}" "${SYSTEMD_CONFPATH}" || exit
FAIL_COUNT=0
GOOD_COUNT=0
callNDE() {
case "$DEBUG" in
yes) time $USE_SHELL $NDE "$@" ;;
trace) time $USE_SHELL -x $NDE "$@" ;;
*) $USE_SHELL $NDE "$@" 2>/dev/null ;;
esac
}
run_testcase() {
# First 3 args are required as defined below; the rest are
# CLI arg(s) to nut-driver-enumerator.sh
CASE_DESCR="$1"
EXPECT_CODE="$2"
EXPECT_TEXT="$3"
shift 3
printf "Testing : SHELL='%s'\tCASE='%s'\t" "$USE_SHELL" "$CASE_DESCR"
OUT="`callNDE "$@"`" ; RESCODE=$?
printf "Got : RESCODE='%s'\t" "$RESCODE"
RES=0
if [ "$RESCODE" = "$EXPECT_CODE" ]; then
printf "STATUS_CODE='MATCHED'\t"
GOOD_COUNT="`expr $GOOD_COUNT + 1`"
else
printf "STATUS_CODE='MISMATCH' expect_code=%s received_code=%s\t" "$EXPECT_CODE" "$RESCODE" >&2
FAIL_COUNT="`expr $FAIL_COUNT + 1`"
RES="`expr $RES + 1`"
fi
if [ "$OUT" = "$EXPECT_TEXT" ]; then
printf "STATUS_TEXT='MATCHED'\n"
GOOD_COUNT="`expr $GOOD_COUNT + 1`"
else
printf "STATUS_TEXT='MISMATCH'\n"
printf '\t--- expected ---\n%s\n\t--- received ---\n%s\n\t--- MISMATCH ABOVE\n\n' "$EXPECT_TEXT" "$OUT" >&2
# Give a nice output to help track the problem:
( rm -f "/tmp/.nde.text.expected.$$" "/tmp/.nde.text.actual.$$" \
&& echo "$EXPECT_TEXT" > "/tmp/.nde.text.expected.$$" \
&& echo "$OUT" > "/tmp/.nde.text.actual.$$" \
&& diff -u "/tmp/.nde.text.expected.$$" "/tmp/.nde.text.actual.$$" ) 2>/dev/null || true
rm -f "/tmp/.nde.text.expected.$$" "/tmp/.nde.text.actual.$$"
FAIL_COUNT="`expr $FAIL_COUNT + 1`"
RES="`expr $RES + 2`"
fi
if [ "$RES" != 0 ] || [ -n "$DEBUG" ] ; then echo "" ; fi
return $RES
}
##################################################################
# Note: expectations in test cases below are tightly connected #
# to both the current code in the script and content of the test #
# configuration file. #
##################################################################
testcase_bogus_args() {
run_testcase "Reject unknown args" 1 "" \
--some-bogus-arg
}
testcase_list_all_devices() {
# We expect a list of unbracketed names from the device sections
# Note: unlike other outputs, this list is alphabetically sorted
run_testcase "List all device names from sections" 0 \
"dummy-proxy
dummy-proxy-localhost
dummy1
epdu-2
epdu-2-snmp
qx-serial
qx-usb1
qx-usb2
sectionWithComment
sectionWithCommentWhitespace
serial.4
usb_3
valueHasEquals
valueHasHashtag
valueHasQuotedHashtag" \
--list-devices
}
testcase_show_all_configs() {
# We expect whitespace trimmed, comment-only lines removed
run_testcase "Show all configs" 0 \
'maxstartdelay=180
globalflag
[dummy1]
driver=dummy-ups
port=file1.dev
desc="This is ups-1"
[epdu-2]
driver=netxml-ups
port=http://172.16.1.2
synchronous=yes
[epdu-2-snmp]
driver=snmp-ups
port=172.16.1.2
synchronous=no
[usb_3]
driver=usbhid-ups
port=auto
[serial.4]
driver=serial-ups
driverflag
port=/dev/ttyS1 # some path
[dummy-proxy]
driver="dummy-ups "
port=remoteUPS@RemoteHost.local
[dummy-proxy-localhost]
driver='"'dummy-ups '"'
port=localUPS@127.0.0.1
[valueHasEquals]
driver=dummy=ups
port=file1.dev # key = val, right?
[valueHasHashtag]
driver=dummy-ups
port=file#1.dev
[valueHasQuotedHashtag]
driver=dummy-ups
port=file#1.dev
[qx-serial]
driver=nutdrv_qx
port=/dev/ttyb
[qx-usb1]
driver=nutdrv_qx
port=auto
[qx-usb2]
driver=nutdrv_qx
port=/dev/usb/8
[sectionWithComment]
driver=nutdrv_qx#comment
port=/dev/usb/8
desc="value with [brackets]"
[brackets with spaces are not sections] # but rather an invalid mess as binary parser may think
[sectionWithCommentWhitespace]
driver=nutdrv_qx # comment
port=/dev/usb/8 # comment
commentedDriverFlag # This flag gotta mean something' \
--show-all-configs
}
testcase_upslist_debug() {
# We expect a list of names, ports and decided MEDIA type (for dependencies)
run_testcase "List decided MEDIA and config checksums for all devices" 0 \
"INST: 68b329da9893e34099c7d8ad5cb9c940~[]: DRV='' PORT='' MEDIA='' SECTIONMD5='9a1f372a850f1ee3ab1fc08b185783e0'
INST: 010cf0aed6dd49865bb49b70267946f5~[dummy-proxy]: DRV='dummy-ups ' PORT='remoteUPS@RemoteHost.local' MEDIA='network' SECTIONMD5='aff543fc07d7fbf83e81001b181c8b97'
INST: 1ea79c6eea3681ba73cc695f3253e605~[dummy-proxy-localhost]: DRV='dummy-ups ' PORT='localUPS@127.0.0.1' MEDIA='network-localhost' SECTIONMD5='73e6b7e3e3b73558dc15253d8cca51b2'
INST: 76b645e28b0b53122b4428f4ab9eb4b9~[dummy1]: DRV='dummy-ups' PORT='file1.dev' MEDIA='' SECTIONMD5='9e0a326b67e00d455494f8b4258a01f1'
INST: a293d65e62e89d6cc3ac6cb88bc312b8~[epdu-2]: DRV='netxml-ups' PORT='http://172.16.1.2' MEDIA='network' SECTIONMD5='0d9a0147dcf87c7c720e341170f69ed4'
INST: 9a5561464ff8c78dd7cb544740ce2adc~[epdu-2-snmp]: DRV='snmp-ups' PORT='172.16.1.2' MEDIA='network' SECTIONMD5='2631b6c21140cea0dd30bb88b942ce3f'
INST: 16adbdafb22d9fdff1d09038520eb32e~[qx-serial]: DRV='nutdrv_qx' PORT='/dev/ttyb' MEDIA='serial' SECTIONMD5='e3e6e586fbe5b3c0a89432f4b993f4ad'
INST: a21bd2b786228b9619f6adba6db8fa83~[qx-usb1]: DRV='nutdrv_qx' PORT='auto' MEDIA='usb' SECTIONMD5='a6139c5da35bef89dc5b96e2296f5369'
INST: 0066605e07c66043a17eccecbeea1ac5~[qx-usb2]: DRV='nutdrv_qx' PORT='/dev/usb/8' MEDIA='usb' SECTIONMD5='5722dd9c21d07a1f5bcb516dbc458deb'
INST: 1280a731e03116f77290e51dd2a2f37e~[sectionWithComment]: DRV='nutdrv_qx#comment' PORT='/dev/usb/8' MEDIA='' SECTIONMD5='be30e15e17d0579c85eecaf176b4a064'
INST: 770abd5659061a29ed3ae4f7c0b00915~[sectionWithCommentWhitespace]: DRV='nutdrv_qx # comment' PORT='/dev/usb/8 # comment' MEDIA='' SECTIONMD5='c757822a331521cdc97310d0241eba28'
INST: efdb1b4698215fdca36b9bc06d24661d~[serial.4]: DRV='serial-ups' PORT='/dev/ttyS1 # some path' MEDIA='' SECTIONMD5='9c485f733aa6d6c85c1724f162929443'
INST: f4a1c33db201c2ca897a3337993c10fc~[usb_3]: DRV='usbhid-ups' PORT='auto' MEDIA='usb' SECTIONMD5='1f6a24becde9bd31c9852610658ef84a'
INST: 8e5686f92a5ba11901996c813e7bb23d~[valueHasEquals]: DRV='dummy=ups' PORT='file1.dev # key = val, right?' MEDIA='' SECTIONMD5='2f04d65da53e3b13771bb65422f0f4c0'
INST: 99da99b1e301e84f34f349443aac545b~[valueHasHashtag]: DRV='dummy-ups' PORT='file#1.dev' MEDIA='' SECTIONMD5='6029bda216de0cf1e81bd55ebd4a0fff'
INST: d50c3281f9b68a94bf9df72a115fbb5c~[valueHasQuotedHashtag]: DRV='dummy-ups' PORT='file#1.dev' MEDIA='' SECTIONMD5='af59c3c0caaa68dcd796d7145ae403ee'" \
upslist_debug
# FIXME : in [valueHasEquals] and [serial.4] the PORT value is quite bogus
# with its embedded comments. Check vs. binary config parser, whether in
# unquoted case only first token is the valid value, and how comments are
# handled in general?
# FIXME : in [valueHasHashtag] the line after "#" should likely be dropped
# (check in binary config parser first) while in [valueHasQuotedHashtag]
# it should stay.
}
testcase_getValue() {
run_testcase "Query a configuration key (SDP)" 0 \
"file1.dev" \
--show-device-config-value dummy1 port
run_testcase "Query a configuration key (other)" 0 \
"yes" \
--show-device-config-value epdu-2 synchronous
run_testcase "Query a configuration key (originally quoted)" 0 \
'This is ups-1' \
--show-device-config-value dummy1 desc
run_testcase "Query a configuration flag (driver)" 0 \
"driverflag" \
--show-config-value 'serial.4' driverflag
run_testcase "Query a missing configuration flag (driver)" 1 \
"" \
--show-config-value 'valueHasQuotedHashtag' nosuchflag
run_testcase "Query multiple configuration keys (originally quoted)" 0 \
'This is ups-1
file1.dev' \
--show-device-config-value dummy1 desc port
run_testcase "Query multiple configuration keys with some missing (originally quoted)" 1 \
'This is ups-1
file1.dev' \
--show-device-config-value dummy1 desc unknownkey port
}
testcase_globalSection() {
run_testcase "Display global config" 0 \
"maxstartdelay=180
globalflag" \
--show-config ''
run_testcase "Query a configuration key (global)" 0 \
"180" \
--show-config-value '' maxstartdelay
run_testcase "Query a configuration flag (global)" 0 \
"globalflag" \
--show-config-value '' globalflag
run_testcase "Query a missing configuration flag (global)" 1 \
"" \
--show-config-value '' nosuchflag
}
# Combine the cases above into a stack
testsuite() {
testcase_bogus_args
testcase_list_all_devices
testcase_show_all_configs
testcase_getValue
testcase_globalSection
# This one can take a while, put it last
testcase_upslist_debug
}
# If no args...
for USE_SHELL in $SHELL_PROGS ; do
case "$USE_SHELL" in
busybox|busybox_sh) USE_SHELL="busybox sh" ;;
esac
testsuite
done
# End of loop over shells
echo "Test suite for nut-driver-enumerator has completed with $FAIL_COUNT failed cases and $GOOD_COUNT good cases" >&2
[ "$FAIL_COUNT" = 0 ] || { echo "As a developer, you may want to export DEBUG=trace or export DEBUG=yes and re-run the test; also make sure you meant the nut-driver-enumerator.sh implementation as NDE='$NDE'" >&2 ; exit 1; }

525
tests/nutclienttest.cpp Normal file
View file

@ -0,0 +1,525 @@
/* nutclienttest - CppUnit nutclient unit test
Copyright (C) 2016 Emilien Kia <emilien.kia@gmail.com>
Copyright (C) 2020 - 2021 Jim Klimov <jimklimov@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "common.h"
/* Current CPPUnit offends the honor of C++98 */
#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS || defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS)
#pragma GCC diagnostic push
# ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS
# pragma GCC diagnostic ignored "-Wglobal-constructors"
# endif
# ifdef HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS
# pragma GCC diagnostic ignored "-Wexit-time-destructors"
# endif
#endif
#include <cppunit/extensions/HelperMacros.h>
namespace nut {
class NutClientTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( NutClientTest );
CPPUNIT_TEST( test_strarr_alloc );
CPPUNIT_TEST( test_stringset_to_strarr );
CPPUNIT_TEST( test_stringvector_to_strarr );
CPPUNIT_TEST( test_copy_constructor_dev );
CPPUNIT_TEST( test_copy_assignment_dev );
CPPUNIT_TEST( test_copy_constructor_cmd );
CPPUNIT_TEST( test_copy_assignment_cmd );
CPPUNIT_TEST( test_copy_constructor_var );
CPPUNIT_TEST( test_copy_assignment_var );
CPPUNIT_TEST( test_nutclientstub_dev );
CPPUNIT_TEST_SUITE_END();
public:
void setUp() override;
void tearDown() override;
void test_strarr_alloc();
void test_stringset_to_strarr();
void test_stringvector_to_strarr();
void test_copy_constructor_dev();
void test_copy_assignment_dev();
void test_copy_constructor_cmd();
void test_copy_assignment_cmd();
void test_copy_constructor_var();
void test_copy_assignment_var();
void test_nutclientstub_dev();
};
// Registers the fixture into the 'registry'
CPPUNIT_TEST_SUITE_REGISTRATION( NutClientTest );
} // namespace nut {}
#ifndef _NUTCLIENTTEST_BUILD
# define _NUTCLIENTTEST_BUILD 1
#endif
#include "../clients/nutclient.h"
#include "../clients/nutclientmem.h"
namespace nut {
extern "C" {
strarr stringset_to_strarr(const std::set<std::string>& strset);
strarr stringvector_to_strarr(const std::vector<std::string>& strset);
} // extern "C"
void NutClientTest::setUp()
{
}
void NutClientTest::tearDown()
{
}
void NutClientTest::test_strarr_alloc()
{
bool noException = true;
strarr arr = nullptr;
try {
arr = strarr_alloc(5);
}
catch(nut::NutException& ex)
{
NUT_UNUSED_VARIABLE(ex);
noException = false;
}
CPPUNIT_ASSERT_MESSAGE(
"Failed strarr_alloc(...): throw exception",
noException);
CPPUNIT_ASSERT_MESSAGE(
"Failed strarr_alloc(...): result is null",
arr != nullptr);
strarr_free(arr);
}
void NutClientTest::test_stringset_to_strarr()
{
std::set<std::string> strset;
strset.insert("test");
strset.insert("hello");
strset.insert("world");
strarr arr = stringset_to_strarr(strset);
CPPUNIT_ASSERT_MESSAGE(
"stringset_to_strarr(...) result is null",
arr != nullptr);
std::set<std::string> res;
char** ptr = arr;
while(*ptr != nullptr)
{
res.insert(std::string(*ptr));
ptr++;
}
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"stringset_to_strarr(...) result has not 3 items",
static_cast<size_t>(3), res.size());
CPPUNIT_ASSERT_MESSAGE(
"stringset_to_strarr(...) result has not item \"test\"",
res.find("test") != res.end());
CPPUNIT_ASSERT_MESSAGE(
"stringset_to_strarr(...) result has not item \"hello\"",
res.find("hello") != res.end());
CPPUNIT_ASSERT_MESSAGE(
"stringset_to_strarr(...) result has not item \"world\"",
res.find("world") != res.end());
strarr_free(arr);
}
void NutClientTest::test_stringvector_to_strarr()
{
std::vector<std::string> strset;
strset.push_back("test");
strset.push_back("hello");
strset.push_back("world");
strarr arr = stringvector_to_strarr(strset);
CPPUNIT_ASSERT_MESSAGE(
"stringvector_to_strarr(...) result is null",
arr != nullptr);
char** ptr = arr;
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"stringvector_to_strarr(...) result has not item 0==\"test\"",
std::string("test"), std::string(*ptr));
++ptr;
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"stringvector_to_strarr(...) result has not item 1==\"hello\"",
std::string("hello"), std::string(*ptr));
++ptr;
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"stringvector_to_strarr(...) result has not item 2==\"world\"",
std::string("world"), std::string(*ptr));
++ptr;
/* https://stackoverflow.com/a/12565009/4715872
* Can not compare nullptr_t and another data type (char*)
* with CPPUNIT template assertEquals()
*/
CPPUNIT_ASSERT_MESSAGE(
"stringvector_to_strarr(...) result has not only 3 items",
nullptr == *ptr);
strarr_free(arr);
}
void NutClientTest::test_copy_constructor_dev() {
nut::TcpClient c;
nut::Device i(&c, "ups1");
nut::Device j(i);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Failed to assign value of Device variable j by initializing from i",
i, j);
}
void NutClientTest::test_copy_assignment_dev() {
nut::TcpClient c;
nut::Device i(&c, "ups1");
nut::Device j(nullptr, "ups2");
CPPUNIT_ASSERT_ASSERTION_FAIL_MESSAGE(
"Device variables i and j were initialized differently "
"but claim to be equal",
CPPUNIT_ASSERT_EQUAL(i, j) );
j = i;
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Failed to assign value of Device Command j by equating to i",
i, j);
}
void NutClientTest::test_copy_constructor_cmd() {
nut::TcpClient c;
nut::Device d(nullptr, "ups1");
nut::Command i(&d, "cmd1");
nut::Command j(i);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Failed to assign value of Command variable j by initializing from i",
i, j);
}
void NutClientTest::test_copy_assignment_cmd() {
nut::TcpClient c;
nut::Device d(nullptr, "ups1");
nut::Command i(&d, "var1");
nut::Command j(nullptr, "var2");
CPPUNIT_ASSERT_ASSERTION_FAIL_MESSAGE(
"Command variables i and j were initialized differently "
"but claim to be equal",
CPPUNIT_ASSERT_EQUAL(i, j) );
j = i;
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Failed to assign value of Command variable j by equating to i",
i, j);
}
void NutClientTest::test_copy_constructor_var() {
nut::TcpClient c;
nut::Device d(nullptr, "ups1");
nut::Variable i(&d, "var1");
nut::Variable j(i);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Failed to assign value of Variable variable j by initializing from i",
i, j);
}
void NutClientTest::test_copy_assignment_var() {
nut::TcpClient c;
nut::Device d(nullptr, "ups1");
nut::Variable i(&d, "var1");
nut::Variable j(nullptr, "var2");
CPPUNIT_ASSERT_ASSERTION_FAIL_MESSAGE(
"Variable variables i and j were initialized differently "
"but claim to be equal",
CPPUNIT_ASSERT_EQUAL(i, j) );
j = i;
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"Failed to assign value of Variable variable j by equating to i",
i, j);
}
void NutClientTest::test_nutclientstub_dev() {
bool noException = true;
nut::MemClientStub c;
nut::Device d(nullptr, "ups_1");
try
{
// set mono value
c.setDeviceVariable("ups_1", "name_1", "value_1");
// get mono value
ListValue values = c.getDeviceVariableValue("ups_1", "name_1");
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: mono wrong values number",
values.size() == 1);
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: mono bad value",
values[0] == std::string("value_1"));
// set multi value
ListValue values_multi = { "multi_1", "multi_2" };
c.setDeviceVariable("ups_1", "name_multi_1", values_multi);
// get multi value
values = c.getDeviceVariableValue("ups_1", "name_multi_1");
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: multi wrong values number",
values.size() == 2);
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: multi first bad value",
values[0] == std::string("multi_1"));
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: multi second bad value",
values[1] == std::string("multi_2"));
// get object values
ListObject objects = c.getDeviceVariableValues("ups_1");
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: objects wrong values number",
objects.size() == 2);
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: objects mono wrong values number",
objects["name_1"].size() == 1);
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: objects mono bad value",
objects["name_1"][0] == std::string("value_1"));
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: objects multi wrong values number",
objects["name_multi_1"].size() == 2);
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: objects mono bad value",
objects["name_multi_1"][0] == std::string("multi_1"));
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: objects mono bad value",
objects["name_multi_1"][1] == std::string("multi_2"));
// get device values
std::set<std::string> devices_name = { "ups_1" };
ListDevice devices = c.getDevicesVariableValues(devices_name);
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: devices wrong values number",
devices.size() == 1);
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: devices mono wrong values number",
devices["ups_1"]["name_1"].size() == 1);
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: devices mono bad value",
devices["ups_1"]["name_1"][0] == std::string("value_1"));
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: devices multi wrong values number",
devices["ups_1"]["name_multi_1"].size() == 2);
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: devices mono bad value",
devices["ups_1"]["name_multi_1"][0] == std::string("multi_1"));
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: devices mono bad value",
devices["ups_1"]["name_multi_1"][1] == std::string("multi_2"));
}
catch(nut::NutException& ex)
{
NUT_UNUSED_VARIABLE(ex);
noException = false;
}
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: throw exception",
noException);
// List of functions not implemented (should return exception)
noException = true;
try {
std::set<std::string> cmd = c.getDeviceCommandNames("ups-1");
CPPUNIT_ASSERT_MESSAGE(
"Variable not use",
cmd.size() == 0);
}
catch(nut::NutException& ex)
{
NUT_UNUSED_VARIABLE(ex);
noException = false;
}
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: throw no exception",
!noException);
noException = true;
try {
std::string desc = c.getDeviceCommandDescription("ups-1", "cmd-1");
CPPUNIT_ASSERT_MESSAGE(
"Variable not use",
desc.empty());
}
catch(nut::NutException& ex)
{
NUT_UNUSED_VARIABLE(ex);
noException = false;
}
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: throw no exception",
!noException);
noException = true;
try {
TrackingID id = c.executeDeviceCommand("ups-1", "cmd-1", "param-1");
CPPUNIT_ASSERT_MESSAGE(
"Variable not use",
id.empty());
}
catch(nut::NutException& ex)
{
NUT_UNUSED_VARIABLE(ex);
noException = false;
}
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: throw no exception",
!noException);
noException = true;
try {
c.deviceLogin("ups-1");
}
catch(nut::NutException& ex)
{
NUT_UNUSED_VARIABLE(ex);
noException = false;
}
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: throw no exception",
!noException);
noException = true;
try {
c.deviceMaster("ups-1");
}
catch(nut::NutException& ex)
{
NUT_UNUSED_VARIABLE(ex);
noException = false;
}
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: throw no exception",
!noException);
noException = true;
try {
c.deviceForcedShutdown("ups-1");
}
catch(nut::NutException& ex)
{
NUT_UNUSED_VARIABLE(ex);
noException = false;
}
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: throw no exception",
!noException);
noException = true;
try {
c.deviceGetNumLogins("ups-1");
}
catch(nut::NutException& ex)
{
NUT_UNUSED_VARIABLE(ex);
noException = false;
}
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: throw no exception",
!noException);
noException = true;
try {
TrackingResult result = c.getTrackingResult("track-1");
CPPUNIT_ASSERT_MESSAGE(
"Variable not use",
result == TrackingResult::SUCCESS);
}
catch(nut::NutException& ex)
{
NUT_UNUSED_VARIABLE(ex);
noException = false;
}
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: throw no exception",
!noException);
noException = true;
try {
bool status = c.isFeatureEnabled(Feature("feature-1"));
CPPUNIT_ASSERT_MESSAGE(
"Variable not use",
!status);
}
catch(nut::NutException& ex)
{
NUT_UNUSED_VARIABLE(ex);
noException = false;
}
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: throw no exception",
!noException);
noException = true;
try {
c.setFeature(Feature("feature-1"), true);
}
catch(nut::NutException& ex)
{
NUT_UNUSED_VARIABLE(ex);
noException = false;
}
CPPUNIT_ASSERT_MESSAGE(
"Failed stub tcp client: throw no exception",
!noException);
}
} // namespace nut {}
#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_EXIT_TIME_DESTRUCTORS || defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_GLOBAL_CONSTRUCTORS)
#pragma GCC diagnostic pop
#endif

65
tests/nutlogtest.c Normal file
View file

@ -0,0 +1,65 @@
/* nutlogtest - some trivial usage for upslog*() and upsdebug*() related
* routines to sanity-check their code (compiler does not warn, test runs
* do not crash).
*
* Copyright (C)
* 2020 Jim Klimov <jimklimov@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "common.h"
int main(void) {
const char *s1 = "!NULL";
const char *s2 = NULL;
#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_OVERFLOW)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wformat-overflow"
#endif
upsdebugx(0, "D: checking with libc handling of NULL: '%s' vs '%s'", s1, s2);
/* This explicitly does not work with -Wformat, due to verbatim NULL without a var:
* nutlogtest.c:20:5: error: reading through null pointer (argument 4) [-Werror=format=]
* and also due to (void*) vs (char*) in naive case:
* upsdebugx(0, "D: '%s' vs '%s'", NUT_STRARG(NULL), NULL);
* but with casting the explicit NULL remains:
* upsdebugx(0, "D: '%s' vs '%s'", NUT_STRARG((char *)NULL), (char *)NULL);
*/
upsdebugx(0, "D: checking with NUT_STRARG macro: '%s' vs '%s'", NUT_STRARG(s2), s2);
#ifdef NUT_STRARG
#undef NUT_STRARG
#endif
#define NUT_STRARG(x) (x?x:"<N/A>")
/* This explicitly does not work with -Wformat, due to a NULL in the '%s'
* format string expansion (e.g. due to NUT PR #675 conversion to macros):
* ../include/common.h:155:41: warning: '%s' directive argument is null [-Wformat-overflow=]
* <...snip...>
* nutlogtest.c:45:63: note: format string is defined here
* 45 | upsdebugx(0, "D: checking with NUT_STRARG macro: '%s' vs '%s'", NUT_STRARG(s2), s2);
* | ^~
*/
upsdebugx(0, "D: checking that macro wrap trick works: '%s' vs '%s'", NUT_STRARG(s2), s2);
#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_OVERFLOW)
# pragma GCC diagnostic pop
#endif
return 0;
}