summaryrefslogtreecommitdiffstats
path: root/fastos/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'fastos/src/tests')
-rw-r--r--fastos/src/tests/job.h3
-rw-r--r--fastos/src/tests/processtest.cpp23
-rw-r--r--fastos/src/tests/typetest.cpp3
3 files changed, 13 insertions, 16 deletions
diff --git a/fastos/src/tests/job.h b/fastos/src/tests/job.h
index a5b84fa0f9c..ede0f702627 100644
--- a/fastos/src/tests/job.h
+++ b/fastos/src/tests/job.h
@@ -2,6 +2,9 @@
#pragma once
+#include <vespa/fastos/mutex.h>
+#include <vespa/fastos/cond.h>
+
enum JobCode
{
PRINT_MESSAGE_AND_WAIT3SEC,
diff --git a/fastos/src/tests/processtest.cpp b/fastos/src/tests/processtest.cpp
index 11e1307027d..cd6839fd0aa 100644
--- a/fastos/src/tests/processtest.cpp
+++ b/fastos/src/tests/processtest.cpp
@@ -17,15 +17,14 @@ public:
static int _allocCount;
static int _successCount;
static int _failCount;
- static FastOS_Mutex *_counterLock;
+ static std::mutex *_counterLock;
MyListener (const char *title)
: _title(title),
_receivedBytes(0)
{
- _counterLock->Lock();
- _allocCount++;
- _counterLock->Unlock();
+ std::lock_guard<std::mutex> guard(*_counterLock);
+ _allocCount++;
}
virtual ~MyListener ()
@@ -34,14 +33,13 @@ public:
const int correctByteCount = 16;
- _counterLock->Lock();
+ std::lock_guard<std::mutex> guard(*_counterLock);
if(_receivedBytes == (isStdout ? correctByteCount : 0))
_successCount++;
else
_failCount++;
_allocCount--;
- _counterLock->Unlock();
}
void OnReceiveData (const void *data, size_t length) override
@@ -62,7 +60,7 @@ public:
int MyListener::_allocCount = 0;
int MyListener::_successCount = 0;
int MyListener::_failCount = 0;
-FastOS_Mutex *MyListener::_counterLock = nullptr;
+std::mutex *MyListener::_counterLock = nullptr;
class ThreadRunJob : public FastOS_Runnable
@@ -122,7 +120,7 @@ private:
// or not.
bool _gotMessage;
int _receivedMessages;
- FastOS_Mutex *_counterLock;
+ std::mutex *_counterLock;
bool _isChild;
public:
ProcessTest ()
@@ -156,9 +154,8 @@ public:
// We only have the counter lock if we are the parent process.
if(_counterLock != nullptr)
{
- _counterLock->Lock();
- _receivedMessages++;
- _counterLock->Unlock();
+ std::lock_guard<std::mutex> guard(*_counterLock);
+ _receivedMessages++;
}
}
@@ -219,7 +216,7 @@ public:
const int numLoops = 100;
const int numEachTime = 40;
- MyListener::_counterLock = new FastOS_Mutex();
+ MyListener::_counterLock = new std::mutex;
char testHeader[200];
strcpy(testHeader, "Process Test");
@@ -381,7 +378,7 @@ public:
TestHeader ("IPC Test");
const char *childProgram = _argv[1];
- _counterLock = new FastOS_Mutex();
+ _counterLock = new std::mutex;
int i;
for(i=0; i<30; i++)
diff --git a/fastos/src/tests/typetest.cpp b/fastos/src/tests/typetest.cpp
index 209af305501..503c9a30d24 100644
--- a/fastos/src/tests/typetest.cpp
+++ b/fastos/src/tests/typetest.cpp
@@ -16,11 +16,8 @@ private:
TestHeader("Object Sizes (bytes)");
Progress(true, "FastOS_Application: %d", sizeof(FastOS_Application));
- Progress(true, "FastOS_BoolCond %d", sizeof(FastOS_BoolCond));
- Progress(true, "FastOS_Cond %d", sizeof(FastOS_Cond));
Progress(true, "FastOS_DirectoryScan %d", sizeof(FastOS_DirectoryScan));
Progress(true, "FastOS_File: %d", sizeof(FastOS_File));
- Progress(true, "FastOS_Mutex: %d", sizeof(FastOS_Mutex));
Progress(true, "FastOS_Runnable %d", sizeof(FastOS_Runnable));
Progress(true, "FastOS_ServerSocket %d", sizeof(FastOS_ServerSocket));
Progress(true, "FastOS_Socket: %d", sizeof(FastOS_Socket));