<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 26, 2017 at 2:41 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:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On 04/25/2017 12:28 PM, enh wrote:<br>
> note that the existing SKIP_HOST mechanism is very error prone. iirc<br>
> none of the sed tests actually run because one near the top needs<br>
> SKIP_HOST and it never gets unset.<br>
<br>
</span>I thought that "VARIABLE=value command" worked the same for shell<br>
functions as it does for external commands? Hmmm...<br>
<br>
$ make test_sed > one.txt<br>
$ TEST_HOST=1 make test_sed > two.txt<br>
$ diff -u one.txt two.txt | grep '^[+-]'<br>
...<br>
-PASS: sed sed - - twice<br>
-PASS: sed match \n literal n<br>
-PASS: sed c empty continuation<br>
-PASS: sed 'y/a\bc/de\f/'<br>
+FAIL: sed 'y/a\bc/de\f/'<br>
-PASS: sed skip start of range<br>
+FAIL: sed skip start of range<br>
<br>
The first three are the ones we skip, the second the host version is<br>
failing but the target version isn't so possibly they should be<br>
annotated too. (Or at least have a comment...)<br>
<br>
What shell are you using to run this? (Not bash?)</blockquote><div><br></div><div>hmm, maybe this got fixed since i last saw it? with TEST_HOST=1 make test_sed i'm not seeing any "SKIP" output, whereas when i ran in to this i saw a whole wall of yellow "SKIP" lines.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-"><br>
> SKIP_HOST is also not very intention-revealing. i'd prefer to explicitly<br>
> distinguish "host tool is just plain broken" from "we deliberately chose<br>
> to diverge [because ...]".<br>
<br>
</span>Which is why I added comments before them, ala:<br>
<br>
# This segfaults ubuntu 12.04's sed. No really.<br>
SKIP_HOST=1 testing 'sed - - twice' 'sed "" - -' "hello\n" "" "hello\n"<br>
<br>
But I see I haven't kept up with that. Blah. (Presumably git annotate<br>
should give a commit comment, and/or let me know what date to look for a<br>
mailing list entry or blog post. I'll throw it on the todo list.)</blockquote><div><br></div><div>exactly: having the skip mechanism require a string would help keep us honest.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-"><br>
> cases like sh.test are awkward too...<br>
<br>
</span>Yeah shellit() tries to compensate a bit but I haven't opened the toysh<br>
can of worms yet. (Tim Bird asked me what it would take to do toysh, and<br>
my estimate was 6 months full-time devoted to it, but he hasn't got a<br>
budget to buy my time from my employer. Meanwhile $DAYJOB is focused on<br>
winning solar/wind grid integration monitoring contracts. The market<br>
opportunity for that is likely to explode in about 3 years and we need<br>
to deploy stuff people can buy before then and be ready to scale up, so<br>
getting any time to spend on toybox takes a bit of pushing...)<br>
<br>
On the bright side I got <a href="https://github.com/landley/mkroot" rel="noreferrer" target="_blank">https://github.com/landley/<wbr>mkroot</a> a bit more<br>
fluffed out this week. Once I get all the musl-cross-make targets<br>
booting, I can coordinate with Rich to get him to tag and ship an actual<br>
release with binaries you can download (maybe he'll even put the<br>
mcm-buildall.sh script in _his_ repo instead of mine).<br>
<br>
Building kernels with mkroot needs toybox commit 9be140ebb29f so I'll<br>
have to cut a new release here to coincide with the mkroot release, but<br>
it's coming up on time for that anyway...<br>
<span class="gmail-"><br>
> exponentiation is a bash extension<br>
> to the more widespread arithmetic extension (which is all the test<br>
> tests).<br>
<br>
</span>Oh toysh is going to need quite possibly a thousand lines of tests. The<br>
tests I have _now_ are just ones that I had lying around because I was<br>
poking at something that was doing this...<br></blockquote><div><br></div><div>mksh has a thousand line perl script to run 13k lines of tests that look like</div><div><br></div><div><div>name: xtrace-2</div><div>description:</div><div> Check that "set -x" is off during PS4 expansion</div><div>stdin:</div><div> f() {</div><div> print -n "(f1:$-)"</div><div> set -x</div><div> print -n "(f2:$-)"</div><div> }</div><div> PS4='[(p:$-)$(f)] '</div><div> print "(o0:$-)"</div><div> set -x -o inherit-xtrace</div><div> print "(o1:$-)"</div><div> set +x</div><div> print "(o2:$-)"</div><div>expected-stdout:</div><div> (o0:sh)</div><div> (o1:shx)</div><div> (o2:sh)</div><div>expected-stderr:</div><div> [(p:sh)(f1:sh)(f2:sh)] print '(o1:shx)'</div><div> [(p:sh)(f1:sh)(f2:sh)] set +x</div></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I thought it was bc/dc but:<br>
<br>
$ dc "1+2"<br>
dc: Could not open file 1+2<br>
$ bc "1+2"<br>
File 1+2 is unavailable.<br>
<br>
Those are both _way_ too stupid to use as a quick and dirty calculator<br>
from the command line. (I usually do echo $((1+2)) when I don't need<br>
floating point, and fire up python when I do. But there should be a<br>
better way, possibly I should have toysh $(()) support floating point?<br>
Hmmm...)<br>
<span class="gmail-"><br>
> so although it's "sh.test", it explicitly invokes "bash".<br>
<br>
</span>Because toysh should provide the bash alias along with bash functionality.<br>
<br>
Ubuntu's epically stupid <a href="https://wiki.ubuntu.com/DashAsBinSh" rel="noreferrer" target="_blank">https://wiki.ubuntu.com/<wbr>DashAsBinSh</a> broke the<br>
#!/bin/sh symlink to point to a broken shell (seriously, at the time it<br>
segfaulted and got signal handling wrong and...), so scripts explicitly<br>
say #!/bin/bash instead. I intend to provide a reasonable bash<br>
replacement that runs those scripts.<br>
<br>
Bash was the first program linux ever ran (and running bash was the<br>
reason Linus implemented system calls in his term program), so it was<br>
the standard shell of Linux from 1991 to 2006. Ubuntu's stated reason<br>
for changing this (speeding up init scripts) didn't work (they then<br>
implemented upstart to get parallelism), but they never admitted the<br>
mistake and reverted it. They said that changing the #! at the start of<br>
each init script was too intrusive a change, so they broke the kernel<br>
build instead.<br>
<br>
That's why all my scripts say #!/bin/bash and not #!/bin/sh. I need to<br>
replace _that_.<br>
<span class="gmail-"><br>
> and if you "fix" it by running sh, bash-as-sh fails too. for now i just have an<br>
> explicit case to skip sh.test in my Android toybox test runner, but in<br>
> an ideal world it would be more fine-grained than that.<br>
<br>
</span>My infrastructure checks .config and should skip tests for commands that<br>
are disabled?<br></blockquote><div><br></div><div>huh. i hadn't thought of that (though i had thought of its moral equivalent: checking to see whether the tool in question is a symlink to `toybox`). that's an option, though i'm potentially still interested in running the toybox tests against a non-toybox implementation. (but maybe my runner should check against .config and explicitly say when we're not running toybox.)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Alas, I don't have a "pending" for the tests directory. In an ideal<br>
world I'd be making progress fast enough this wouldn't be an issue. In<br>
practice we're coming up on the one year anniversary of $DAYJOB's<br>
"funding knothole" where we've been in perpetual crisis mode ever since.<br>
(It's compelling technology I really want to see ship, but the pay sucks<br>
and it's eating my life. Doing what I can here...)<br>
<br>
In the meantime, I can add a check for "bash" in the $PATH and skip if<br>
not". Does that help?</blockquote><div><br></div><div>if you hadn't committed it already i'd say "don't worry about it": there's not enough in sh.test at the moment to worry about. what i _ought_ to be doing for shell testing is building a perl binary to run the mksh suite, but the thought of building perl in 2017 really stretches my pragmatism to its limit!<br></div><div><br></div><div>i'm more interested in seeing the gzip/gunzip/zcat tests go in so we can start arguing about how to upstream my toybox rewrite of the toolbox zlib-based gzip/gunzip/zcat. (i did the port on monday, so i do have a toybox gzip/gunzip/zcat that passes the tests, but i didn't even try to integrate the half-finished gz code from toys/pending/compress.c.)</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-"><br>
> here though, is there a strong reason to prefer \e? otherwise why not<br>
> just do what the host does in this case?<br>
<br>
</span>Because "man echo" says \e and my escape/unescape plumbing is<br>
symmetrical. I'd have to special case it to _not_ understand this.<br>
<br>
I suppose I can also have the test run the output through sed to replace<br>
"\e" with "\033" and then it'd except either?<br>
<div class="gmail-HOEnZb"><div class="gmail-h5"><br>
Rob<br>
______________________________<wbr>_________________<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/<wbr>listinfo.cgi/toybox-landley.<wbr>net</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Elliott Hughes - <a href="http://who/enh" target="_blank">http://who/enh</a> - <a href="http://jessies.org/~enh/" target="_blank">http://jessies.org/~enh/</a><br>Android native code/tools questions? Mail me/drop by/add me as a reviewer.</div>
</div></div>