Testing Notes (Appendix)¶
Some additional specifics on template string testing appear below. I wrote a unit test program to exercise the template engine while I was developing it:
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/bootbanner.h>
void
printfunc(const char *line, uint_t lnum)
{
printf(" [%u] %s\n", lnum, line);
}
int
main(int argc, char *argv[])
{
bootbanner_print(printfunc, 0);
return (0);
}
Run under a harness:
#!/bin/bash
function t {
printf -- '---- TEMPLATE: %s ----\n' "$1"
shift
[[ -n $1 ]] && printf ' BOOTBANNER1="%s"\n' "$1"
[[ -n $2 ]] && printf ' BOOTBANNER2="%s"\n' "$2"
[[ -n $3 ]] && printf ' BOOTBANNER3="%s"\n' "$3"
[[ -n $4 ]] && printf ' BOOTBANNER4="%s"\n' "$4"
[[ -n $5 ]] && printf ' BOOTBANNER5="%s"\n' "$5"
printf '\n'
rm -f bbt
gcc \
-I$SRC/uts/common \
-DBOOTBANNER1="\"$1\"" \
-DBOOTBANNER2="\"$2\"" \
-DBOOTBANNER3="\"$3\"" \
-DBOOTBANNER4="\"$4\"" \
-DBOOTBANNER5="\"$5\"" \
-o bbt bbt.c bootbanner.c
printf -- 'output:\n' "$1"
./bbt
printf '\n'
}
t 'five lines, no expansion' a b c d e
t 'one line, no expansion' a
t 'illumos default' '^o Version ^v ^w-bit'
t 'retro' '^s Release ^r Version ^v ^w-bit'
t 'tribblix' 'Welcome to Tribblix, the retro ^o distribution' \
'^v | March 2020 | http://www.tribblix.org/'
The test harness produces this output:
---- TEMPLATE: five lines, no expansion ----
BOOTBANNER1="a"
BOOTBANNER2="b"
BOOTBANNER3="c"
BOOTBANNER4="d"
BOOTBANNER5="e"
output:
[0] a
[1] b
[2] c
[3] d
[4] e
---- TEMPLATE: one line, no expansion ----
BOOTBANNER1="a"
output:
[0] a
---- TEMPLATE: illumos default ----
BOOTBANNER1="^o Version ^v ^w-bit"
output:
[0] illumos Version rti-banner-0-g6dc88a2f5f 64-bit
---- TEMPLATE: retro ----
BOOTBANNER1="^s Release ^r Version ^v ^w-bit"
output:
[0] SunOS Release 5.11 Version rti-banner-0-g6dc88a2f5f 64-bit
---- TEMPLATE: tribblix ----
BOOTBANNER1="Welcome to Tribblix, the retro ^o distribution"
BOOTBANNER2="^v | March 2020 | http://www.tribblix.org/"
output:
[0] Welcome to Tribblix, the retro illumos distribution
[1] rti-banner-0-g6dc88a2f5f | March 2020 | http://www.tribblix.org/
I have also done the full OS build and reboot and zone checks for both the default configuration (no overrides in the environment) and the sample Tribblix string from above. The chief difference between the kernel and the usermode implementation is how we produce the bit width string, and the default banner template exercises that.