Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Issue 3005003: Don't wait for the http server forever. (Closed)

Created:
10 years, 5 months ago by petkov
Modified:
9 years, 7 months ago
Reviewers:
adlr
CC:
chromium-os-reviews_chromium.org
Visibility:
Public.

Description

Don't wait for the http server forever. This prevents the unit tests from going into an infinite loop if the HTTP server fails to start (for example, because the dev server is already running). BUG=none TEST=ran unit tests with and without dev server running

Patch Set 1 #

Patch Set 2 : fix copyright #

Unified diffs Side-by-side diffs Delta from patch set Stats (+8 lines, -2 lines) Patch
M subprocess_unittest.cc View 1 3 chunks +8 lines, -2 lines 0 comments Download

Messages

Total messages: 2 (0 generated)
petkov
10 years, 5 months ago (2010-07-15 18:03:53 UTC) #1
adlr
10 years, 5 months ago (2010-07-15 18:33:45 UTC) #2
LGTM

On Thu, Jul 15, 2010 at 11:03 AM, <petkov@chromium.org> wrote:

> Reviewers: adlr,
>
> Description:
> Don't wait for the http server forever.
>
> This prevents the unit tests from going into an infinite loop
> if the HTTP server fails to start (for example, because the dev
> server is already running).
>
> BUG=none
> TEST=ran unit tests with and without dev server running
>
> Please review this at http://codereview.chromium.org/3005003/show
>
> SVN Base: ssh://git@gitrw.chromium.org:9222/update_engine.git
>
> Affected files:
>  M subprocess_unittest.cc
>
>
> Index: subprocess_unittest.cc
> diff --git a/subprocess_unittest.cc b/subprocess_unittest.cc
> index
>
86fba0148f93d8b75402354f02c5f573a0142c5b..610644d7aeaacf7be63176549fd2e4b014b0de51
> 100644
> --- a/subprocess_unittest.cc
> +++ b/subprocess_unittest.cc
> @@ -67,6 +67,8 @@ gboolean StartAndCancelInRunLoop(gpointer data) {
>   cancel_test_data->spawned = true;
>   printf("spawned\n");
>   // Wait for server to be up and running
> +  useconds_t total_wait_time = 0;
> +  const useconds_t kMaxWaitTime = 3 * 1000000;  // 3 seconds
>   for (;;) {
>     int status =
>         System(StringPrintf("wget -O /dev/null http://127.0.0.1:%d/foo",
> @@ -76,7 +78,11 @@ gboolean StartAndCancelInRunLoop(gpointer data) {
>         << "command failed to run or died abnormally";
>     if (0 == WEXITSTATUS(status))
>       break;
> -    usleep(100 * 1000);  // 100 ms
> +
> +    const useconds_t kSleepTime = 100 * 1000;  // 100ms
> +    usleep(kSleepTime);  // 100 ms
> +    total_wait_time += kSleepTime;
> +    CHECK_LT(total_wait_time, kMaxWaitTime);
>   }
>   Subprocess::Get().CancelExec(tag);
>   return FALSE;
>
>
>

Powered by Google App Engine
This is Rietveld 408576698