diff --git a/Core/Code/Testing/files.cmake b/Core/Code/Testing/files.cmake index 059107ca32..7d6a3cde9c 100644 --- a/Core/Code/Testing/files.cmake +++ b/Core/Code/Testing/files.cmake @@ -1,114 +1,115 @@ # tests with no extra command line parameter set(MODULE_TESTS mitkAccessByItkTest.cpp mitkCoreObjectFactoryTest.cpp mitkMaterialTest.cpp mitkActionTest.cpp mitkEnumerationPropertyTest.cpp mitkEventTest.cpp mitkFocusManagerTest.cpp mitkGenericPropertyTest.cpp mitkGeometry3DTest.cpp mitkGeometryDataToSurfaceFilterTest.cpp mitkGlobalInteractionTest.cpp mitkImageDataItemTest.cpp #mitkImageMapper2DTest.cpp mitkImageGeneratorTest.cpp mitkBaseDataTest.cpp #mitkImageToItkTest.cpp mitkInstantiateAccessFunctionTest.cpp mitkInteractorTest.cpp mitkITKThreadingTest.cpp # mitkLevelWindowManagerTest.cpp mitkLevelWindowTest.cpp mitkMessageTest.cpp #mitkPipelineSmartPointerCorrectnessTest.cpp mitkPixelTypeTest.cpp mitkPlaneGeometryTest.cpp mitkPointSetFileIOTest.cpp mitkPointSetTest.cpp mitkPointSetWriterTest.cpp mitkPointSetReaderTest.cpp mitkPointSetInteractorTest.cpp mitkPropertyTest.cpp mitkPropertyListTest.cpp #mitkRegistrationBaseTest.cpp #mitkSegmentationInterpolationTest.cpp mitkSlicedGeometry3DTest.cpp mitkSliceNavigationControllerTest.cpp mitkStateMachineTest.cpp mitkStateTest.cpp mitkSurfaceTest.cpp mitkSurfaceToSurfaceFilterTest.cpp mitkTimeSlicedGeometryTest.cpp mitkTransitionTest.cpp mitkUndoControllerTest.cpp mitkVtkWidgetRenderingTest.cpp mitkVerboseLimitedLinearUndoTest.cpp mitkWeakPointerTest.cpp mitkTransferFunctionTest.cpp #mitkAbstractTransformGeometryTest.cpp mitkStepperTest.cpp itkTotalVariationDenoisingImageFilterTest.cpp mitkRenderingManagerTest.cpp vtkMitkThickSlicesFilterTest.cpp mitkNodePredicateSourceTest.cpp mitkVectorTest.cpp mitkClippedSurfaceBoundsCalculatorTest.cpp #QmitkRenderingTestHelper.cpp mitkExceptionTest.cpp mitkExtractSliceFilterTest.cpp + mitkLogTest.cpp ) # test with image filename as an extra command line parameter set(MODULE_IMAGE_TESTS mitkPlanePositionManagerTest.cpp mitkSurfaceVtkWriterTest.cpp #mitkImageSliceSelectorTest.cpp mitkImageTimeSelectorTest.cpp # mitkVtkPropRendererTest.cpp mitkDataNodeFactoryTest.cpp #mitkSTLFileReaderTest.cpp ) # list of images for which the tests are run set(MODULE_TESTIMAGES # Pic-Factory no more available in Core, test images now in .nrrd format US4DCyl.nrrd Pic3D.nrrd Pic2DplusT.nrrd BallBinary30x30x30.nrrd binary.stl ball.stl ) set(MODULE_CUSTOM_TESTS #mitkLabeledImageToSurfaceFilterTest.cpp #mitkExternalToolsTest.cpp mitkDataStorageTest.cpp mitkDataNodeTest.cpp mitkDicomSeriesReaderTest.cpp mitkDICOMLocaleTest.cpp mitkEventMapperTest.cpp mitkNodeDependentPointSetInteractorTest.cpp mitkStateMachineFactoryTest.cpp mitkPointSetLocaleTest.cpp mitkImageTest.cpp mitkImageWriterTest.cpp mitkImageVtkMapper2DTest.cpp mitkImageVtkMapper2DLevelWindowTest.cpp mitkImageVtkMapper2DOpacityTest.cpp mitkImageVtkMapper2DColorTest.cpp ) # Create an artificial module initializing class for # the usServiceListenerTest.cpp usFunctionGenerateModuleInit(testdriver_init_file NAME ${MODULE_NAME}TestDriver DEPENDS "Mitk" VERSION "0.1.0" EXECUTABLE ) set(TEST_CPP_FILES ${testdriver_init_file} mitkRenderingTestHelper.cpp) diff --git a/Core/Code/Testing/mitkLogTest.cpp b/Core/Code/Testing/mitkLogTest.cpp new file mode 100644 index 0000000000..7bcc861e54 --- /dev/null +++ b/Core/Code/Testing/mitkLogTest.cpp @@ -0,0 +1,166 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#include "mitkCommon.h" +#include "mitkTestingMacros.h" +#include +#include + +class mitkTestThread +{ +protected: + +bool LoggingRunning; + +int ThreadID; + +public: + +void SetThreadID(int id) +{ThreadID = id;} + +void LogMessages() + { + LoggingRunning = true; + + while(LoggingRunning) + { + MITK_INFO << "Test info stream in thread " << ThreadID; + MITK_WARN << "Test warning stream in thread " << ThreadID; + MITK_DEBUG << "Test debugging stream in thread " << ThreadID; + MITK_ERROR << "Test error stream in thread " << ThreadID; + MITK_FATAL << "Test fatal stream in thread " << ThreadID; + } + } + +void Stop() + { + LoggingRunning = false; + } +}; + +/** + * TODO + */ +class mitkLogTestClass +{ + +public: + +static bool ThreadsRunning; + +static ITK_THREAD_RETURN_TYPE ThreadStartTracking1(void* data) + { + struct itk::MultiThreader::ThreadInfoStruct * pInfo = (struct itk::MultiThreader::ThreadInfoStruct*)data; + if (pInfo == NULL) + { + return ITK_THREAD_RETURN_VALUE; + } + if (pInfo->UserData == NULL) + { + return ITK_THREAD_RETURN_VALUE; + } + while(mitkLogTestClass::ThreadsRunning) + { + MITK_INFO << "Test info stream in thread 1."; + MITK_WARN << "Test warning stream in thread 1."; + MITK_DEBUG << "Test debugging stream in thread 1."; + MITK_ERROR << "Test error stream in thread 1."; + MITK_FATAL << "Test fatal stream in thread 1."; + } + } + +static ITK_THREAD_RETURN_TYPE ThreadStartTracking2(void* data) + { + struct itk::MultiThreader::ThreadInfoStruct * pInfo = (struct itk::MultiThreader::ThreadInfoStruct*)data; + if (pInfo == NULL) + { + return ITK_THREAD_RETURN_VALUE; + } + if (pInfo->UserData == NULL) + { + return ITK_THREAD_RETURN_VALUE; + } + while(mitkLogTestClass::ThreadsRunning) + { + /*MITK_INFO << "Test info stream in thread 2."; + MITK_WARN << "Test warning stream in thread 2."; + MITK_DEBUG << "Test debugging stream in thread 2."; + MITK_ERROR << "Test error stream in thread 2."; + MITK_FATAL << "Test fatal stream in thread 2.";*/ + } + } + +static void TestSimpleLog() + { + bool testSucceded = true; + try + { + //MITK_INFO << "Test info stream."; + //MITK_WARN << "Test warning stream."; + //MITK_DEBUG << "Test debugging stream."; //only activated if cmake variable is on! + // //so no worries if you see no output for this line + //MITK_ERROR << "Test error stream."; + //MITK_FATAL << "Test fatal stream."; + } + catch(mitk::Exception e) + { + testSucceded = false; + } + MITK_TEST_CONDITION_REQUIRED(testSucceded,"Test logging streams."); + } + +static void TestThreadSaveLog() + { + ThreadsRunning = true; + itk::MultiThreader::Pointer MultiThreader; + int ThreadID1 = MultiThreader->SpawnThread(ThreadStartTracking1,&mitkLogTestClass()); + int ThreadID2 = MultiThreader->SpawnThread(ThreadStartTracking2,&mitkLogTestClass()); + Sleep(2000); + ThreadsRunning = false; + } + +static void TestLoggingToFile() + { + + } + +static void TestAddAndRemoveBackends() + { + + } + +static void TestDefaultBackend() + { + + } + + +}; //mitkLogTestClass + +bool mitkLogTestClass::ThreadsRunning = false; + +int mitkLogTest(int /* argc */, char* /*argv*/[]) +{ + // always start with this! + MITK_TEST_BEGIN("Log") + + mitkLogTestClass::TestSimpleLog(); + mitkLogTestClass::TestThreadSaveLog(); + + // always end with this! + MITK_TEST_END() +}