text
stringlengths 0
2.2M
|
---|
namespace {
|
int testStatus = 0;
|
void aSsErT(bool condition, const char *message, int line)
|
{
|
if (condition) {
|
cout << "Error " __FILE__ "(" << line << "): " << message
|
<< " (failed)" << endl;
|
if (0 <= testStatus && testStatus <= 100) {
|
++testStatus;
|
}
|
}
|
}
|
} // close unnamed namespace
|
// ============================================================================
|
// STANDARD BDE TEST DRIVER MACRO ABBREVIATIONS
|
// ----------------------------------------------------------------------------
|
#define ASSERT BSLIM_TESTUTIL_ASSERT
|
#define ASSERTV BSLIM_TESTUTIL_ASSERTV
|
#define LOOP_ASSERT BSLIM_TESTUTIL_LOOP_ASSERT
|
#define LOOP0_ASSERT BSLIM_TESTUTIL_LOOP0_ASSERT
|
#define LOOP1_ASSERT BSLIM_TESTUTIL_LOOP1_ASSERT
|
#define LOOP2_ASSERT BSLIM_TESTUTIL_LOOP2_ASSERT
|
#define LOOP3_ASSERT BSLIM_TESTUTIL_LOOP3_ASSERT
|
#define LOOP4_ASSERT BSLIM_TESTUTIL_LOOP4_ASSERT
|
#define LOOP5_ASSERT BSLIM_TESTUTIL_LOOP5_ASSERT
|
#define LOOP6_ASSERT BSLIM_TESTUTIL_LOOP6_ASSERT
|
#define Q BSLIM_TESTUTIL_Q // Quote identifier literally.
|
#define P BSLIM_TESTUTIL_P // Print identifier and value.
|
#define P_ BSLIM_TESTUTIL_P_ // P(X) without '\n'.
|
#define T_ BSLIM_TESTUTIL_T_ // Print a tab (w/o newline).
|
#define L_ BSLIM_TESTUTIL_L_ // current Line number
|
// ============================================================================
|
// GLOBAL TYPEDEFS/CONSTANTS FOR TESTING
|
// ----------------------------------------------------------------------------
|
int verbose = 0;
|
int veryVerbose = 0;
|
// ----------------------------------------------------------------------------
|
// Class providing thread pool to run testCase functions
|
// ----------------------------------------------------------------------------
|
class MyTask {
|
public:
|
typedef void* (*TestFunc)(int threadNum, const MyTask& task);
|
private:
|
enum { k_MAX_THREADS = 100 };
|
bslmt::ThreadAttributes d_attr;
|
TestFunc d_f;
|
void *d_arg;
|
bslmt::ThreadUtil::Handle d_handles[k_MAX_THREADS];
|
bslmt::Mutex d_logMutex;
|
bsls::AtomicInt d_numThreadsStarted;
|
// number of threads started since last call start ()
|
bsls::AtomicInt d_numThreadsFinished;
|
// number of threads finished since last call start ()
|
bsls::AtomicInt d_totalThreadsStarted;
|
// total number of threads started since task creation
|
bsls::AtomicInt d_totalThreadsFinished;
|
// number of threads finished since task creation
|
bslmt::Barrier *d_barrier;
|
// Barrier to provide hard contention. It is created on each start()call
|
// and it is destroyed on each stop() call
|
public:
|
MyTask(TestFunc f, void *arg);
|
virtual ~MyTask();
|
int start(int numThreads);
|
int stop();
|
void *arg() const
|
{
|
return d_arg;
|
}
|
bslmt::Barrier *barrier() const
|
{
|
return d_barrier;
|
}
|
int numThreadsStarted() const
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.