New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 844597 link

Starred by 2 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug


Sign in to add a comment

Bring base/task_scheduler to 100% code coverage

Project Member Reported by gab@chromium.org, May 18 2018

Issue description

Coverage @ https://chromium-coverage.appspot.com/reports/latest/linux/chromium/src/base/task_scheduler/report.html

@ r559420 we're at 96.5%, a great place to be :)

but looking at the coverage I'm already spotting what initially looks like dead code :
21.5M  if (started_.IsSet()) {
21.2M    AddDelayedTaskNow(std::move(task), delay,
21.2M                      std::move(post_task_now_callback));
21.2M  } else {
301k    AutoSchedulerLock auto_lock(lock_);
301k    if (started_.IsSet()) {
0         AddDelayedTaskNow(std::move(task), delay,
0                           std::move(post_task_now_callback));
301k    } else {
301k      tasks_added_before_start_.push_back(
301k          {std::move(task), std::move(post_task_now_callback)});
301k    }
301k  }

Looking deeper we see this re-check behind the lock is required, so a test exercising PostDelayedTask while starting DelayedTaskManager will be required.
 

Comment 1 by gab@chromium.org, May 18 2018

Hmmm interesting, actually that re-check behind the lock is intentional... I guess we need a racy test to hit that case.

Comment 2 by gab@chromium.org, May 18 2018

Description: Show this description

Comment 3 by gab@chromium.org, May 18 2018

Components: Tools>CodeCoverage

Comment 4 by mmoroz@chromium.org, May 18 2018

Not sure if that's the case of base/task_scheduler, but in general it might be problematic to get a pure 100% coverage due to issue 843209. However, we'll eventually find a solution for that, so just FYI.
Project Member

Comment 5 by bugdroid1@chromium.org, May 22 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/029d79cd5c7d38489ba843951f0ec47f213bf05a

commit 029d79cd5c7d38489ba843951f0ec47f213bf05a
Author: Gabriel Charette <gab@chromium.org>
Date: Tue May 22 16:08:12 2018

[TaskScheduler] Add a test to exercise AddDelayedTask() during Start().

https://chromium-coverage.appspot.com/reports/559420/linux/chromium/src/base/task_scheduler/delayed_task_manager.cc.html

Highlighted that we had untested code. The re-check behind the lock is
required to support AddDelayedTask() racing with Start(). Added a test
for this race which will hopefully trigger coverage here :)

21.5M  if (started_.IsSet()) {
21.2M    AddDelayedTaskNow(std::move(task), delay,
21.2M                      std::move(post_task_now_callback));
21.2M  } else {
301k    AutoSchedulerLock auto_lock(lock_);
301k    if (started_.IsSet()) {
0         AddDelayedTaskNow(std::move(task), delay,
0                           std::move(post_task_now_callback));
301k    } else {
301k      tasks_added_before_start_.push_back(
301k          {std::move(task), std::move(post_task_now_callback)});
301k    }
301k  }

R=fdoray@chromium.org

Bug: 844597
Change-Id: I7bd9f47e0c76db5f0a4309210db33cb746b83eeb
Reviewed-on: https://chromium-review.googlesource.com/1066621
Reviewed-by: François Doray <fdoray@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560626}
[modify] https://crrev.com/029d79cd5c7d38489ba843951f0ec47f213bf05a/base/task_scheduler/delayed_task_manager_unittest.cc

Comment 6 by gab@chromium.org, May 22 2018

@#4, thanks for the FYI mmoroz@ : in base/task_scheduler we typically have death tests to exercise our DCHECKs, will this work?

Comment 8 by gab@chromium.org, May 22 2018

Blockedon: 843209

Comment 9 by gab@chromium.org, May 22 2018

Cc: fdoray@chromium.org
@fdoray:

in lazy_task_runner.cc we have :

29  47.5k   // Return if no reference is held by this instance.
30  47.5k   if (!state)
31  0         return;

I guess we just need to test that double Reset() no-ops.

Comment 10 by gab@chromium.org, May 22 2018

Blockedon: 845575

Comment 11 by gab@chromium.org, May 22 2018

Blockedon: 845590

Comment 12 by gab@chromium.org, May 22 2018

Blockedon: 809150
Project Member

Comment 13 by bugdroid1@chromium.org, May 23 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/260715d73a50435907a404e14f8eeed563d83b92

commit 260715d73a50435907a404e14f8eeed563d83b92
Author: Gabriel Charette <gab@chromium.org>
Date: Wed May 23 19:40:03 2018

[TaskScheduler] Remove unused Sequence::PeekTaskTraits()

R=fdoray@chromium.org

Bug: 844597
Change-Id: I9ee0e989c5e77922e7d6cc57cea3cab6d024966b
Reviewed-on: https://chromium-review.googlesource.com/1067651
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561209}
[modify] https://crrev.com/260715d73a50435907a404e14f8eeed563d83b92/base/task_scheduler/sequence.cc
[modify] https://crrev.com/260715d73a50435907a404e14f8eeed563d83b92/base/task_scheduler/sequence.h

Project Member

Comment 14 by bugdroid1@chromium.org, May 23 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2ea8d0a1b24aca6e5a6e9e553d8a3555f1f83c3f

commit 2ea8d0a1b24aca6e5a6e9e553d8a3555f1f83c3f
Author: Gabriel Charette <gab@chromium.org>
Date: Wed May 23 22:55:25 2018

[TaskScheduler] Delete unused operator in priority_queue.cc

R=fodray@chromium.org

Bug: 844597
Change-Id: I22a339568de6596335b64c947fbe87be060c469e
Reviewed-on: https://chromium-review.googlesource.com/1067646
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561294}
[modify] https://crrev.com/2ea8d0a1b24aca6e5a6e9e553d8a3555f1f83c3f/base/task_scheduler/priority_queue.cc

Comment 15 by gab@chromium.org, May 24 2018

Labels: -Hotlist-GoodFirstBug
Status: ExternalDependency (was: Available)
Turns out these were the only little things missing coverage :)

Everything else is because of the issues blocking this bug (DCHECKs are not covered, nor is code only running in dcheck builds, and code specific to Windows configuration isn't covered either).
Owner: gab@chromium.org
Status: Assigned (was: ExternalDependency)
DCHECKs are now covered. Can you evaluate results and report any issue you see. Once done, then feel free to put back to available (blocked on windows support).

Comment 17 by gab@chromium.org, May 25 2018

Labels: Hotlist-GoodFirstBug
Owner: ----
Status: Available (was: Assigned)
Nice, that brings us to 97.57% :).

It still reports some DCHECKs as uncovered but I guess that's because they're never hit (i.e. we'd need more death tests).

Remaining things are :
 * a few one-liners (e.g. simple early no-op returns when doing an operation twice) which I'd missed when they were surrounded with missing DCHECK coverage.
 * code specific to Windows configuration (issue 809150)
 * code evaluated at compile-time (constexpr) (issue 845575)

Nothing high-priority but we could go up a few more points before being blocked again with thorough death tests and redundant tests (no-op on second call).

Sign in to add a comment