# BST-TIMEOUT: 900 # placeholder — replaced with the measured value below . "$BST_LIB" # libsmi 0.5.0 -- "a library to access SMI MIB information" (meta-oe # recipes-support/libsmi). What ships is /usr/lib/libsmi.a plus seven CLI tools # (smilint, smidump, smiquery, smixlate, smidiff, smistrip, smicache), the # /etc/smi.conf the recipe installs, and libsmi-mibs -- the 300-module IETF/IANA # MIB collection under /usr/share/mibs that every one of those tools resolves # IMPORTS against. # # --------------------------------------------------------------------------- # WHY THE CLI IS THE LIBRARY'S OWN COVERAGE HERE # # Several library ports on this image (libestr, libksba) ship a cross-linked # probe because the library has no CLI and a payload-shape-only suite would go # green on a library that returns silently wrong answers -- the BRINTOS-217 # lesson, where oniguruma compiled and packaged perfectly and then returned wrong # offsets to every caller. libsmi does not need that construction: smilint and # smidump ARE libsmi's callers, linked against the very archive that ships, and # everything they print is a value the library computed -- the parse tree, the # type lattice, the OID registrations, the conformance structure. Driving them # over a real 300-module corpus exercises far more of libsmi than a probe could, # so the probe would be the weaker instrument, not the stronger one. # # --------------------------------------------------------------------------- # THE ORACLE IS A NATIVE CONTROL BECAUSE UPSTREAM'S SUITE CANNOT BE RUN HERE # # libsmi tests itself well: test/*.test drive smilint and smidump over test/mibs # and diff the result against expectations the corpus carries. That whole harness # was run against a native x86_64 build of this exact tarball and patch series # and passes clean, so it is trustworthy -- but it is not runnable ON TARGET. The # drivers need the in-tree build directory (they invoke ../tools/smidump against # ../mibs), and the test corpus is not installed by any package: none of # test/mibs or test/dumps reaches the image, and shipping ~19 MIB fixtures plus # 20 directories of nominal dumps as selftest payload to re-create it would be a # large payload to re-assert what the control already establishes. # # So the oracle is data/libsmi-native.txt: the same tarball, the same patches, # the same MIB collection and the same commands, captured on x86_64 -- and every # command below runs against the MIBs the image actually ships, which is the # corpus a user of these tools would meet. That file's header carries the # details. # # Every scored value is MIB semantics -- an OID, a type, a registration tree, a # re-serialised module. None of it carries a pointer width, a sizeof, an address, # a locale or a wall-clock time, so nothing in it is allowed to differ between # the arms and any disagreement is a defect on this one. # # -c /dev/null is passed to every tool ON PURPOSE. The image installs # /etc/smi.conf, which sets a default error level, hides namelength-32 and # preloads three modules; the native control had no config file at all. Pinning # both sides to "no configuration" is what makes the two runs comparable, and it # is why the smi.conf case below asserts the file's PRESENCE separately rather # than letting it silently colour every other case. ORACLE="$BST_DATA/libsmi-native.txt" MIBROOT=/usr/share/mibs require smilint libsmi/present require smidump libsmi/smidump-present require smiquery libsmi/smiquery-present require md5sum libsmi/md5sum-present if [ ! -f "$ORACLE" ]; then bst_notok libsmi/oracle "native control $ORACLE not installed" exit 0 fi bst_ok libsmi/oracle # The MIB collection is part of the port (libsmi-mibs), so its absence is a # packaging failure -- a red -- not a legitimately-absent tool to skip over. if [ ! -d "$MIBROOT/ietf" ]; then bst_notok libsmi/mibs-installed "$MIBROOT/ietf missing -- libsmi-mibs not in the image" exit 0 fi bst_ok libsmi/mibs-installed # Leading colon on purpose -- it is upstream's own convention (test/parser.test # writes SMIPATH=$SMIPATH:...), and the empty first element keeps libsmi's # compiled-in default module directory in the search path alongside the two # explicit ones. Dropping it changes how an imported module's OID prefix # resolves: without it, libsmi's own test corpus reports index sizes 6 # subidentifiers short and loses two warnings outright. The real IETF modules # scored below resolve identically either way -- they are found in the explicit # directories -- but the control was captured with this exact string, and the # target must use the same one for the comparison to mean anything. SMIPATH=":$MIBROOT/ietf:$MIBROOT/iana" export SMIPATH # oracle lookup: everything after the key on its line. o() { awk -v k="$1" '$1==k{$1="";sub(/^ /,"");print;exit}' "$ORACLE"; } # --- payload shape ---------------------------------------------------------- check libsmi/lib-archive test -f /usr/lib/libsmi.a check libsmi/header test -f /usr/include/smi.h check libsmi/pkgconfig test -f /usr/lib/pkgconfig/libsmi.pc check libsmi/smi-conf test -f /etc/smi.conf check libsmi/mibs-ietf-core test -f "$MIBROOT/ietf/SNMPv2-SMI" check libsmi/mibs-iana test -d "$MIBROOT/iana" # --- versions --------------------------------------------------------------- check_eq libsmi/version-smilint "$(o version/smilint)" "$(smilint -V 2>&1 | head -1)" check_eq libsmi/version-smidump "$(o version/smidump)" "$(smidump -V 2>&1 | head -1)" # --- smidump: ten formats x four modules, byte-exact against the control ----- # Read the oracle on fd 3 so the tools below keep their own stdin. exec 3< "$ORACLE" while read -r key f1 f2 f3 <&3; do case "$key" in dump/*) ;; *) continue ;; esac fmt=${key#dump/}; mod=${fmt#*/}; fmt=${fmt%%/*} out=$(smidump -c /dev/null -f "$fmt" "$mod" 2>/dev/null ::, and the path differs between the # two install prefixes, so it is stripped to a bare module name; -l9 asks for # every severity. Stripping only the module UNDER TEST is not enough: a # redefinition warning cites the OTHER module's file too ("previous definition # of ..."), and RMON2-MIB's three of those carry the prefix as well. Anchored to # the leading token so a path quoted inside a message is left alone. exec 3< "$ORACLE" while read -r key f1 f2 <&3; do case "$key" in lint/*) ;; *) continue ;; esac mod=${key#lint/} out=$(smilint -c /dev/null -l9 "$MIBROOT/ietf/$mod" 2>&1 /dev/null || true) md5=$(printf '%s\n' "$out" | md5sum | cut -d' ' -f1) if [ "$n" = "$f1" ] && [ "$md5" = "$f2" ]; then bst_ok "libsmi/$key" elif bst_execfail "$out"; then bst_unrun "libsmi/$key" "$out" else bst_notok "libsmi/$key" "diagnostics=$n/$f1 md5=$md5/$f2" fi done exec 3<&- # --- smiquery: individual semantic lookups, readable on sight --------------- Q=$(smiquery -c /dev/null node IF-MIB::ifNumber 2>/dev/null /dev/null /dev/null /dev/null