Ocean
Loading...
Searching...
No Matches
TestWorker.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_TEST_TESTBASE_WORKER_H
9#define META_OCEAN_TEST_TESTBASE_WORKER_H
10
13
14#include "ocean/base/Worker.h"
15
16namespace Ocean
17{
18
19namespace Test
20{
21
22namespace TestBase
23{
24
25/**
26 * This class implements worker tests.
27 * @ingroup testbase
28 */
29class OCEAN_TEST_BASE_EXPORT TestWorker : protected Worker
30{
31 public:
32
33 /**
34 * Tests the entire worker functionalities.
35 * @param testDuration The number of seconds for each test, with range (0, infinity)
36 * @param selector Optional test selector
37 * @return True, if succeeded
38 */
39 static bool test(const double testDuration, const TestSelector& selector = TestSelector());
40
41 /**
42 * Tests the constructor.
43 * @return True, if succeeded
44 */
45 static bool testConstructor();
46
47 /**
48 * Tests the worker delay.
49 * @param testDuration The number of seconds for each test, with range (0, infinity)
50 * @param worker The worker object to be used
51 * @return True, if succeeded
52 */
53 static bool testDelay(const double testDuration, Worker& worker);
54
55 /**
56 * Tests the worker calling a static function.
57 * @param worker The worker object to be used
58 * @return True, if succeeded
59 */
60 static bool testStaticWorker(Worker& worker);
61
62 /**
63 * Tests the validation of the worker calling a static function.
64 * @param testDuration The number of seconds for each test, with range (0, infinity)
65 * @param worker The worker object to be used
66 * @return True, if succeeded
67 */
68 static bool testStaticWorkerSumOfSquares(const double testDuration, Worker& worker);
69
70 /**
71 * Tests the validation of the worker calling a static function.
72 * @param testDuration The number of seconds for each test, with range (0, infinity)
73 * @param worker The worker object to be used
74 * @return True, if succeeded
75 */
76 static bool testStaticWorkerSumOfSquareRoots(const double testDuration, Worker& worker);
77
78 /**
79 * Tests the validation of the worker calling a static abortable function.
80 * @param worker The worker object to be used
81 * @return True, if succeeded
82 */
83 static bool testAbortableFunction(Worker& worker);
84
85 /**
86 * Tests the validation of the worker calling a static separable and abortable function.
87 * @param worker The worker object to be used
88 * @return True, if succeeded
89 */
91
92 private:
93
94 /**
95 * Static worker function.
96 * @param time The time parameters, must be valid
97 * @param first The first element
98 * @param size The number of elements, with range [1, infinity)
99 */
100 static void staticWorkerFunctionDelay(uint64_t* time, const unsigned int first, const unsigned int size);
101
102 /**
103 * Static worker function.
104 * @param first The first element
105 * @param size The number of elements, with range [1, infinity)
106 */
107 static void staticWorkerFunction(const unsigned int first, const unsigned int size);
108
109 /**
110 * Static worker function to calculate the sum of square values.
111 * @param values The values to be handled, must be valid
112 * @param first The first element
113 * @param size The number of elements, with range [1, infinity)
114 */
115 static void staticWorkerFunctionSumOfSquares(unsigned int* values, const unsigned int first, const unsigned int size);
116
117 /**
118 * Static worker function to calculate the sum of square root values.
119 * @param values The values to be handled, must be valid
120 * @param first The first element
121 * @param size The number of elements, with range [1, infinity)
122 */
123 static void staticWorkerFunctionSumOfSquareRoots(double* values, const unsigned int first, const unsigned int size);
124
125 /**
126 * Static abortable worker function.
127 * @param result Function result
128 * @param abort The abort state
129 * @return True, if succeeded and not aborted
130 */
131 static bool staticWorkerFunctionAbortable(double* result, bool* abort);
132
133 /**
134 * Static separable and abortable worker function.
135 * @param result Function result
136 * @param first The first object to be handled
137 * @param size Number of objects to be handled
138 * @param abort The abort state
139 * @return True, if succeeded and not aborted
140 */
141 static bool staticWorkerFunctionSeparableAndAbortable(double* result, const unsigned int first, const unsigned int size, bool* abort);
142};
143
144}
145
146}
147
148}
149
150#endif // META_OCEAN_TEST_TESTBASE_WORKER_H
This class implements worker tests.
Definition TestWorker.h:30
static bool testConstructor()
Tests the constructor.
static bool staticWorkerFunctionAbortable(double *result, bool *abort)
Static abortable worker function.
static bool staticWorkerFunctionSeparableAndAbortable(double *result, const unsigned int first, const unsigned int size, bool *abort)
Static separable and abortable worker function.
static bool testStaticWorkerSumOfSquareRoots(const double testDuration, Worker &worker)
Tests the validation of the worker calling a static function.
static bool testStaticWorker(Worker &worker)
Tests the worker calling a static function.
static void staticWorkerFunctionDelay(uint64_t *time, const unsigned int first, const unsigned int size)
Static worker function.
static void staticWorkerFunctionSumOfSquareRoots(double *values, const unsigned int first, const unsigned int size)
Static worker function to calculate the sum of square root values.
static bool testStaticWorkerSumOfSquares(const double testDuration, Worker &worker)
Tests the validation of the worker calling a static function.
static bool testDelay(const double testDuration, Worker &worker)
Tests the worker delay.
static void staticWorkerFunction(const unsigned int first, const unsigned int size)
Static worker function.
static bool testSeparableAndAbortableFunction(Worker &worker)
Tests the validation of the worker calling a static separable and abortable function.
static bool testAbortableFunction(Worker &worker)
Tests the validation of the worker calling a static abortable function.
static void staticWorkerFunctionSumOfSquares(unsigned int *values, const unsigned int first, const unsigned int size)
Static worker function to calculate the sum of square values.
static bool test(const double testDuration, const TestSelector &selector=TestSelector())
Tests the entire worker functionalities.
This class implements a test selector that parses test function strings and determines which tests sh...
Definition TestSelector.h:51
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
The namespace covering the entire Ocean framework.
Definition Accessor.h:15