This revision adds some tests for racct. They test the upcoming addition of racct to POSIX shared memory as well as the upcoming fixes to pcpu and cputime calculations.
Overall this looks good to me. There are some stylistic nits which I pointed out.
What do you think of adding a short test to verify the runtime accounting? It might be easiest to write a short C program which loops for N seconds (with N == 3 or so, we don't want tests that take too long to run) and exits. alarm(3) would be a useful function there.
This can be removed, it's a holdover from when we used Subversion. It's not useful anymore.
|6 ↗||(On Diff #91531)|
It's good form to also set descr to a sentence describing what the test is verifying.
|97 ↗||(On Diff #91531)|
Rather than checking exit statuses manually, you might consider using atf-check(1).
|121 ↗||(On Diff #91531)|
Since you're defining names for the parameters, it's a bit nicer to make them locally-scoped:
local jailname i size jailname=$1 ...
|135 ↗||(On Diff #91531)|
A simpler way to write these kinds of loops is
for i in $(seq 1 $max); do ... done
Then you don't need to initialize $i or increment it.
I have added a test for cputime and pcpu which takes 4 seconds to complete. Since it is a loop that executes another process, the calculations involved are inexact (compared to a loop that simply spins) and we cannot expect a precise value for these measurements.
I have also added another interesting test, for maxproc. It is a currently failing test, but I'm not sure why. The test uses a process to create 6 children, but expects to fail on the last one. In my manual testing, I have found that it instead fails on the 5th child even though maxproc is set to 5 (the parent process does not count as one of the processes, since it is executed using jexec). We can change this to atf_expect_fail, if needed.