Page MenuHomeFreeBSD

fix racy xargs test
ClosedPublic

Authored by lifanov_mail.lifanov.com on Aug 19 2015, 6:27 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 25 2024, 12:05 PM
Unknown Object (File)
Jan 6 2024, 4:08 PM
Unknown Object (File)
Dec 27 2023, 12:20 AM
Unknown Object (File)
Dec 19 2023, 9:52 PM
Unknown Object (File)
Nov 13 2023, 11:07 AM
Unknown Object (File)
Nov 13 2023, 9:09 AM
Unknown Object (File)
Oct 25 2023, 5:40 AM
Unknown Object (File)
Sep 5 2023, 3:52 AM
Subscribers

Details

Reviewers
allanjude
ngie
Summary

sort test output for xargs -n2 -P0

Test Plan

kyua test in usr.bin/xargs

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 179
Build 179: arc lint + arc unit

Event Timeline

lifanov_mail.lifanov.com retitled this revision from to fix racy xargs test.
lifanov_mail.lifanov.com updated this object.
lifanov_mail.lifanov.com edited the test plan for this revision. (Show Details)

This won't fix it unfortunately. The test does a direct comparison of output. It needs to use a slightly more intelligent algorithm for determining pass/fail criteria.

If the output was changed to this:

  1. quick brown
  2. fox jumped
  3. over the
  4. lazy dog

Running cat file | xargs -P0 | sort -n should give the desired output 100% of the time.

In D3432#70298, @ngie wrote:

This won't fix it unfortunately. The test does a direct comparison of output. It needs to use a slightly more intelligent algorithm for determining pass/fail criteria.

If the output was changed to this:

  1. quick brown
  2. fox jumped
  3. over the
  4. lazy dog

Running cat file | xargs -P0 | sort -n should give the desired output 100% of the time.

The assumption I made was that these were on separate lines. This is definitely not the case. My suggestion might be on the right track (numbering), but the solution itself is flawed.

Ugh. I totally missed the | sort part in regress.sh. Yes, that's fine..

ngie edited edge metadata.
This revision is now accepted and ready to land.Aug 21 2015, 6:27 PM

Please let me know if my proposed change to use sort instead of sort -u seems reasonable.

Before:

  • Deterministically failed on my VMware Fusion instance.

After:

  • Survived 200 consecutive runs with kyua test (I changed the sort command to use sort instead of sort -u to avoid disguising potential bugs with xargs):

$ cd /usr/tests/usr.bin/xargs
$ for i in $(seq 1 200); do kyua test||break; done

$ svn diff .

Index: regress.n2P0.out

  • regress.n2P0.out (revision 287002)

+++ regress.n2P0.out (working copy)
@@ -1,4 +1,4 @@
-quick brown
fox jumped
+lazy dog
over the
-lazy dog
+quick brown

Index: regress.sh

  • regress.sh (revision 287004)

+++ regress.sh (working copy)
@@ -12,7 +12,7 @@
REGRESSION_TEST(R', xargs -I% -R1 echo The % % % %% % % <${SRCDIR}/regress.in')
REGRESSION_TEST(n1', xargs -n1 echo <${SRCDIR}/regress.in')
REGRESSION_TEST(n2', xargs -n2 echo <${SRCDIR}/regress.in')
-#REGRESSION_TEST(n2P0',xargs -n2 -P0 echo <${SRCDIR}/regress.in')
+REGRESSION_TEST(n2P0',xargs -n2 -P0 echo <${SRCDIR}/regress.in | sort')
REGRESSION_TEST(n3', xargs -n3 echo <${SRCDIR}/regress.in')
REGRESSION_TEST(0', xargs -0 -n1 echo <${SRCDIR}/regress.0.in')
REGRESSION_TEST(0I', xargs -0 -I% echo The % %% % <${SRCDIR}/regress.0.in')

lifanov_mail.lifanov.com edited edge metadata.

reroll patch and replace "sort -u" with "sort" per ngie's feedback

This revision now requires review to proceed.Aug 21 2015, 6:39 PM
ngie edited edge metadata.

Committed in r287005 -- thanks :)!

This revision is now accepted and ready to land.Aug 21 2015, 6:44 PM

The change has been committed in r287005.