Skip to content

Commit

Permalink
Merge branch 'master' into maxgolov/shutdown_fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgolov authored Feb 6, 2020
2 parents fe20129 + f659f0f commit d8e4a89
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 27 deletions.
22 changes: 13 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,30 @@ endif()

# iOS build options
option(BUILD_IOS "Build for iOS" NO)
option(BUILD_SIMULATOR "Build using simulator SDK" NO)

# Begin Uncomment for iOS Device build
#set(BUILD_SIMULATOR NO)
# End of iOS Device build

if(BUILD_IOS)
set(TARGET_ARCH "APPLE")
set(IOS True)
set(APPLE True)
set (CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for iOS" FORCE)
set(CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for iOS" FORCE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -miphoneos-version-min=${IOS_DEPLOYMENT_TARGET}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -miphoneos-version-min=${IOS_DEPLOYMENT_TARGET}")

if(BUILD_SIMULATOR)
if(${IOS_ARCH} STREQUAL "x86_64")
set(IOS_PLATFORM "iphonesimulator")
set(CMAKE_SYSTEM_PROCESSOR x86_64)
else()
elseif(${IOS_ARCH} STREQUAL "arm64")
set(IOS_PLATFORM "iphoneos")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch arm64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch arm64")
set(CMAKE_SYSTEM_PROCESSOR arm64)
elseif(${IOS_ARCH} STREQUAL "arm64e")
set(IOS_PLATFORM "iphoneos")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch arm64e")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch arm64e")
set(CMAKE_SYSTEM_PROCESSOR arm64e)
else()
message(FATAL_ERROR "Unrecognized iOS architecture '${IOS_ARCH}'")
endif()

execute_process(COMMAND xcodebuild -version -sdk ${IOS_PLATFORM} Path
Expand All @@ -47,7 +51,7 @@ if(BUILD_IOS)
endif()

message("-- BUILD_IOS: ${BUILD_IOS}")
message("-- BUILD_SIMULATOR: ${BUILD_SIMULATOR}")
message("-- IOS_ARCH: ${IOS_ARCH}")
message("-- CMAKE_SYSTEM_INFO_FILE: ${CMAKE_SYSTEM_INFO_FILE}")
message("-- CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
message("-- CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
Expand Down
17 changes: 15 additions & 2 deletions build-ios.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
#!/bin/sh

if [ "$1" == "release" ] || [ "$2" == "release" ]; then
if [ "$1" == "release" ]; then
BUILD_TYPE="Release"
else
BUILD_TYPE="Debug"
fi

if [ "$2" == "arm64" ]; then
IOS_ARCH="arm64"
elif [ "$2" == "arm64e" ]; then
IOS_ARCH="arm64e"
elif [ "$2" == "x86_64" ] || "$2" == "simulator" ]; then
IOS_ARCH="x86_64"
else
IOS_ARCH="x86_64"
fi

# Set target iOS minver
IOS_DEPLOYMENT_TARGET=10.10

# Install build tools and recent sqlite3
FILE=.buildtools
OS_NAME=`uname -a`
Expand All @@ -28,7 +41,7 @@ cd out

CMAKE_PACKAGE_TYPE=tgz

cmake -DBUILD_IOS=YES -DBUILD_SIMULATOR=YES -DBUILD_UNIT_TESTS=YES -DBUILD_FUNC_TESTS=YES -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PACKAGE_TYPE=$CMAKE_PACKAGE_TYPE ..
cmake -DBUILD_IOS=YES -DIOS_ARCH=$IOS_ARCH -DIOS_DEPLOYMENT_TARGET=$IOS_DEPLOYMENT_TARGET -DBUILD_UNIT_TESTS=YES -DBUILD_FUNC_TESTS=YES -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PACKAGE_TYPE=$CMAKE_PACKAGE_TYPE ..
make

make package
2 changes: 1 addition & 1 deletion lib/http/HttpClient_Apple.mm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import <CFNetwork/CFNetwork.h>

#include "HttpClient_Apple.hpp"
#include "Utils.hpp"
#include "utils/Utils.hpp"

namespace ARIASDK_NS_BEGIN {

Expand Down
24 changes: 12 additions & 12 deletions tests/functests/APITest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,20 +419,20 @@ TEST(APITest, LogManager_KilledEventsAreDropped)
EXPECT_EQ(MAX_ITERATIONS, debugListener.numLogged);
// TODO: it is possible that collector would return 503 here, in that case we may not get the 'kill-tokens' hint.
// If it ever happens, the test would fail because the second iteration might try to upload.
EXPECT_EQ(1, debugListener.numHttpError);
EXPECT_EQ(1u, debugListener.numHttpError);
debugListener.numCached = 0;
}
if (i == 1)
{
// At this point we should get the error response from collector because we ingested with invalid tokens.
// Collector should have also asked us to ban that token... Check the counts
EXPECT_EQ(2 * MAX_ITERATIONS, debugListener.numLogged);
EXPECT_EQ(0, debugListener.numCached);
EXPECT_EQ(0u, debugListener.numCached);
EXPECT_EQ(MAX_ITERATIONS, debugListener.numDropped);
}
}
LogManager::FlushAndTeardown();
EXPECT_EQ(0, debugListener.numCached);
EXPECT_EQ(0u, debugListener.numCached);
debugListener.printStats();
removeAllListeners(debugListener);
}
Expand Down Expand Up @@ -473,7 +473,7 @@ TEST(APITest, LogManager_Initialize_DebugEventListener)
debugListener.storageFullPct = 0;
LogManager::Initialize(TEST_TOKEN, configuration);
LogManager::FlushAndTeardown();
EXPECT_EQ(debugListener.storageFullPct.load(), 0);
EXPECT_EQ(debugListener.storageFullPct.load(), 0u);

}
debugListener.numCached = 0;
Expand All @@ -489,12 +489,12 @@ TEST(APITest, LogManager_Initialize_DebugEventListener)
result->LogEvent(eventToLog);
// Check the counts
EXPECT_EQ(MAX_ITERATIONS, debugListener.numLogged);
EXPECT_EQ(0, debugListener.numDropped);
EXPECT_EQ(0, debugListener.numReject);
EXPECT_EQ(0u, debugListener.numDropped);
EXPECT_EQ(0u, debugListener.numReject);

LogManager::UploadNow(); // Try to upload whatever we got
PAL::sleep(1000); // Give enough time to upload at least one event
EXPECT_NE(0, debugListener.numSent); // Some posts must succeed within 500ms
EXPECT_NE(0u, debugListener.numSent); // Some posts must succeed within 500ms
LogManager::PauseTransmission(); // There could still be some pending at this point
LogManager::Flush(); // Save all pending to disk

Expand Down Expand Up @@ -767,7 +767,7 @@ TEST(APITest, C_API_Test)
std::string guidStr2 = "01020304-0506-0708-090a-0b0c0d0e0f00";
ASSERT_STRCASEEQ(guidStr.c_str(), guidStr2.c_str());
// Verify time
ASSERT_EQ(record.data[0].properties["timeKey"].longValue, ticks.ticks);
ASSERT_EQ(record.data[0].properties["timeKey"].longValue, (int64_t)ticks.ticks);
};

evt_handle_t handle = evt_open(config);
Expand All @@ -788,7 +788,7 @@ TEST(APITest, C_API_Test)
{
evt_log(handle, event);
}
EXPECT_EQ(totalEvents, 5);
EXPECT_EQ(totalEvents, 5u);

evt_flush(handle);
evt_upload(handle);
Expand Down Expand Up @@ -850,7 +850,7 @@ TEST(APITest, UTC_Callback_Test)
std::string guidStr2 = "01020304-0506-0708-090a-0b0c0d0e0f00";
ASSERT_STRCASEEQ(guidStr.c_str(), guidStr2.c_str());
// Verify time
ASSERT_EQ(record.data[0].properties["timeKey"].longValue, ticks.ticks);
ASSERT_EQ(record.data[0].properties["timeKey"].longValue, (int64_t)ticks.ticks);

// Transform to JSON and print
std::string s;
Expand Down Expand Up @@ -910,7 +910,7 @@ TEST(APITest, Pii_DROP_Test)
return;
}

ASSERT_EQ(record.extProtocol[0].ticketKeys.size(), 0);
ASSERT_EQ(record.extProtocol[0].ticketKeys.size(), 0ul);
// more events with random device id
EXPECT_STRNE(record.extDevice[0].localId.c_str(), realDeviceId.c_str());
EXPECT_STREQ(record.extDevice[0].authId.c_str(), "");
Expand Down Expand Up @@ -954,7 +954,7 @@ TEST(APITest, Pii_DROP_Test)
}

LogManager::FlushAndTeardown();
ASSERT_EQ(totalEvents, 4);
ASSERT_EQ(totalEvents, 4u);
LogManager::RemoveEventListener(EVT_LOG_EVENT, debugListener);

}
Expand Down
2 changes: 1 addition & 1 deletion tests/functests/BondDecoderTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void SendEvents(ILogger* pLogger, uint8_t eventCount, std::chrono::milliseconds
{
// Key-values
{ "strKey", "hello" },
{ "int64Key", 1L },
{ "int64Key", 1LL },
{ "dblKey", 3.14 },
{ "boolKey", false },
{ "guidKey0", GUID_t("00000000-0000-0000-0000-000000000000") },
Expand Down
4 changes: 2 additions & 2 deletions tests/functests/LogSessionDataFuncTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ TEST_F(LogSessionDataFuncTests, Constructor_ValidSessionFileExists_MembersSetToE
ConstructSesFile(SessionFile, validSessionFirstTime, validSkuId);
LogSessionData logSessionData{ SessionFileArgument };

ASSERT_EQ(logSessionData.getSessionFirstTime(), 123456);
ASSERT_EQ(logSessionData.getSessionFirstTime(), 123456ull);
ASSERT_EQ(logSessionData.getSessionSDKUid(), validSkuId);
}

Expand All @@ -95,7 +95,7 @@ TEST_F(LogSessionDataFuncTests, Constructor_InvalidSessionFileExists_MembersRege
ConstructSesFile(SessionFile, invalidSessionFirstTime, validSkuId);
LogSessionData logSessionData{ SessionFileArgument };

ASSERT_NE(logSessionData.getSessionFirstTime(), 123456);
ASSERT_NE(logSessionData.getSessionFirstTime(), 123456ull);
ASSERT_NE(logSessionData.getSessionSDKUid(), validSkuId);
}

Expand Down

0 comments on commit d8e4a89

Please sign in to comment.