Skip to content

Commit b03af2d

Browse files
authored
Merge pull request #2932 from jimklimov/fix-ci-unmapped
Fix CI for "unmapped" data points, and update some docs
2 parents 99c8a0e + 3116c0b commit b03af2d

11 files changed

+220
-10
lines changed

NEWS.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ https://github.com/networkupstools/nut/milestone/9
7373
and misfired on some platforms, and the way to print had a theoretical
7474
potential for buffer overflow. [#2915]
7575

76-
- `usbhid-ups` updates:
76+
- `usbhid-ups` driver updates:
7777
* The `cps-hid` subdriver's existing mechanism for fixing broken report
7878
descriptors was extended to cover a newly reported case of nominal UPS
7979
power being incorrectly reported due to an unrealistically low maximum

ci_build.sh

+165-4
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ if [ "$BUILD_TYPE" = fightwarn ]; then
9999

100100
# Similarly for libusb implementations with varying support
101101
#[ -n "$NUT_USB_VARIANTS" ] || NUT_USB_VARIANTS=auto
102+
103+
# Similarly for testing builds with and without "unmapped" values
104+
# (normally hidden by #ifdef blocks) in certain evolving drivers
105+
#[ -n "$NUT_UNMAPPED_VARIANTS" ] || NUT_UNMAPPED_VARIANTS=auto
102106
fi
103107

104108
# configure default is "no"; an "auto" value is "yes unless CFLAGS say something"
@@ -1449,7 +1453,7 @@ echo "Processing BUILD_TYPE='${BUILD_TYPE}' ..."
14491453

14501454
ensure_CI_CCACHE_SYMLINKDIR_envvar
14511455
echo "Build host settings:"
1452-
set | grep -E '^(PATH|[^ ]*CCACHE[^ ]*|CI_[^ ]*|OS_[^ ]*|CANBUILD_[^ ]*|NODE_LABELS|MAKE|C[^ ]*FLAGS|LDFLAGS|ARCH[^ ]*|BITS[^ ]*|CC|CXX|CPP|DO_[^ ]*|BUILD_[^ ]*|[^ ]*_TGT)=' || true
1456+
set | grep -E '^(PATH|[^ ]*CCACHE[^ ]*|CI_[^ ]*|OS_[^ ]*|CANBUILD_[^ ]*|NODE_LABELS|MAKE|C[^ ]*FLAGS|LDFLAGS|ARCH[^ ]*|BITS[^ ]*|CC|CXX|CPP|DO_[^ ]*|BUILD_[^ ]*|[^ ]*_TGT|INPLACE_RUNTIME)=' || true
14531457
uname -a
14541458
echo "LONG_BIT:`getconf LONG_BIT` WORD_BIT:`getconf WORD_BIT`" || true
14551459
if command -v xxd >/dev/null ; then xxd -c 1 -l 6 | tail -1; else if command -v od >/dev/null; then od -N 1 -j 5 -b | head -1 ; else hexdump -s 5 -n 1 -C | head -1; fi; fi < /bin/ls 2>/dev/null | awk '($2 == 1){print "Endianness: LE"}; ($2 == 2){print "Endianness: BE"}' || true
@@ -1513,6 +1517,16 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-sp
15131517
CONFIG_OPTS+=("--with-devd-dir=${BUILD_PREFIX}/etc/devd")
15141518
CONFIG_OPTS+=("--with-hotplug-dir=${BUILD_PREFIX}/etc/hotplug")
15151519

1520+
if [ "${BUILD_TYPE}" != "default-all-errors" ] ; then
1521+
case x"${WITH_UNMAPPED_DATAPOINTS-}" in
1522+
[Tt][Rr][Uu][Ee]|[Yy][Ee][Ss])
1523+
CONFIG_OPTS+=("--with-unmapped-data-points") ;;
1524+
[Ff][Aa][Ll][Ss][Ee]|[Nn][Oo])
1525+
CONFIG_OPTS+=("--without-unmapped-data-points") ;;
1526+
*) ;; # Keep built-in default
1527+
esac
1528+
fi
1529+
15161530
if [ x"${INPLACE_RUNTIME-}" = xtrue ]; then
15171531
CONFIG_OPTS+=("--enable-inplace-runtime")
15181532
fi
@@ -1967,6 +1981,17 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-sp
19671981
fi
19681982
fi
19691983

1984+
if [ -z "$NUT_UNMAPPED_VARIANTS" ] || [ "$NUT_UNMAPPED_VARIANTS" = auto ] ; then
1985+
case x"${WITH_UNMAPPED_DATAPOINTS-}" in
1986+
[Tt][Rr][Uu][Ee]|[Yy][Ee][Ss])
1987+
NUT_UNMAPPED_VARIANTS="yes" ;;
1988+
[Ff][Aa][Ll][Ss][Ee]|[Nn][Oo])
1989+
NUT_UNMAPPED_VARIANTS="no" ;;
1990+
*)
1991+
NUT_UNMAPPED_VARIANTS="yes no" ;;
1992+
esac
1993+
fi
1994+
19701995
# Count our expected build variants, so the last one gets the
19711996
# "maintainer-clean" check and not a mere "distclean" check
19721997
# NOTE: We count different dependency variations separately,
@@ -1981,6 +2006,15 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-sp
19812006
BUILDSTODO_USB="`expr $BUILDSTODO_USB + 1`"
19822007
done
19832008

2009+
BUILDSTODO_UNMAPPED=0
2010+
for NUT_UNMAPPED_VARIANT in $NUT_UNMAPPED_VARIANTS ; do
2011+
BUILDSTODO_UNMAPPED="`expr $BUILDSTODO_UNMAPPED + 1`"
2012+
done
2013+
# Use the only one requested right away
2014+
if [ "${BUILDSTODO_UNMAPPED}" -eq 1 ] ; then
2015+
CONFIG_OPTS+=("--with-unmapped-data-points=${NUT_UNMAPPED_VARIANT}")
2016+
fi
2017+
19842018
if [ "${BUILDSTODO_SSL}" -gt 1 ] \
19852019
&& [ "${BUILDSTODO_USB}" -gt 1 ] \
19862020
; then
@@ -2012,10 +2046,17 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-sp
20122046
echo "=== Only build USB scenario(s) picking whatever SSL is found"
20132047
BUILDSTODO="${BUILDSTODO_USB}"
20142048
fi
2049+
2050+
fi
2051+
2052+
# Tack a remaining yes/no in the end to whatever scenario is there;
2053+
# NOT a full matrix
2054+
if [ "${BUILDSTODO_UNMAPPED}" -gt 1 ] ; then
2055+
BUILDSTODO="`expr $BUILDSTODO + $BUILDSTODO_UNMAPPED - 1`"
20152056
fi
20162057

20172058
BUILDSTODO_INITIAL="$BUILDSTODO"
2018-
echo "=== Will loop now with $BUILDSTODO build variants: found ${BUILDSTODO_SSL} SSL ($NUT_SSL_VARIANTS) and ${BUILDSTODO_USB} USB ($NUT_USB_VARIANTS) variations..."
2059+
echo "=== Will loop now with $BUILDSTODO build variants: found ${BUILDSTODO_SSL} SSL ($NUT_SSL_VARIANTS) and ${BUILDSTODO_USB} USB ($NUT_USB_VARIANTS) and ${BUILDSTODO_UNMAPPED} UNMAPPED ($NUT_UNMAPPED_VARIANTS) variations..."
20192060
# If we don't care about SSL implem and want to pick USB, go straight there
20202061
( [ "$NUT_SSL_VARIANTS" = "auto" ] && [ "${BUILDSTODO_USB}" -gt 0 ] ) || \
20212062
for NUT_SSL_VARIANT in $NUT_SSL_VARIANTS ; do
@@ -2130,7 +2171,7 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-sp
21302171
echo "=== SKIPPED sandbox cleanup because DO_CLEAN_CHECK=$DO_CLEAN_CHECK and $BUILDSTODO build variants remaining"
21312172
fi
21322173
fi
2133-
done
2174+
done # end of "for NUT_SSL_VARIANT in $NUT_SSL_VARIANTS"
21342175

21352176
# Effectively, whatever up to one version of LibUSB support
21362177
# was detected (or not), was tested above among SSL builds.
@@ -2278,7 +2319,112 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-sp
22782319
echo "=== SKIPPED sandbox cleanup because DO_CLEAN_CHECK=$DO_CLEAN_CHECK and $BUILDSTODO build variants remaining"
22792320
fi
22802321
fi
2281-
done
2322+
done # end of "for NUT_USB_VARIANT in $NUT_USB_VARIANTS"
2323+
2324+
# Tack a remaining yes/no in the end to whatever scenario is there;
2325+
# NOT a full matrix
2326+
if [ "${BUILDSTODO_UNMAPPED}" -gt 1 ] ; then
2327+
for NUT_UNMAPPED_VARIANT in $NUT_UNMAPPED_VARIANTS ; do
2328+
case "${NUT_UNMAPPED_VARIANT}" in
2329+
no) ;; # we already did the default ("no") implicitly
2330+
*) # Try this variant
2331+
echo "=== Starting 'NUT_UNMAPPED_VARIANT=$NUT_UNMAPPED_VARIANT', $BUILDSTODO build variants remaining..."
2332+
( if [ "$NUT_SSL_VARIANTS" != "auto" ] ; then
2333+
CONFIG_OPTS+=("--without-all")
2334+
CONFIG_OPTS+=("--without-ssl")
2335+
fi
2336+
CONFIG_OPTS+=("--with-serial=auto")
2337+
if [ "$NUT_USB_VARIANTS" != "no" ] ; then
2338+
CONFIG_OPTS+=("--with-usb=auto")
2339+
fi
2340+
CONFIG_OPTS+=("--with-unmapped-data-points=${NUT_UNMAPPED_VARIANT}")
2341+
configure_nut
2342+
) || {
2343+
RES_ALLERRORS=$?
2344+
FAILED="${FAILED} NUT_UNMAPPED_VARIANT=${NUT_UNMAPPED_VARIANT}[configure]"
2345+
# TOTHINK: Do we want to try clean-up if we likely have no Makefile?
2346+
if [ "$CI_FAILFAST" = true ]; then
2347+
echo "===== Aborting because CI_FAILFAST=$CI_FAILFAST" >&2
2348+
break
2349+
fi
2350+
BUILDSTODO="`expr $BUILDSTODO - 1`" || [ "$BUILDSTODO" = "0" ] || break
2351+
continue
2352+
}
2353+
2354+
echo "=== Configured 'NUT_UNMAPPED_VARIANT=$NUT_UNMAPPED_VARIANT', $BUILDSTODO build variants (including this one) remaining to complete; trying to build..."
2355+
cd "${CI_BUILDDIR}"
2356+
# Use default target e.g. "all":
2357+
build_to_only_catch_errors_target && {
2358+
SUCCEEDED="${SUCCEEDED} NUT_UNMAPPED_VARIANT=${NUT_UNMAPPED_VARIANT}[build]"
2359+
} || {
2360+
RES_ALLERRORS=$?
2361+
FAILED="${FAILED} NUT_UNMAPPED_VARIANT=${NUT_UNMAPPED_VARIANT}[build]"
2362+
# Help find end of build (before cleanup noise) in logs:
2363+
echo "=== FAILED 'NUT_UNMAPPED_VARIANT=${NUT_UNMAPPED_VARIANT}' build"
2364+
if [ "$CI_FAILFAST" = true ]; then
2365+
echo "===== Aborting because CI_FAILFAST=$CI_FAILFAST" >&2
2366+
break
2367+
fi
2368+
}
2369+
2370+
build_to_only_catch_errors_check && {
2371+
SUCCEEDED="${SUCCEEDED} NUT_UNMAPPED_VARIANT=${NUT_UNMAPPED_VARIANT}[check]"
2372+
} || {
2373+
RES_ALLERRORS=$?
2374+
FAILED="${FAILED} NUT_UNMAPPED_VARIANT=${NUT_UNMAPPED_VARIANT}[check]"
2375+
# Help find end of build (before cleanup noise) in logs:
2376+
echo "=== FAILED 'NUT_UNMAPPED_VARIANT=${NUT_UNMAPPED_VARIANT}' check"
2377+
if [ "$CI_FAILFAST" = true ]; then
2378+
echo "===== Aborting because CI_FAILFAST=$CI_FAILFAST" >&2
2379+
break
2380+
fi
2381+
}
2382+
2383+
# Note: when `expr` calculates a zero value below, it returns
2384+
# an "erroneous" `1` as exit code. Notes above.
2385+
BUILDSTODO="`expr $BUILDSTODO - 1`" || [ "$BUILDSTODO" = "0" ] || break
2386+
2387+
if [ "$BUILDSTODO" -gt 0 ] && [ "${DO_CLEAN_CHECK-}" != no ]; then
2388+
# For last iteration with DO_CLEAN_CHECK=no,
2389+
# we would leave built products in place
2390+
echo "=== Clean the sandbox, $BUILDSTODO build variants remaining..."
2391+
fi
2392+
2393+
if can_clean_check ; then
2394+
if [ $BUILDSTODO -gt 0 ]; then
2395+
### Avoid having to re-autogen in a loop:
2396+
optional_dist_clean_check && {
2397+
if [ "${DO_DIST_CLEAN_CHECK-}" != "no" ] ; then
2398+
SUCCEEDED="${SUCCEEDED} NUT_UNMAPPED_VARIANT=${NUT_UNMAPPED_VARIANT}[dist_clean]"
2399+
fi
2400+
} || {
2401+
RES_ALLERRORS=$?
2402+
FAILED="${FAILED} NUT_UNMAPPED_VARIANT=${NUT_UNMAPPED_VARIANT}[dist_clean]"
2403+
}
2404+
else
2405+
optional_maintainer_clean_check && {
2406+
if [ "${DO_MAINTAINER_CLEAN_CHECK-}" != no ] ; then
2407+
SUCCEEDED="${SUCCEEDED} NUT_UNMAPPED_VARIANT=${NUT_UNMAPPED_VARIANT}[maintainer_clean]"
2408+
fi
2409+
} || {
2410+
RES_ALLERRORS=$?
2411+
FAILED="${FAILED} NUT_UNMAPPED_VARIANT=${NUT_UNMAPPED_VARIANT}[maintainer_clean]"
2412+
}
2413+
fi
2414+
echo "=== Completed sandbox cleanup-check after NUT_UNMAPPED_VARIANT=${NUT_UNMAPPED_VARIANT}, $BUILDSTODO build variants remaining"
2415+
else
2416+
if [ "$BUILDSTODO" -gt 0 ] && [ "${DO_CLEAN_CHECK-}" != no ]; then
2417+
$MAKE distclean $MAKE_FLAGS_CLEAN -k \
2418+
|| echo "WARNING: 'make distclean' FAILED: $? ... proceeding" >&2
2419+
echo "=== Completed sandbox cleanup after NUT_UNMAPPED_VARIANT=${NUT_UNMAPPED_VARIANT}, $BUILDSTODO build variants remaining"
2420+
else
2421+
echo "=== SKIPPED sandbox cleanup because DO_CLEAN_CHECK=$DO_CLEAN_CHECK and $BUILDSTODO build variants remaining"
2422+
fi
2423+
fi
2424+
;; # end of "Try this variant"
2425+
esac
2426+
done # end of "for NUT_UNMAPPED_VARIANT in $NUT_UNMAPPED_VARIANTS"
2427+
fi
22822428

22832429
# TODO: Similar loops for other variations like TESTING,
22842430
# MGE SHUT vs. other serial protocols...
@@ -2461,6 +2607,21 @@ bindings)
24612607
CONFIG_OPTS+=("--disable-silent-rules")
24622608
fi
24632609

2610+
if [ -z "${WITH_UNMAPPED_DATAPOINTS-}" ] ; then
2611+
if [ x"${INPLACE_RUNTIME-}" = xtrue ]; then
2612+
WITH_UNMAPPED_DATAPOINTS=false
2613+
else
2614+
WITH_UNMAPPED_DATAPOINTS=true
2615+
fi
2616+
fi
2617+
2618+
if [ x"${WITH_UNMAPPED_DATAPOINTS-}" = xtrue ] ; then
2619+
# This is assumed for non-production builds to avoid confusion
2620+
# for end-users (not dev/testers).
2621+
# See above for defaulting of this vs. inplace builds.
2622+
CONFIG_OPTS+=("--with-unmapped-data-points")
2623+
fi
2624+
24642625
if [ -n "${BUILD_DEBUGINFO-}" ]; then
24652626
CONFIG_OPTS+=("--with-debuginfo=${BUILD_DEBUGINFO}")
24662627
else

docs/Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ MAINTAINER_ASCIIDOCS_CHANGELOG_DEBUG = no
433433
-e 's%\(PR\|pull request\) *networkupstools/\([^ ][^ ]*\)\#\([1-9][0-9]*\)\([^0-9]\|$$\)%link:https://github.com/networkupstools/\2/pull/\3[\1 \2\#\#\3]\4%g' \
434434
-e 's%\([[ ,]\)networkupstools/\([^ ][^ ]*\)\#\([1-9][0-9]*\)\([^0-9]\|$$\)%\1link:https://github.com/networkupstools/\2/issues/\3[\2\#\#\3]\4%g' \
435435
-e 's%\#\(\#[1-9][0-9]*\)%\1%g' \
436+
-e 's,\(https*://[^ \+]*\)[\]*[+],\1%2B,g' \
436437
; } > "$@.tmp.$$$$" \
437438
&& mv -f "$@.tmp.$$$$" "$@"
438439
@if [ x'$@' = x'$(top_builddir)/ChangeLog.adoc-parsed' ] ; then \

docs/config-prereqs.txt

+8-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,14 @@ recommended for build agents with immutable system areas, etc.
106106
Build prerequisites to make NUT from scratch on various Operating Systems
107107
-------------------------------------------------------------------------
108108

109-
Debian 10/11/12/13
110-
~~~~~~~~~~~~~~~~~~
109+
Debian, Ubuntu and derivatives
110+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
111+
112+
NOTE: Documented according to NUT CI farm build agents and development
113+
workstation running Debian 10/11/12/13 (should at least partially apply
114+
as far back as Debian 7/8), Ubuntu 14.x-25.x, and Termux revisions circa
115+
2023-2025. This section generally covers a very wide family of APT-based
116+
Debian-derived Linux operating system distributions.
111117

112118
Being a popular baseline among Linux distributions, Debian is an
113119
important build target. Related common operating systems include

docs/developers.txt

+32
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,38 @@ function do_stuff(void)
186186
}
187187
--------------------------------------------------------------------------------
188188

189+
Variable length arrays
190+
~~~~~~~~~~~~~~~~~~~~~~
191+
192+
We also avoid initialization of arrays using a variable (e.g. a method
193+
argument) as poorly portable to older compilers, and prefer explicitly
194+
allocated and freed buffers, if variable size is needed.
195+
196+
This should be avoided:
197+
--------------------------------------------------------------------------------
198+
function avoid_vla(int len)
199+
{
200+
char *buf[len];
201+
...
202+
}
203+
--------------------------------------------------------------------------------
204+
205+
This should be sued instead (preferably with `size_t` arguments right away),
206+
be sure to `free()` anywhere you `return` from the function:
207+
--------------------------------------------------------------------------------
208+
int use_xcalloc(size_t len)
209+
{
210+
char *buf = xcalloc(len, sizeof(char));
211+
212+
if (!buf)
213+
return -1;
214+
...
215+
free(buf);
216+
return 1;
217+
}
218+
--------------------------------------------------------------------------------
219+
220+
189221
Other hints
190222
~~~~~~~~~~~
191223

docs/man/nutdrv_qx.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ Some devices "natively" report just report a part of the total battery voltage
137137
device or properly guessed by the driver otherwise).
138138
+
139139
If this flag is set, most of the subdrivers (except those which know about
140-
more complicated device-specific nuances, currently: *ablerex*, *masterguard*
140+
more complicated device-specific nuances, currently: *ablerex*, *masterguard*
141141
and *voltronic-qs-hex*) adjust their ultimately reported *battery.voltage*
142142
value as a multiple of *battery.packs* and "native" *battery.voltage*).
143143
+

docs/nut.dict

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
personal_ws-1.1 en 3470 utf-8
1+
personal_ws-1.1 en 3473 utf-8
22
AAC
33
AAS
44
ABI
@@ -2244,6 +2244,7 @@ interruptonly
22442244
interruptsize
22452245
intltool
22462246
inverter
2247+
inverters
22472248
invmode
22482249
io
22492250
ioLogik
@@ -2729,6 +2730,7 @@ pfy
27292730
ph
27302731
phoenixcontact
27312732
phoenixtec
2733+
photovoltaic
27322734
picocom
27332735
pid
27342736
pidpath
@@ -3355,9 +3357,9 @@ varname
33553357
varvalue
33563358
vbat
33573359
vbatt
3358-
ve
33593360
vc
33603361
vda
3362+
ve
33613363
vendorid
33623364
ver
33633365
verifySourceSig
@@ -3375,6 +3377,7 @@ virtinst
33753377
virtualization
33763378
virtualized
33773379
vivo
3380+
vla
33783381
vo
33793382
volsize
33803383
voltronic

docs/nutdrv_qx-subdrivers.txt

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ the main `nutdrv_qx.c` file. However, in `ups.conf` this entity is referred
2525
to via the communication `protocol` keyword, if the end-user wants to pick
2626
one explicitly (bypassing auto-detection).
2727

28+
The string value of each `protocol` setting is derived from the respective
29+
source module's self-identification, by picking the first space-separated token
30+
(its `NAME`, assuming a `NAME VERSION` pattern) and making a case-insensitive
31+
comparison. The self-identification value is maintained as a string macro at
32+
the top of each module's C source file, and is passed to the main driver code
33+
as part of `subdriver_t` structure instance defined in the end of the file.
34+
2835
Confusingly, there *is* also an optional USB `subdriver` setting (available
2936
when the driver is built with USB support), for "Serial-over-USB subdriver
3037
selection", corresponding to entries in the `usbsubdriver` array and several

drivers/nutdrv_qx_ablerex.c

100755100644
File mode changed.

drivers/nutdrv_qx_ablerex.h

100755100644
File mode changed.

drivers/powervar-hid.h

100755100644
File mode changed.

0 commit comments

Comments
 (0)