Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
DISCONTINUED:openSUSE:11.2
blocxx
blocxx-1.0.0-testsuite01.dif
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File blocxx-1.0.0-testsuite01.dif of Package blocxx
--- test/unit/IPCMutexTestCases.cpp +++ test/unit/IPCMutexTestCases.cpp 2006/03/27 18:43:33 @@ -36,6 +36,7 @@ #include <sys/ipc.h> #include <sys/shm.h> #include <sys/types.h> +#include <signal.h> #include <unistd.h> @@ -79,13 +80,16 @@ void IPCMutexTestCases::testSomething() { size_t sz = sizeof(SharedStuff_t); - int pid = fork(); + pid_t own, pid = fork(); unitAssert(pid != -1); if (pid == 0) { // child cout << endl; - sleep (1); + + own = getpid(); + kill(own, SIGSTOP); + int shmid = shmget(IPCMUTEX_KEYVAL, sz, 0666); unitAssert(shmid != -1); SharedStuff_t* ssp; @@ -100,10 +104,11 @@ unitAssert(strcmp(ssp->buf, parent1) == 0); ssp->num = 21; strcpy(ssp->buf, child1); - sleep(1); + + sleep(3); // give parent a chance to acquire + // before we reacquire in next block cout << "Child releasing semaphore" << endl; } - sleep(1); { cout << "Child acquiring semaphore..." << endl; IPCMutexLock sl(sem); @@ -112,14 +117,16 @@ unitAssert(strcmp(ssp->buf, parent2) == 0); ssp->num = 22; strcpy(ssp->buf, child2); - sleep(1); cout << "Child releasing semaphore" << endl; } _exit(0); } else { // parent - cout << endl; + cout << "Parent waits for child " << endl; + sleep(3); + cout << "Parent continues now " << endl; + SharedStuff_t* ssp; unitAssert(sz == 256 + sizeof(int)); int shmid = shmget(IPCMUTEX_KEYVAL, sz, @@ -132,12 +139,16 @@ cout << "Parent acquiring semaphore..." << endl; IPCMutexLock sl(sem); cout << "Parent acquired semaphore" << endl; + + kill(pid, SIGCONT); // wake up client + ssp->num = 11; strcpy(ssp->buf, parent1); - sleep(2); + + sleep(3); // give client a chance to acquire + // before we reacquire in next block cout << "Parent releasing semaphore" << endl; } - sleep(1); { cout << "Parent acquiring semaphore..." << endl; IPCMutexLock sl(sem); @@ -146,10 +157,11 @@ unitAssert(strcmp(ssp->buf, child1) == 0); ssp->num = 12; strcpy(ssp->buf, parent2); - sleep(1); + + sleep(3); // give client a chance to acquire + // before we reacquire in next block cout << "Parent releasing semaphore" << endl; } - sleep(1); { cout << "Parent acquiring semaphore..." << endl; IPCMutexLock sl(sem); --- test/unit/RWLockerTestCases.cpp +++ test/unit/RWLockerTestCases.cpp 2006/03/27 19:25:31 @@ -97,12 +97,12 @@ { m_locker->getReadLock(0); m_sem->signal(); - Thread::sleep(10); + Thread::sleep(3000); m_locker->releaseReadLock(); m_locker->getWriteLock(0); m_sem->signal(); - Thread::sleep(10); + Thread::sleep(3000); m_locker->releaseWriteLock(); return 0; } @@ -117,7 +117,7 @@ Semaphore sem; testThread t1(&locker, &sem); t1.start(); - sem.wait(); // wait for the thread to start. It's already got the read lock, and will keep it for 10 ms. + sem.wait(); // wait for the thread to start. It's already got the read lock, and will keep it for 3000 ms. // now try to get a write lock. But we'll use a short timeout to make sure an exception is thrown. try
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor