
Most of the nodes in the general sysctl tree will be managed directly by the MIB service, which obtains the necessary information as needed. However, in certain cases, it makes more sense to let another service manage a part of the sysctl tree itself, in order to avoid replicating part of that other service in the MIB service. This patch adds the basic support for such delegation: remote services may now register their own subtrees within the full sysctl tree with the MIB service, which will then forward any sysctl(2) requests on such subtrees to the remote services. The system works much like mounting a file system, but in addition to support for shadowing an existing node, the MIB service also supports creating temporary mount point nodes. Each have their own use cases. A remote "kern.ipc" would use the former, because even when such a subtree were not mounted, userland would still expect some of its children to exist and return default values. A remote "net.inet" would use the latter, as there is no reason to precreate nodes for all possible supported networking protocols in the MIB "net" subtree. A standard remote MIB (RMIB) implementation is provided for services that wish to make use of this functionality. It is essentially a simplified and somewhat more lightweight version of the MIB service's internals, and works more or less the same from a programmer's point of view. The most important difference is the "rmib" prefix instead of the "mib" prefix. Documentation will hopefully follow later. Overall, the RMIB functionality should not be used lightly, for several reasons. First, despite being more lightweight than the MIB service, the RMIB module still adds substantially to the code footprint of the containing service. Second, the RMIB protocol not only adds extra IPC for sysctl(2), but has also not been optimized for performance in other ways. Third, and most importantly, the RMIB implementation also several limitations. The main limitation is that remote MIB subtrees must be fully static. Not only may the user not create or destroy nodes, the service itself may not either, as this would clash with the simplified remote node versioning system and the cached subtree root node child counts. Other limitations exist, such as the fact that the root of a remote subtree may only be a node-type node, and a stricter limit on the highest node identifier of any child in this subtree root (currently 4095). The current implementation was born out of necessity, and therefore it leaves several improvements to future work. Most importantly, support for exit and crash notification is missing, primarily in the MIB service. This means that remote subtrees may not be cleaned up immediately, but instead only when the MIB service attempts to talk to the dead remote service. In addition, if the MIB service itself crashes, re-registration of remote subtrees is currently left up to the individual RMIB users. Finally, the MIB service uses synchronous (sendrec-based) calls to the remote services, which while convenient may cause cascading service hangs. The underlying protocol is ready for conversion to an asynchronous implementation already, though. A new test set, testrmib.sh, tests the basic RMIB functionality. To this end it uses a test service, rmibtest, and also reuses part of the existing test87 MIB service test. Change-Id: I3378fe04f2e090ab231705bde7e13d6289a9183e
183 lines
4.4 KiB
Bash
Executable File
183 lines
4.4 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# Are we running as root?
|
|
unset ROOT
|
|
if [ "`id -u`" = 0 ]
|
|
then ROOT=yes
|
|
fi
|
|
|
|
# Initialization
|
|
PATH=:/bin:/usr/bin:/sbin
|
|
export PATH
|
|
|
|
rm -rf DIR* # remove any old junk lying around
|
|
passed=`expr 0` # count number of tests run correctly
|
|
failed=`expr 0` # count number of tests that failed
|
|
skipped=`expr 0` # count number of tests that were skipped
|
|
total=`expr 0` # total number of tests tried
|
|
badones= # list of tests that failed
|
|
export USENETWORK # set to "yes" for test48+82 to use the network
|
|
|
|
# In the lists below, shell scripts should be listed without ".sh" suffix
|
|
|
|
# Programs that require setuid
|
|
setuids="test11 test33 test43 test44 test46 test56 test60 test61 test65 \
|
|
test69 test73 test74 test78 test83 test85 test87 test88 test89"
|
|
# Scripts that require to be run as root
|
|
rootscripts="testisofs testvnd testrmib testrelpol"
|
|
|
|
alltests="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
|
|
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 \
|
|
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 \
|
|
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 \
|
|
81 82 83 84 85 86 87 88 89 sh1 sh2 interp mfs isofs vnd rmib"
|
|
tests_no=`expr 0`
|
|
|
|
# If root, make sure the setuid tests have the correct permissions
|
|
# and make the dir bin-owned.
|
|
if [ "$ROOT" ]
|
|
then /usr/sbin/chown bin .
|
|
/usr/sbin/chown root ${setuids}
|
|
chmod 4755 ${setuids}
|
|
fi
|
|
|
|
tests=$alltests
|
|
|
|
# Are we given any args? If so, we might have to give
|
|
# or change our testlist
|
|
while getopts 'lt:T' opt
|
|
do
|
|
case $opt in
|
|
l) echo "$alltests"
|
|
exit 0
|
|
;;
|
|
t) tests="$OPTARG"
|
|
;;
|
|
T) tapmode=yes
|
|
diagprefix="# "
|
|
;;
|
|
?) echo "Usage: run [-l] [-t testlist] [-T]" >&2
|
|
echo " -l: list tests, exit" >&2
|
|
echo " -t: execute given set of tests, default: all" >&2
|
|
echo " -T: produce TAP-format output" >&2
|
|
exit 1
|
|
esac
|
|
done
|
|
|
|
# Count tests
|
|
for i in `echo $tests`; do
|
|
if [ -x ./test$i -o -x ./test${i}.sh ]; then
|
|
tests_no=`expr $tests_no + 1`
|
|
fi
|
|
done
|
|
|
|
if [ $tests_no -eq 0 ]
|
|
then
|
|
echo "No test binaries found. did you compile?"
|
|
exit 1
|
|
fi
|
|
|
|
# Print tests list whenever user asks for TAP mode. It is up
|
|
# to the caller to make sure it makes sense, i.e. he knows what it
|
|
# represents.
|
|
if [ "$tapmode" ]
|
|
then echo "1..$tests_no"
|
|
fi
|
|
|
|
if [ "$tests" = "$alltests" ]
|
|
then # Print test welcome message
|
|
if [ ! "$tapmode" ]; then clear; fi
|
|
echo -n "${diagprefix}Running POSIX compliance test suite. "
|
|
echo "There are $tests_no tests in total."
|
|
echo "${diagprefix}"
|
|
fi
|
|
|
|
# Provide an argument for test63
|
|
ARGS_63=`pwd`/mod
|
|
|
|
runtest() {
|
|
i=$1
|
|
ARG=$2
|
|
# setuid doesn't work with scripts, so we can only run those as root
|
|
if echo "$rootscripts" | tr ' ' '\n' | grep "^test${i}\$" >/dev/null
|
|
then needroot=1
|
|
else needroot=0
|
|
fi
|
|
# depending on where we are, scripts might have a .sh suffix or not
|
|
if [ -x test${i}.sh ]
|
|
then NAME=./test${i}.sh
|
|
else NAME=./test$i
|
|
fi
|
|
if [ "$ROOT" ]
|
|
then
|
|
if [ $needroot -eq 1 ]
|
|
then $NAME $ARG || return 1
|
|
else su bin -c "$NAME $ARG" || return 1
|
|
fi
|
|
else
|
|
if [ $needroot -eq 1 ]
|
|
then echo "skipping test$i, not root." >&2 && return 0
|
|
else $NAME $ARG || return 1
|
|
fi
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
# Run all the tests, keeping track of who failed.
|
|
for i in `echo $tests`
|
|
do
|
|
if [ -x ./test$i -o -x ./test${i}.sh ]
|
|
then
|
|
total=`expr $total + 1`
|
|
FAIL=0
|
|
ARG=`eval echo "\\${ARGS_$i}"`
|
|
|
|
if [ "$tapmode" ]
|
|
then out=out.$$
|
|
rm -f $out
|
|
runtest $i $ARG >$out 2>&1
|
|
else runtest $i $ARG
|
|
fi
|
|
|
|
FAIL=$?
|
|
|
|
if [ $FAIL -eq 0 ]
|
|
then if [ "$tapmode" ]
|
|
then echo "ok test $i"
|
|
fi
|
|
passed=`expr $passed + 1`
|
|
else if [ "$tapmode" ]
|
|
then echo "not ok test $i"
|
|
fi
|
|
failed=`expr $failed + 1`
|
|
badones=`echo $badones " " $i`
|
|
fi
|
|
|
|
if [ "$tapmode" ]
|
|
then cat $out | sed "s/^/$diagprefix/"
|
|
rm -f $out
|
|
fi
|
|
else
|
|
echo "${diagprefix}warning: skipping test$i"
|
|
skipped=`expr $skipped + 1`
|
|
fi
|
|
done
|
|
|
|
# Print results of the tests.
|
|
if [ "$tests" = "$alltests" ]
|
|
then echo "${diagprefix}"
|
|
if test $total = $passed
|
|
then echo "${diagprefix}All $passed tests completed without error ($skipped skipped)."
|
|
else echo "${diagprefix}Testing completed. Score: $passed passed, $failed failed, skipped $skipped"
|
|
echo "${diagprefix}The following tests failed: $badones"
|
|
fi
|
|
fi
|
|
|
|
# if any test failed return an error
|
|
if [ $failed -gt 0 ]
|
|
then
|
|
exit 1
|
|
fi
|
|
|
|
# echo " "
|