xref: /minix/minix/tests/testrmib.sh (revision 03de4d97)
1#!/bin/sh
2
3# Shell script used to test the Remote MIB (RMIB) functionality.
4
5# We test a couple of things here, using the rmibtest service and test87:
6# - some cases where remote MIB subtree registration should fail;
7# - a new mount point (minix.rtest) with a small tree behind it, on which we
8#   test some basic reads and writes on an integer pointer and a function;
9# - shadowing of an existing subtree (minix.test) with a similarly looking
10#   subtree, which we then subject to a subset of test87;
11# - resource accounting, making sure everything is the same before and after.
12
13bomb() {
14  echo $*
15  service down rmibtest 2>/dev/null
16  exit 1
17}
18
19PATH=/bin:/usr/bin:/sbin:/usr/sbin
20export PATH
21
22echo -n "Test RMIB "
23
24cd rmibtest
25
26sysctl -q minix.rtest && bomb "there should not be a minix.rtest"
27
28old_nodes=`sysctl -n minix.mib.nodes 2>/dev/null` || bomb "no MIB stats?"
29old_objects=`sysctl -n minix.mib.objects 2>/dev/null` || bomb "no MIB stats?"
30old_remotes=`sysctl -n minix.mib.remotes 2>/dev/null` || bomb "no MIB stats?"
31
32service up `pwd`/rmibtest -label rmibtest -config rmibtest.conf || \
33  bomb "unable to start test service"
34
35cd ..
36
37sleep 1
38
39new_remotes=`sysctl -n minix.mib.remotes 2>/dev/null` || \
40  bomb "unable to get mount stats"
41[ $(($old_remotes + 2)) -eq $new_remotes ] || bomb "mounting subtree failed"
42
43# Test the temporary minix.rtest subtree with its two mirroring nodes
44sysctl -q minix.rtest || bomb "there should be a minix.rtest"
45
46[ $(sysctl -n minix.rtest.int) -eq 5375123 ] || bomb "unexpected int value"
47[ $(sysctl -n minix.rtest.func) -eq 5375123 ] || bomb "unexpected func value"
48sysctl -wq minix.rtest.int=456 || bomb "unable to set int value"
49[ $(sysctl -n minix.rtest.int) -eq 456 ] || bomb "unexpected int value"
50[ $(sysctl -n minix.rtest.func) -eq 456 ] || bomb "unexpected func value"
51sysctl -wq minix.rtest.func=7895375 || bomb "unable to set func value"
52[ $(sysctl -n minix.rtest.int) -eq 7895375 ] || bomb "unexpected int value"
53[ $(sysctl -n minix.rtest.func) -eq 7895375 ] || bomb "unexpected func value"
54
55# Test the minix.test shadowing subtree using a subset of the regular MIB test
56./test87 19 >/dev/null || bomb "test87 reported failure"
57
58service down rmibtest
59
60sleep 1
61
62# Is everything back to the old situation?
63new_nodes=`sysctl -n minix.mib.nodes 2>/dev/null` || bomb "no MIB stats?"
64new_objects=`sysctl -n minix.mib.objects 2>/dev/null` || bomb "no MIB stats?"
65new_remotes=`sysctl -n minix.mib.remotes 2>/dev/null` || bomb "no MIB stats?"
66
67[ $old_nodes -eq $new_nodes ] || bomb "stats not equal after unmount"
68[ $old_objects -eq $new_objects ] || bomb "stats not equal after unmount"
69[ $old_remotes -eq $new_remotes ] || bomb "stats not equal after unmount"
70
71sysctl -q minix.rtest && bomb "there should not be a minix.rtest anymore"
72
73echo "ok"
74exit 0
75