Skip to content

Commit 01401fa

Browse files
authored
Merge d3070a0 into 14dd0a7
2 parents 14dd0a7 + d3070a0 commit 01401fa

6 files changed

Lines changed: 34 additions & 15 deletions

File tree

NEWS.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,9 @@ https://github.com/networkupstools/nut/milestone/12
274274
to bumping the debug verbosity of `upsdrvctl` tool. [#3276]
275275
* If we fail to stop a driver by signal (e.g. PID file was not saved),
276276
retry to `INSTCMD driver.exit` it by socket protocol. [#3277]
277+
* The NUT Integration Testing suite now also involves `upsdrvctl` to
278+
run one driver instance indirectly, helping make check-NIT` catch
279+
portability issues with different builds of the tool. [#2800, #3292]
277280

278281
- `upslog` tool updates:
279282
* Updated `help()` and failure messages to suggest `-m '*,-'` for logging

configure.ac

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3445,7 +3445,7 @@ if test x"${nut_with_nut_monitor}" != xno ; then
34453445
PYTHON2_TEST_MODULES="re,glob,codecs,gtk,gtk.glade,gobject,ConfigParser"
34463446
PYTHON3_TEST_MODULES_QT5="re,glob,codecs,PyQt5.uic,configparser"
34473447
PYTHON3_TEST_MODULES_QT6="re,glob,codecs,PyQt6.uic,configparser"
3448-
if test -n "${PYTHON2_VERSION_INFO_REPORT}" ; then
3448+
if test -n "${PYTHON2_VERSION_INFO_REPORT}" -a -n "${PYTHON2}" ; then
34493449
AC_MSG_CHECKING([if we have Python2 prerequisites for NUT-Monitor desktop application])
34503450
if ${PYTHON2} -c "import ${PYTHON2_TEST_MODULES}" 1>&5 2>&5 \
34513451
; then
@@ -3499,7 +3499,7 @@ if test x"${nut_with_nut_monitor}" != xno ; then
34993499
fi
35003500
fi
35013501

3502-
if test -n "${PYTHON3_VERSION_INFO_REPORT}" ; then
3502+
if test -n "${PYTHON3_VERSION_INFO_REPORT}" -a -n "${PYTHON3}" ; then
35033503
AC_MSG_CHECKING([if we have Python3 Qt5 prerequisites for NUT-Monitor desktop application])
35043504
if ${PYTHON3} -c "import ${PYTHON3_TEST_MODULES_QT5}" 1>&5 2>&5 \
35053505
; then
@@ -3515,7 +3515,7 @@ if test x"${nut_with_nut_monitor}" != xno ; then
35153515
fi
35163516
fi
35173517

3518-
if test -n "${PYTHON3_VERSION_INFO_REPORT}" ; then
3518+
if test -n "${PYTHON3_VERSION_INFO_REPORT}" -a -n "${PYTHON3}" ; then
35193519
AC_MSG_CHECKING([if we have Python3 Qt6 prerequisites for NUT-Monitor desktop application])
35203520
if ${PYTHON3} -c "import ${PYTHON3_TEST_MODULES_QT6}" 1>&5 2>&5 \
35213521
; then
@@ -3533,7 +3533,7 @@ if test x"${nut_with_nut_monitor}" != xno ; then
35333533

35343534
dnl Fall back to default interpreter
35353535
if test -z "${nut_with_nut_monitor_py2gtk2}${nut_with_nut_monitor_py3qt5}${nut_with_nut_monitor_py3qt6}" \
3536-
&& test -n "${PYTHON_VERSION_INFO_REPORT}" \
3536+
&& test -n "${PYTHON_VERSION_INFO_REPORT}" -a -n "${PYTHON}" \
35373537
&& test x"${PYTHON_VERSION_INFO_REPORT}" != x"${PYTHON3_VERSION_INFO_REPORT}" \
35383538
&& test x"${PYTHON_VERSION_INFO_REPORT}" != x"${PYTHON2_VERSION_INFO_REPORT}" \
35393539
; then
@@ -6749,10 +6749,13 @@ AS_CASE([${target_os}],
67496749
AC_MSG_NOTICE([FWIW, assuming ABS_TOP_SRCDIR="$ABS_TOP_SRCDIR" and ABS_TOP_BUILDDIR="$ABS_TOP_BUILDDIR"])
67506750
])
67516751

6752-
dnl Use these at best for tests (e.g. nutconf), not production code:
6752+
dnl Use these at best for tests (e.g. nutconf, NIT), not production code:
67536753
AC_DEFINE_UNQUOTED([ABS_TOP_SRCDIR], ["${ABS_TOP_SRCDIR}"], [NUT source directory when the build was configured])
67546754
AC_DEFINE_UNQUOTED([ABS_TOP_BUILDDIR], ["${ABS_TOP_BUILDDIR}"], [NUT build directory when the build was configured])
67556755

6756+
AC_SUBST(ABS_TOP_SRCDIR)
6757+
AC_SUBST(ABS_TOP_BUILDDIR)
6758+
67566759
dnl ---------------------------------------------------------------------
67576760
AC_MSG_CHECKING([whether to install External API integration script: Enphase Monitor])
67586761
nut_with_extapi_enphase="no"

drivers/upsdrvctl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,6 +1622,10 @@ int main(int argc, char **argv)
16221622

16231623
prog = argv[0];
16241624

1625+
#if (defined ENABLE_SHARED_PRIVATE_LIBS) && ENABLE_SHARED_PRIVATE_LIBS
1626+
callback_upsconf_args = do_upsconf_args;
1627+
#endif
1628+
16251629
/* Historically special banner*/
16261630
snprintf(progdesc, sizeof(progdesc), "%s - UPS driver controller", xbasename(prog));
16271631
print_banner_once(progdesc, 0);

tests/NIT/Makefile.am

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,25 @@ EXTRA_DIST = nit.sh README.adoc
1313

1414
if WITH_CHECK_NIT
1515
check: check-NIT
16-
else
16+
else !WITH_CHECK_NIT
1717
check:
1818
@echo "NO-OP: $@ in `pwd` is inactive by default. Run 'configure --enable-check-NIT' or 'make check-NIT' explicitly" >&2
19-
endif
19+
endif !WITH_CHECK_NIT
20+
21+
# Paths possibly different from what automake provides (POSIXish)
22+
# when building on/for e.g. Windows. Matters where system() is used,
23+
# such as NIT suite using/testing upsdrvctl:
24+
ABS_TOP_SRCDIR = @ABS_TOP_SRCDIR@
25+
ABS_TOP_BUILDDIR = @ABS_TOP_BUILDDIR@
2026

2127
# Run in builddir, use script from srcdir
2228
# Avoid running "$<" - not all make implementations handle that
2329
check-NIT: $(abs_srcdir)/nit.sh
2430
GREP="$(GREP)"; EGREP="$(EGREP)"; export GREP; export EGREP; \
2531
BUILTIN_RUN_AS_USER='$(RUN_AS_USER)' BUILTIN_RUN_AS_GROUP='$(RUN_AS_GROUP)' \
2632
abs_srcdir='$(abs_srcdir)' abs_builddir='$(abs_builddir)' \
27-
abs_top_srcdir='$(abs_top_srcdir)' abs_top_builddir='$(abs_top_builddir)' \
33+
abs_top_srcdir_orig='$(abs_top_srcdir)' abs_top_builddir_orig='$(abs_top_builddir)' \
34+
abs_top_srcdir='$(ABS_TOP_SRCDIR)' abs_top_builddir='$(ABS_TOP_BUILDDIR)' \
2835
EXEEXT='$(EXEEXT)' \
2936
"$(abs_srcdir)/nit.sh"
3037

@@ -47,7 +54,8 @@ check-NIT-sandbox: $(abs_srcdir)/nit.sh
4754
NUT_PORT=$(NUT_PORT) NIT_CASE="$(NIT_CASE)" NUT_FOREGROUND_WITH_PID=true \
4855
BUILTIN_RUN_AS_USER='$(RUN_AS_USER)' BUILTIN_RUN_AS_GROUP='$(RUN_AS_GROUP)' \
4956
abs_srcdir='$(abs_srcdir)' abs_builddir='$(abs_builddir)' \
50-
abs_top_srcdir='$(abs_top_srcdir)' abs_top_builddir='$(abs_top_builddir)' \
57+
abs_top_srcdir_orig='$(abs_top_srcdir)' abs_top_builddir_orig='$(abs_top_builddir)' \
58+
abs_top_srcdir='$(ABS_TOP_SRCDIR)' abs_top_builddir='$(ABS_TOP_BUILDDIR)' \
5159
EXEEXT='$(EXEEXT)' \
5260
"$(abs_srcdir)/nit.sh"
5361

tests/NIT/nit.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
# different value like "nobody" or "nogroup" would be defaulted for test.
5454
#
5555
# Copyright
56-
# 2022-2025 Jim Klimov <jimklimov+nut@gmail.com>
56+
# 2022-2026 Jim Klimov <jimklimov+nut@gmail.com>
5757
#
5858
# License: GPLv2+
5959

@@ -427,7 +427,7 @@ else
427427
fi
428428

429429
log_info "Locating NUT programs to test:"
430-
for PROG in upsd upsc dummy-ups upsmon upslog upssched ; do
430+
for PROG in upsd upsc dummy-ups upsdrvctl upsmon upslog upssched ; do
431431
(command -v ${PROG}) || (command -v ${PROG}${EXEEXT-}) || die "Useless setup: ${PROG} not found in PATH: ${PATH}"
432432
done
433433

@@ -1001,7 +1001,7 @@ generatecfg_ups_trivial() {
10011001
# Populate the configs for the run
10021002
( echo 'maxretry = 3' > "$NUT_CONFPATH/ups.conf" || exit
10031003
if [ x"${TOP_BUILDDIR}" != x ]; then
1004-
echo "driverpath = \"${TOP_BUILDDIR}/drivers\"" >> "$NUT_CONFPATH/ups.conf" || exit
1004+
echo "driverpath = \"${TOP_BUILDDIR}/drivers\"" | sed 's,\\,\\\\,g' >> "$NUT_CONFPATH/ups.conf" || exit
10051005
fi
10061006
if [ -n "${NUT_DEBUG_MIN-}" ] ; then
10071007
echo "debug_min = ${NUT_DEBUG_MIN}" >> "$NUT_CONFPATH/ups.conf" || exit
@@ -1359,8 +1359,9 @@ sandbox_start_drivers() {
13591359
if [ -n "${NUT_DEBUG_LEVEL_DRIVERS-}" ]; then
13601360
NUT_DEBUG_LEVEL="${NUT_DEBUG_LEVEL_DRIVERS}"
13611361
fi
1362-
#execcmd upsdrvctl ${ARG_FG} ${ARG_USER} start dummy &
1363-
execcmd dummy-ups -a dummy ${ARG_USER} ${ARG_FG} &
1362+
# Run one driver instance indirectly, to test the upsdrvctl tool too:
1363+
execcmd upsdrvctl ${ARG_FG} ${ARG_USER} start dummy &
1364+
#execcmd dummy-ups -a dummy ${ARG_USER} ${ARG_FG} &
13641365
PID_DUMMYUPS="$!"
13651366
log_debug "Tried to start dummy-ups driver for 'dummy' as PID $PID_DUMMYUPS"
13661367

tools/nut-scanner/nutscan-init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ size_t max_threads_ipmi = 0; /* limits not yet known */
138138
#endif /* HAVE_PTHREAD */
139139

140140
#ifdef WIN32
141-
/* Stub for libupsclient */
141+
/* Stub for libupsclient, no need to register a callback for ENABLE_SHARED_PRIVATE_LIBS builds */
142142
void do_upsconf_args(char *confupsname, char *var, char *val) {
143143
NUT_UNUSED_VARIABLE(confupsname);
144144
NUT_UNUSED_VARIABLE(var);

0 commit comments

Comments
 (0)