diff --git a/CHAOSFrameworkTests/CHAOSFrameworkTests.xcodeproj/project.pbxproj b/CHAOSFrameworkTests/CHAOSFrameworkTests.xcodeproj/project.pbxproj new file mode 100644 index 0000000000000000000000000000000000000000..bd3e3150ff7d6c350197ba25a2a8a31117a93075 --- /dev/null +++ b/CHAOSFrameworkTests/CHAOSFrameworkTests.xcodeproj/project.pbxproj @@ -0,0 +1,760 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 3299434F1D6B3951008DBAE9 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3299434E1D6B3951008DBAE9 /* main.cpp */; }; + 329943551D6B3AB7008DBAE9 /* TestTrigger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 329943531D6B3AB7008DBAE9 /* TestTrigger.cpp */; }; + 3299435E1D6B465F008DBAE9 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3299435D1D6B465F008DBAE9 /* main.cpp */; }; + 329943641D6B468E008DBAE9 /* TestTemplateKeyValueHashMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 329943621D6B468E008DBAE9 /* TestTemplateKeyValueHashMap.cpp */; }; + 3299436D1D6B48FA008DBAE9 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3299436C1D6B48FA008DBAE9 /* main.cpp */; }; + 329943731D6B4911008DBAE9 /* TestStateFlagCatalog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 329943711D6B4911008DBAE9 /* TestStateFlagCatalog.cpp */; }; + 3299437C1D6B5456008DBAE9 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3299437B1D6B5456008DBAE9 /* main.cpp */; }; + 329943821D6B5469008DBAE9 /* TestURLFeeder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 329943801D6B5469008DBAE9 /* TestURLFeeder.cpp */; }; + 3299438B1D6B58EE008DBAE9 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3299438A1D6B58EE008DBAE9 /* main.cpp */; }; + 329943911D6B5902008DBAE9 /* TestObjectProcessingPriorityQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3299438F1D6B5902008DBAE9 /* TestObjectProcessingPriorityQueue.cpp */; }; + 3299439A1D6B5C5F008DBAE9 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 329943991D6B5C5F008DBAE9 /* main.cpp */; }; + 329943A01D6B5CC4008DBAE9 /* TestObjectProcessingQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3299439E1D6B5CC4008DBAE9 /* TestObjectProcessingQueue.cpp */; }; + 32DAABA11D6B64DF00464F7A /* TestObjectProcessingPriorityQueueForPriority.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 32DAAB9F1D6B64DF00464F7A /* TestObjectProcessingPriorityQueueForPriority.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 3299434A1D6B3951008DBAE9 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; + 329943591D6B465F008DBAE9 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; + 329943681D6B48F9008DBAE9 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; + 329943771D6B5456008DBAE9 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; + 329943861D6B58EE008DBAE9 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; + 329943951D6B5C5F008DBAE9 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 3299434C1D6B3951008DBAE9 /* TestTriggerSystem */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TestTriggerSystem; sourceTree = BUILT_PRODUCTS_DIR; }; + 3299434E1D6B3951008DBAE9 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; + 329943531D6B3AB7008DBAE9 /* TestTrigger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestTrigger.cpp; sourceTree = "<group>"; }; + 329943541D6B3AB7008DBAE9 /* TestTrigger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestTrigger.h; sourceTree = "<group>"; }; + 329943561D6B404C008DBAE9 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; }; + 3299435B1D6B465F008DBAE9 /* TestTemplatedKeyValueHashMap */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TestTemplatedKeyValueHashMap; sourceTree = BUILT_PRODUCTS_DIR; }; + 3299435D1D6B465F008DBAE9 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; + 329943621D6B468E008DBAE9 /* TestTemplateKeyValueHashMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestTemplateKeyValueHashMap.cpp; sourceTree = "<group>"; }; + 329943631D6B468E008DBAE9 /* TestTemplateKeyValueHashMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestTemplateKeyValueHashMap.h; sourceTree = "<group>"; }; + 329943651D6B4702008DBAE9 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; }; + 3299436A1D6B48F9008DBAE9 /* TestStateFlagCatalog */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TestStateFlagCatalog; sourceTree = BUILT_PRODUCTS_DIR; }; + 3299436C1D6B48FA008DBAE9 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; + 329943711D6B4911008DBAE9 /* TestStateFlagCatalog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestStateFlagCatalog.cpp; sourceTree = "<group>"; }; + 329943721D6B4911008DBAE9 /* TestStateFlagCatalog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestStateFlagCatalog.h; sourceTree = "<group>"; }; + 329943741D6B4931008DBAE9 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; }; + 329943791D6B5456008DBAE9 /* TestURLFeeder */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TestURLFeeder; sourceTree = BUILT_PRODUCTS_DIR; }; + 3299437B1D6B5456008DBAE9 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; + 329943801D6B5469008DBAE9 /* TestURLFeeder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestURLFeeder.cpp; sourceTree = "<group>"; }; + 329943811D6B5469008DBAE9 /* TestURLFeeder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestURLFeeder.h; sourceTree = "<group>"; }; + 329943831D6B585C008DBAE9 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; }; + 329943881D6B58EE008DBAE9 /* TestObjectProcessingPriorityQueue */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TestObjectProcessingPriorityQueue; sourceTree = BUILT_PRODUCTS_DIR; }; + 3299438A1D6B58EE008DBAE9 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; + 3299438F1D6B5902008DBAE9 /* TestObjectProcessingPriorityQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestObjectProcessingPriorityQueue.cpp; sourceTree = "<group>"; }; + 329943901D6B5902008DBAE9 /* TestObjectProcessingPriorityQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestObjectProcessingPriorityQueue.h; sourceTree = "<group>"; }; + 329943921D6B59DB008DBAE9 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; }; + 329943971D6B5C5F008DBAE9 /* TestObjectProcessingQueue */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TestObjectProcessingQueue; sourceTree = BUILT_PRODUCTS_DIR; }; + 329943991D6B5C5F008DBAE9 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; }; + 3299439E1D6B5CC4008DBAE9 /* TestObjectProcessingQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestObjectProcessingQueue.cpp; sourceTree = "<group>"; }; + 3299439F1D6B5CC4008DBAE9 /* TestObjectProcessingQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestObjectProcessingQueue.h; sourceTree = "<group>"; }; + 329943A11D6B5D42008DBAE9 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; }; + 32DAAB9F1D6B64DF00464F7A /* TestObjectProcessingPriorityQueueForPriority.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestObjectProcessingPriorityQueueForPriority.cpp; sourceTree = "<group>"; }; + 32DAABA01D6B64DF00464F7A /* TestObjectProcessingPriorityQueueForPriority.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestObjectProcessingPriorityQueueForPriority.h; sourceTree = "<group>"; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 329943491D6B3951008DBAE9 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 329943581D6B465F008DBAE9 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 329943671D6B48F9008DBAE9 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 329943761D6B5456008DBAE9 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 329943851D6B58EE008DBAE9 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 329943941D6B5C5F008DBAE9 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 329943351D6B38CC008DBAE9 = { + isa = PBXGroup; + children = ( + 3299434D1D6B3951008DBAE9 /* TestTriggerSystem */, + 3299435C1D6B465F008DBAE9 /* TestTemplatedKeyValueHashMap */, + 3299436B1D6B48FA008DBAE9 /* TestStateFlagCatalog */, + 3299437A1D6B5456008DBAE9 /* TestURLFeeder */, + 329943891D6B58EE008DBAE9 /* TestObjectProcessingPriorityQueue */, + 329943981D6B5C5F008DBAE9 /* TestObjectProcessingQueue */, + 3299433F1D6B38CC008DBAE9 /* Products */, + ); + sourceTree = "<group>"; + }; + 3299433F1D6B38CC008DBAE9 /* Products */ = { + isa = PBXGroup; + children = ( + 3299434C1D6B3951008DBAE9 /* TestTriggerSystem */, + 3299435B1D6B465F008DBAE9 /* TestTemplatedKeyValueHashMap */, + 3299436A1D6B48F9008DBAE9 /* TestStateFlagCatalog */, + 329943791D6B5456008DBAE9 /* TestURLFeeder */, + 329943881D6B58EE008DBAE9 /* TestObjectProcessingPriorityQueue */, + 329943971D6B5C5F008DBAE9 /* TestObjectProcessingQueue */, + ); + name = Products; + sourceTree = "<group>"; + }; + 3299434D1D6B3951008DBAE9 /* TestTriggerSystem */ = { + isa = PBXGroup; + children = ( + 329943561D6B404C008DBAE9 /* CMakeLists.txt */, + 3299434E1D6B3951008DBAE9 /* main.cpp */, + 329943531D6B3AB7008DBAE9 /* TestTrigger.cpp */, + 329943541D6B3AB7008DBAE9 /* TestTrigger.h */, + ); + path = TestTriggerSystem; + sourceTree = "<group>"; + }; + 3299435C1D6B465F008DBAE9 /* TestTemplatedKeyValueHashMap */ = { + isa = PBXGroup; + children = ( + 329943651D6B4702008DBAE9 /* CMakeLists.txt */, + 3299435D1D6B465F008DBAE9 /* main.cpp */, + 329943621D6B468E008DBAE9 /* TestTemplateKeyValueHashMap.cpp */, + 329943631D6B468E008DBAE9 /* TestTemplateKeyValueHashMap.h */, + ); + path = TestTemplatedKeyValueHashMap; + sourceTree = "<group>"; + }; + 3299436B1D6B48FA008DBAE9 /* TestStateFlagCatalog */ = { + isa = PBXGroup; + children = ( + 329943741D6B4931008DBAE9 /* CMakeLists.txt */, + 3299436C1D6B48FA008DBAE9 /* main.cpp */, + 329943711D6B4911008DBAE9 /* TestStateFlagCatalog.cpp */, + 329943721D6B4911008DBAE9 /* TestStateFlagCatalog.h */, + ); + path = TestStateFlagCatalog; + sourceTree = "<group>"; + }; + 3299437A1D6B5456008DBAE9 /* TestURLFeeder */ = { + isa = PBXGroup; + children = ( + 329943831D6B585C008DBAE9 /* CMakeLists.txt */, + 3299437B1D6B5456008DBAE9 /* main.cpp */, + 329943801D6B5469008DBAE9 /* TestURLFeeder.cpp */, + 329943811D6B5469008DBAE9 /* TestURLFeeder.h */, + ); + path = TestURLFeeder; + sourceTree = "<group>"; + }; + 329943891D6B58EE008DBAE9 /* TestObjectProcessingPriorityQueue */ = { + isa = PBXGroup; + children = ( + 329943921D6B59DB008DBAE9 /* CMakeLists.txt */, + 3299438A1D6B58EE008DBAE9 /* main.cpp */, + 3299438F1D6B5902008DBAE9 /* TestObjectProcessingPriorityQueue.cpp */, + 329943901D6B5902008DBAE9 /* TestObjectProcessingPriorityQueue.h */, + 32DAAB9F1D6B64DF00464F7A /* TestObjectProcessingPriorityQueueForPriority.cpp */, + 32DAABA01D6B64DF00464F7A /* TestObjectProcessingPriorityQueueForPriority.h */, + ); + path = TestObjectProcessingPriorityQueue; + sourceTree = "<group>"; + }; + 329943981D6B5C5F008DBAE9 /* TestObjectProcessingQueue */ = { + isa = PBXGroup; + children = ( + 329943A11D6B5D42008DBAE9 /* CMakeLists.txt */, + 329943991D6B5C5F008DBAE9 /* main.cpp */, + 3299439E1D6B5CC4008DBAE9 /* TestObjectProcessingQueue.cpp */, + 3299439F1D6B5CC4008DBAE9 /* TestObjectProcessingQueue.h */, + ); + path = TestObjectProcessingQueue; + sourceTree = "<group>"; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 3299434B1D6B3951008DBAE9 /* TestTriggerSystem */ = { + isa = PBXNativeTarget; + buildConfigurationList = 329943501D6B3951008DBAE9 /* Build configuration list for PBXNativeTarget "TestTriggerSystem" */; + buildPhases = ( + 329943481D6B3951008DBAE9 /* Sources */, + 329943491D6B3951008DBAE9 /* Frameworks */, + 3299434A1D6B3951008DBAE9 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = TestTriggerSystem; + productName = TestTriggerSystem; + productReference = 3299434C1D6B3951008DBAE9 /* TestTriggerSystem */; + productType = "com.apple.product-type.tool"; + }; + 3299435A1D6B465F008DBAE9 /* TestTemplatedKeyValueHashMap */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3299435F1D6B465F008DBAE9 /* Build configuration list for PBXNativeTarget "TestTemplatedKeyValueHashMap" */; + buildPhases = ( + 329943571D6B465F008DBAE9 /* Sources */, + 329943581D6B465F008DBAE9 /* Frameworks */, + 329943591D6B465F008DBAE9 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = TestTemplatedKeyValueHashMap; + productName = TestTemplatedKeyValueHashMap; + productReference = 3299435B1D6B465F008DBAE9 /* TestTemplatedKeyValueHashMap */; + productType = "com.apple.product-type.tool"; + }; + 329943691D6B48F9008DBAE9 /* TestStateFlagCatalog */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3299436E1D6B48FA008DBAE9 /* Build configuration list for PBXNativeTarget "TestStateFlagCatalog" */; + buildPhases = ( + 329943661D6B48F9008DBAE9 /* Sources */, + 329943671D6B48F9008DBAE9 /* Frameworks */, + 329943681D6B48F9008DBAE9 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = TestStateFlagCatalog; + productName = TestStateFlagCatalog; + productReference = 3299436A1D6B48F9008DBAE9 /* TestStateFlagCatalog */; + productType = "com.apple.product-type.tool"; + }; + 329943781D6B5456008DBAE9 /* TestURLFeeder */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3299437D1D6B5456008DBAE9 /* Build configuration list for PBXNativeTarget "TestURLFeeder" */; + buildPhases = ( + 329943751D6B5456008DBAE9 /* Sources */, + 329943761D6B5456008DBAE9 /* Frameworks */, + 329943771D6B5456008DBAE9 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = TestURLFeeder; + productName = TestURLFeeder; + productReference = 329943791D6B5456008DBAE9 /* TestURLFeeder */; + productType = "com.apple.product-type.tool"; + }; + 329943871D6B58EE008DBAE9 /* TestObjectProcessingPriorityQueue */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3299438C1D6B58EE008DBAE9 /* Build configuration list for PBXNativeTarget "TestObjectProcessingPriorityQueue" */; + buildPhases = ( + 329943841D6B58EE008DBAE9 /* Sources */, + 329943851D6B58EE008DBAE9 /* Frameworks */, + 329943861D6B58EE008DBAE9 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = TestObjectProcessingPriorityQueue; + productName = TestPriorityQueue; + productReference = 329943881D6B58EE008DBAE9 /* TestObjectProcessingPriorityQueue */; + productType = "com.apple.product-type.tool"; + }; + 329943961D6B5C5F008DBAE9 /* TestObjectProcessingQueue */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3299439B1D6B5C5F008DBAE9 /* Build configuration list for PBXNativeTarget "TestObjectProcessingQueue" */; + buildPhases = ( + 329943931D6B5C5F008DBAE9 /* Sources */, + 329943941D6B5C5F008DBAE9 /* Frameworks */, + 329943951D6B5C5F008DBAE9 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = TestObjectProcessingQueue; + productName = TestObjectProcessingQueue; + productReference = 329943971D6B5C5F008DBAE9 /* TestObjectProcessingQueue */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 329943361D6B38CC008DBAE9 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0800; + ORGANIZATIONNAME = bisegni; + TargetAttributes = { + 3299434B1D6B3951008DBAE9 = { + CreatedOnToolsVersion = 8.0; + DevelopmentTeam = ZZ5BMKV37Y; + ProvisioningStyle = Automatic; + }; + 3299435A1D6B465F008DBAE9 = { + CreatedOnToolsVersion = 8.0; + DevelopmentTeam = ZZ5BMKV37Y; + ProvisioningStyle = Automatic; + }; + 329943691D6B48F9008DBAE9 = { + CreatedOnToolsVersion = 8.0; + DevelopmentTeam = ZZ5BMKV37Y; + ProvisioningStyle = Automatic; + }; + 329943781D6B5456008DBAE9 = { + CreatedOnToolsVersion = 8.0; + DevelopmentTeam = ZZ5BMKV37Y; + ProvisioningStyle = Automatic; + }; + 329943871D6B58EE008DBAE9 = { + CreatedOnToolsVersion = 8.0; + DevelopmentTeam = ZZ5BMKV37Y; + ProvisioningStyle = Automatic; + }; + 329943961D6B5C5F008DBAE9 = { + CreatedOnToolsVersion = 8.0; + DevelopmentTeam = ZZ5BMKV37Y; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = 329943391D6B38CC008DBAE9 /* Build configuration list for PBXProject "CHAOSFrameworkTests" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 329943351D6B38CC008DBAE9; + productRefGroup = 3299433F1D6B38CC008DBAE9 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 3299434B1D6B3951008DBAE9 /* TestTriggerSystem */, + 3299435A1D6B465F008DBAE9 /* TestTemplatedKeyValueHashMap */, + 329943691D6B48F9008DBAE9 /* TestStateFlagCatalog */, + 329943781D6B5456008DBAE9 /* TestURLFeeder */, + 329943871D6B58EE008DBAE9 /* TestObjectProcessingPriorityQueue */, + 329943961D6B5C5F008DBAE9 /* TestObjectProcessingQueue */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 329943481D6B3951008DBAE9 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 329943551D6B3AB7008DBAE9 /* TestTrigger.cpp in Sources */, + 3299434F1D6B3951008DBAE9 /* main.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 329943571D6B465F008DBAE9 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 329943641D6B468E008DBAE9 /* TestTemplateKeyValueHashMap.cpp in Sources */, + 3299435E1D6B465F008DBAE9 /* main.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 329943661D6B48F9008DBAE9 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3299436D1D6B48FA008DBAE9 /* main.cpp in Sources */, + 329943731D6B4911008DBAE9 /* TestStateFlagCatalog.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 329943751D6B5456008DBAE9 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 329943821D6B5469008DBAE9 /* TestURLFeeder.cpp in Sources */, + 3299437C1D6B5456008DBAE9 /* main.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 329943841D6B58EE008DBAE9 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3299438B1D6B58EE008DBAE9 /* main.cpp in Sources */, + 32DAABA11D6B64DF00464F7A /* TestObjectProcessingPriorityQueueForPriority.cpp in Sources */, + 329943911D6B5902008DBAE9 /* TestObjectProcessingPriorityQueue.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 329943931D6B5C5F008DBAE9 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3299439A1D6B5C5F008DBAE9 /* main.cpp in Sources */, + 329943A01D6B5CC4008DBAE9 /* TestObjectProcessingQueue.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 329943431D6B38CC008DBAE9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVES = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../usr/local/bin"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ../usr/local/include; + INSTALL_PATH = "$(SRCROOT)/../usr/local/bin"; + LIBRARY_SEARCH_PATHS = "$(SRCROOT)/../usr/local/lib"; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = "-lchaos_common"; + SDKROOT = macosx; + }; + name = Debug; + }; + 329943441D6B38CC008DBAE9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVES = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + CONFIGURATION_BUILD_DIR = "$(SRCROOT)/../usr/local/bin"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ../usr/local/include; + INSTALL_PATH = "$(SRCROOT)/../usr/local/bin"; + LIBRARY_SEARCH_PATHS = "$(SRCROOT)/../usr/local/lib"; + MACOSX_DEPLOYMENT_TARGET = 10.11; + MTL_ENABLE_DEBUG_INFO = NO; + OTHER_LDFLAGS = "-lchaos_common"; + SDKROOT = macosx; + }; + name = Release; + }; + 329943511D6B3951008DBAE9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CONFIGURATION_BUILD_DIR = $inherited; + DEVELOPMENT_TEAM = ZZ5BMKV37Y; + INSTALL_PATH = $inherited; + OTHER_LDFLAGS = $inherited; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 329943521D6B3951008DBAE9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CONFIGURATION_BUILD_DIR = $inherited; + DEVELOPMENT_TEAM = ZZ5BMKV37Y; + INSTALL_PATH = $inherited; + OTHER_LDFLAGS = $inherited; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + 329943601D6B465F008DBAE9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEVELOPMENT_TEAM = ZZ5BMKV37Y; + OTHER_LDFLAGS = $inherited; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 329943611D6B465F008DBAE9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEVELOPMENT_TEAM = ZZ5BMKV37Y; + OTHER_LDFLAGS = $inherited; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + 3299436F1D6B48FA008DBAE9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEVELOPMENT_TEAM = ZZ5BMKV37Y; + OTHER_LDFLAGS = $inherited; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 329943701D6B48FA008DBAE9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEVELOPMENT_TEAM = ZZ5BMKV37Y; + OTHER_LDFLAGS = $inherited; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + 3299437E1D6B5456008DBAE9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEVELOPMENT_TEAM = ZZ5BMKV37Y; + OTHER_LDFLAGS = $inherited; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 3299437F1D6B5456008DBAE9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEVELOPMENT_TEAM = ZZ5BMKV37Y; + OTHER_LDFLAGS = $inherited; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + 3299438D1D6B58EE008DBAE9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEVELOPMENT_TEAM = ZZ5BMKV37Y; + OTHER_LDFLAGS = $inherited; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 3299438E1D6B58EE008DBAE9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEVELOPMENT_TEAM = ZZ5BMKV37Y; + OTHER_LDFLAGS = $inherited; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + 3299439C1D6B5C5F008DBAE9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEVELOPMENT_TEAM = ZZ5BMKV37Y; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 3299439D1D6B5C5F008DBAE9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + DEVELOPMENT_TEAM = ZZ5BMKV37Y; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 329943391D6B38CC008DBAE9 /* Build configuration list for PBXProject "CHAOSFrameworkTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 329943431D6B38CC008DBAE9 /* Debug */, + 329943441D6B38CC008DBAE9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 329943501D6B3951008DBAE9 /* Build configuration list for PBXNativeTarget "TestTriggerSystem" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 329943511D6B3951008DBAE9 /* Debug */, + 329943521D6B3951008DBAE9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 3299435F1D6B465F008DBAE9 /* Build configuration list for PBXNativeTarget "TestTemplatedKeyValueHashMap" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 329943601D6B465F008DBAE9 /* Debug */, + 329943611D6B465F008DBAE9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 3299436E1D6B48FA008DBAE9 /* Build configuration list for PBXNativeTarget "TestStateFlagCatalog" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3299436F1D6B48FA008DBAE9 /* Debug */, + 329943701D6B48FA008DBAE9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 3299437D1D6B5456008DBAE9 /* Build configuration list for PBXNativeTarget "TestURLFeeder" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3299437E1D6B5456008DBAE9 /* Debug */, + 3299437F1D6B5456008DBAE9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 3299438C1D6B58EE008DBAE9 /* Build configuration list for PBXNativeTarget "TestObjectProcessingPriorityQueue" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3299438D1D6B58EE008DBAE9 /* Debug */, + 3299438E1D6B58EE008DBAE9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 3299439B1D6B5C5F008DBAE9 /* Build configuration list for PBXNativeTarget "TestObjectProcessingQueue" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3299439C1D6B5C5F008DBAE9 /* Debug */, + 3299439D1D6B5C5F008DBAE9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 329943361D6B38CC008DBAE9 /* Project object */; +} diff --git a/CHAOSFrameworkTests/TestObjectProcessingPriorityQueue/TestObjectProcessingPriorityQueue.cpp b/CHAOSFrameworkTests/TestObjectProcessingPriorityQueue/TestObjectProcessingPriorityQueue.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7f452bee3dc0d8fd34db2a81de4ff0df9c691109 --- /dev/null +++ b/CHAOSFrameworkTests/TestObjectProcessingPriorityQueue/TestObjectProcessingPriorityQueue.cpp @@ -0,0 +1,91 @@ +/* + * TestObjectProcessingPriorityQueue.cpp + * + * !CHAOS [CHAOSFrameworkTests] + * Created by bisegni. + * + * Copyright 22/08/16 INFN, National Institute of Nuclear Physics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "TestObjectProcessingPriorityQueue.h" + +#include <stdio.h> +#include <cassert> + +using namespace chaos::common::pqueue::test; + +TestObjectProcessingPriorityQueue::TestObjectProcessingPriorityQueue(): +number_of_consumer(0), +number_of_producer(0), +number_of_production(0) { +} + +TestObjectProcessingPriorityQueue::~TestObjectProcessingPriorityQueue() { +} + +bool TestObjectProcessingPriorityQueue::test(int _number_of_producer, + int _number_of_production, + int _number_of_consumer, + unsigned int _sec_to_whait, + bool _whait_to_finish) { + job_to_do = 0; + error_in_job = 0; + priority_counter = 0; + //init and start the consumer thread + init(number_of_consumer = _number_of_consumer); + number_of_production = _number_of_production; + number_of_producer = _number_of_producer; + + //init the producer + for(int idx = 0;idx < number_of_producer; idx++) { + tg.add_thread(new boost::thread(boost::bind(&TestObjectProcessingPriorityQueue::producer, + this))); + } + + if(_sec_to_whait) { + sleep(_sec_to_whait); + } + //waith the priducer has terminated to generate job + tg.join_all(); + + //now deinit the queue + deinit(_whait_to_finish); + + //print statistic + std::cout << "Error in job = " << error_in_job << std::endl; + std::cout << "Job not done = " << job_to_do << std::endl; + std::cout << "end whit element number = " << queueSize() << std::endl; + return (job_to_do == 0) && + (error_in_job == 0) && + (queueSize() == 0); +} + +void TestObjectProcessingPriorityQueue::processBufferElement(TestJobPriorityStruct *job, + ElementManagingPolicy& p) throw(CException) { + assert(job); + job_to_do--; + if((--job->check_concurence) != 0) { + error_in_job++; + } +} + +void TestObjectProcessingPriorityQueue::producer() { + for(int idx = 0;idx < number_of_production; idx++) { + TestJobPriorityStruct *job = (TestJobPriorityStruct*)malloc(sizeof(TestJobPriorityStruct)); + job->check_concurence = 1; + job_to_do++; + push(job, (job->priority = priority_counter++)); + } +} diff --git a/CHAOSFrameworkTests/TestObjectProcessingPriorityQueue/TestObjectProcessingPriorityQueue.h b/CHAOSFrameworkTests/TestObjectProcessingPriorityQueue/TestObjectProcessingPriorityQueue.h new file mode 100644 index 0000000000000000000000000000000000000000..d60ec3970c06497287f80963e657044a672e2d4d --- /dev/null +++ b/CHAOSFrameworkTests/TestObjectProcessingPriorityQueue/TestObjectProcessingPriorityQueue.h @@ -0,0 +1,68 @@ +/* + * TestObjectProcessingPriorityQueue.h + * + * !CHAOS [CHAOSFrameworkTests] + * Created by bisegni. + * + * Copyright 22/08/16 INFN, National Institute of Nuclear Physics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CHAOSFrameworkTests__E2A0E5A_E2D9_47FC_880A_39C7695501E3_TestObjectProcessingPriorityQueue_h +#define __CHAOSFrameworkTests__E2A0E5A_E2D9_47FC_880A_39C7695501E3_TestObjectProcessingPriorityQueue_h + +#include <chaos/common/pqueue/CObjectProcessingPriorityQueue.h> + +#include <boost/atomic.hpp> +#include <boost/thread.hpp> + +namespace chaos { + namespace common { + namespace pqueue { + namespace test { + + typedef struct TestJobPriorityStruct { + int priority; + boost::atomic<int> check_concurence; + } TestJobPriorityStruct; + + //! thest for the chaos::common::pqueue::CObjectProcessingQueue + class TestObjectProcessingPriorityQueue: + protected CObjectProcessingPriorityQueue<TestJobPriorityStruct> { + int number_of_consumer; + int number_of_producer; + int number_of_production; + boost::atomic<int> job_to_do; + boost::atomic<int> error_in_job; + boost::atomic<int> priority_counter; + boost::thread_group tg; + void processBufferElement(TestJobPriorityStruct *job, + ElementManagingPolicy& p) throw(CException); + + void producer(); + public: + TestObjectProcessingPriorityQueue(); + virtual ~TestObjectProcessingPriorityQueue(); + bool test(int _number_of_producer, + int _number_of_production, + int _number_of_consumer, + unsigned int _sec_to_whait = 0, + bool _whait_to_finish = true); + }; + } + } + } +} + +#endif /* __CHAOSFrameworkTests__E2A0E5A_E2D9_47FC_880A_39C7695501E3_TestObjectProcessingPriorityQueue_h */ diff --git a/CHAOSFrameworkTests/TestObjectProcessingPriorityQueue/TestObjectProcessingPriorityQueueForPriority.cpp b/CHAOSFrameworkTests/TestObjectProcessingPriorityQueue/TestObjectProcessingPriorityQueueForPriority.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0873bf96a25d814d54e6b65fb1306c2fecd187d2 --- /dev/null +++ b/CHAOSFrameworkTests/TestObjectProcessingPriorityQueue/TestObjectProcessingPriorityQueueForPriority.cpp @@ -0,0 +1,66 @@ +/* + * TestObjectProcessingPriorityQueueForPriority.cpp + * + * !CHAOS [CHAOSFrameworkTests] + * Created by bisegni. + * + * Copyright 22/08/16 INFN, National Institute of Nuclear Physics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "TestObjectProcessingPriorityQueueForPriority.h" + +using namespace chaos::common::pqueue::test; + +TestObjectProcessingPriorityQueueForPriority::TestObjectProcessingPriorityQueueForPriority(): +last_sequence(0), +last_priority(100), +max_priority(0), +number_of_production(0){} + +TestObjectProcessingPriorityQueueForPriority::~TestObjectProcessingPriorityQueueForPriority(){} + +void TestObjectProcessingPriorityQueueForPriority::processBufferElement(TestPriorityElement *element, + ElementManagingPolicy& p) throw(CException) { + if(last_priority != element->priority) { + assert(last_priority>=element->priority); + last_priority = element->priority; + last_sequence = 0; + } + if(last_sequence != element->id) { + assert(last_sequence<element->id); + last_sequence = element->id; + } +} + +void TestObjectProcessingPriorityQueueForPriority::init(int threadNumber) throw(CException) { + + //fill queue initlize to test priority for all element + int priority = 0; + for(int idx = 0; idx < number_of_production; idx++) { + priority = std::rand()%max_priority+1; + push(new TestPriorityElement(chaos::common::utility::UUIDUtil::generateUUID(), idx, priority), priority, true); + } + + CObjectProcessingPriorityQueue<TestPriorityElement>::init(threadNumber); +} + +bool TestObjectProcessingPriorityQueueForPriority::test(int _max_priority, + int _number_of_production) { + max_priority = _max_priority; + number_of_production =_number_of_production; + init(1); + deinit(true); + return true; +} diff --git a/CHAOSFrameworkTests/TestObjectProcessingPriorityQueue/TestObjectProcessingPriorityQueueForPriority.h b/CHAOSFrameworkTests/TestObjectProcessingPriorityQueue/TestObjectProcessingPriorityQueueForPriority.h new file mode 100644 index 0000000000000000000000000000000000000000..e9be93fa7229ed7c6ccc85b5cb9fad617b3df9be --- /dev/null +++ b/CHAOSFrameworkTests/TestObjectProcessingPriorityQueue/TestObjectProcessingPriorityQueueForPriority.h @@ -0,0 +1,72 @@ +/* + * TestObjectProcessingPriorityQueueForPriority.h + * + * !CHAOS [CHAOSFrameworkTests] + * Created by bisegni. + * + * Copyright 22/08/16 INFN, National Institute of Nuclear Physics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CHAOSFrameworkTests__2FFCAB2_CA85_4A0C_9816_68F0ED3F2CA8_TestObjectProcessingPriorityQueueForPriority_h +#define __CHAOSFrameworkTests__2FFCAB2_CA85_4A0C_9816_68F0ED3F2CA8_TestObjectProcessingPriorityQueueForPriority_h + + +#include <chaos/common/pqueue/CObjectProcessingPriorityQueue.h> + +#include <boost/atomic.hpp> +#include <boost/thread.hpp> + +namespace chaos { + namespace common { + namespace pqueue { + namespace test { + + typedef struct TestPriorityElement { + std::string element_value; + uint64_t id; + int priority; + TestPriorityElement(const std::string& _element_value, + uint64_t _id, + int _priority): + element_value(_element_value), + id(_id), + priority(_priority){} + } TestPriorityElement; + + + //! thest for the chaos::common::pqueue::CObjectProcessingQueue + class TestObjectProcessingPriorityQueueForPriority: + protected CObjectProcessingPriorityQueue<TestPriorityElement> { + uint64_t last_sequence; + int last_priority; + int max_priority; + int number_of_production; + void processBufferElement(TestPriorityElement *job, + ElementManagingPolicy& p) throw(CException); + + void init(int threadNumber) throw(CException); + + public: + TestObjectProcessingPriorityQueueForPriority(); + virtual ~TestObjectProcessingPriorityQueueForPriority(); + bool test(int _max_priority, + int _number_of_production); + }; + } + } + } +} + +#endif /* __CHAOSFrameworkTests__2FFCAB2_CA85_4A0C_9816_68F0ED3F2CA8_TestObjectProcessingPriorityQueueForPriority_h */ diff --git a/CHAOSFrameworkTests/TestObjectProcessingPriorityQueue/main.cpp b/CHAOSFrameworkTests/TestObjectProcessingPriorityQueue/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1dbfd1549f3528bc5c5bf46dcc471ac2ca7df454 --- /dev/null +++ b/CHAOSFrameworkTests/TestObjectProcessingPriorityQueue/main.cpp @@ -0,0 +1,19 @@ +// +// main.cpp +// TestPriorityQueue +// +// Created by bisegni on 22/08/16. +// Copyright © 2016 bisegni. All rights reserved. +// + +#include "TestObjectProcessingPriorityQueue.h" +#include "TestObjectProcessingPriorityQueueForPriority.h" + +int main(int argc, const char * argv[]) { + + chaos::common::pqueue::test::TestObjectProcessingPriorityQueue opqt; + chaos::common::pqueue::test::TestObjectProcessingPriorityQueueForPriority opqt_priority; + if(!opqt.test(10, 100, 100, 0, true)) return 1; + if(!opqt_priority.test(50, 1000)) return 1; + return 0; +} diff --git a/CHAOSFrameworkTests/TestObjectProcessingQueue/TestObjectProcessingQueue.cpp b/CHAOSFrameworkTests/TestObjectProcessingQueue/TestObjectProcessingQueue.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b1090cbfc0b8880d61c10efe15a977717e8550b8 --- /dev/null +++ b/CHAOSFrameworkTests/TestObjectProcessingQueue/TestObjectProcessingQueue.cpp @@ -0,0 +1,89 @@ +/* + * TestObjectProcessingQueue.cpp + * + * !CHAOS [CHAOSFrameworkTests] + * Created by bisegni. + * + * Copyright 22/08/16 INFN, National Institute of Nuclear Physics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "TestObjectProcessingQueue.h" + +#include <stdio.h> +#include <cassert> + +using namespace chaos::common::pqueue::test; +TestObjectProcessingQueue::TestObjectProcessingQueue(): +number_of_consumer(0), +number_of_producer(0), +number_of_production(0) { +} + +TestObjectProcessingQueue::~TestObjectProcessingQueue() { +} + +bool TestObjectProcessingQueue::test(int _number_of_producer, + int _number_of_production, + int _number_of_consumer, + unsigned int _sec_to_whait, + bool _whait_to_finish) { + job_to_do = 0; + error_in_job = 0; + //init and start the consumer thread + init(number_of_consumer = _number_of_consumer); + number_of_production = _number_of_production; + number_of_producer = _number_of_producer; + + //init the producer + for(int idx = 0;idx < number_of_producer; idx++) { + tg.add_thread(new boost::thread(boost::bind(&TestObjectProcessingQueue::producer, + this))); + } + + if(_sec_to_whait) { + sleep(_sec_to_whait); + } + //waith the priducer has terminated to generate job + tg.join_all(); + + //now deinit the queue + deinit(_whait_to_finish); + + //print statistic + std::cout << "Error in job = " << error_in_job << std::endl; + std::cout << "Job not done = " << job_to_do << std::endl; + std::cout << "end whit element number = " << queueSize() << std::endl; + return (job_to_do == 0) && + (error_in_job == 0) && + (queueSize() == 0); +} + +void TestObjectProcessingQueue::processBufferElement(TestJobStruct *job, + ElementManagingPolicy& p) throw(CException) { + assert(job); + job_to_do--; + if((--job->check_concurence) != 0) { + error_in_job++; + } +} + +void TestObjectProcessingQueue::producer() { + for(int idx = 0;idx < number_of_production; idx++) { + TestJobStruct *job = (TestJobStruct*)malloc(sizeof(TestJobStruct)); + job->check_concurence = 1; + job_to_do++; + push(job); + } +} diff --git a/CHAOSFrameworkTests/TestObjectProcessingQueue/TestObjectProcessingQueue.h b/CHAOSFrameworkTests/TestObjectProcessingQueue/TestObjectProcessingQueue.h new file mode 100644 index 0000000000000000000000000000000000000000..57858b74abb96f7d1807d36e0d9773bd52c4b9b3 --- /dev/null +++ b/CHAOSFrameworkTests/TestObjectProcessingQueue/TestObjectProcessingQueue.h @@ -0,0 +1,66 @@ +/* + * TestObjectProcessingQueue.h + * + * !CHAOS [CHAOSFrameworkTests] + * Created by bisegni. + * + * Copyright 22/08/16 INFN, National Institute of Nuclear Physics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CHAOSFrameworkTests_EEF7605F_524D_404E_B146_DA17DD3C2AAF_TestObjectProcessingQueue_h +#define __CHAOSFrameworkTests_EEF7605F_524D_404E_B146_DA17DD3C2AAF_TestObjectProcessingQueue_h + +#include <chaos/common/pqueue/CObjectProcessingQueue.h> + +#include <boost/atomic.hpp> +#include <boost/thread.hpp> + +namespace chaos { + namespace common { + namespace pqueue { + namespace test { + + typedef struct TestJobStruct { + boost::atomic<int> check_concurence; + } TestJobStruct; + + //! thest for the chaos::common::pqueue::CObjectProcessingQueue + class TestObjectProcessingQueue: + protected chaos::CObjectProcessingQueue<TestJobStruct> { + int number_of_consumer; + int number_of_producer; + int number_of_production; + boost::atomic<int> job_to_do; + boost::atomic<int> error_in_job; + boost::thread_group tg; + void processBufferElement(TestJobStruct *job, + ElementManagingPolicy& p) throw(CException); + + void producer(); + public: + TestObjectProcessingQueue(); + virtual~ TestObjectProcessingQueue(); + bool test(int _number_of_producer, + int _number_of_production, + int _number_of_consumer, + unsigned int _sec_to_whait = 0, + bool _whait_to_finish = true); + }; + } + } + } +} + +#endif /* __CHAOSFrameworkTests_EEF7605F_524D_404E_B146_DA17DD3C2AAF_TestObjectProcessingQueue_h */ diff --git a/CHAOSFrameworkTests/TestObjectProcessingQueue/main.cpp b/CHAOSFrameworkTests/TestObjectProcessingQueue/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4829e9162f1b56f0a2148279410b3a0b845f6135 --- /dev/null +++ b/CHAOSFrameworkTests/TestObjectProcessingQueue/main.cpp @@ -0,0 +1,14 @@ +// +// main.cpp +// TestObjectProcessingQueue +// +// Created by bisegni on 22/08/16. +// Copyright © 2016 bisegni. All rights reserved. +// + +#include "TestObjectProcessingQueue.h" + +int main(int argc, const char * argv[]) { + chaos::common::pqueue::test::TestObjectProcessingQueue oqt; + if(!(oqt.test(10, 100, 100, 0, true) == true)) return 1; +} diff --git a/CHAOSFrameworkTests/TestStateFlagCatalog/TestStateFlagCatalog.cpp b/CHAOSFrameworkTests/TestStateFlagCatalog/TestStateFlagCatalog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..488d76abaa177fa5dc550e5e8a7ea26b4169e70a --- /dev/null +++ b/CHAOSFrameworkTests/TestStateFlagCatalog/TestStateFlagCatalog.cpp @@ -0,0 +1,134 @@ +/* + * TestStateFlagCatalog.cpp + * + * !CHAOS [CHAOSFrameworkTests] + * Created by bisegni. + * + * Copyright 22/08/16 INFN, National Institute of Nuclear Physics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include "TestStateFlagCatalog.h" + +#include <chaos/common/status_manager/StatusFlagCatalogSDWrapper.h> + +#include <boost/foreach.hpp> + +using namespace chaos::common::utility::test; +using namespace chaos::common::status_manager; + +TestStateFlagCatalog::TestStateFlagCatalog(): +catalog_a("catalog_a"), +catalog_b("catalog_b"){} + +TestStateFlagCatalog::~TestStateFlagCatalog() {} + +bool TestStateFlagCatalog::test() { + boost::shared_ptr<StatusFlag> flag; + boost::shared_ptr<StatusFlag> flag_powersupply_state; + boost::shared_ptr<StatusFlag> flag_serial_comunication; + boost::shared_ptr<StatusFlag> flag_serial_port; + + flag_powersupply_state.reset(new StatusFlag("powersupply_state", + "Represent the state of internal power supply")); + flag_powersupply_state->addLevel(StateLevel(0, "Off", "Powersupply is off", StatusFlagServerityRegular)); + flag_powersupply_state->addLevel(StateLevel(1, "Standby", "Power supply can't erogate current", StatusFlagServerityRegular)); + flag_powersupply_state->addLevel(StateLevel(2, "Operational", "Powersupply erogate current", StatusFlagServerityRegular)); + flag_powersupply_state->addLevel(StateLevel(3, "faulty", "Powersupply is in faulty", StatusFlagServerityWarning)); + catalog_a.addFlag(flag_powersupply_state); + + flag_serial_comunication.reset(new StatusFlag("serial_comunication", + "Represente the state of the comunication over the serial port")); + flag_serial_comunication->addLevel(StateLevel(0, "Working", "Comunication are OK!", StatusFlagServerityRegular)); + flag_serial_comunication->addLevel(StateLevel(1, "Timeout", "No answqer over serial port", StatusFlagServerityWarning)); + catalog_a.addFlag(flag_serial_comunication); + + flag_serial_port.reset(new StatusFlag("serial_port_state", + "Represente the state of the serial port")); + flag_serial_port->addLevel(StateLevel(0, "Working", "Serial porto working", StatusFlagServerityRegular)); + flag_serial_port->addLevel(StateLevel(1, "KernelError", "Comunication problem using serial port", StatusFlagServerityCritical)); + catalog_b.addFlag(flag_serial_port); + + flag = catalog_a.getFlagByName("powersupply_state"); + assert(flag->getName().compare("powersupply_state") == 0); + flag = catalog_a.getFlagByName("serial_comunication"); + assert(flag->getName().compare("serial_comunication") == 0); + flag = catalog_b.getFlagByName("serial_port_state"); + assert(flag->getName().compare("serial_port_state") == 0); + + flag = catalog_a.getFlagByOrderedID(0); + assert(flag->getName().compare("powersupply_state") == 0); + flag = catalog_a.getFlagByOrderedID(1); + assert(flag->getName().compare("serial_comunication") == 0); + flag = catalog_b.getFlagByOrderedID(0); + assert(flag->getName().compare("serial_port_state") == 0); + + //cataog union test + catalog_b.appendCatalog(catalog_a); + flag = catalog_b.getFlagByOrderedID(0); + assert(flag->getName().compare("serial_port_state") == 0); + flag = catalog_b.getFlagByOrderedID(1); + assert(flag->getName().compare("powersupply_state") == 0); + flag = catalog_b.getFlagByOrderedID(2); + assert(flag->getName().compare("serial_comunication") == 0); + + flag = catalog_b.getFlagByName("serial_port_state"); + assert(flag->getName().compare("serial_port_state") == 0); + flag = catalog_b.getFlagByName("catalog_a/powersupply_state"); + assert(flag->getName().compare("powersupply_state") == 0); + flag = catalog_b.getFlagByName("catalog_a/serial_comunication"); + assert(flag->getName().compare("serial_comunication") == 0); + + //change some level + flag_powersupply_state->setCurrentLevel(3); + flag_serial_port->setCurrentLevel(1); + VectorStatusFlag found_flag_for_severity; + + catalog_a.getFlagsForSeverity(StatusFlagServerityRegular, found_flag_for_severity); + std::cout << "catalog_a StatusFlagServerityRegular"<<std::endl; + BOOST_FOREACH(boost::shared_ptr<StatusFlag> flag, found_flag_for_severity ){std::cout << flag->getName() << std::endl;} + + found_flag_for_severity.clear(); + catalog_a.getFlagsForSeverity(StatusFlagServerityWarning, found_flag_for_severity); + std::cout << "catalog_a StatusFlagServerityWarning"<<std::endl; + BOOST_FOREACH(boost::shared_ptr<StatusFlag> flag, found_flag_for_severity ){std::cout << flag->getName() << std::endl;} + + found_flag_for_severity.clear(); + catalog_a.getFlagsForSeverity(StatusFlagServerityCritical, found_flag_for_severity); + std::cout << "catalog_a StatusFlagServerityCritical"<<std::endl; + BOOST_FOREACH(boost::shared_ptr<StatusFlag> flag, found_flag_for_severity ){std::cout << flag->getName() << std::endl;} + + found_flag_for_severity.clear(); + catalog_b.getFlagsForSeverity(StatusFlagServerityRegular, found_flag_for_severity); + std::cout << "catalog_b StatusFlagServerityRegular"<<std::endl; + BOOST_FOREACH(boost::shared_ptr<StatusFlag> flag, found_flag_for_severity ){std::cout << flag->getName() << std::endl;} + + found_flag_for_severity.clear(); + catalog_b.getFlagsForSeverity(StatusFlagServerityWarning, found_flag_for_severity); + std::cout << "catalog_b StatusFlagServerityWarning"<<std::endl; + BOOST_FOREACH(boost::shared_ptr<StatusFlag> flag, found_flag_for_severity ){std::cout << flag->getName() << std::endl;} + + found_flag_for_severity.clear(); + catalog_b.getFlagsForSeverity(StatusFlagServerityCritical, found_flag_for_severity); + std::cout << "catalog_b StatusFlagServerityCritical"<<std::endl; + BOOST_FOREACH(boost::shared_ptr<StatusFlag> flag, found_flag_for_severity ){std::cout << flag->getName() << std::endl;} + + //print serialization + StatusFlagCatalogSDWrapper sfcsdw; + sfcsdw.dataWrapped() = catalog_b; + std::cout << sfcsdw.serialize()->getJSONString() << std::endl; + return true; +} + diff --git a/CHAOSFrameworkTests/TestStateFlagCatalog/TestStateFlagCatalog.h b/CHAOSFrameworkTests/TestStateFlagCatalog/TestStateFlagCatalog.h new file mode 100644 index 0000000000000000000000000000000000000000..931c31a9719022b2b6ee733ee7dafd1c7e001b7f --- /dev/null +++ b/CHAOSFrameworkTests/TestStateFlagCatalog/TestStateFlagCatalog.h @@ -0,0 +1,45 @@ +/* + * TestStateFlagCatalog.h + * + * !CHAOS [CHAOSFrameworkTests] + * Created by bisegni. + * + * Copyright 22/08/16 INFN, National Institute of Nuclear Physics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CHAOSFrameworkTests_D40485EA_AE3A_461F_818A_4272F4DC9097_TestStateFlagCatalog_h +#define __CHAOSFrameworkTests_D40485EA_AE3A_461F_818A_4272F4DC9097_TestStateFlagCatalog_h + +#include <chaos/common/status_manager/StatusFlagCatalog.h> + +namespace chaos { + namespace common { + namespace utility { + namespace test { + + class TestStateFlagCatalog { + chaos::common::status_manager::StatusFlagCatalog catalog_a; + chaos::common::status_manager::StatusFlagCatalog catalog_b; + public: + TestStateFlagCatalog(); + ~TestStateFlagCatalog(); + bool test(); + }; + } + } + } +} + +#endif /* __CHAOSFrameworkTests_D40485EA_AE3A_461F_818A_4272F4DC9097_TestStateFlagCatalog_h */ diff --git a/CHAOSFrameworkTests/TestStateFlagCatalog/main.cpp b/CHAOSFrameworkTests/TestStateFlagCatalog/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dabe7133a720ecf81c03fd57ff3eec8d55076f7f --- /dev/null +++ b/CHAOSFrameworkTests/TestStateFlagCatalog/main.cpp @@ -0,0 +1,16 @@ +// +// main.cpp +// TestStateFlagCatalog +// +// Created by bisegni on 22/08/16. +// Copyright © 2016 bisegni. All rights reserved. +// + +#include "TestStateFlagCatalog.h" + +int main(int argc, const char * argv[]) { + // insert code here... + chaos::common::utility::test::TestStateFlagCatalog test; + if(!test.test()) return 1; + return 0; +} diff --git a/CHAOSFrameworkTests/TestTemplatedKeyValueHashMap/TestTemplateKeyValueHashMap.cpp b/CHAOSFrameworkTests/TestTemplatedKeyValueHashMap/TestTemplateKeyValueHashMap.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b6533ac087b33a39e98bf67e3c70e837d5d09547 --- /dev/null +++ b/CHAOSFrameworkTests/TestTemplatedKeyValueHashMap/TestTemplateKeyValueHashMap.cpp @@ -0,0 +1,118 @@ +/* + * TestTemplateKeyValueHashMap.cpp + * + * !CHAOS [CHAOSFrameworkTests] + * Created by bisegni. + * + * Copyright 22/08/16 INFN, National Institute of Nuclear Physics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "TestTemplateKeyValueHashMap.h" + +#include <cassert> +#include <boost/lexical_cast.hpp> + +using namespace chaos::common::utility::test; + +void TestTemplateKeyValueHashMap::producer() { + for(int idx = 0; + idx < number_of_production; + idx++) { + TestTemplateKeyValueHashMapElement *element = (TestTemplateKeyValueHashMapElement *)malloc(sizeof(TestTemplateKeyValueHashMapElement)); + element->product_id = production_id++; + + std::string element_key = std::string("element_") + boost::lexical_cast<std::string>(element->product_id); + addElement(element_key.c_str(), (uint32_t)element_key.size(), element); + } +} + +void TestTemplateKeyValueHashMap::consumer() { + TestTemplateKeyValueHashMapElement *element_found = NULL; + for(int idx = 0; + idx < production_id; + idx++) { + + std::string element_key = std::string("element_") + boost::lexical_cast<std::string>(idx); + + if(getElement(element_key.c_str(), + (uint32_t)element_key.size(), + &element_found) == 0){ + //ok + assert(element_found); + assert(element_found->product_id == idx); + + //sum the product id + product_id_sum += element_found->product_id; + } + else { + error_count++; + } + } +} + +void TestTemplateKeyValueHashMap::clearHashTableElement(const void *key, + uint32_t key_len, + TestTemplateKeyValueHashMapElement *element) { + assert(element); + free(element); +} + +int TestTemplateKeyValueHashMap::sumOfNumbersUptTo(int num) { + unsigned int result = 0; + + for(int idx = 0; + idx < num; + idx++) { + result += idx; + } + return result; +} + +bool TestTemplateKeyValueHashMap::test(int _number_of_producer, + int _number_of_production, + int _number_of_consumer) { + number_of_producer = _number_of_producer; + number_of_production = _number_of_production; + number_of_consumer = _number_of_consumer; + production_id = 0; + product_id_sum = 0; + + //init the producer + for(int idx = 0; + idx < number_of_producer; + idx++) { + producer_thread_group.add_thread(new boost::thread(boost::bind(&TestTemplateKeyValueHashMap::producer, this))); + } + + //waith that all insert has been done + producer_thread_group.join_all(); + assert(production_id == (_number_of_producer * _number_of_production)); + + //init the consumer + for(int idx = 0; + idx < number_of_consumer; + idx++) { + consumer_thread_group.add_thread(new boost::thread(boost::bind(&TestTemplateKeyValueHashMap::consumer, this))); + } + + //waith that all insert has been done + consumer_thread_group.join_all(); + + assert((number_of_consumer * sumOfNumbersUptTo(_number_of_producer * _number_of_production)) == product_id_sum); + + clear(); + + return true; +} diff --git a/CHAOSFrameworkTests/TestTemplatedKeyValueHashMap/TestTemplateKeyValueHashMap.h b/CHAOSFrameworkTests/TestTemplatedKeyValueHashMap/TestTemplateKeyValueHashMap.h new file mode 100644 index 0000000000000000000000000000000000000000..32f02bf0706d8001c782b10f2507ce71e99f686e --- /dev/null +++ b/CHAOSFrameworkTests/TestTemplatedKeyValueHashMap/TestTemplateKeyValueHashMap.h @@ -0,0 +1,70 @@ +/* + * TestTemplateKeyValueHashMap.h + * + * !CHAOS [CHAOSFrameworkTests] + * Created by bisegni. + * + * Copyright 22/08/16 INFN, National Institute of Nuclear Physics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CHAOSFrameworkTests__1BE9BCC_CC46_46CD_8B1C_6C06C9FC07E0_TestTemplateKeyValueHashMap_h +#define __CHAOSFrameworkTests__1BE9BCC_CC46_46CD_8B1C_6C06C9FC07E0_TestTemplateKeyValueHashMap_h + +#include <chaos/common/utility/TemplatedKeyValueHashMap.h> + +#include <boost/atomic.hpp> +#include <boost/thread.hpp> +namespace chaos { + namespace common { + namespace utility { + namespace test { + + typedef struct TestTemplateKeyValueHashMapElement { + int product_id; + boost::atomic<int> access_count; + } TestTemplateKeyValueHashMapElement; + + class TestTemplateKeyValueHashMap: + public TemplatedKeyValueHashMap<TestTemplateKeyValueHashMapElement*> { + int number_of_producer; + int number_of_production; + int number_of_consumer; + + boost::atomic<int> production_id; + boost::atomic<int> product_id_sum; + boost::atomic<int> error_count; + boost::thread_group producer_thread_group; + boost::thread_group consumer_thread_group; + + std::vector<std::string> production_name_list; + protected: + //! template element deallocation user method (to override) + void clearHashTableElement(const void *key, + uint32_t key_len, + TestTemplateKeyValueHashMapElement *element); + public: + void producer(); + void consumer(); + int sumOfNumbersUptTo(int num); + bool test(int _number_of_producer, + int _number_of_producetion, + int _number_of_consumer); + }; + } + } + } +} + +#endif /* __CHAOSFrameworkTests__1BE9BCC_CC46_46CD_8B1C_6C06C9FC07E0_TestTemplateKeyValueHashMap_h */ diff --git a/CHAOSFrameworkTests/TestTemplatedKeyValueHashMap/main.cpp b/CHAOSFrameworkTests/TestTemplatedKeyValueHashMap/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3da4002aaa110b4b49778ed568d78fb0e2104718 --- /dev/null +++ b/CHAOSFrameworkTests/TestTemplatedKeyValueHashMap/main.cpp @@ -0,0 +1,15 @@ +// +// main.cpp +// TestTemplatedKeyValueHashMap +// +// Created by bisegni on 22/08/16. +// Copyright © 2016 bisegni. All rights reserved. +// + +#include "TestTemplateKeyValueHashMap.h" + +int main(int argc, const char * argv[]) { + chaos::common::utility::test::TestTemplateKeyValueHashMap test; + if(!test.test(10, 100, 10)) return 1; + return 0; +} diff --git a/CHAOSFrameworkTests/TestTriggerSystem/TestTrigger.cpp b/CHAOSFrameworkTests/TestTriggerSystem/TestTrigger.cpp new file mode 100644 index 0000000000000000000000000000000000000000..013536379b225447c7699eb428b004c3f56d603b --- /dev/null +++ b/CHAOSFrameworkTests/TestTriggerSystem/TestTrigger.cpp @@ -0,0 +1,174 @@ +/* + * TestTrigger.cpp + * + * !CHAOS [CHAOSFramework] + * Created by bisegni. + * + * Copyright 02/08/16 INFN, National Institute of Nuclear Physics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "TestTrigger.h" + +#include <chaos/common/property/PropertyGroup.h> + +using namespace chaos::common::data; +using namespace chaos::test::trigger_system; + +TriggeredData::TriggeredData(int _new_value): +data_value(_new_value){} +//--------------------------------- + +Subject::Subject(const TriggeredDataShrdPtr& _subject_data): +AbstractSubject("TriggeredData"), +subject_data(_subject_data){} + +//--------------------------------- +ConsumerResult SubjectConsumerIncrement::consumeEvent(TriggerDataEventType event_type, + Subject& trigger_data) { + int32_t incremnet_size = 0; + const CDataVariant& inc_value = getPropertyValue("offset"); + if(inc_value.isValid()) { + //get increment size + incremnet_size = inc_value.asInt32(); + } + trigger_data.subject_data->data_value += (1+incremnet_size); + return ConsumerResultOK; +} + +//--------------------------------- +ConsumerResult SubjectConsumerDecrement::consumeEvent(TriggerDataEventType event_type, + Subject& trigger_data) { + int32_t incremnet_size = 0; + const CDataVariant& dec_value = getPropertyValue("offset"); + if(dec_value.isValid()) { + + //get increment size + incremnet_size = dec_value.asInt32(); + } + trigger_data.subject_data->data_value -= (1+incremnet_size); + return ConsumerResultOK; +} + +//--------------------------------- +TestTrigger::TestTrigger(){ + +} + +TestTrigger::~TestTrigger(){ + +} + +bool TestTrigger::test(){ + //instantiate the trigger environment + SubjectTriggerEnviroment trigger_environment; + + //create the subjects + SubjectTriggerEnviroment::SubjectInstanceShrdPtr subject_one(boost::make_shared<Subject>(boost::make_shared<TriggeredData>(0))); + SubjectTriggerEnviroment::SubjectInstanceShrdPtr subject_two(boost::make_shared<Subject>(boost::make_shared<TriggeredData>(0))); + + trigger_environment.registerSubject(subject_one); + trigger_environment.registerSubject(subject_two); + + //attach conusmer to subject + assert(trigger_environment.addConsumerOnSubjectForEvent(kTriggerDataEventTypeOne, + subject_one, + "SubjectConsumerIncrement")); + + assert(trigger_environment.addConsumerOnSubjectForEvent(kTriggerDataEventTypeTwo, + subject_two, + "SubjectConsumerDecrement")); + + SubjectTriggerEnviroment::EventInstanceShrdPtr event_one = trigger_environment.getEventInstance(kTriggerDataEventTypeOne); + assert(event_one.get()); + SubjectTriggerEnviroment::EventInstanceShrdPtr event_two = trigger_environment.getEventInstance(kTriggerDataEventTypeTwo); + assert(event_two.get()); + + assert(subject_one->subject_data->data_value == 0); + assert(subject_two->subject_data->data_value == 0); + + trigger_environment.fireEventOnSubject(event_one, subject_one); + assert(subject_one->subject_data->data_value == 1); + assert(subject_two->subject_data->data_value == 0); + + event_one->getProperties()("offset", 10); + trigger_environment.fireEventOnSubject(event_one, subject_one); + assert(subject_one->subject_data->data_value == 12); + assert(subject_two->subject_data->data_value == 0); + + trigger_environment.fireEventOnSubject(event_two, subject_two); + assert(subject_one->subject_data->data_value == 12); + assert(subject_two->subject_data->data_value == -1); + + event_two->getProperties()("offset", 10); + trigger_environment.fireEventOnSubject(event_two, subject_two); + assert(subject_one->subject_data->data_value == 12); + assert(subject_two->subject_data->data_value == -12); + + //add xross consumer and fire event to reset the counter in the subject + assert(trigger_environment.addConsumerOnSubjectForEvent(kTriggerDataEventTypeTwo, + subject_one, + "SubjectConsumerDecrement")); + + assert(trigger_environment.addConsumerOnSubjectForEvent(kTriggerDataEventTypeOne, + subject_two, + "SubjectConsumerIncrement")); + event_two->getProperties()();//reset the values; + trigger_environment.fireEventOnSubject(event_two, subject_one); + + event_two->getProperties()("offset", 10); + trigger_environment.fireEventOnSubject(event_two, subject_one); + + event_one->getProperties()();//reset the value + trigger_environment.fireEventOnSubject(event_one, subject_two); + event_one->getProperties()("offset", 10); + trigger_environment.fireEventOnSubject(event_one, subject_two); + assert(subject_one->subject_data->data_value == 0); + assert(subject_two->subject_data->data_value == 0); + + //add consumer decrement to event one to subject one in this case counter need to remain to 0 + assert(trigger_environment.addConsumerOnSubjectForEvent(kTriggerDataEventTypeOne, + subject_one, + "SubjectConsumerDecrement")); + event_one->getProperties()(); + trigger_environment.fireEventOnSubject(event_one, subject_one); + assert(subject_one->subject_data->data_value == 0); + + event_one->getProperties()("offset", 10); + trigger_environment.fireEventOnSubject(event_one, subject_one); + assert(subject_one->subject_data->data_value == 0); + + int idx = 0; + SubjectTriggerEnviroment::VectorConsumerInstance consumer_list; + trigger_environment.getConsumerListBy(kTriggerDataEventTypeOne, subject_one, consumer_list); + for(SubjectTriggerEnviroment::VectorConsumerInstanceIterator it = consumer_list.begin(), + end = consumer_list.end(); + it != end; + it++, idx++) { + switch (idx) { + case 0: + assert((*it)->getConsumerName().compare("SubjectConsumerIncrement") == 0); + break; + case 1: + assert((*it)->getConsumerName().compare("SubjectConsumerDecrement") == 0); + break; + } + + } + //test property group + //SubjectConsumerIncrementPropertyDescription cons_desc; + //common::property::PropertyGroupSDWrapper group_ref_wrapper(CHAOS_DATA_WRAPPER_REFERENCE_AUTO_PTR(common::property::PropertyGroup, cons_desc)); + std::cout << trigger_environment.serialize()->getJSONString() << std::endl; + return true; +} diff --git a/CHAOSFrameworkTests/TestTriggerSystem/TestTrigger.h b/CHAOSFrameworkTests/TestTriggerSystem/TestTrigger.h new file mode 100644 index 0000000000000000000000000000000000000000..7f9ab1bdf341b3210054c3ef1f5fc4faa7ad1d88 --- /dev/null +++ b/CHAOSFrameworkTests/TestTriggerSystem/TestTrigger.h @@ -0,0 +1,117 @@ +/* + * TestTrigger.h + * + * !CHAOS [CHAOSFramework] + * Created by bisegni. + * + * Copyright 02/08/16 INFN, National Institute of Nuclear Physics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CHAOSFramework_F0DCD41F_00FB_479F_A2F9_DB04B820DD8F_TestTrigger_h +#define __CHAOSFramework_F0DCD41F_00FB_479F_A2F9_DB04B820DD8F_TestTrigger_h + +#include <chaos/common/trigger/trigger.h> + +using namespace chaos::common::trigger; + +namespace chaos { + namespace test { + namespace trigger_system { + //--------------------------------- + typedef enum TriggerDataEventType { + kTriggerDataEventTypeOne, + kTriggerDataEventTypeTwo + }TriggerDataEventType; + //--------------------------------- + class TriggeredData { + public: + int data_value; + TriggeredData(int _new_value); + }; + + typedef boost::shared_ptr<TriggeredData> TriggeredDataShrdPtr; + //--------------------------------- + + class Subject: + public AbstractSubject { + public: + TriggeredDataShrdPtr subject_data; + Subject(const TriggeredDataShrdPtr& _subject_data); + }; + + //--------------------------------- + //create two event + CHAOS_TRIGGER_EVENT_OPEN_DESCRIPTION(SubjectEventOne, + "Signal for int increment event", + kTriggerDataEventTypeOne, + TriggerDataEventType, + Subject) + CHAOS_TRIGGER_EVENT_ADD_PROPERTY("offset", "amount of int's added to 1", chaos::DataType::TYPE_INT32); + CHAOS_TRIGGER_EVENT_CLOSE_DESCRIPTION() + + CHAOS_TRIGGER_EVENT_OPEN_DESCRIPTION(SubjectEventTwo, + "Signal for int increment event", + kTriggerDataEventTypeTwo, + TriggerDataEventType, + Subject) + CHAOS_TRIGGER_EVENT_ADD_PROPERTY("offset", "amount of int's added to 1", chaos::DataType::TYPE_INT32); + CHAOS_TRIGGER_EVENT_CLOSE_DESCRIPTION() + + //--------------------------------- + //create two consumer + CHAOS_TRIGGER_CONSUMER_OPEN_DESCRIPTION(SubjectConsumerIncrement, + "Preform integer increment", + TriggerDataEventType, + Subject) + + CHAOS_TRIGGER_CONSUMER_ADD_PROPERTY("offset", "good property", chaos::DataType::TYPE_INT32); + CHAOS_TRIGGER_CONSUMER_CLOSE_DESCRIPTION() + + CHAOS_TRIGGER_CONSUMER_OPEN_DESCRIPTION(SubjectConsumerDecrement, + "Preform integer decrement", + TriggerDataEventType, + Subject) + CHAOS_TRIGGER_CONSUMER_ADD_PROPERTY("offset", "good property", chaos::DataType::TYPE_INT32); + CHAOS_TRIGGER_CONSUMER_CLOSE_DESCRIPTION() + + //--------------------------------- + + class SubjectTriggerEnviroment: + public TriggerExecutionEnviroment<Subject, TriggerDataEventType> { + public: + SubjectTriggerEnviroment(): + TriggerExecutionEnviroment<Subject, TriggerDataEventType>("SubjectName"){ + + registerEventClass<SubjectEventOneTriggerEventDescription>(); + registerEventClass<SubjectEventTwoTriggerEventDescription>(); + + registerConsumerClass<SubjectConsumerIncrementTriggerConsumerDescription>(); + registerConsumerClass<SubjectConsumerDecrementTriggerConsumerDescription>(); + } + ~SubjectTriggerEnviroment(){} + }; + + //--------------------------------- + class TestTrigger { + public: + TestTrigger(); + ~TestTrigger(); + bool test(); + }; + } + } +} + +#endif /* __CHAOSFramework_F0DCD41F_00FB_479F_A2F9_DB04B820DD8F_TestTrigger_h */ diff --git a/CHAOSFrameworkTests/TestTriggerSystem/main.cpp b/CHAOSFrameworkTests/TestTriggerSystem/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b85bdc43199f96201c573421e439562a596c4f93 --- /dev/null +++ b/CHAOSFrameworkTests/TestTriggerSystem/main.cpp @@ -0,0 +1,29 @@ +/* + * main.cpp + * + * !CHAOS [CHAOSFramework] + * Created by bisegni. + * + * Copyright 02/08/16 INFN, National Institute of Nuclear Physics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "TestTrigger.h" + +int main(int argc, const char * argv[]) { + // insert code here... + chaos::test::trigger_system::TestTrigger test_trigger; + if(!test_trigger.test()) return 1; + return 0; +} diff --git a/CHAOSFrameworkTests/TestURLFeeder/TestURLFeeder.cpp b/CHAOSFrameworkTests/TestURLFeeder/TestURLFeeder.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d7ebf3f5519ae4657e35c42679908d39451fe3da --- /dev/null +++ b/CHAOSFrameworkTests/TestURLFeeder/TestURLFeeder.cpp @@ -0,0 +1,226 @@ +/* + * TestURLFeeder.cpp + * + * !CHAOS [CHAOSFrameworkTests] + * Created by bisegni. + * + * Copyright 22/08/16 INFN, National Institute of Nuclear Physics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "TestURLFeeder.h" +#include <boost/date_time/posix_time/posix_time.hpp> + +#define NUMBER_OF_CYCLE 1000000 + +#define STR_ASSERT(a,b) \ +assert(std::string(a).compare(std::string(b)) == 0); + +#define PRINT_SERVICE \ +service = static_cast<chaos::test::network::ServiceForURL *>(feeder_engine.getService()); \ +if(service) \ +std::cout << service->url <<std::endl; \ +else \ +std::cout << "no service" <<std::endl; \ + +#define CHECK_SERVICE(b) \ +assert(service); \ +if(service) STR_ASSERT(service->url, b) + +#define NO_SERVICE \ +assert(service == NULL); +using namespace chaos::test::network; + +TestURLFeeder::TestURLFeeder(): +feeder_engine("feeder_test", this), +number_of_cycle(NUMBER_OF_CYCLE) { +} + +void TestURLFeeder::disposeService(void *service_ptr) { + delete ((ServiceForURL*)service_ptr); +} + +void* TestURLFeeder::serviceForURL(const common::network::URL& url, + uint32_t service_index) { + ServiceForURL *result = new ServiceForURL(); + result->url = url.getURL(); + return (void*)result; +} + +void TestURLFeeder::test_feeder_logic() { + std::cout << "----------------logic feeder test-----------" << std::endl; + feeder_engine.addURL(chaos::common::network::URL("http://test:9091"), 100); + feeder_engine.addURL(chaos::common::network::URL("http://test:9092"), 50); + feeder_engine.addURL(chaos::common::network::URL("http://test:9093"), 25); + chaos::test::network::ServiceForURL *service = NULL; + feeder_engine.setFeedMode(chaos::common::network::URLServiceFeeder::URLServiceFeedModeFailOver); + PRINT_SERVICE + CHECK_SERVICE("http://test:9091") + PRINT_SERVICE + CHECK_SERVICE("http://test:9091") + feeder_engine.setURLOffline(0); + PRINT_SERVICE + CHECK_SERVICE("http://test:9092") + PRINT_SERVICE + CHECK_SERVICE("http://test:9092") + feeder_engine.setURLOnline(0); + PRINT_SERVICE + CHECK_SERVICE("http://test:9091") + PRINT_SERVICE + CHECK_SERVICE("http://test:9091") + + feeder_engine.setFeedMode(chaos::common::network::URLServiceFeeder::URLServiceFeedModeRoundRobin); + PRINT_SERVICE + CHECK_SERVICE("http://test:9092") + PRINT_SERVICE + CHECK_SERVICE("http://test:9093") + PRINT_SERVICE + CHECK_SERVICE("http://test:9091") + + feeder_engine.setURLOffline(0); + PRINT_SERVICE + CHECK_SERVICE("http://test:9092") + PRINT_SERVICE + CHECK_SERVICE("http://test:9093") + PRINT_SERVICE + CHECK_SERVICE("http://test:9092") + + feeder_engine.setURLOnline(0); + feeder_engine.setURLOffline(1); + feeder_engine.setURLOffline(2); + PRINT_SERVICE + CHECK_SERVICE("http://test:9091") + PRINT_SERVICE + CHECK_SERVICE("http://test:9091") + + feeder_engine.setURLOffline(0); + PRINT_SERVICE + NO_SERVICE + PRINT_SERVICE + NO_SERVICE + + feeder_engine.setURLOnline(0); + feeder_engine.setURLOnline(1); + feeder_engine.setURLOnline(2); + PRINT_SERVICE + CHECK_SERVICE("http://test:9091") + PRINT_SERVICE + CHECK_SERVICE("http://test:9092") + PRINT_SERVICE + CHECK_SERVICE("http://test:9093") + PRINT_SERVICE + CHECK_SERVICE("http://test:9091") + PRINT_SERVICE + CHECK_SERVICE("http://test:9092") + PRINT_SERVICE + CHECK_SERVICE("http://test:9093") + std::cout << "----------------logic feeder test-----------" << std::endl; +} + +void TestURLFeeder::test_feeder_logic_equal_priority() { + std::cout << "----------------logic feeder test equal priority-----------" << std::endl; + + feeder_engine.addURL(chaos::common::network::URL("http://test:8000"), 50); + feeder_engine.addURL(chaos::common::network::URL("http://test:8001"), 50); + feeder_engine.addURL(chaos::common::network::URL("http://test:8002"), 50); + + feeder_engine.setURLOffline(0); + feeder_engine.setURLOffline(1); + feeder_engine.setURLOffline(2); + + chaos::test::network::ServiceForURL *service = NULL; + feeder_engine.setFeedMode(chaos::common::network::URLServiceFeeder::URLServiceFeedModeFailOver); + PRINT_SERVICE + CHECK_SERVICE("http://test:8000") + PRINT_SERVICE + CHECK_SERVICE("http://test:8000") + + feeder_engine.setFeedMode(chaos::common::network::URLServiceFeeder::URLServiceFeedModeRoundRobin); + PRINT_SERVICE + CHECK_SERVICE("http://test:8000") + PRINT_SERVICE + CHECK_SERVICE("http://test:8001") + PRINT_SERVICE + CHECK_SERVICE("http://test:8002") + + feeder_engine.setURLOffline(3); + PRINT_SERVICE + CHECK_SERVICE("http://test:8001") + PRINT_SERVICE + CHECK_SERVICE("http://test:8002") + PRINT_SERVICE + CHECK_SERVICE("http://test:8001") + + feeder_engine.setURLOnline(3); + feeder_engine.setURLOffline(4); + feeder_engine.setURLOffline(5); + PRINT_SERVICE + CHECK_SERVICE("http://test:8000") + PRINT_SERVICE + CHECK_SERVICE("http://test:8000") + + feeder_engine.setURLOffline(3); + PRINT_SERVICE + NO_SERVICE + PRINT_SERVICE + NO_SERVICE + + feeder_engine.setURLOnline(3); + feeder_engine.setURLOnline(4); + feeder_engine.setURLOnline(5); + PRINT_SERVICE + CHECK_SERVICE("http://test:8000") + PRINT_SERVICE + CHECK_SERVICE("http://test:8001") + PRINT_SERVICE + CHECK_SERVICE("http://test:8002") + PRINT_SERVICE + CHECK_SERVICE("http://test:8000") + PRINT_SERVICE + CHECK_SERVICE("http://test:8001") + PRINT_SERVICE + CHECK_SERVICE("http://test:8002") + std::cout << "----------------logic feeder test equal priority-----------" << std::endl; + + feeder_engine.setURLOnline(0); + feeder_engine.setURLOnline(1); + feeder_engine.setURLOnline(2); +} + +void TestURLFeeder::test_feeder_preformance() { + std::cout << "----------------performance feeder test-----------" << std::endl; + boost::posix_time::ptime end; + boost::posix_time::ptime start; + + start = boost::posix_time::microsec_clock::universal_time(); + for (int idx = 0; idx < number_of_cycle; idx++) { + feeder_engine.getService(); + } + end = boost::posix_time::microsec_clock::universal_time(); + uint64_t time_for_test = (end-start).total_microseconds(); + std::cout << "total time for "<< number_of_cycle << " cycle of getService() in round robin->" << time_for_test << std::endl; + std::cout << "every cycle is ->" << ((double)time_for_test/(double)number_of_cycle) << " microseconds "<<std::endl; + std::cout << "----------------performance feeder test-----------" << std::endl; + std::cout << std::endl; + +} + +void TestURLFeeder::test(uint32_t _number_of_cycle) { + if(_number_of_cycle>0)number_of_cycle = _number_of_cycle; + test_feeder_logic(); + test_feeder_preformance(); + test_feeder_logic_equal_priority(); + test_feeder_preformance(); + +} diff --git a/CHAOSFrameworkTests/TestURLFeeder/TestURLFeeder.h b/CHAOSFrameworkTests/TestURLFeeder/TestURLFeeder.h new file mode 100644 index 0000000000000000000000000000000000000000..86a6e20519d9b5a7e979e9fdc9e36d51a0aa8436 --- /dev/null +++ b/CHAOSFrameworkTests/TestURLFeeder/TestURLFeeder.h @@ -0,0 +1,57 @@ +/* + * TestURLFeeder.h + * + * !CHAOS [CHAOSFrameworkTests] + * Created by bisegni. + * + * Copyright 22/08/16 INFN, National Institute of Nuclear Physics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __CHAOSFrameworkTests__01071BC_B99C_407B_B3F0_721B6EE771A4_TestURLFeeder_h +#define __CHAOSFrameworkTests__01071BC_B99C_407B_B3F0_721B6EE771A4_TestURLFeeder_h + +#include <chaos/common/network/URLServiceFeeder.h> + +namespace chaos { + namespace test { + namespace network { + + class ServiceForURL { + public: + std::string url; + }; + + class TestURLFeeder : public common::network::URLServiceFeederHandler { + chaos::common::network::URLServiceFeeder feeder_engine; + uint32_t number_of_cycle; + protected: + + void disposeService(void *service_ptr); + void* serviceForURL(const common::network::URL& url, + uint32_t service_index); + + void test_feeder_logic(); + void test_feeder_logic_equal_priority(); + void test_feeder_preformance(); + public: + void test(uint32_t _number_of_cycle = 0); + TestURLFeeder(); + }; + + } + } +} + +#endif /* __CHAOSFrameworkTests__01071BC_B99C_407B_B3F0_721B6EE771A4_TestURLFeeder_h */ diff --git a/CHAOSFrameworkTests/TestURLFeeder/main.cpp b/CHAOSFrameworkTests/TestURLFeeder/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..91ff529f3b09e1ff66f438fe0e822560e18486d3 --- /dev/null +++ b/CHAOSFrameworkTests/TestURLFeeder/main.cpp @@ -0,0 +1,14 @@ +// +// main.cpp +// TestURLFeeder +// +// Created by bisegni on 22/08/16. +// Copyright © 2016 bisegni. All rights reserved. +// + +#include "TestURLFeeder.h" +int main(int argc, const char * argv[]) { + chaos::test::network::TestURLFeeder fd; + fd.test(100000); + return 0; +} diff --git a/CHAOSWorkspace.xcworkspace/contents.xcworkspacedata b/CHAOSWorkspace.xcworkspace/contents.xcworkspacedata index ab9b05865e62e17ac6cbb9d057e6084821bdabe8..095c478ef7ef80b7ed3444743bfddd188fc1b2fe 100644 --- a/CHAOSWorkspace.xcworkspace/contents.xcworkspacedata +++ b/CHAOSWorkspace.xcworkspace/contents.xcworkspacedata @@ -17,6 +17,9 @@ <FileRef location = "group:CHAOSFramework.xcodeproj"> </FileRef> + <FileRef + location = "group:CHAOSFrameworkTests/CHAOSFrameworkTests.xcodeproj"> + </FileRef> <FileRef location = "group:example/ChaosCLI/ChaosCLI.xcodeproj"> </FileRef> diff --git a/CMakeLists.txt b/CMakeLists.txt index 76299a262f2c9e9fb155b69843d15c71cc9584e4..a3d9f8ad3f5ff2bf444980d2c4d8820a79f496e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,8 +104,18 @@ IF (CHAOS_MEMCACHE_TEST) ENDIF() IF (CHAOS_ARCHITECTURE_TEST) - MESG("Configure ChaosArchitectureTests test excutable") - ADD_SUBDIRECTORY(test/ArchitectureTests) +#scan all subdirectory of test directory + MESG("Configure infrastructure tests") + SET(CHAOS_TEST_DIRECTORY "CHAOSFrameworkTests") + + SUBDIRLIST(TEST_SUBDIRS ${CHAOS_TEST_DIRECTORY}) + FOREACH(_TEST_DIRECTORY ${TEST_SUBDIRS}) + IF(EXISTS "${_TEST_DIRECTORY}/CMakeLists.txt") + get_filename_component(_TEST_DIR_NAME ${_TEST_DIRECTORY} NAME) + MESG("Configure ${_TEST_DIR_NAME} test") + ADD_SUBDIRECTORY(${_TEST_DIRECTORY}) + ENDIF() + ENDFOREACH() ENDIF() MESG("Done") diff --git a/chaos/common/pqueue/CObjectProcessingPriorityQueue.h b/chaos/common/pqueue/CObjectProcessingPriorityQueue.h index 92247593170686d3e0c6a8a32b8ce41338841dca..c13543b027529f54f3ce062e2c6b8ec55318dfc3 100644 --- a/chaos/common/pqueue/CObjectProcessingPriorityQueue.h +++ b/chaos/common/pqueue/CObjectProcessingPriorityQueue.h @@ -110,8 +110,8 @@ namespace chaos { template<typename T> class CObjectProcessingPriorityQueue { typedef std::priority_queue< PRIORITY_ELEMENT(T)*, - std::vector< PRIORITY_ELEMENT(T)* >, - PriorityElementCompare<T> > ChaosPriorityQueue; + std::vector< PRIORITY_ELEMENT(T)* >, + PriorityElementCompare<T> > ChaosPriorityQueue; std::string uid; ChaosPriorityQueue bufferQueue; diff --git a/chaos/common/pqueue/CObjectProcessingQueue.h b/chaos/common/pqueue/CObjectProcessingQueue.h index 2df29a018fb8b6b926b6392a50f31e7172ad62b1..3234621c5b74814cad21b50c81cd267dfc3bfe69 100644 --- a/chaos/common/pqueue/CObjectProcessingQueue.h +++ b/chaos/common/pqueue/CObjectProcessingQueue.h @@ -40,7 +40,7 @@ namespace chaos { - typedef struct { + typedef struct ElementManagingPolicy { bool elementHasBeenDetached; } ElementManagingPolicy; diff --git a/config/CMakeChaos.txt b/config/CMakeChaos.txt index 5af7994aa020ae784207caa9016afd6372fb59f4..488a051a18c6760e620c1154a3469e62b709da7c 100644 --- a/config/CMakeChaos.txt +++ b/config/CMakeChaos.txt @@ -1,4 +1,24 @@ cmake_minimum_required(VERSION 2.8) + +### MACRO +macro (MESG parm) +# get_filename_component(WHERE ${CMAKE_CURRENT_LIST_DIR} DIRECTORY) + SET(WHERE ${CMAKE_CURRENT_LIST_DIR}) + MESSAGE(STATUS "[${WHERE}] ${parm}") +endmacro() + +MACRO (SUBDIRLIST result curdir) + MESG("Find all subdirectory of ${curdir}") + SET(_ALL_SUBDIR "") + FILE(GLOB _ALL_FILES ${CHAOS_TEST_DIRECTORY}/*) + FOREACH(_FILE ${_ALL_FILES}) + IF(IS_DIRECTORY ${_FILE}) + LIST(APPEND _ALL_SUBDIR ${_FILE}) + ENDIF() + ENDFOREACH() + SET(${result} ${_ALL_SUBDIR}) +ENDMACRO() + IF(NOT TOP_DIRECTORY) SET(TOP_DIRECTORY ${CMAKE_SOURCE_DIR}) ENDIF() @@ -8,12 +28,6 @@ IF (NOT CACHE_DIR) SET(EXTERNAL_BUILD_DIR ${CMAKE_CURRENT_LIST_DIR}/../external) SET(CMAKE_FIND_LIBRARY_PREFIXES "lib") SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a") - ### MACRO - macro (MESG parm) -# get_filename_component(WHERE ${CMAKE_CURRENT_LIST_DIR} DIRECTORY) - SET(WHERE ${CMAKE_CURRENT_LIST_DIR}) - MESSAGE(STATUS "[${WHERE}] ${parm}") - endmacro() macro (CheckCompiler what name) unset(comp CACHE) @@ -48,8 +62,8 @@ IF (NOT CACHE_DIR) MESG("copy from cache ${CACHE_DIR}/${arg}") FILE(COPY ${CACHE_DIR}/${arg} DESTINATION ${EXTERNAL_BUILD_DIR}) ELSE() - execute_process( - COMMAND git clone ${arg1}/${arg}.git + execute_process( + COMMAND git clone ${arg1}/${arg}.git WORKING_DIRECTORY ${EXTERNAL_BUILD_DIR} RESULT_VARIABLE err OUTPUT_VARIABLE out @@ -58,12 +72,12 @@ IF (NOT CACHE_DIR) ERROR("cloning from ${arg1} error: ${out}") ELSE() MESG("save in cache ${EXTERNAL_BUILD_DIR}/${arg}") - FILE(COPY ${EXTERNAL_BUILD_DIR}/${arg} DESTINATION ${CACHE_DIR} ) + FILE(COPY ${EXTERNAL_BUILD_DIR}/${arg} DESTINATION ${CACHE_DIR} ) endif() ENDIF() ELSE() - execute_process( - COMMAND git clone ${arg1}/${arg}.git + execute_process( + COMMAND git clone ${arg1}/${arg}.git WORKING_DIRECTORY ${EXTERNAL_BUILD_DIR} RESULT_VARIABLE err OUTPUT_VARIABLE out @@ -81,7 +95,7 @@ IF (NOT CACHE_DIR) macro (wget what url) file(MAKE_DIRECTORY ${EXTERNAL_BUILD_DIR}/) IF(CHAOS_BUILD_CACHE) - + IF(EXISTS "${CACHE_DIR}/${what}") MESG("copy from cache ${CACHE_DIR}/${what}") FILE(COPY ${CACHE_DIR}/${what} DESTINATION ${EXTERNAL_BUILD_DIR}) @@ -91,7 +105,7 @@ IF (NOT CACHE_DIR) ENDIF() IF(NOT EXISTS "${EXTERNAL_BUILD_DIR}/${what}") MESG("wget ${url}/${what} in ${EXTERNAL_BUILD_DIR}/${what}") - execute_process( + execute_process( COMMAND wget ${url}/${what} --no-check-certificate -O ${what} WORKING_DIRECTORY ${EXTERNAL_BUILD_DIR} RESULT_VARIABLE err @@ -111,7 +125,7 @@ IF (NOT CACHE_DIR) macro (tar opt what) MESG("tar ${opt} ${what}") - execute_process( + execute_process( COMMAND tar ${opt} ${what} WORKING_DIRECTORY ${EXTERNAL_BUILD_DIR} RESULT_VARIABLE err @@ -191,7 +205,7 @@ IF (NOT CACHE_DIR) endmacro() macro (GitCheckout arg arg1) MESG("Checkout branch ${arg1}") - execute_process( + execute_process( COMMAND git checkout ${arg1} WORKING_DIRECTORY ${EXTERNAL_BUILD_DIR}/${arg} RESULT_VARIABLE err @@ -205,18 +219,18 @@ IF (NOT CACHE_DIR) unset(SKIPBUILD CACHE) IF (EXISTS "${EXTERNAL_BUILD_DIR}/${arg}/autogen.sh") MESG("[${arg}] generation of configuration") - execute_process( + execute_process( COMMAND ./autogen.sh WORKING_DIRECTORY ${EXTERNAL_BUILD_DIR}/${arg} RESULT_VARIABLE err OUTPUT_VARIABLE mod ) - + IF( err) ERROR("[${arg}] performing generation of configuration: ${err}") ENDIF() ENDIF() - + IF (EXISTS "${EXTERNAL_BUILD_DIR}/${arg}/configure") MESG("[${arg}] CONFIGURE tool") SET(CONFPARM ./configure CXXFLAGS=${CHAOS_CXX_FLAGS} CFLAGS=${CHAOS_C_FLAGS} CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} LDFLAGS=${CHAOS_LINKER_FLAGS} --prefix=${CMAKE_INSTALL_PREFIX} ${arg1} ${CROSS_HOST}) @@ -229,10 +243,10 @@ IF (NOT CACHE_DIR) RESULT_VARIABLE err OUTPUT_VARIABLE out ) - IF (err) + IF (err) ERROR("[${arg}] cleaning b2: ${out}") ENDIF() - + SET(CONFPARM "./b2;${arg1}") SET(SKIPBUILD ON) @@ -240,7 +254,7 @@ IF (NOT CACHE_DIR) IF (EXISTS "${EXTERNAL_BUILD_DIR}/${arg}/CMakeLists.txt") MESG("[${arg}] CMAKE configuration tool") SET(CONFPARM cmake ${arg1} ${CMAKE_CHAOS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_CXX_FLAGS=${CHAOS_CXX_FLAGS} -DCMAKE_C_FLAGS=${CHAOS_C_FLAGS} -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_EXE_LINKER_FLAGS=${CHAOS_LINKER_FLAGS} .) - + ELSE() IF(EXISTS "${EXTERNAL_BUILD_DIR}/${arg}/SConstruct") MESG("[${arg}] SCONS configuration tool") @@ -254,25 +268,25 @@ IF (NOT CACHE_DIR) ENDIF() ENDIF() ENDIF() - + MESG("[${arg}] configuring with \"${CONFPARM}\"") # separate_arguments(CONFPARM) # MESG("configuring separated with \"${CONFPARM}\"") - - execute_process( + + execute_process( COMMAND ${CONFPARM} WORKING_DIRECTORY ${EXTERNAL_BUILD_DIR}/${arg} RESULT_VARIABLE err OUTPUT_VARIABLE out ) - + if( err) ERROR("[${arg}] configuring ${arg} :${out}") endif() - + IF(NOT SKIPBUILD) message(STATUS "[${arg}] compiling (${PROCESSOR_COUNT})") - execute_process( + execute_process( COMMAND make install -j ${PROCESSOR_COUNT} WORKING_DIRECTORY ${EXTERNAL_BUILD_DIR}/${arg} RESULT_VARIABLE err2 @@ -283,10 +297,10 @@ IF (NOT CACHE_DIR) endif() ELSE() message(STATUS "[${arg}] compilation skipped...") - SET(SKIPBUILD OFF) - unset(SKIPBUILD CACHE) + SET(SKIPBUILD OFF) + unset(SKIPBUILD CACHE) ENDIF() - + endmacro() @@ -298,7 +312,7 @@ IF (NOT CACHE_DIR) tar(xf boost_1_${ver}_0.tar.gz) execute_process( - COMMAND ./bootstrap.sh + COMMAND ./bootstrap.sh WORKING_DIRECTORY ${EXTERNAL_BUILD_DIR}/boost_1_${ver}_0 RESULT_VARIABLE err OUTPUT_VARIABLE out @@ -328,7 +342,7 @@ IF (NOT CACHE_DIR) STRING(REPLACE ":" ";" GITLIST ${lib}) list(GET GITLIST 0 GITNAME) list(LENGTH GITLIST len) - if(len EQUAL 2) + if(len EQUAL 2) list(GET GITLIST 1 GITVER) ELSE() unset(GITVER) @@ -392,10 +406,10 @@ IF (NOT CACHE_DIR) EXECUTE_PROCESS(COMMAND uname -m OUTPUT_VARIABLE CHAOS_SYSTEM_MACHINE) STRING(REPLACE "\n" "" CHAOS_SYSTEM_NAME ${CHAOS_SYSTEM_NAME}) STRING(REPLACE "\n" "" CHAOS_SYSTEM_MACHINE ${CHAOS_SYSTEM_MACHINE}) - + SET(SYSTEM_NAME ${CHAOS_SYSTEM_NAME}) SET(CMAKE_SYSTEM_NAME ${CHAOS_SYSTEM_NAME}) - + IF (DEFINED ENV{CHAOS_TARGET} AND NOT CHAOS_TARGET) SET(CHAOS_TARGET $ENV{CHAOS_TARGET}) ENDIF() @@ -433,28 +447,28 @@ IF (NOT CACHE_DIR) MESG("Overriding default CHAOS_PREFIX to ${CMAKE_INSTALL_PREFIX}") ELSE() MESG("Default prefix ${CMAKE_INSTALL_PREFIX}") - + ENDIF() ENDIF() - + IF (CHAOS_TARGET) - IF(${CHAOS_TARGET} MATCHES "armhf") + IF(${CHAOS_TARGET} MATCHES "armhf") MESG("checking armhf cross compilation chain....") CheckCompiler("CXX" arm-linux-gnueabihf-g++-4.8) CheckCompiler("C" arm-linux-gnueabihf-gcc-4.8) SET(CMAKE_SYSTEM_NAME "Linux") SET(CMAKE_SYSTEM_PROCESSOR "arm") - # SET(CMAKE_FIND_ROOT_PATH /usr/arm-linux-gnueabihf/) + # SET(CMAKE_FIND_ROOT_PATH /usr/arm-linux-gnueabihf/) SET(COMP_FLAGS "-D__BSON_USEMEMCPY__ -mcpu=xscale -D__BSON_USEM") SET(CHAOS_CROSS_HOST arm-linux-gnueabihf) ELSE() - IF(${CHAOS_TARGET} MATCHES "arm-linux-2.6") + IF(${CHAOS_TARGET} MATCHES "arm-linux-2.6") MESG("Cross compiling for ARM(soft float) platforms on linux 2.6") CheckCompiler("CXX" arm-infn-linux-gnueabi-g++) CheckCompiler("C" arm-infn-linux-gnueabi-gcc) @@ -462,20 +476,20 @@ IF (NOT CACHE_DIR) SET(CMAKE_C_COMPILER arm-infn-linux-gnueabi-gcc) SET(CHAOS_CROSS_HOST arm-infn-linux-gnueabi) - SET(CHAOS_CXX_FLAGS "${CHAOS_CXX_FLAGS} -DBOOST_ASIO_DISABLE_EVENTFD -D__BSON_USEMEMCPY__ -mcpu=xscale -D__BSON_USEMEMCPY__ -DBOOST_ASIO_DISABLE_EVENTFD -mno-unaligned-access -DDISABLE_COMPARE_AND_SWAP -mfloat-abi=soft") + SET(CHAOS_CXX_FLAGS "${CHAOS_CXX_FLAGS} -DBOOST_ASIO_DISABLE_EVENTFD -D__BSON_USEMEMCPY__ -mcpu=xscale -D__BSON_USEMEMCPY__ -DBOOST_ASIO_DISABLE_EVENTFD -mno-unaligned-access -DDISABLE_COMPARE_AND_SWAP -mfloat-abi=soft") SET(CHAOS_BOOST_FLAGS toolset=gcc-arm target-os=linux compiler=) SET(CHAOS_DISABLE_EVENTFD ON) ELSE() - IF(${CHAOS_TARGET} MATCHES "i686-linux26") + IF(${CHAOS_TARGET} MATCHES "i686-linux26") MESG("Cross compiling for i686 platforms on linux 2.6") CheckCompiler("CXX" i686-nptl-linux-gnu-g++) CheckCompiler("C" i686-nptl-linux-gnu-gcc) SET(CHAOS_CROSS_HOST i686-nptl-linux-gnu) - SET(CHAOS_CXX_FLAGS "${CHAOS_CXX_FLAGS} -DBOOST_ASIO_DISABLE_EVENTFD") + SET(CHAOS_CXX_FLAGS "${CHAOS_CXX_FLAGS} -DBOOST_ASIO_DISABLE_EVENTFD") SET(CHAOS_BOOST_FLAGS target-os=linux) SET(CHAOS_DISABLE_EVENTFD ON) ELSE() - IF(${CHAOS_TARGET} MATCHES "crio90xx") + IF(${CHAOS_TARGET} MATCHES "crio90xx") MESG("Cross compiling for crio90xx") CheckCompiler("CXX" arm-nilrt-linux-gnueabi-g++) CheckCompiler("C" arm-nilrt-linux-gnueabi-gcc) @@ -483,7 +497,7 @@ IF (NOT CACHE_DIR) SET(CHAOS_DISABLE_EVENTFD ON) SET(CHAOS_LINKER_FLAGS "${CHAOS_LINKER_FLAGS} -L/usr/local/chaos/oecore-x86_64/sysroots/armv7a-vfp-neon-nilrt-linux-gnueabi/lib") SET(CHAOS_CROSS_HOST arm-nilrt-linux-gnueabi) - SET(CHAOS_CXX_FLAGS "${CHAOS_CXX_FLAGS} -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mno-unaligned-access --sysroot=/usr/local/chaos/oecore-x86_64/sysroots/armv7a-vfp-neon-nilrt-linux-gnueabi -L/usr/local/chaos/oecore-x86_64/sysroots/armv7a-vfp-neon-nilrt-linux-gnueabi/lib -DBOOST_ASIO_DISABLE_EVENTFD") + SET(CHAOS_CXX_FLAGS "${CHAOS_CXX_FLAGS} -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mno-unaligned-access --sysroot=/usr/local/chaos/oecore-x86_64/sysroots/armv7a-vfp-neon-nilrt-linux-gnueabi -L/usr/local/chaos/oecore-x86_64/sysroots/armv7a-vfp-neon-nilrt-linux-gnueabi/lib -DBOOST_ASIO_DISABLE_EVENTFD") SET(CHAOS_BOOST_FLAGS target-os=linux) ELSE() ERROR("UNSUPPORTED CHAOS_TARGET ${CHAOS_TARGET}") @@ -561,7 +575,7 @@ IF (NOT CACHE_DIR) ADD_DEFINITIONS(-O2) - if (CHAOS_DEBUG) + if (CHAOS_DEBUG) add_definitions(-DDEBUG -g) SET(CMAKE_BUILD_TYPE Debug) ENDIF() @@ -610,12 +624,12 @@ IF (NOT CACHE_DIR) FILE(RELATIVE_PATH PROJECT_OUT_H ${TOP_DIRECTORY} "${CMAKE_CURRENT_LIST_DIR}/${dd}") # string (REGEX MATCH "[a-zA-Z_\\.]+/[a-zA-Z_\\.]+$" PROJECT_OUT_H ${CMAKE_CURRENT_LIST_DIR}) # get_filename_component(BASE ${CMAKE_CURRENT_LIST_DIR} NAME) - + FILE(GLOB core_src ${CMAKE_CURRENT_LIST_DIR}/${dd}/*.h) MESG("installing headers ${CMAKE_CURRENT_LIST_DIR}/${dd} in include/${PROJECT_OUT_H}/") INSTALL(FILES ${core_src} DESTINATION include/${PROJECT_OUT_H}) if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/conf") - MESG("copying ${PROJECT_NAME} configuration files") + MESG("copying ${PROJECT_NAME} configuration files") FILE(GLOB core_src ${CMAKE_CURRENT_LIST_DIR}/conf/*) INSTALL(FILES ${core_src} DESTINATION etc/${PROJECT_NAME}/) ENDIF() @@ -655,7 +669,7 @@ IF (NOT CACHE_DIR) find_library(LIB_NEED NAMES boost_program_options boost_regex boost_date_time boost_system boost_chrono boost_log_setup boost_log boost_filesystem boost_thread boost_atomic PATHS ${CMAKE_INSTALL_PREFIX}/lib NO_DEFAULT_PATH) if(LIB_NEED) MESG("BOOST found !!") - # include_directories(${Boost_INCLUDE_DIRS}) + # include_directories(${Boost_INCLUDE_DIRS}) else() MESG("boost not found in ${CMAKE_INSTALL_PREFIX}/lib downloading...") boostInstall(${BOOST_VERSION} http://download.sourceforge.net/project/boost/boost/1.${BOOST_VERSION}.0 "${CHAOS_BOOST_FLAGS}") diff --git a/test/ArchitectureTests/thread/ObjectPriorityQueueTest.cpp b/test/ArchitectureTests/thread/ObjectPriorityQueueTest.cpp index 813bf17602dff6ad024681bb004c800f3d9727d7..cf430ecce7d3c465ebe31c1d10928dce6ce65041 100644 --- a/test/ArchitectureTests/thread/ObjectPriorityQueueTest.cpp +++ b/test/ArchitectureTests/thread/ObjectPriorityQueueTest.cpp @@ -33,7 +33,42 @@ number_of_production(0) { ObjectPriorityQueueTest::~ObjectPriorityQueueTest() { } -bool ObjectPriorityQueueTest::test(int _number_of_producer, +bool ObjectPriorityQueueTest::testPriority(int _max_priority, + int _number_of_production) { + std::srand(std::time(0)); + std::cout << "Generate "<< _number_of_production <<" number of iteration of sequences of data with rando priority of max value "<<_max_priority<<"--------------------------" << std::endl; + for(int idx = 0; idx < _number_of_production; idx++) { + command_submitted_queue.push(new PriorityQueuedElement<TestElement>(new TestElement(chaos::common::utility::UUIDUtil::generateUUID()), idx, std::rand()%_max_priority+1, true)); + } + uint64_t last_sequence = 0; + int last_priority = 100; + std::cout << "Checking ------------------------------------------------------------------------" << _max_priority << std::endl; + while (command_submitted_queue.size()) { + current_element = command_submitted_queue.top(); + command_submitted_queue.pop(); + if(last_priority != current_element->priority) { + if(last_priority<current_element->priority) { + std::cerr << "Bad priority sequence"<< std::endl; + return false; + } + last_priority = current_element->priority; + last_sequence = 0; + } + if(last_sequence != current_element->sequence_id) { + if(last_sequence>current_element->sequence_id) { + std::cerr << "Bad sequence order"<< std::endl; + return false; + } + last_sequence = current_element->sequence_id; + } + std::cout << current_element->element->element_value << "[P:" << current_element->priority << " seq:"<< current_element->sequence_id << "]" << std::endl; + delete(current_element); + } + std::cout << "No error during Checking ------------------------------------------------------------------------" << _max_priority << std::endl; + return true; +} + +bool ObjectPriorityQueueTest::testConcurency(int _number_of_producer, int _number_of_production, int _number_of_consumer, unsigned int _sec_to_whait, @@ -86,4 +121,4 @@ void ObjectPriorityQueueTest::producer() { job_to_do++; push(job, (job->priority = priority_counter++)); } -} \ No newline at end of file +} diff --git a/test/ArchitectureTests/thread/ObjectPriorityQueueTest.h b/test/ArchitectureTests/thread/ObjectPriorityQueueTest.h index a4a5fc5c48e8a8f5d8658eedc6c55b7e1660af44..c63101140d99fd8d3de7542ae55f22cd9949894e 100644 --- a/test/ArchitectureTests/thread/ObjectPriorityQueueTest.h +++ b/test/ArchitectureTests/thread/ObjectPriorityQueueTest.h @@ -52,11 +52,13 @@ namespace chaos { public: ObjectPriorityQueueTest(); virtual ~ObjectPriorityQueueTest(); - bool test(int _number_of_producer, - int _number_of_production, - int _number_of_consumer, - unsigned int _sec_to_whait = 0, + bool testConcurency(int _number_of_producer, + int _number_of_production, + int _number_of_consumer, + unsigned int _sec_to_whait = 0, bool _whait_to_finish = true); + bool testPriority(int _max_priority, + int _number_of_production); }; } }