Skip to content

Commit

Permalink
use atomic for global test counters
Browse files Browse the repository at this point in the history
TSAN is failing because
multiple threads are incrementing the
same global

[email protected]

Bug: skia:
Change-Id: I9c3bc6bb4aa7cbe7ced5b3080790d3c4ad1ff798
Reviewed-on: https://skia-review.googlesource.com/146446
Commit-Queue: Cary Clark <[email protected]>
Reviewed-by: Cary Clark <[email protected]>
Auto-Submit: Cary Clark <[email protected]>
  • Loading branch information
Cary Clark committed Aug 9, 2018
1 parent 81aa38d commit 8af4c40
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion tests/PathOpsChalkboardTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
#include "PathOpsExtendedTest.h"
#include "PathOpsThreadedCommon.h"
#include "SkRandom.h"
#include <atomic>

#define TEST(name) { name, #name }

static int gTestNo = 0;
static std::atomic<int> gTestNo{0};

static void chalkboard(skiatest::Reporter* reporter, uint64_t testlines) {
SkPath path;
Expand Down
3 changes: 2 additions & 1 deletion tests/PathOpsOpCircleThreadedTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
#include "PathOpsExtendedTest.h"
#include "PathOpsThreadedCommon.h"
#include "SkString.h"
#include <atomic>

static int loopNo = 4;
static int gCirclesTestNo = 0;
static std::atomic<int> gCirclesTestNo{0};

static void testOpCirclesMain(PathOpsThreadState* data) {
SkASSERT(data);
Expand Down
3 changes: 2 additions & 1 deletion tests/PathOpsOpCubicThreadedTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
#include "PathOpsExtendedTest.h"
#include "PathOpsThreadedCommon.h"
#include "SkString.h"
#include <atomic>

static int loopNo = 158;
static int gCubicsTestNo = 0;
static std::atomic<int> gCubicsTestNo{0};

static void testOpCubicsMain(PathOpsThreadState* data) {
#if DEBUG_SHOW_TEST_NAME
Expand Down
3 changes: 2 additions & 1 deletion tests/PathOpsOpLoopThreadedTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "PathOpsExtendedTest.h"
#include "PathOpsThreadedCommon.h"
#include "SkString.h"
#include <atomic>

static int loopNo = 17;

Expand All @@ -27,7 +28,7 @@ static void add_point(SkString* str, SkScalar x, SkScalar y) {
}
}

static int gLoopsTestNo = 0;
static std::atomic<int> gLoopsTestNo{0};

static void testOpLoopsMain(PathOpsThreadState* data) {
#if DEBUG_SHOW_TEST_NAME
Expand Down
5 changes: 3 additions & 2 deletions tests/PathOpsOpRectThreadedTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "PathOpsExtendedTest.h"
#include "PathOpsThreadedCommon.h"
#include "SkString.h"
#include <atomic>

// four rects, of four sizes
// for 3 smaller sizes, tall, wide
Expand All @@ -17,7 +18,7 @@
// cw or ccw (1 bit)

static int loopNo = 6;
static int gRectsTestNo = 0;
static std::atomic<int> gRectsTestNo{0};

static void testPathOpsRectsMain(PathOpsThreadState* data)
{
Expand Down Expand Up @@ -105,7 +106,7 @@ DEF_TEST(PathOpsRectsThreaded, reporter) {
testRunner.render();
}

static int gFastTestNo = 0;
static std::atomic<int> gFastTestNo{0};

static void testPathOpsFastMain(PathOpsThreadState* data)
{
Expand Down
3 changes: 2 additions & 1 deletion tests/PathOpsTigerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "PathOpsDebug.h"
#include "PathOpsExtendedTest.h"
#include "PathOpsThreadedCommon.h"
#include <atomic>

#define TEST(name) { name, #name }

Expand Down Expand Up @@ -133,7 +134,7 @@ path.close();
testSimplify(reporter, path, filename);
}

int gTigerTests = 0;
static std::atomic<int> gTigerTests{0};

static void tiger8a_x(skiatest::Reporter* reporter, uint64_t testlines) {
SkPath path;
Expand Down

0 comments on commit 8af4c40

Please sign in to comment.