2000-01-15 02:00:06 +00:00
|
|
|
/********************************************************************
|
|
|
|
* COPYRIGHT:
|
2001-03-21 20:09:56 +00:00
|
|
|
* Copyright (c) 1997-2001, International Business Machines Corporation and
|
2000-01-15 02:00:06 +00:00
|
|
|
* others. All Rights Reserved.
|
|
|
|
********************************************************************/
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
#include "tsmutex.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2000-06-30 21:35:03 +00:00
|
|
|
#ifdef U_SOLARIS
|
1999-08-16 21:50:52 +00:00
|
|
|
#include <signal.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//////////////////////////
|
|
|
|
//
|
|
|
|
// Simple Mutex structure
|
|
|
|
// Increments lockCount each time the mutex is locked.
|
|
|
|
// Decrements lockCount each time the mutex is unlocked.
|
|
|
|
//Note: This test does not actually create locks, since
|
|
|
|
//that would be platform specific. This test simply tests
|
|
|
|
//the functionality of the Mutex class.
|
|
|
|
//
|
|
|
|
//////////////////////////
|
|
|
|
#if 0
|
|
|
|
struct MyMutexImp {
|
|
|
|
MyMutexImp();
|
|
|
|
uint32_t lockCount;
|
|
|
|
};
|
|
|
|
|
|
|
|
MyMutexImp::MyMutexImp() {
|
|
|
|
lockCount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _myLock(MutexPointer p) {
|
|
|
|
MyMutexImp* imp = (MyMutexImp*)p;
|
|
|
|
(imp->lockCount)++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void _myUnlock(MutexPointer p) {
|
|
|
|
MyMutexImp* imp = (MyMutexImp*)p;
|
|
|
|
(imp->lockCount)--;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
//////////////////////////
|
|
|
|
//
|
|
|
|
// The Test Class
|
|
|
|
//
|
|
|
|
//////////////////////////
|
|
|
|
MutexTest::MutexTest() {
|
|
|
|
}
|
|
|
|
|
|
|
|
MutexTest::~MutexTest() {
|
|
|
|
}
|
|
|
|
|
2000-05-18 22:08:39 +00:00
|
|
|
void MutexTest::runIndexedTest( int32_t index, UBool exec,
|
2000-08-23 19:11:16 +00:00
|
|
|
const char* &name, char* /*par*/ ) {
|
1999-08-16 21:50:52 +00:00
|
|
|
if (exec) logln("TestSuite MutexTest: ");
|
|
|
|
switch (index) {
|
|
|
|
case 0: name = "TestMutex"; if (exec) TestMutex(); break;
|
|
|
|
|
|
|
|
default: name = ""; break; //needed to end loop
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-25 22:15:52 +00:00
|
|
|
UBool MutexTest::gMutexInitialized = FALSE;
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
void MutexTest::TestMutex() {
|
2002-04-25 22:15:52 +00:00
|
|
|
/* This is tested in intltest.cpp before anything starts. */
|
|
|
|
if (!gMutexInitialized) {
|
2002-05-23 23:56:47 +00:00
|
|
|
logln("*** Failure! The global mutex was not initialized.\n"
|
2002-04-25 22:15:52 +00:00
|
|
|
"*** Make sure the right linker was used.\n");
|
|
|
|
}
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MutexTest::TestLock() {
|
2002-05-23 23:56:47 +00:00
|
|
|
}
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
|