From 7f7e6f80c5c8c1e67eb022a2bde9918512b98c65 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sun, 14 Apr 2013 19:13:42 -0400 Subject: [PATCH] Modify output-sync tests to be more reliable. --- tests/ChangeLog | 4 ++ tests/scripts/features/output-sync | 88 +++++++++++++++++++++--------- 2 files changed, 67 insertions(+), 25 deletions(-) diff --git a/tests/ChangeLog b/tests/ChangeLog index cf78c58d..31f1dee4 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,11 +1,15 @@ 2013-04-14 Paul Smith + * scripts/features/output-sync: Rewrite to be more reliable. + * test_driver.pl (_run_command): Don't set SIGALRM until after we start the child. Print errors to the top-level output, which will be stderr. (attach_default_output): Use a list of file handles as the stack. (detach_default_output): Ditto. + * scripts/features/output-sync: Add a test for output-sync. + 2013-02-25 Paul Smith * run_make_tests.pl (valid_option): Support the -srcdir flag. diff --git a/tests/scripts/features/output-sync b/tests/scripts/features/output-sync index 66c09365..100646cb 100644 --- a/tests/scripts/features/output-sync +++ b/tests/scripts/features/output-sync @@ -15,18 +15,50 @@ else { $sleep_command = "sleep"; } +@syncfiles = (); + +sub output_sync_clean { + rmfiles('foo/Makefile', 'bar/Makefile', @syncfiles); + rmdir('foo'); + rmdir('bar'); +} + +# We synchronize the different jobs by having them wait for a sentinel file to +# be created, instead of relying on a certain amount of time passing. +# Unfortunately in this test we have to sleep after we see the sync file, +# since we also want to make the obtaining of the write synchronization lock +# reliable. If things are too fast, then sometimes a different job will steal +# the output sync lock and the output is mis-ordered from what we expect. +sub output_sync_wait { + return "while [ ! -f ../mksync.$_[0] ]; do :; done; rm -f ../mksync.$_[0].wait; $sleep_command 1"; +} +sub output_sync_set { + return "date > ../mksync.$_[0]"; +} + +@syncfiles = qw(mksync.foo mksync.bar); + # The following subdirectories with Makefiles are used in several # of the following tests. +output_sync_clean(); mkdir('foo', 0777); mkdir('bar', 0777); +$set_foo = output_sync_set('foo'); +$set_bar = output_sync_set('bar'); + +$wait_foo = output_sync_wait('foo'); +$wait_bar = output_sync_wait('bar'); + open(MAKEFILE,"> foo/Makefile"); print MAKEFILE < bar/Makefile"); print MAKEFILE <