Opened 12 months ago

#26105 new defect

Perhaps, make test coverage deterministic _within_ lines

Reported by: nickm Owned by:
Priority: Low Milestone: Tor: unspecified
Component: Core Tor/Tor Version:
Severity: Normal Keywords: coverage, tests, determinism
Cc: catalyst Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

See #25907 and #26101 for background: apparently gcov now has a feature where it can tell us that a line was reached, but not every basic block within the line was reached.

Right now, our unit tests have two cases where sometimes a line is completely covered, and sometime the line is only partially covered:

--- a/workqueue.c.gcov.tmp
+++ /workqueue.c.gcov.tmp
@@ -198,7 +198,7 @@
         1:  tor_mutex_acquire(&ent->on_pool->lock);
         1:  workqueue_priority_t prio = ent->priority;
         1:  if (ent->pending) {
-        1*:    TOR_TAILQ_REMOVE(&ent->on_pool->work[prio], ent, next_work);
+        1:    TOR_TAILQ_REMOVE(&ent->on_pool->work[prio], ent, next_work);
         1:    cancelled = 1;
         1:    result = ent->arg;
         -:  }
--- a/compat_pthreads.c.gcov.tmp
+++ /compat_pthreads.c.gcov.tmp
@@ -271,7 +271,7 @@
         -:      }
         1:      tvnow.tv_sec = ts.tv_sec;
         1:      tvnow.tv_usec = (int)(ts.tv_nsec / 1000);
-        1*:      timeradd(tv, &tvnow, &tvsum);
+        1:      timeradd(tv, &tvnow, &tvsum);
         -:#else /* !(defined(HAVE_CLOCK_GETTIME) && defined(USE_COND_CLOCK)) */
         -:      if (gettimeofday(&tvnow, NULL) < 0)
         -:        return -1;

Unless coveralls cares about these, I think solving the determinism here is not super-important, though it might be fun from a completionist perspective.

Child Tickets

Change History (0)

Note: See TracTickets for help on using tickets.