Skip to content

Commit daa8aa4

Browse files
authored
Merge 15cee54 into 9275ebe
2 parents 9275ebe + 15cee54 commit daa8aa4

4 files changed

Lines changed: 28 additions & 9 deletions

File tree

NEWS.adoc

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

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

configure.ac

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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"

tests/NIT/Makefile.am

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@ 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
@@ -25,6 +31,7 @@ check-NIT: $(abs_srcdir)/nit.sh
2531
BUILTIN_RUN_AS_USER='$(RUN_AS_USER)' BUILTIN_RUN_AS_GROUP='$(RUN_AS_GROUP)' \
2632
abs_srcdir='$(abs_srcdir)' abs_builddir='$(abs_builddir)' \
2733
abs_top_srcdir='$(abs_top_srcdir)' abs_top_builddir='$(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

@@ -48,6 +55,7 @@ check-NIT-sandbox: $(abs_srcdir)/nit.sh
4855
BUILTIN_RUN_AS_USER='$(RUN_AS_USER)' BUILTIN_RUN_AS_GROUP='$(RUN_AS_GROUP)' \
4956
abs_srcdir='$(abs_srcdir)' abs_builddir='$(abs_builddir)' \
5057
abs_top_srcdir='$(abs_top_srcdir)' abs_top_builddir='$(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: 11 additions & 6 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

@@ -1000,8 +1000,12 @@ generatecfg_upsmon_secondary() {
10001000
generatecfg_ups_trivial() {
10011001
# Populate the configs for the run
10021002
( echo 'maxretry = 3' > "$NUT_CONFPATH/ups.conf" || exit
1003-
if [ x"${TOP_BUILDDIR}" != x ]; then
1004-
echo "driverpath = \"${TOP_BUILDDIR}/drivers\"" >> "$NUT_CONFPATH/ups.conf" || exit
1003+
if [ x"${ABS_TOP_BUILDDIR}" != x ]; then
1004+
echo "driverpath = \"${ABS_TOP_BUILDDIR}/drivers\"" | sed 's,\\,\\\\,g' >> "$NUT_CONFPATH/ups.conf" || exit
1005+
else
1006+
if [ x"${TOP_BUILDDIR}" != x ]; then
1007+
echo "driverpath = \"${TOP_BUILDDIR}/drivers\"" | sed 's,\\,\\\\,g' >> "$NUT_CONFPATH/ups.conf" || exit
1008+
fi
10051009
fi
10061010
if [ -n "${NUT_DEBUG_MIN-}" ] ; then
10071011
echo "debug_min = ${NUT_DEBUG_MIN}" >> "$NUT_CONFPATH/ups.conf" || exit
@@ -1359,8 +1363,9 @@ sandbox_start_drivers() {
13591363
if [ -n "${NUT_DEBUG_LEVEL_DRIVERS-}" ]; then
13601364
NUT_DEBUG_LEVEL="${NUT_DEBUG_LEVEL_DRIVERS}"
13611365
fi
1362-
#execcmd upsdrvctl ${ARG_FG} ${ARG_USER} start dummy &
1363-
execcmd dummy-ups -a dummy ${ARG_USER} ${ARG_FG} &
1366+
# Run one driver instance indirectly, to test the upsdrvctl tool too:
1367+
execcmd upsdrvctl ${ARG_FG} ${ARG_USER} start dummy &
1368+
#execcmd dummy-ups -a dummy ${ARG_USER} ${ARG_FG} &
13641369
PID_DUMMYUPS="$!"
13651370
log_debug "Tried to start dummy-ups driver for 'dummy' as PID $PID_DUMMYUPS"
13661371

0 commit comments

Comments
 (0)