<div dir="ltr">Quothe the Raven, "Nevermore."</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 26, 2015 at 1:29 PM, Rob Landley <span dir="ltr"><<a href="mailto:rob@landley.net" target="_blank">rob@landley.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Sorry for the radio silence, I've been working on stuff.<br>
<br>
So there's a pile of ps and top patches awaiting me on the list, and I<br>
want to fold top _into_ patch because in theory they're 90% the same<br>
infrastructure. So I started by adding --sort to ps, which involved<br>
splitting the "fetch data from /proc" and "display data" parts into<br>
two separate passes. (In the common case the first function calls the<br>
second, and I managed to slice and dice toybuf so it all still fits in<br>
there in that case.)<br>
<br>
However, breaking stuff up and shuffling it around broke things, to<br>
the point where the TTY field is showing "-1:-1" for some processes,<br>
and I need to retest everything in ps to make sure I fix it all.<br>
(That's why I haven't checked it in yet, right now it's a regression.)<br>
<br>
As LONG as I need to retest everything, I decided to sit down and fix<br>
up the aboriginal linux infrastructure to let me run a testsuite in a<br>
controlled (and run as root) environment under there.<br>
<br>
So I did the aboriginal upgrades (including more granular dependencies<br>
that make rebuilding minor userspace tweaks over and over go faster),<br>
and started a ps test suite and...<br>
<br>
It's still pretty darn hard. Here's what I have so far<br>
<br>
---<br>
#!/bin/sh<br>
<br>
[ -f testing.sh ] && . testing.sh<br>
<br>
notroot && continue<br>
<br>
#testing "name" "command" "result" "infile" "stdin"<br>
<br>
# This is necessarily somewhat brittle, because the PID numbers change<br>
# all over the place (how many kernel threads did this kernel version launch?)<br>
# the time field can change, tty varies by target (serial device name)...<br>
<br>
# We test matching expected PIDs under aboriginal linux running under qemu for<br>
# the first few, then mask them out or don't request them for the rest.<br>
<br>
TTY="$(tty | sed 's@^/dev/@@')"<br>
<br>
# The $() around printf strips trailing newline, so we have to add it back<br>
DEFPAT="%5s %-8s 00:00:00 %s\n"<br>
<br>
# calculat/match an actual PID<br>
BASEPID="$(awk '{print $1}' /proc/self/stat)"<br>
testing "ps" "ps | tail -n 2" "$(printf $DEFPAT\n" $(($BASEPID+5))<br>
$TTY ps $(($BASEPID+6)) $TTY "tail -n 2")\n" "" ""<br>
# init can use a single digit number of seconds of cpu time before this breaks<br>
testing "ps -A" "ps -A | head -n 2 | sed 's/00:00:0[0-9]/00:00:00/'" \<br>
"$(printf $DEFPAT\n" 1 ? BLAH" "" ""<br>
<br>
-----<br>
<br>
And the "BLAH" part at the end is where I hit "of course the name of<br>
init isn't init here, in this test environment it's "/sbin/oneit -c<br>
/dev/ttySO /mnt/init" which is TOTALLY generic isn't it? I'm already<br>
hitting the time with sed to regularize it and have a HEURISTIC to<br>
skip 5 process IDs because that's what the "testing" script eats<br>
before running the actual test, but _that_ level of regularizing means<br>
what am I actually _testing_ here...<br>
<br>
Grrr. When I say many tests are easy to do by hand and a serious pain<br>
to automate, that is exactly what I mean...<br>
<br>
Rob<br>
<br>
P.S. The kernel moved the jiffy start time to something like ten<br>
minutes before it wraps to force that to get testing, it hasn't done<br>
that to the PIDs but it COULD. Probably won't because PID 1 is special<br>
and it already wraps in regular use anyway, but still...<br>
_______________________________________________<br>
Toybox mailing list<br>
<a href="mailto:Toybox@lists.landley.net">Toybox@lists.landley.net</a><br>
<a href="http://lists.landley.net/listinfo.cgi/toybox-landley.net" rel="noreferrer" target="_blank">http://lists.landley.net/listinfo.cgi/toybox-landley.net</a><br>
</blockquote></div><br></div>