Repository: geode-native Updated Branches: refs/heads/develop 67c6ee2c2 -> 1658a120a
GEODE-2741: Removes obsolete NativeWrapper tests. Project: http://git-wip-us.apache.org/repos/asf/geode-native/repo Commit: http://git-wip-us.apache.org/repos/asf/geode-native/commit/1658a120 Tree: http://git-wip-us.apache.org/repos/asf/geode-native/tree/1658a120 Diff: http://git-wip-us.apache.org/repos/asf/geode-native/diff/1658a120 Branch: refs/heads/develop Commit: 1658a120a3a38487034d63e89ccbe44538300e7f Parents: 67c6ee2 Author: Jacob Barrett <[email protected]> Authored: Sun May 21 22:48:46 2017 +0000 Committer: Jacob Barrett <[email protected]> Committed: Sun May 21 22:50:35 2017 +0000 ---------------------------------------------------------------------- src/cppcache/integration-test/CMakeLists.txt | 1 - .../integration-test/testNativeCompareBasic.cpp | 66 ------- src/tests/cli/CMakeLists.txt | 1 - src/tests/cli/NativeWrapper/AssemblyInfo.cpp | 54 ------ src/tests/cli/NativeWrapper/CMakeLists.txt | 39 ---- src/tests/cli/NativeWrapper/ManagedWrapper.cpp | 67 ------- src/tests/cli/NativeWrapper/ManagedWrapper.hpp | 181 ------------------- src/tests/cli/NativeWrapper/NativeType.cpp | 77 -------- src/tests/cli/NativeWrapper/NativeType.hpp | 38 ---- 9 files changed, 524 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode-native/blob/1658a120/src/cppcache/integration-test/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/CMakeLists.txt b/src/cppcache/integration-test/CMakeLists.txt index ff49485..6a6f3e7 100644 --- a/src/cppcache/integration-test/CMakeLists.txt +++ b/src/cppcache/integration-test/CMakeLists.txt @@ -125,7 +125,6 @@ set_property(TEST testRegionMap PROPERTY LABELS STABLE QUICK) set_property(TEST testXmlCacheCreationWithRefid PROPERTY LABELS STABLE QUICK) set_property(TEST testAttributesFactory PROPERTY LABELS STABLE QUICK) set_property(TEST testXmlCacheCreationWithOverFlow PROPERTY LABELS STABLE QUICK) -set_property(TEST testNativeCompareBasic PROPERTY LABELS STABLE QUICK) set_property(TEST testConnect PROPERTY LABELS STABLE QUICK) set_property(TEST testThinClientRemoveAllLocal PROPERTY LABELS STABLE QUICK) set_property(TEST testDunit PROPERTY LABELS STABLE QUICK) http://git-wip-us.apache.org/repos/asf/geode-native/blob/1658a120/src/cppcache/integration-test/testNativeCompareBasic.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/integration-test/testNativeCompareBasic.cpp b/src/cppcache/integration-test/testNativeCompareBasic.cpp deleted file mode 100644 index 5b5b582..0000000 --- a/src/cppcache/integration-test/testNativeCompareBasic.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -#define ROOT_NAME "testNativeCompareBasic" - -#include "fw_helper.hpp" -#include "../../tests/cli/NativeWrapper/NativeType.cpp" - -#define WARMUP_ITERS 1000000 -#define TIMED_ITERS 50000000 -#define TIMED_OBJSIZE 10 - -BEGIN_TEST(NATIVE_OPS_PERF) - { - NativeType obj; - - // warmup task - bool res = true; - for (int i = 1; i <= WARMUP_ITERS; ++i) { - res &= obj.doOp(TIMED_OBJSIZE, 0, 0); - } - ASSERT(res, "Expected the object to be alive"); - -// timed task - -#ifdef _WIN32 - LARGE_INTEGER freq, start, end; - QueryPerformanceFrequency(&freq); - QueryPerformanceCounter(&start); -#else - ACE_Time_Value start, end; - start = ACE_OS::gettimeofday(); -#endif //_WIN32 - - for (int i = 1; i <= TIMED_ITERS; ++i) { - res &= obj.doOp(TIMED_OBJSIZE, 0, 0); - } - -#ifdef _WIN32 - QueryPerformanceCounter(&end); - double time = (double)(end.LowPart - start.LowPart) / (double)freq.LowPart; - printf("Performance counter in native test with result %d is: %lf\n", res, - time); -#else - end = ACE_OS::gettimeofday(); - end -= start; - printf("Time taken in native test with result %d is: %lu.%06lusecs\n", res, - end.sec(), static_cast<unsigned long>(end.usec())); -#endif //_WIN32 - ASSERT(res, "Expected the object to be alive"); - } -END_TEST(NATIVE_OPS_PERF) http://git-wip-us.apache.org/repos/asf/geode-native/blob/1658a120/src/tests/cli/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/src/tests/cli/CMakeLists.txt b/src/tests/cli/CMakeLists.txt index 5ae1cb3..a7cb225 100644 --- a/src/tests/cli/CMakeLists.txt +++ b/src/tests/cli/CMakeLists.txt @@ -15,7 +15,6 @@ cmake_minimum_required(VERSION 3.4) project(nativeclient.tests) -add_subdirectory(NativeWrapper) add_subdirectory(PkcsWrapper) add_subdirectory(QueryHelper) http://git-wip-us.apache.org/repos/asf/geode-native/blob/1658a120/src/tests/cli/NativeWrapper/AssemblyInfo.cpp ---------------------------------------------------------------------- diff --git a/src/tests/cli/NativeWrapper/AssemblyInfo.cpp b/src/tests/cli/NativeWrapper/AssemblyInfo.cpp deleted file mode 100644 index 564966e..0000000 --- a/src/tests/cli/NativeWrapper/AssemblyInfo.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -using namespace System; -using namespace System::Reflection; -using namespace System::Runtime::CompilerServices; -using namespace System::Runtime::InteropServices; -using namespace System::Security::Permissions; - -// -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -// -[assembly:AssemblyTitleAttribute("NativeWrapper")]; -[assembly:AssemblyDescriptionAttribute("")]; -[assembly:AssemblyConfigurationAttribute("")]; -[assembly:AssemblyProductAttribute("NativeWrapper")]; -[assembly:AssemblyCopyrightAttribute("Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership.")] -[assembly:AssemblyTrademarkAttribute("")]; -[assembly:AssemblyCultureAttribute("")]; - -// -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the value or you can default the Revision and Build Numbers -// by using the '*' as shown below: - -[assembly:AssemblyVersionAttribute("1.0.0.0")]; - -[assembly:ComVisible(false)]; - -[assembly:CLSCompliantAttribute(true)]; - -[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)]; http://git-wip-us.apache.org/repos/asf/geode-native/blob/1658a120/src/tests/cli/NativeWrapper/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/src/tests/cli/NativeWrapper/CMakeLists.txt b/src/tests/cli/NativeWrapper/CMakeLists.txt deleted file mode 100644 index 833e9c6..0000000 --- a/src/tests/cli/NativeWrapper/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -cmake_minimum_required(VERSION 3.4) -project(NativeWrapper) - -file(GLOB_RECURSE SOURCES "*.cpp") - -add_library(NativeWrapper SHARED ${SOURCES}) - -target_link_libraries(NativeWrapper - PUBLIC - Apache.Geode - c++11 -) - -add_dependencies(NativeWrapper Apache.Geode) - -include_directories(${CMAKE_SOURCE_DIR}/clicache/src) -set_target_properties(NativeWrapper PROPERTIES FOLDER test/cliTests) - -set( DOT_NET_FRAMEWORK "C:/Program Files (x86)/Reference Assemblies/Microsoft/Framework/.NETFramework/v4.0") -set( ASM_PATH ${ASM_PATH} "/FU ${DOT_NET_FRAMEWORK}/System.dll") -set( ASM_PATH ${ASM_PATH} "/FU ${DOT_NET_FRAMEWORK}/System.Xml.dll") -target_compile_options(NativeWrapper PRIVATE ${ASM_PATH}) -string(REPLACE "/EHsc" "/EHa" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") -string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /clr /wd4947") http://git-wip-us.apache.org/repos/asf/geode-native/blob/1658a120/src/tests/cli/NativeWrapper/ManagedWrapper.cpp ---------------------------------------------------------------------- diff --git a/src/tests/cli/NativeWrapper/ManagedWrapper.cpp b/src/tests/cli/NativeWrapper/ManagedWrapper.cpp deleted file mode 100644 index b16c776..0000000 --- a/src/tests/cli/NativeWrapper/ManagedWrapper.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 "ManagedWrapper.hpp" - -using namespace Apache::Geode::Client; -using namespace Apache::Geode::Client::Tests; - -ManagedWrapper::ManagedWrapper(int len) : m_nativePtr(new NativeType()) -{ - m_str = gcnew System::String('A', len); -} - -ManagedWrapper::~ManagedWrapper() -{ - Apache::Geode::Client::Log::Info("Invoked Dispose of ManagedWrapper"); - InternalCleanup(); -} - -ManagedWrapper::!ManagedWrapper() -{ - Apache::Geode::Client::Log::Info("Invoked Finalizer of ManagedWrapper"); - InternalCleanup(); -} - -void ManagedWrapper::InternalCleanup() -{ - delete m_nativePtr; - m_nativePtr = nullptr; -} - -bool ManagedWrapper::UnsafeDoOp(int size, int numOps) -{ - Apache::Geode::Client::Log::Info("Managed string length: {0}", m_str->Length); - return UnsafeNativePtr->doOp(size, numOps, (numOps / 5) + 1); -} - -bool ManagedWrapper::SafeDoOp1(int size, int numOps) -{ - return SafeNativePtr1->doOp(size, numOps, (numOps / 5) + 1); -} - -bool ManagedWrapper::SafeDoOp2(int size, int numOps) -{ - bool res = UnsafeNativePtr->doOp(size, numOps, (numOps / 5) + 1); - GC::KeepAlive(this); - return res; -} - -bool ManagedWrapper::SafeDoOp3(int size, int numOps) -{ - return SafeNativePtr2->doOp(size, numOps, (numOps / 5) + 1); -} http://git-wip-us.apache.org/repos/asf/geode-native/blob/1658a120/src/tests/cli/NativeWrapper/ManagedWrapper.hpp ---------------------------------------------------------------------- diff --git a/src/tests/cli/NativeWrapper/ManagedWrapper.hpp b/src/tests/cli/NativeWrapper/ManagedWrapper.hpp deleted file mode 100644 index 97b5a70..0000000 --- a/src/tests/cli/NativeWrapper/ManagedWrapper.hpp +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - */ - -#pragma once - -#include "NativeType.hpp" -#include "impl/NativeWrapper.hpp" -#include <vcclr.h> - -using namespace System; - -namespace Apache -{ - namespace Geode - { - namespace Client - { -namespace Internal - { - - /// <summary> - /// Internal class used to keep a reference of the managed object - /// alive while a method on the native object is in progress - /// (one possible fix for bug #309) - /// </summary> - template <typename TNative, typename TManaged> - class NativePtrWrap - { - public: - inline NativePtrWrap(TNative* nativePtr, TManaged^ mgObj) : - m_nativePtr(nativePtr), m_mgObj(mgObj) { } - inline TNative* operator->() - { - return m_nativePtr; - } - inline TNative* operator()() - { - return m_nativePtr; - } - - private: - TNative* m_nativePtr; - gcroot<TManaged^> m_mgObj; - }; - } - - namespace Tests - { - /// <summary> - /// This class tests GC for managed wrapped objects when - /// a method on the native object is still in progress. - /// </summary> - public ref class ManagedWrapper - { - public: - /// <summary> - /// constructor with given length of (dummy) string - /// </summary> - ManagedWrapper(int len); - /// <summary> - /// destructor (.NET's IDisposable.Dispose method) - /// </summary> - ~ManagedWrapper(); - /// <summary> - /// finalizer - /// </summary> - !ManagedWrapper(); - - /// <summary> - /// Invokes NativeType::doOp method in an unsafe manner i.e. - /// without making sure that the managed wrapper can be GCed - /// while the NativeType::doOp is in progress. - /// </summary> - bool UnsafeDoOp(int size, int numOps); - - /// <summary> - /// Invokes NativeType::doOp method in an safe manner i.e. - /// making sure that the managed wrapper will not be GCed - /// while the NativeType::doOp is in progress. - /// This implementation uses native temporary wrapper. - /// </summary> - bool SafeDoOp1(int size, int numOps); - - /// <summary> - /// Invokes NativeType::doOp method in an safe manner i.e. - /// making sure that the managed wrapper will not be GCed - /// while the NativeType::doOp is in progress. - /// This implementation uses managed value type temporary wrapper. - /// </summary> - bool SafeDoOp2(int size, int numOps); - - /// <summary> - /// Invokes NativeType::doOp method in an safe manner i.e. - /// making sure that the managed wrapper will not be GCed - /// while the NativeType::doOp is in progress. - /// This implementation uses GC::KeepAlive. - /// </summary> - bool SafeDoOp3(int size, int numOps); - - private: - /// <summary> - /// Get the native pointer in an unsafe manner i.e. such that the - /// managed object can be GCed while a method on the native object - /// is still in progress. - /// </summary> - property NativeType* UnsafeNativePtr - { - inline NativeType* get() - { - return m_nativePtr; - } - } - - /// <summary> - /// Get the native pointer in a safe manner i.e. such that the - /// managed object cannot be GCed while a method on the native - /// object is in progress since the temporary <c>NativePtrWrap</c> - /// object holds a reference to the managed object. - /// </summary> - property Internal::NativePtrWrap<NativeType, ManagedWrapper> - SafeNativePtr1 - { - inline Internal::NativePtrWrap<NativeType, ManagedWrapper> get() - { - return Internal::NativePtrWrap<NativeType, ManagedWrapper>( - m_nativePtr, this); - } - } - - /// <summary> - /// Get the native pointer in a safe manner i.e. such that the - /// managed object cannot be GCed while a method on the native - /// object is in progress since the temporary <c>ManagedPtrWrap</c> - /// object holds a reference to the managed object. - /// </summary> - property Apache::Geode::Client::Internal::ManagedPtrWrap<NativeType, ManagedWrapper> - SafeNativePtr2 - { - inline Apache::Geode::Client::Internal::ManagedPtrWrap<NativeType, ManagedWrapper> get() - { - return Apache::Geode::Client::Internal::ManagedPtrWrap<NativeType, ManagedWrapper>( - m_nativePtr, this); - } - } - - /// <summary> - /// pointer to native object - /// </summary> - NativeType* m_nativePtr; - /// <summary> - /// Dummy string to make GC believe that this managed object - /// has a large size and is worth GCing. - /// </summary> - System::String^ m_str; - - /// <summary> - /// Internal cleanup method invoked by both the destructor - /// and finalizer. - /// </summary> - void InternalCleanup(); - }; - - } - } - } -} - http://git-wip-us.apache.org/repos/asf/geode-native/blob/1658a120/src/tests/cli/NativeWrapper/NativeType.cpp ---------------------------------------------------------------------- diff --git a/src/tests/cli/NativeWrapper/NativeType.cpp b/src/tests/cli/NativeWrapper/NativeType.cpp deleted file mode 100644 index 1b986e9..0000000 --- a/src/tests/cli/NativeWrapper/NativeType.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 "NativeType.hpp" - -#include <vector> -#include <string> - -namespace -{ - volatile bool g_nativeTypeDestroyed = false; -} // namespace - -NativeType::NativeType() -{ - g_nativeTypeDestroyed = false; -} - -NativeType::~NativeType() -{ -#ifdef _MANAGED - Apache::Geode::Client::Log::Info("Invoked destructor of NativeType"); -#endif - g_nativeTypeDestroyed = true; -} - -bool NativeType::doOp(int size, int numOps, int numGCOps) -{ - if (numOps == 0) { // special case for performance testing - std::string s(size, 'A'); - return (!g_nativeTypeDestroyed && s.size() > 0); - } - if (numGCOps == 0) { - numGCOps = 1; - } - int sum = 0; - std::vector<std::string> vec; - for (int i = 1; i <= numOps; ++i) { -#ifdef _MANAGED - Apache::Geode::Client::Log::Info("Allocating string number {0} with " - "size {1}", i, size); -#endif - std::string s(size, 'A' + i); - sum += static_cast<int> (s.size()); - vec.push_back(s); -#ifdef _MANAGED - System::GC::AddMemoryPressure(size); - if ((i % numGCOps) == 0) { - Apache::Geode::Client::Log::Info("Started GC collection."); - System::GC::Collect(); - System::GC::WaitForPendingFinalizers(); - Apache::Geode::Client::Log::Info("Completed GC collection."); - } - System::Threading::Thread::Sleep(500); -#else - SLEEP(500); -#endif - } -#ifdef _MANAGED - System::GC::RemoveMemoryPressure(sum); -#endif - return !g_nativeTypeDestroyed; -} http://git-wip-us.apache.org/repos/asf/geode-native/blob/1658a120/src/tests/cli/NativeWrapper/NativeType.hpp ---------------------------------------------------------------------- diff --git a/src/tests/cli/NativeWrapper/NativeType.hpp b/src/tests/cli/NativeWrapper/NativeType.hpp deleted file mode 100644 index 03f3b06..0000000 --- a/src/tests/cli/NativeWrapper/NativeType.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 _GF_NATIVETYPE_HPP -#define _GF_NATIVETYPE_HPP - -/** -* This class is to test GC invocation for managed wrapper objects -* when a method on the underlying native object is still in progress. -* See bug #309 for detailed scenario. -*/ -class NativeType -{ -public: - /** default constructor */ - NativeType(); - /** destructor */ - ~NativeType(); - /** test method that allocated large amounts of memory in steps */ - bool doOp(int size, int numOps, int numGCOps); -}; - -#endif // _GF_NATIVETYPE_HPP -
