aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/test_sanity.cpp
diff options
context:
space:
mode:
authorMatthew Gregan <[email protected]>2016-11-11 16:27:12 +1300
committerPaul Adenot <[email protected]>2016-11-14 10:00:07 +0100
commit8bab182cd70ff66dec5bbecb69a69422f5d57647 (patch)
tree7ac0fd45df0fae081f561b896f4dd944a1164294 /test/test_sanity.cpp
parent987896408bd85989955e978276660c71aba72a91 (diff)
downloadcubeb-8bab182cd70ff66dec5bbecb69a69422f5d57647.tar.gz
cubeb-8bab182cd70ff66dec5bbecb69a69422f5d57647.zip
Fix TSAN issues in test_sanity.
Diffstat (limited to 'test/test_sanity.cpp')
-rw-r--r--test/test_sanity.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/test/test_sanity.cpp b/test/test_sanity.cpp
index e039999..cbf2248 100644
--- a/test/test_sanity.cpp
+++ b/test/test_sanity.cpp
@@ -9,6 +9,7 @@
#define _XOPEN_SOURCE 600
#endif
#include "cubeb/cubeb.h"
+#include <atomic>
#include <stdio.h>
#include <string.h>
#include <math.h>
@@ -58,7 +59,7 @@ int is_windows_7()
}
static int dummy;
-static uint64_t total_frames_written;
+static std::atomic<uint64_t> total_frames_written;
static int delay_callback;
static long
@@ -468,7 +469,7 @@ TEST(cubeb, stream_position)
delay(500);
/* stream should have prefilled */
- ASSERT_TRUE(total_frames_written > 0);
+ ASSERT_TRUE(total_frames_written.load() > 0);
r = cubeb_stream_get_position(stream, &position);
ASSERT_EQ(r, CUBEB_OK);
@@ -486,7 +487,7 @@ TEST(cubeb, stream_position)
r = cubeb_stream_get_position(stream, &position);
ASSERT_EQ(r, CUBEB_OK);
ASSERT_GE(position, last_position);
- ASSERT_LE(position, total_frames_written);
+ ASSERT_LE(position, total_frames_written.load());
last_position = position;
delay(500);
}
@@ -529,8 +530,8 @@ TEST(cubeb, stream_position)
cubeb_destroy(ctx);
}
-static int do_drain;
-static int got_drain;
+static std::atomic<int> do_drain;
+static std::atomic<int> got_drain;
static long
test_drain_data_callback(cubeb_stream * stm, void * user_ptr, const void * /*inputbuffer*/, void * outputbuffer, long nframes)
@@ -600,7 +601,7 @@ TEST(cubeb, drain)
if (got_drain) {
break;
} else {
- ASSERT_LE(position, total_frames_written);
+ ASSERT_LE(position, total_frames_written.load());
}
delay(500);
}
@@ -611,7 +612,7 @@ TEST(cubeb, drain)
// Really, we should be able to rely on position reaching our final written frame, but
// for now let's make sure it doesn't continue beyond that point.
- //ASSERT_LE(position, total_frames_written);
+ //ASSERT_LE(position, total_frames_written.load());
cubeb_stream_destroy(stream);
cubeb_destroy(ctx);