The NetBSD Project

CVS log for src/tests/bin/sh/t_fsplit.sh

[BACK] Up to [cvs.NetBSD.org] / src / tests / bin / sh

Request diff between arbitrary revisions


Keyword substitution: kv
Default branch: MAIN


Revision 1.10: download - view: text, markup, annotated - select for diffs
Sat Oct 19 11:59:51 2024 UTC (3 months ago) by kre
Branches: MAIN
CVS tags: HEAD
Diff to: previous 1.9: preferred, colored
Changes since revision 1.9: +1 -64 lines

Delete the dummy "always fail" test.

It has demonstrated that the code elsewhere will successfully
handle sub-test errors, should any occur, so has served its purpose.

Revision 1.9: download - view: text, markup, annotated - select for diffs
Fri Oct 18 09:05:23 2024 UTC (3 months ago) by kre
Branches: MAIN
Diff to: previous 1.8: preferred, colored
Changes since revision 1.8: +195 -48 lines
Always run all sub-tests in a test case.

Previously, as soon as a sub-test in a test case failed,
the sub-test failed along with it, and no further sub-tests
were run, which would mean "fix one, run it again, fix
another, run it again, ...".   Now all the sub-tests that
fail are reported in each run.   Many of the other sh
ATF tests work the same way (approximately anyway).

This does mean that it is no longer possible to do (as was
once done here)

	atf_expect_fail "whatever reason"
	run_the_sub_test
	atf_expect pass

to allow for just one known sub-test to fail, and expect all
the others to work, as the individual sub-tests no longer atf_fail.

This change would have made no observable difference, as all
the sub-tests in all the test cases currently pass.

That's no fun!   So I added a new test case which contains a
bunch of sub-tests, some of which fail.   Don't bother attempting
to work out why, they fail because they were deliberately broken,
that is, broken in the test, not in sh.

Once this update has settled for a day or so, I'll remove that
new test case again (its sub-tests were simply stolen from other
test-cases, there's nothing new, and then some mangled, so they
fail).

While here, since there were (more or less rote) changes throughout,
some sh formatting style changes, 80-col, ..., slipped in as well.

Revision 1.8: download - view: text, markup, annotated - select for diffs
Fri Oct 18 06:32:08 2024 UTC (3 months ago) by kre
Branches: MAIN
Diff to: previous 1.7: preferred, colored
Changes since revision 1.7: +95 -2 lines

Test field splitting as used by the read built-in.

This includes a couple of sub-tests which test for the bug from
PR bin/58749

Other aspects of read should be tested elsewhere (someday).

Revision 1.7: download - view: text, markup, annotated - select for diffs
Sat Jun 24 11:06:17 2017 UTC (7 years, 6 months ago) by kre
Branches: MAIN
CVS tags: phil-wifi-base, phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, phil-wifi-20190609, phil-wifi, pgoyette-compat-merge-20190127, pgoyette-compat-base, pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, pgoyette-compat, perseant-stdc-iso10646-base, perseant-stdc-iso10646, perseant-exfatfs-base-20240630, perseant-exfatfs-base, perseant-exfatfs, netbsd-9-base, netbsd-9-4-RELEASE, netbsd-9-3-RELEASE, netbsd-9-2-RELEASE, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-9, netbsd-10-base, netbsd-10-1-RELEASE, netbsd-10-0-RELEASE, netbsd-10-0-RC6, netbsd-10-0-RC5, netbsd-10-0-RC4, netbsd-10-0-RC3, netbsd-10-0-RC2, netbsd-10-0-RC1, netbsd-10, is-mlppp-base, is-mlppp, cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x
Diff to: previous 1.6: preferred, colored
Changes since revision 1.6: +12 -1 lines

NFC:   Added some comments (about other comments)

We currently parse var expansions like "${x-"a b c"}" incorrectly
according to POSIX (and ancient tradition) though in a way that is
generally unexpcted (there are 2 quoted strings there, according
to the standard, "${x-" and "}" and 'a b c' is unquoted.)  This has
never been fixed in our sh, as like in many other shells, it is just
a little unbelievable, most people expect that inside the {} is a
whole new ballpark, and everything starts again, and it does in cases
like "${x%"a b c"}" (the newer matching operators.)  There have been
comments in this test explaining how the test is actually testing for
incorrect behaviour for a while now.

But I have since learned of POSIX bug #221 (2010), the resolution of which is
to make the problem case unspecified.  This will not actually become part
of posix until the next major version (POSIX 8) whenever that appears (still
years away I expect) - but at least we now can feel happier about the
way our code works and not worry quite so much about testing that incorrect
code keeps working incorrectly....

Revision 1.6: download - view: text, markup, annotated - select for diffs
Sat Jun 3 15:15:49 2017 UTC (7 years, 7 months ago) by kre
Branches: MAIN
CVS tags: netbsd-8-base, netbsd-8-3-RELEASE, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, matt-nb8-mediatek-base, matt-nb8-mediatek
Diff to: previous 1.5: preferred, colored
Changes since revision 1.5: +75 -2 lines

Paranoia:   add a new test case testing that $(( )) results get split
by IFS just the same as any other expansion (split when they should be,
and not when they shouldn't).

Good thing I did ... this discovered a regression in the new expand
code (from an hour or three ago) where quoted arith expansions are
being split, and shouldn't be.  (on the other hand, when they should
be split, they are being split correctly, so that's good...)

No need to worry too much about this, in real life (as opposed to
torture tests) no-one ever puts digits in IFS, and a $(( )) expansion
only ever contains digits, so in practice, splitting never happens,
whether because it is quoted, or just becaue there is nothing to split.

The FreeBSD shell does it correctly (they do word splitting using a
totally different mechanism than we do) - I will find where I missed
testing for quoted expansions later tonight.  Until that happens,
expect a test failure from t_fsplit:split_arith

While here add more comments in the other test casess (one had a comment
already) that our shell parses incorrectly (this is a parsing problem,
not an expansion problem, and the bug has existed forever .. and is
shared by bash).

That is, in an expression like "${var:-word}" the whole thing (including
word) is quoted by the double quotes, and in "${var:-"word"}" the
expansion is quoted, but 'word' is not, the 2nd " (the one before 'w')
ends the opening quote, and the third (before }) turns quoting on
again (it is required that there be an even number of unquoted quotes inside
a ${} expression, so things like "${var:-"word} are simply invalid.)
Another way of saying this, is that if the { is quoted (for which the
only way is using " to get to this kind of expansion at all) the }
must also be quoted (" quoted).  There is no quote nesting here.

This also means that in "${var:-'word'}" the single quotes are just
characters, they are quoted by the "" that surround them, just as in
"a 'string' containing quotes", but "${var:-"'word'"}} is valid and
contains a single quoted word.

Note that this is different than the patetrn-match/trim expansions
( ${var%pattern} etc) where any surrounding quotes do not affect the
pattern, and all forms of quoting can be used in it - but it always
parses as a pattern, and is never subject to filename expansion, so
a '*' in it that is to mean "match any string" does not need special
quoting to avoid it expanding to file names, regardless of whether
the ${var%*} is quoted or not, but a * that is to be matched as a
character literally does need to be quoted.

I will probably file a PR about this bug sometime, but as it is
very old, and doesn't every seem to bother anyone (and is shared by
bash) there isn't any big hurry to open yet another verry messy can
of excrement to fix it...

This does mean that the FreeBSD shell "fails" some of our tests.
(The test is wrong, their shell is correct.)

Revision 1.5: download - view: text, markup, annotated - select for diffs
Sat Jun 3 10:27:05 2017 UTC (7 years, 7 months ago) by kre
Branches: MAIN
Diff to: previous 1.4: preferred, colored
Changes since revision 1.4: +15 -7 lines

Add some extra sub-tests checking splitting of ${#var} - just for my
piece of mind (to verify I was not breaking anything here.)

Also added some commentary better explaining why one of the tests of splitting
quoted variable expansions is almost certainly incorrect (both the tests,
and what sh does) ... though bash does the same as us, so all is not lost!

Revision 1.4: download - view: text, markup, annotated - select for diffs
Sun Mar 27 14:50:01 2016 UTC (8 years, 9 months ago) by christos
Branches: MAIN
CVS tags: prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, localcount-20160914, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan
Diff to: previous 1.3: preferred, colored
Changes since revision 1.3: +6 -1 lines
Finish TEST_SH - all tests should support it now.
Misc other KNF changes, minor bug fixes, and a few minor
extra tests added. (from kre@)

Revision 1.3: download - view: text, markup, annotated - select for diffs
Thu Mar 10 22:30:57 2016 UTC (8 years, 10 months ago) by christos
Branches: MAIN
Diff to: previous 1.2: preferred, colored
Changes since revision 1.2: +4 -1 lines
Set TEST_SH

Revision 1.2: download - view: text, markup, annotated - select for diffs
Tue Mar 8 14:26:54 2016 UTC (8 years, 10 months ago) by christos
Branches: MAIN
Diff to: previous 1.1: preferred, colored
Changes since revision 1.1: +201 -35 lines
Added more test cases, more exhaustive testing. (from kre)

Revision 1.1.2.2: download - view: text, markup, annotated - select for diffs
Tue Apr 17 00:09:02 2012 UTC (12 years, 9 months ago) by yamt
Branches: yamt-pagecache
CVS tags: yamt-pagecache-tag8
Diff to: previous 1.1.2.1: preferred, colored; branchpoint 1.1: preferred, colored; next MAIN 1.2: preferred, colored
Changes since revision 1.1.2.1: +186 -0 lines
sync with head

Revision 1.1.2.1
Sat Mar 17 16:33:11 2012 UTC (12 years, 10 months ago) by yamt
Branches: yamt-pagecache
FILE REMOVED
Changes since revision 1.1: +0 -186 lines
file t_fsplit.sh was added on branch yamt-pagecache on 2012-04-17 00:09:02 +0000

Revision 1.1: download - view: text, markup, annotated - select for diffs
Sat Mar 17 16:33:11 2012 UTC (12 years, 10 months ago) by jruoho
Branches: MAIN
CVS tags: yamt-pagecache-base9, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, tls-maxphys-base, tls-maxphys, tls-earlyentropy-base, tls-earlyentropy, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3, riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7, agc-symver-base, agc-symver
Branch point for: yamt-pagecache
Deprecate tests/util.

Diff request

This form allows you to request diffs between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.

Log view options

CVSweb <webmaster@jp.NetBSD.org>