forked from OSchip/llvm-project
[libc++] Add a test that uses the debug database from multiple threads
This test helped us concurrently discover the problem that was fixed in r355367. llvm-svn: 358591
This commit is contained in:
parent
57f686310e
commit
00f2ab1c2f
|
@ -22,6 +22,9 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
#if !defined(_LIBCPP_HAS_NO_THREADS)
|
||||||
|
# include <thread>
|
||||||
|
#endif
|
||||||
#include "container_debug_tests.hpp"
|
#include "container_debug_tests.hpp"
|
||||||
#include "debug_mode_helper.h"
|
#include "debug_mode_helper.h"
|
||||||
|
|
||||||
|
@ -51,6 +54,7 @@ public:
|
||||||
InsertIterIterIter();
|
InsertIterIterIter();
|
||||||
EmplaceIterValue();
|
EmplaceIterValue();
|
||||||
EraseIterIter();
|
EraseIterIter();
|
||||||
|
ThreadUseIter();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SpliceFirstElemAfter();
|
SpliceFirstElemAfter();
|
||||||
|
@ -185,6 +189,36 @@ private:
|
||||||
EXPECT_DEATH( CC.front() );
|
EXPECT_DEATH( CC.front() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ThreadUseIter() {
|
||||||
|
#if !defined(_LIBCPP_HAS_NO_THREADS)
|
||||||
|
CHECKPOINT("thread iter use");
|
||||||
|
const size_t maxRounds = 7;
|
||||||
|
struct TestRunner{
|
||||||
|
void operator()() {
|
||||||
|
for (size_t count = 0; count < maxRounds; count++) {
|
||||||
|
const size_t containerCount = 21;
|
||||||
|
std::vector<Container> containers;
|
||||||
|
std::vector<typename Container::iterator> iterators;
|
||||||
|
for (size_t containerIndex = 0; containerIndex < containerCount; containerIndex++) {
|
||||||
|
containers.push_back(makeContainer(3));
|
||||||
|
Container &c = containers.back();
|
||||||
|
iterators.push_back(c.begin());
|
||||||
|
iterators.push_back(c.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
TestRunner r;
|
||||||
|
const size_t threadCount = 13;
|
||||||
|
std::vector<std::thread> threads;
|
||||||
|
for (size_t count = 0; count < threadCount; count++)
|
||||||
|
threads.emplace_back(r);
|
||||||
|
r();
|
||||||
|
for (size_t count = 0; count < threadCount; count++)
|
||||||
|
threads[count].join();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static void EraseIterIter() {
|
static void EraseIterIter() {
|
||||||
CHECKPOINT("testing erase iter iter invalidation");
|
CHECKPOINT("testing erase iter iter invalidation");
|
||||||
Container C1 = makeContainer(3);
|
Container C1 = makeContainer(3);
|
||||||
|
|
Loading…
Reference in New Issue