summaryrefslogtreecommitdiffstats
path: root/fastos
diff options
context:
space:
mode:
authorArne H Juul <arnej@yahoo-inc.com>2016-06-30 12:19:35 +0200
committerArne H Juul <arnej@yahoo-inc.com>2016-06-30 12:19:35 +0200
commit141b92cbe0db97b28430a150c218d66455ba6398 (patch)
tree633ae497352a9f624e275f9b91281161bd3a4dc2 /fastos
parent9f9ed5453b45c1fba47bcd4e83cf8b36afddb95a (diff)
split out common job code
Diffstat (limited to 'fastos')
-rw-r--r--fastos/src/tests/jobs.h66
-rw-r--r--fastos/src/tests/thread_bounce_test.cpp66
-rw-r--r--fastos/src/tests/thread_joinwait_test.cpp66
-rw-r--r--fastos/src/tests/thread_mutex_test.cpp66
-rw-r--r--fastos/src/tests/thread_sleep_test.cpp66
-rw-r--r--fastos/src/tests/thread_stats_test.cpp66
-rw-r--r--fastos/src/tests/threadtest.cpp65
7 files changed, 72 insertions, 389 deletions
diff --git a/fastos/src/tests/jobs.h b/fastos/src/tests/jobs.h
new file mode 100644
index 00000000000..1f771effba3
--- /dev/null
+++ b/fastos/src/tests/jobs.h
@@ -0,0 +1,66 @@
+// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+enum JobCode
+{
+ PRINT_MESSAGE_AND_WAIT3SEC,
+ INCREASE_NUMBER,
+ PRIORITY_TEST,
+ WAIT_FOR_BREAK_FLAG,
+ WAIT_FOR_THREAD_TO_FINISH,
+ WAIT_FOR_CONDITION,
+ BOUNCE_CONDITIONS,
+ TEST_ID,
+ WAIT2SEC_AND_SIGNALCOND,
+ HOLD_MUTEX_FOR2SEC,
+ WAIT_2_SEC,
+ SILENTNOP,
+ NOP
+};
+
+class Job
+{
+private:
+ Job(const Job &);
+ Job &operator=(const Job&);
+
+public:
+ JobCode code;
+ char *message;
+ FastOS_Mutex *mutex;
+ FastOS_Cond *condition;
+ FastOS_BoolCond *boolcondition;
+ FastOS_ThreadInterface *otherThread, *ownThread;
+ double *timebuf;
+ double average;
+ int result;
+ FastOS_ThreadId _threadId;
+ Job *otherjob;
+ int bouncewakeupcnt;
+ bool bouncewakeup;
+
+ Job()
+ : code(NOP),
+ message(NULL),
+ mutex(NULL),
+ condition(NULL),
+ boolcondition(NULL),
+ otherThread(NULL),
+ ownThread(NULL),
+ timebuf(NULL),
+ average(0.0),
+ result(-1),
+ _threadId(),
+ otherjob(NULL),
+ bouncewakeupcnt(0),
+ bouncewakeup(false)
+ {
+ }
+
+ ~Job()
+ {
+ if(message != NULL)
+ free(message);
+ }
+};
diff --git a/fastos/src/tests/thread_bounce_test.cpp b/fastos/src/tests/thread_bounce_test.cpp
index 6d629b9f919..51c986b0502 100644
--- a/fastos/src/tests/thread_bounce_test.cpp
+++ b/fastos/src/tests/thread_bounce_test.cpp
@@ -3,71 +3,7 @@
#include <vespa/fastos/fastos.h>
#include "tests.h"
-
-#define PRI_TIME_COUNT 4096
-
-enum JobCode
-{
- PRINT_MESSAGE_AND_WAIT3SEC,
- INCREASE_NUMBER,
- PRIORITY_TEST,
- WAIT_FOR_BREAK_FLAG,
- WAIT_FOR_THREAD_TO_FINISH,
- WAIT_FOR_CONDITION,
- BOUNCE_CONDITIONS,
- TEST_ID,
- WAIT2SEC_AND_SIGNALCOND,
- HOLD_MUTEX_FOR2SEC,
- WAIT_2_SEC,
- SILENTNOP,
- NOP
-};
-
-class Job
-{
-private:
- Job(const Job &);
- Job &operator=(const Job&);
-
-public:
- JobCode code;
- char *message;
- FastOS_Mutex *mutex;
- FastOS_Cond *condition;
- FastOS_BoolCond *boolcondition;
- FastOS_ThreadInterface *otherThread, *ownThread;
- double *timebuf;
- double average;
- int result;
- FastOS_ThreadId _threadId;
- Job *otherjob;
- int bouncewakeupcnt;
- bool bouncewakeup;
-
- Job()
- : code(NOP),
- message(NULL),
- mutex(NULL),
- condition(NULL),
- boolcondition(NULL),
- otherThread(NULL),
- ownThread(NULL),
- timebuf(NULL),
- average(0.0),
- result(-1),
- _threadId(),
- otherjob(NULL),
- bouncewakeupcnt(0),
- bouncewakeup(false)
- {
- }
-
- ~Job()
- {
- if(message != NULL)
- free(message);
- }
-};
+#include "jobs.h"
static volatile int64_t number;
#define INCREASE_NUMBER_AMOUNT 10000
diff --git a/fastos/src/tests/thread_joinwait_test.cpp b/fastos/src/tests/thread_joinwait_test.cpp
index a8dec6ab140..003c515ef4a 100644
--- a/fastos/src/tests/thread_joinwait_test.cpp
+++ b/fastos/src/tests/thread_joinwait_test.cpp
@@ -3,71 +3,7 @@
#include <vespa/fastos/fastos.h>
#include "tests.h"
-
-#define PRI_TIME_COUNT 4096
-
-enum JobCode
-{
- PRINT_MESSAGE_AND_WAIT3SEC,
- INCREASE_NUMBER,
- PRIORITY_TEST,
- WAIT_FOR_BREAK_FLAG,
- WAIT_FOR_THREAD_TO_FINISH,
- WAIT_FOR_CONDITION,
- BOUNCE_CONDITIONS,
- TEST_ID,
- WAIT2SEC_AND_SIGNALCOND,
- HOLD_MUTEX_FOR2SEC,
- WAIT_2_SEC,
- SILENTNOP,
- NOP
-};
-
-class Job
-{
-private:
- Job(const Job &);
- Job &operator=(const Job&);
-
-public:
- JobCode code;
- char *message;
- FastOS_Mutex *mutex;
- FastOS_Cond *condition;
- FastOS_BoolCond *boolcondition;
- FastOS_ThreadInterface *otherThread, *ownThread;
- double *timebuf;
- double average;
- int result;
- FastOS_ThreadId _threadId;
- Job *otherjob;
- int bouncewakeupcnt;
- bool bouncewakeup;
-
- Job()
- : code(NOP),
- message(NULL),
- mutex(NULL),
- condition(NULL),
- boolcondition(NULL),
- otherThread(NULL),
- ownThread(NULL),
- timebuf(NULL),
- average(0.0),
- result(-1),
- _threadId(),
- otherjob(NULL),
- bouncewakeupcnt(0),
- bouncewakeup(false)
- {
- }
-
- ~Job()
- {
- if(message != NULL)
- free(message);
- }
-};
+#include "jobs.h"
static volatile int64_t number;
#define INCREASE_NUMBER_AMOUNT 10000
diff --git a/fastos/src/tests/thread_mutex_test.cpp b/fastos/src/tests/thread_mutex_test.cpp
index 636edae2139..90bdc40dbf5 100644
--- a/fastos/src/tests/thread_mutex_test.cpp
+++ b/fastos/src/tests/thread_mutex_test.cpp
@@ -3,71 +3,7 @@
#include <vespa/fastos/fastos.h>
#include "tests.h"
-
-#define PRI_TIME_COUNT 4096
-
-enum JobCode
-{
- PRINT_MESSAGE_AND_WAIT3SEC,
- INCREASE_NUMBER,
- PRIORITY_TEST,
- WAIT_FOR_BREAK_FLAG,
- WAIT_FOR_THREAD_TO_FINISH,
- WAIT_FOR_CONDITION,
- BOUNCE_CONDITIONS,
- TEST_ID,
- WAIT2SEC_AND_SIGNALCOND,
- HOLD_MUTEX_FOR2SEC,
- WAIT_2_SEC,
- SILENTNOP,
- NOP
-};
-
-class Job
-{
-private:
- Job(const Job &);
- Job &operator=(const Job&);
-
-public:
- JobCode code;
- char *message;
- FastOS_Mutex *mutex;
- FastOS_Cond *condition;
- FastOS_BoolCond *boolcondition;
- FastOS_ThreadInterface *otherThread, *ownThread;
- double *timebuf;
- double average;
- int result;
- FastOS_ThreadId _threadId;
- Job *otherjob;
- int bouncewakeupcnt;
- bool bouncewakeup;
-
- Job()
- : code(NOP),
- message(NULL),
- mutex(NULL),
- condition(NULL),
- boolcondition(NULL),
- otherThread(NULL),
- ownThread(NULL),
- timebuf(NULL),
- average(0.0),
- result(-1),
- _threadId(),
- otherjob(NULL),
- bouncewakeupcnt(0),
- bouncewakeup(false)
- {
- }
-
- ~Job()
- {
- if(message != NULL)
- free(message);
- }
-};
+#include "jobs.h"
static volatile int64_t number;
#define INCREASE_NUMBER_AMOUNT 10000
diff --git a/fastos/src/tests/thread_sleep_test.cpp b/fastos/src/tests/thread_sleep_test.cpp
index 031ac30e5c9..25cd6f6095b 100644
--- a/fastos/src/tests/thread_sleep_test.cpp
+++ b/fastos/src/tests/thread_sleep_test.cpp
@@ -3,71 +3,7 @@
#include <vespa/fastos/fastos.h>
#include "tests.h"
-
-#define PRI_TIME_COUNT 4096
-
-enum JobCode
-{
- PRINT_MESSAGE_AND_WAIT3SEC,
- INCREASE_NUMBER,
- PRIORITY_TEST,
- WAIT_FOR_BREAK_FLAG,
- WAIT_FOR_THREAD_TO_FINISH,
- WAIT_FOR_CONDITION,
- BOUNCE_CONDITIONS,
- TEST_ID,
- WAIT2SEC_AND_SIGNALCOND,
- HOLD_MUTEX_FOR2SEC,
- WAIT_2_SEC,
- SILENTNOP,
- NOP
-};
-
-class Job
-{
-private:
- Job(const Job &);
- Job &operator=(const Job&);
-
-public:
- JobCode code;
- char *message;
- FastOS_Mutex *mutex;
- FastOS_Cond *condition;
- FastOS_BoolCond *boolcondition;
- FastOS_ThreadInterface *otherThread, *ownThread;
- double *timebuf;
- double average;
- int result;
- FastOS_ThreadId _threadId;
- Job *otherjob;
- int bouncewakeupcnt;
- bool bouncewakeup;
-
- Job()
- : code(NOP),
- message(NULL),
- mutex(NULL),
- condition(NULL),
- boolcondition(NULL),
- otherThread(NULL),
- ownThread(NULL),
- timebuf(NULL),
- average(0.0),
- result(-1),
- _threadId(),
- otherjob(NULL),
- bouncewakeupcnt(0),
- bouncewakeup(false)
- {
- }
-
- ~Job()
- {
- if(message != NULL)
- free(message);
- }
-};
+#include "jobs.h"
static volatile int64_t number;
#define INCREASE_NUMBER_AMOUNT 10000
diff --git a/fastos/src/tests/thread_stats_test.cpp b/fastos/src/tests/thread_stats_test.cpp
index e38fb49a787..a570212b657 100644
--- a/fastos/src/tests/thread_stats_test.cpp
+++ b/fastos/src/tests/thread_stats_test.cpp
@@ -3,71 +3,7 @@
#include <vespa/fastos/fastos.h>
#include "tests.h"
-
-#define PRI_TIME_COUNT 4096
-
-enum JobCode
-{
- PRINT_MESSAGE_AND_WAIT3SEC,
- INCREASE_NUMBER,
- PRIORITY_TEST,
- WAIT_FOR_BREAK_FLAG,
- WAIT_FOR_THREAD_TO_FINISH,
- WAIT_FOR_CONDITION,
- BOUNCE_CONDITIONS,
- TEST_ID,
- WAIT2SEC_AND_SIGNALCOND,
- HOLD_MUTEX_FOR2SEC,
- WAIT_2_SEC,
- SILENTNOP,
- NOP
-};
-
-class Job
-{
-private:
- Job(const Job &);
- Job &operator=(const Job&);
-
-public:
- JobCode code;
- char *message;
- FastOS_Mutex *mutex;
- FastOS_Cond *condition;
- FastOS_BoolCond *boolcondition;
- FastOS_ThreadInterface *otherThread, *ownThread;
- double *timebuf;
- double average;
- int result;
- FastOS_ThreadId _threadId;
- Job *otherjob;
- int bouncewakeupcnt;
- bool bouncewakeup;
-
- Job()
- : code(NOP),
- message(NULL),
- mutex(NULL),
- condition(NULL),
- boolcondition(NULL),
- otherThread(NULL),
- ownThread(NULL),
- timebuf(NULL),
- average(0.0),
- result(-1),
- _threadId(),
- otherjob(NULL),
- bouncewakeupcnt(0),
- bouncewakeup(false)
- {
- }
-
- ~Job()
- {
- if(message != NULL)
- free(message);
- }
-};
+#include "jobs.h"
static volatile int64_t number;
#define INCREASE_NUMBER_AMOUNT 10000
diff --git a/fastos/src/tests/threadtest.cpp b/fastos/src/tests/threadtest.cpp
index 88254108557..cf2ab70bec9 100644
--- a/fastos/src/tests/threadtest.cpp
+++ b/fastos/src/tests/threadtest.cpp
@@ -3,71 +3,8 @@
#include <vespa/fastos/fastos.h>
#include "tests.h"
+#include "jobs.h"
-#define PRI_TIME_COUNT 4096
-
-enum JobCode
-{
- PRINT_MESSAGE_AND_WAIT3SEC,
- INCREASE_NUMBER,
- PRIORITY_TEST,
- WAIT_FOR_BREAK_FLAG,
- WAIT_FOR_THREAD_TO_FINISH,
- WAIT_FOR_CONDITION,
- BOUNCE_CONDITIONS,
- TEST_ID,
- WAIT2SEC_AND_SIGNALCOND,
- HOLD_MUTEX_FOR2SEC,
- WAIT_2_SEC,
- SILENTNOP,
- NOP
-};
-
-class Job
-{
-private:
- Job(const Job &);
- Job &operator=(const Job&);
-
-public:
- JobCode code;
- char *message;
- FastOS_Mutex *mutex;
- FastOS_Cond *condition;
- FastOS_BoolCond *boolcondition;
- FastOS_ThreadInterface *otherThread, *ownThread;
- double *timebuf;
- double average;
- int result;
- FastOS_ThreadId _threadId;
- Job *otherjob;
- int bouncewakeupcnt;
- bool bouncewakeup;
-
- Job()
- : code(NOP),
- message(NULL),
- mutex(NULL),
- condition(NULL),
- boolcondition(NULL),
- otherThread(NULL),
- ownThread(NULL),
- timebuf(NULL),
- average(0.0),
- result(-1),
- _threadId(),
- otherjob(NULL),
- bouncewakeupcnt(0),
- bouncewakeup(false)
- {
- }
-
- ~Job()
- {
- if(message != NULL)
- free(message);
- }
-};
static volatile int64_t number;
#define INCREASE_NUMBER_AMOUNT 10000