diff options
Diffstat (limited to 'fastos/src/tests')
-rw-r--r-- | fastos/src/tests/CMakeLists.txt | 21 | ||||
-rw-r--r-- | fastos/src/tests/job.h | 51 | ||||
-rw-r--r-- | fastos/src/tests/tests.h | 10 | ||||
-rw-r--r-- | fastos/src/tests/thread_joinwait_test.cpp | 118 | ||||
-rw-r--r-- | fastos/src/tests/thread_stats_test.cpp | 129 | ||||
-rw-r--r-- | fastos/src/tests/thread_test_base.hpp | 161 | ||||
-rw-r--r-- | fastos/src/tests/threadtest.cpp | 283 | ||||
-rw-r--r-- | fastos/src/tests/typetest.cpp | 3 |
8 files changed, 2 insertions, 774 deletions
diff --git a/fastos/src/tests/CMakeLists.txt b/fastos/src/tests/CMakeLists.txt index 3bf68a88e79..7d4b014b6b3 100644 --- a/fastos/src/tests/CMakeLists.txt +++ b/fastos/src/tests/CMakeLists.txt @@ -6,27 +6,6 @@ vespa_add_executable(fastos_filetest_app TEST fastos ) vespa_add_test(NAME fastos_filetest_app NO_VALGRIND COMMAND fastos_filetest_app) -vespa_add_executable(fastos_thread_stats_test_app TEST - SOURCES - thread_stats_test.cpp - DEPENDS - fastos -) -vespa_add_test(NAME fastos_thread_stats_test_app NO_VALGRIND COMMAND fastos_thread_stats_test_app) -vespa_add_executable(fastos_thread_joinwait_test_app TEST - SOURCES - thread_joinwait_test.cpp - DEPENDS - fastos -) -vespa_add_test(NAME fastos_thread_joinwait_test_app NO_VALGRIND COMMAND fastos_thread_joinwait_test_app) -vespa_add_executable(fastos_threadtest_app TEST - SOURCES - threadtest.cpp - DEPENDS - fastos -) -vespa_add_test(NAME fastos_threadtest_app NO_VALGRIND COMMAND fastos_threadtest_app) vespa_add_executable(fastos_typetest_app TEST SOURCES typetest.cpp diff --git a/fastos/src/tests/job.h b/fastos/src/tests/job.h deleted file mode 100644 index 4546cfe1daa..00000000000 --- a/fastos/src/tests/job.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#pragma once - -#include <mutex> -#include <condition_variable> - -enum JobCode -{ - PRINT_MESSAGE_AND_WAIT3MSEC, - INCREASE_NUMBER, - WAIT_FOR_BREAK_FLAG, - WAIT_FOR_THREAD_TO_FINISH, - TEST_ID, - SILENTNOP, - NOP -}; - -class Job -{ -private: - Job(const Job &); - Job &operator=(const Job&); - -public: - JobCode code; - char *message; - std::mutex *mutex; - std::condition_variable *condition; - FastOS_ThreadInterface *otherThread, *ownThread; - std::atomic<int> result; - FastOS_ThreadId _threadId; - - Job() - : code(NOP), - message(nullptr), - mutex(nullptr), - condition(nullptr), - otherThread(nullptr), - ownThread(nullptr), - result(-1), - _threadId() - { - } - - ~Job() - { - if(message != nullptr) - free(message); - } -}; diff --git a/fastos/src/tests/tests.h b/fastos/src/tests/tests.h index 3a6f2ef9010..9cd7a10ab48 100644 --- a/fastos/src/tests/tests.h +++ b/fastos/src/tests/tests.h @@ -1,8 +1,9 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/thread.h> #include <cstring> #include <csignal> +#include <cstdio> +#include <cstdint> class BaseTest { @@ -83,13 +84,6 @@ public: return Progress(result, string); } - bool Progress (bool result, const char *str, const FastOS_ThreadInterface *s1) - { - char string[MAX_STR_LEN-100]; - snprintf(string, sizeof(string), str, s1); - return Progress(result, string); - } - bool Progress (bool result, const char *str, const char *s1, const char *s2) { char string[MAX_STR_LEN-100]; diff --git a/fastos/src/tests/thread_joinwait_test.cpp b/fastos/src/tests/thread_joinwait_test.cpp deleted file mode 100644 index 6c7e8a7dc3c..00000000000 --- a/fastos/src/tests/thread_joinwait_test.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "tests.h" -#include "job.h" -#include "thread_test_base.hpp" - -class Thread_JoinWait_Test : public ThreadTestBase -{ - int Main () override; - - void SingleThreadJoinWaitMultipleTest(int variant) - { - bool rc=false; - - char testName[300]; - - snprintf(testName, sizeof(testName), "Single Thread Join Wait Multiple Test %d", variant); - TestHeader(testName); - - FastOS_ThreadPool pool; - - const int testThreads=5; - int lastThreadNum = testThreads-1; - int i; - - Job jobs[testThreads]; - - std::mutex jobMutex; - - // The mutex is used to pause the first threads until we have created - // the last one. - jobMutex.lock(); - - for(i=0; i<lastThreadNum; i++) - { - jobs[i].code = WAIT_FOR_THREAD_TO_FINISH; - jobs[i].mutex = &jobMutex; - jobs[i].ownThread = pool.NewThread(this, static_cast<void *>(&jobs[i])); - - rc = (jobs[i].ownThread != nullptr); - Progress(rc, "Creating Thread %d", i+1); - - if(!rc) - break; - } - - if (rc) - { - jobs[lastThreadNum].code = (((variant & 2) != 0) ? NOP : PRINT_MESSAGE_AND_WAIT3MSEC); - jobs[lastThreadNum].message = strdup("This is the thread that others wait for."); - - FastOS_ThreadInterface *lastThread; - - lastThread = pool.NewThread(this, - static_cast<void *> - (&jobs[lastThreadNum])); - - rc = (lastThread != nullptr); - Progress(rc, "Creating last thread"); - - if (rc) - { - for(i=0; i<lastThreadNum; i++) { - jobs[i].otherThread = lastThread; - } - } - } - - jobMutex.unlock(); - - if ((variant & 1) != 0) - { - for (i=0; i<lastThreadNum; i++) - { - Progress(true, "Waiting for thread %d to finish using Join()", i+1); - jobs[i].ownThread->Join(); - Progress(true, "Thread %d finished.", i+1); - } - } - - Progress(true, "Closing pool."); - pool.Close(); - Progress(true, "Pool closed."); - PrintSeparator(); - } - -}; - -int Thread_JoinWait_Test::Main () -{ - printf("grep for the string '%s' to detect failures.\n\n", failString); - time_t before = time(0); - - SingleThreadJoinWaitMultipleTest(0); - { time_t now = time(0); printf("[%ld seconds]\n", now-before); before = now; } - SingleThreadJoinWaitMultipleTest(1); - { time_t now = time(0); printf("[%ld seconds]\n", now-before); before = now; } - SingleThreadJoinWaitMultipleTest(2); - { time_t now = time(0); printf("[%ld seconds]\n", now-before); before = now; } - SingleThreadJoinWaitMultipleTest(3); - { time_t now = time(0); printf("[%ld seconds]\n", now-before); before = now; } - SingleThreadJoinWaitMultipleTest(2); - { time_t now = time(0); printf("[%ld seconds]\n", now-before); before = now; } - SingleThreadJoinWaitMultipleTest(1); - { time_t now = time(0); printf("[%ld seconds]\n", now-before); before = now; } - SingleThreadJoinWaitMultipleTest(0); - { time_t now = time(0); printf("[%ld seconds]\n", now-before); before = now; } - - printf("END OF TEST (%s)\n", _argv[0]); - return allWasOk() ? 0 : 1; -} - -int main (int argc, char **argv) -{ - Thread_JoinWait_Test app; - setvbuf(stdout, nullptr, _IOLBF, 8192); - return app.Entry(argc, argv); -} diff --git a/fastos/src/tests/thread_stats_test.cpp b/fastos/src/tests/thread_stats_test.cpp deleted file mode 100644 index 40c1199135c..00000000000 --- a/fastos/src/tests/thread_stats_test.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "tests.h" -#include "job.h" -#include "thread_test_base.hpp" - -class Thread_Stats_Test : public ThreadTestBase -{ - void ThreadStatsTest () - { - int inactiveThreads; - int activeThreads; - int startedThreads; - - TestHeader("Thread Statistics Test"); - - FastOS_ThreadPool pool; - Job job[2]; - - inactiveThreads = pool.GetNumInactiveThreads(); - Progress(inactiveThreads == 0, "Initial inactive threads = %d", inactiveThreads); - activeThreads = pool.GetNumActiveThreads(); - Progress(activeThreads == 0, "Initial active threads = %d", activeThreads); - startedThreads = pool.GetNumStartedThreads(); - Progress(startedThreads == 0, "Initial started threads = %d", startedThreads); - - job[0].code = WAIT_FOR_BREAK_FLAG; - job[0].ownThread = pool.NewThread(this, static_cast<void *>(&job[0])); - - inactiveThreads = pool.GetNumInactiveThreads(); - Progress(inactiveThreads == 0, "Inactive threads = %d", inactiveThreads); - activeThreads = pool.GetNumActiveThreads(); - Progress(activeThreads == 1, "Active threads = %d", activeThreads); - startedThreads = pool.GetNumStartedThreads(); - Progress(startedThreads == 1, "Started threads = %d", startedThreads); - - job[1].code = WAIT_FOR_BREAK_FLAG; - job[1].ownThread = pool.NewThread(this, static_cast<void *>(&job[1])); - - inactiveThreads = pool.GetNumInactiveThreads(); - Progress(inactiveThreads == 0, "Inactive threads = %d", inactiveThreads); - activeThreads = pool.GetNumActiveThreads(); - Progress(activeThreads == 2, "Active threads = %d", activeThreads); - startedThreads = pool.GetNumStartedThreads(); - Progress(startedThreads == 2, "Started threads = %d", startedThreads); - - Progress(true, "Setting breakflag on threads..."); - job[0].ownThread->SetBreakFlag(); - job[1].ownThread->SetBreakFlag(); - - job[0].ownThread->Join(); - job[1].ownThread->Join(); - while (pool.GetNumInactiveThreads() != 2) { - std::this_thread::sleep_for(1ms); - } - - inactiveThreads = pool.GetNumInactiveThreads(); - Progress(inactiveThreads == 2, "Inactive threads = %d", inactiveThreads); - activeThreads = pool.GetNumActiveThreads(); - Progress(activeThreads == 0, "Active threads = %d", activeThreads); - startedThreads = pool.GetNumStartedThreads(); - Progress(startedThreads == 2, "Started threads = %d", startedThreads); - - Progress(true, "Repeating process in the same pool..."); - - job[0].code = WAIT_FOR_BREAK_FLAG; - job[0].ownThread = pool.NewThread(this, static_cast<void *>(&job[0])); - - inactiveThreads = pool.GetNumInactiveThreads(); - Progress(inactiveThreads == 1, "Inactive threads = %d", inactiveThreads); - activeThreads = pool.GetNumActiveThreads(); - Progress(activeThreads == 1, "Active threads = %d", activeThreads); - startedThreads = pool.GetNumStartedThreads(); - Progress(startedThreads == 3, "Started threads = %d", startedThreads); - - job[1].code = WAIT_FOR_BREAK_FLAG; - job[1].ownThread = pool.NewThread(this, static_cast<void *>(&job[1])); - - inactiveThreads = pool.GetNumInactiveThreads(); - Progress(inactiveThreads == 0, "Inactive threads = %d", inactiveThreads); - activeThreads = pool.GetNumActiveThreads(); - Progress(activeThreads == 2, "Active threads = %d", activeThreads); - startedThreads = pool.GetNumStartedThreads(); - Progress(startedThreads == 4, "Started threads = %d", startedThreads); - - Progress(true, "Setting breakflag on threads..."); - job[0].ownThread->SetBreakFlag(); - job[1].ownThread->SetBreakFlag(); - - job[0].ownThread->Join(); - job[1].ownThread->Join(); - while (pool.GetNumInactiveThreads() != 2) { - std::this_thread::sleep_for(1ms); - } - - inactiveThreads = pool.GetNumInactiveThreads(); - Progress(inactiveThreads == 2, "Inactive threads = %d", inactiveThreads); - activeThreads = pool.GetNumActiveThreads(); - Progress(activeThreads == 0, "Active threads = %d", activeThreads); - startedThreads = pool.GetNumStartedThreads(); - Progress(startedThreads == 4, "Started threads = %d", startedThreads); - - pool.Close(); - Progress(true, "Pool closed."); - - PrintSeparator(); - } - - int Main () override; -}; - -int Thread_Stats_Test::Main () -{ - printf("grep for the string '%s' to detect failures.\n\n", failString); - time_t before = time(0); - - ThreadStatsTest(); - { time_t now = time(0); printf("[%ld seconds]\n", now-before); before = now; } - - printf("END OF TEST (%s)\n", _argv[0]); - return allWasOk() ? 0 : 1; -} - -int main (int argc, char **argv) -{ - Thread_Stats_Test app; - setvbuf(stdout, nullptr, _IOLBF, 8192); - return app.Entry(argc, argv); -} diff --git a/fastos/src/tests/thread_test_base.hpp b/fastos/src/tests/thread_test_base.hpp deleted file mode 100644 index eb994537f6e..00000000000 --- a/fastos/src/tests/thread_test_base.hpp +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#pragma once - -#include <chrono> -#include <thread> - -static std::atomic<int64_t> number; -#define INCREASE_NUMBER_AMOUNT 10000 - -using namespace std::chrono_literals; - -class ThreadTestBase : public BaseTest, public FastOS_Runnable -{ -private: - std::mutex printMutex; - -public: - ThreadTestBase(void) - : printMutex() - { - } - virtual ~ThreadTestBase() {} - - void PrintProgress (char *string) override { - std::lock_guard<std::mutex> guard(printMutex); - BaseTest::PrintProgress(string); - } - - void Run (FastOS_ThreadInterface *thread, void *arg) override; - - void WaitForThreadsToFinish (Job *jobs, int count) { - int i; - - Progress(true, "Waiting for threads to finish..."); - for(;;) { - bool threadsFinished=true; - - for (i=0; i<count; i++) { - if (jobs[i].result == -1) { - threadsFinished = false; - break; - } - } - - std::this_thread::sleep_for(1us); - - if(threadsFinished) - break; - } - - Progress(true, "Threads finished"); - } -}; - - -void ThreadTestBase::Run (FastOS_ThreadInterface *thread, void *arg) -{ - if(arg == nullptr) - return; - - Job *job = static_cast<Job *>(arg); - char someStack[15*1024]; - - memset(someStack, 0, 15*1024); - - switch(job->code) - { - case SILENTNOP: - { - job->result = 1; - break; - } - - case NOP: - { - Progress(true, "Doing NOP"); - job->result = 1; - break; - } - - case PRINT_MESSAGE_AND_WAIT3MSEC: - { - Progress(true, "Thread printing message: [%s]", job->message); - job->result = strlen(job->message); - - std::this_thread::sleep_for(3ms); - break; - } - - case INCREASE_NUMBER: - { - int result; - - std::unique_lock<std::mutex> guard; - if(job->mutex != nullptr) { - guard = std::unique_lock<std::mutex>(*job->mutex); - } - - result = static_cast<int>(number.load(std::memory_order_relaxed)); - - int sleepOn = (INCREASE_NUMBER_AMOUNT/2) * 321/10000; - for (int i=0; i<(INCREASE_NUMBER_AMOUNT/2); i++) { - number.fetch_add(2, std::memory_order_relaxed); - - if (i == sleepOn) - std::this_thread::sleep_for(1ms); - } - - guard = std::unique_lock<std::mutex>(); - - job->result = result; // This marks the end of the thread - - break; - } - - case WAIT_FOR_BREAK_FLAG: - { - for(;;) { - std::this_thread::sleep_for(1us); - - if (thread->GetBreakFlag()) { - Progress(true, "Thread %p got breakflag", thread); - break; - } - } - break; - } - - case WAIT_FOR_THREAD_TO_FINISH: - { - std::unique_lock<std::mutex> guard; - if (job->mutex != nullptr) { - guard = std::unique_lock<std::mutex>(*job->mutex); - } - - if (job->otherThread != nullptr) - job->otherThread->Join(); - - break; - } - - case TEST_ID: - { - job->mutex->lock(); // Initially the parent threads owns the lock - job->mutex->unlock(); // It is unlocked when we should start - - FastOS_ThreadId currentId = FastOS_Thread::GetCurrentThreadId(); - - if(currentId == job->_threadId) - job->result = 1; - else - job->result = -1; - break; - } - - default: - Progress(false, "Unknown jobcode"); - break; - } -} diff --git a/fastos/src/tests/threadtest.cpp b/fastos/src/tests/threadtest.cpp deleted file mode 100644 index 563b41ac229..00000000000 --- a/fastos/src/tests/threadtest.cpp +++ /dev/null @@ -1,283 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "tests.h" -#include "job.h" -#include "thread_test_base.hpp" -#include <cstdlib> -#include <chrono> - -#define MAX_THREADS 7 - -using namespace std::chrono; -using namespace std::chrono_literals; - -class ThreadTest : public ThreadTestBase -{ - int Main () override; - - void TooManyThreadsTest () - { - TestHeader("Too Many Threads Test"); - static constexpr size_t message_size = 100; - - FastOS_ThreadPool *pool = new FastOS_ThreadPool(MAX_THREADS); - - if (Progress(pool != nullptr, "Allocating ThreadPool")) { - int i; - Job jobs[MAX_THREADS+1]; - - for (i=0; i<MAX_THREADS+1; i++) { - jobs[i].code = WAIT_FOR_BREAK_FLAG; - jobs[i].message = static_cast<char *>(malloc(message_size)); - if (jobs[i].message == nullptr) { - abort(); // GCC may infer that a potentially null ptr is passed to sprintf - } - snprintf(jobs[i].message, message_size, "Thread %d invocation", i+1); - } - - for (i=0; i<MAX_THREADS+1; i++) { - if (i==MAX_THREADS) { - while (pool->GetNumInactiveThreads() > 0); - jobs[MAX_THREADS].code = PRINT_MESSAGE_AND_WAIT3MSEC; - bool rc = (nullptr == pool->NewThread(this, static_cast<void *>(&jobs[MAX_THREADS]))); - Progress(rc, "Creating too many threads should fail."); - } else { - jobs[i].ownThread = pool->NewThread(this, static_cast<void *>(&jobs[i])); - Progress(jobs[i].ownThread != nullptr, "Creating Thread"); - } - } - for (i=0; i<MAX_THREADS; i++) { - jobs[i].ownThread->SetBreakFlag(); - } - - Progress(true, "Closing threadpool..."); - pool->Close(); - - Progress(true, "Deleting threadpool..."); - delete(pool); - } - PrintSeparator(); - } - - void CreateSingleThreadAndJoin () - { - TestHeader("Create Single Thread And Join Test"); - - FastOS_ThreadPool *pool = new FastOS_ThreadPool; - - if (Progress(pool != nullptr, "Allocating ThreadPool")) { - Job job; - - job.code = NOP; - job.result = -1; - - bool rc = (nullptr != pool->NewThread(this, &job)); - Progress(rc, "Creating Thread"); - - WaitForThreadsToFinish(&job, 1); - } - - Progress(true, "Closing threadpool..."); - pool->Close(); - - Progress(true, "Deleting threadpool..."); - delete(pool); - PrintSeparator(); - } - - void ThreadCreatePerformance (bool silent, int count, int outercount) { - int i; - int j; - bool rc; - int threadsok; - - if (!silent) - TestHeader("Thread Create Performance"); - - FastOS_ThreadPool *pool = new FastOS_ThreadPool; - - if (!silent) - Progress(pool != nullptr, "Allocating ThreadPool"); - if (pool != nullptr) { - Job *jobs = new Job[count]; - - threadsok = 0; - steady_clock::time_point start = steady_clock::now(); - for (i = 0; i < count; i++) { - jobs[i].code = SILENTNOP; - jobs[i].ownThread = pool->NewThread(this, &jobs[i]); - rc = (jobs[i].ownThread != nullptr); - if (rc) - threadsok++; - } - - for (j = 0; j < outercount; j++) { - for (i = 0; i < count; i++) { - if (jobs[i].ownThread != nullptr) - jobs[i].ownThread->Join(); - jobs[i].ownThread = pool->NewThread(this, &jobs[i]); - rc = (jobs[i].ownThread != nullptr); - if (rc) - threadsok++; - } - } - for (i = 0; i < count; i++) { - if (jobs[i].ownThread != nullptr) - jobs[i].ownThread->Join(); - } - nanoseconds used = steady_clock::now() - start; - - if (!silent) { - double timeused = used.count() / 1000000000.0; - - Progress(true, "Used time: %2.3f", timeused); - ProgressFloat(true, "Threads/s: %6.1f", - static_cast<float>(static_cast<double>(threadsok) / timeused)); - } - if (threadsok != ((outercount + 1) * count)) - Progress(false, "Only started %d of %d threads", threadsok, - (outercount + 1) * count); - - if (!silent) - Progress(true, "Closing threadpool..."); - pool->Close(); - delete [] jobs; - - if (!silent) - Progress(true, "Deleting threadpool..."); - delete(pool); - if (!silent) - PrintSeparator(); - } - } - - void ClosePoolStability(void) { - int i; - TestHeader("ThreadPool close stability test"); - for (i = 0; i < 1000; i++) { - // Progress(true, "Creating pool iteration %d", i + 1); - ThreadCreatePerformance(true, 2, 1); - } - PrintSeparator(); - } - - - - void ClosePoolTest () - { - TestHeader("Close Pool Test"); - - FastOS_ThreadPool pool; - const int closePoolThreads=9; - Job jobs[closePoolThreads]; - - number = 0; - - for(int i=0; i<closePoolThreads; i++) { - jobs[i].code = INCREASE_NUMBER; - - bool rc = (nullptr != pool.NewThread(this, static_cast<void *>(&jobs[i]))); - Progress(rc, "Creating Thread %d", i+1); - } - - Progress(true, "Waiting for threads to finish using pool.Close()..."); - pool.Close(); - Progress(true, "Pool closed."); - PrintSeparator(); - } - - void BreakFlagTest () { - TestHeader("BreakFlag Test"); - - FastOS_ThreadPool pool; - - const int breakFlagThreads=4; - - Job jobs[breakFlagThreads]; - - for (int i=0; i<breakFlagThreads; i++) { - jobs[i].code = WAIT_FOR_BREAK_FLAG; - - bool rc = (nullptr != pool.NewThread(this, static_cast<void *>(&jobs[i]))); - Progress(rc, "Creating Thread %d", i+1); - } - - Progress(true, "Waiting for threads to finish using pool.Close()..."); - pool.Close(); - Progress(true, "Pool closed."); - PrintSeparator(); - } - - void ThreadIdTest () { - constexpr int numThreads = 5; - - TestHeader ("Thread Id Test"); - - FastOS_ThreadPool pool; - Job jobs[numThreads]; - std::mutex slowStartMutex; - - slowStartMutex.lock(); // Halt all threads until we want them to run - - for (int i=0; i<numThreads; i++) { - jobs[i].code = TEST_ID; - jobs[i].result = -1; - jobs[i]._threadId = 0; - jobs[i].mutex = &slowStartMutex; - jobs[i].ownThread = pool.NewThread(this, static_cast<void *>(&jobs[i])); - bool rc=(jobs[i].ownThread != nullptr); - if (rc) { - jobs[i]._threadId = jobs[i].ownThread->GetThreadId(); - } - Progress(rc, "CreatingThread %d id:%lu", i+1, (unsigned long)(jobs[i]._threadId)); - - for (int j=0; j<i; j++) { - if (jobs[j]._threadId == jobs[i]._threadId) { - Progress(false, "Two different threads received the same thread id (%lu)", - (unsigned long)(jobs[i]._threadId)); - } - } - } - - slowStartMutex.unlock(); // Allow threads to run - - Progress(true, "Waiting for threads to finish using pool.Close()..."); - pool.Close(); - Progress(true, "Pool closed."); - - for (int i=0; i<numThreads; i++) { - Progress(jobs[i].result == 1, - "Thread %lu: ID comparison (current vs stored)", - (unsigned long)(jobs[i]._threadId)); - } - - PrintSeparator(); - } - -}; - -int ThreadTest::Main () -{ - printf("grep for the string '%s' to detect failures.\n\n", failString); - time_t before = time(0); - - ThreadIdTest(); - CreateSingleThreadAndJoin(); - TooManyThreadsTest(); - ClosePoolTest(); - BreakFlagTest(); - CreateSingleThreadAndJoin(); - ThreadCreatePerformance(false, 50, 10); - ClosePoolStability(); - { time_t now = time(0); printf("[%ld seconds]\n", now-before); before = now; } - - printf("END OF TEST (%s)\n", _argv[0]); - return allWasOk() ? 0 : 1; -} - -int main (int argc, char **argv) -{ - ThreadTest app; - setvbuf(stdout, nullptr, _IOLBF, 8192); - return app.Entry(argc, argv); -} diff --git a/fastos/src/tests/typetest.cpp b/fastos/src/tests/typetest.cpp index e5d7e9ceb74..7871275e17c 100644 --- a/fastos/src/tests/typetest.cpp +++ b/fastos/src/tests/typetest.cpp @@ -13,10 +13,7 @@ private: Progress(true, "FastOS_DirectoryScan %d", sizeof(FastOS_DirectoryScan)); Progress(true, "FastOS_File: %d", sizeof(FastOS_File)); - Progress(true, "FastOS_Runnable %d", sizeof(FastOS_Runnable)); Progress(true, "FastOS_StatInfo %d", sizeof(FastOS_StatInfo)); - Progress(true, "FastOS_Thread: %d", sizeof(FastOS_Thread)); - Progress(true, "FastOS_ThreadPool: %d", sizeof(FastOS_ThreadPool)); PrintSeparator(); } |