Skip to content

Commit

Permalink
Test: GemuseBouche dylibs for testing injection
Browse files Browse the repository at this point in the history
We need some dylibs to test injection on Test Cloud.
  • Loading branch information
jmoody committed Jan 31, 2018
1 parent 83988e4 commit 8425d66
Show file tree
Hide file tree
Showing 10 changed files with 720 additions and 2 deletions.
456 changes: 456 additions & 0 deletions DeviceAgent.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F5FEA54F201B1F7D00CEF56A"
BuildableName = "GemuseBouche"
BlueprintName = "GemuseBouche"
ReferencedContainer = "container:DeviceAgent.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F5FEA54F201B1F7D00CEF56A"
BuildableName = "GemuseBouche"
BlueprintName = "GemuseBouche"
ReferencedContainer = "container:DeviceAgent.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F5FEA54F201B1F7D00CEF56A"
BuildableName = "GemuseBouche"
BlueprintName = "GemuseBouche"
ReferencedContainer = "container:DeviceAgent.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
11 changes: 11 additions & 0 deletions GemuseBouche/libBetaVulgaris/CBXBetaVulgaris.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

#import <Foundation/Foundation.h>

extern NSString *const kCBXBetaVulgarisLibVersion;

@interface CBXBetaVulgaris : NSObject

+ (NSString *)familyName;
+ (NSArray *)vegetables;

@end
16 changes: 16 additions & 0 deletions GemuseBouche/libBetaVulgaris/CBXBetaVulgaris.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

#import "CBXBetaVulgaris.h"

NSString *const kCBXBetaVulgarisLibVersion = @"kCBXLibVersion:1.0.0";

@implementation CBXBetaVulgaris

+ (NSString *)familyName {
return @"Beta Vulgaris";
}

+ (NSArray *)vegetables {
return @[@"beets", @"chard"];
}

@end
11 changes: 11 additions & 0 deletions GemuseBouche/libBrassica/CBXBrassica.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

#import <Foundation/Foundation.h>

extern NSString *const kCBXBrassicaLibVersion;

@interface CBXBrassica : NSObject

+ (NSString *)familyName;
+ (NSArray *)vegetables;

@end
16 changes: 16 additions & 0 deletions GemuseBouche/libBrassica/CBXBrassica.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

#import "CBXBrassica.h"

NSString *const kCBXBrassicaLibVersion = @"kCBXLibVersion:1.0.0";

@implementation CBXBrassica

+ (NSString *)familyName {
return @"Brassica";
}

+ (NSArray *)vegetables {
return @[@"cabbage", @"broccoli", @"kale", @"pak choi"];
}

@end
11 changes: 11 additions & 0 deletions GemuseBouche/libCucurbits/CBXCurcubits.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

#import <Foundation/Foundation.h>

extern NSString *const kCBXCurcubitsLibVersion;

@interface CBXCurcubits : NSObject

+ (NSString *)familyName;
+ (NSArray *)vegetables;

@end
16 changes: 16 additions & 0 deletions GemuseBouche/libCucurbits/CBXCurcubits.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

#import "CBXCurcubits.h"

NSString *const kCBXCurcubitsLibVersion = @"kCBXLibVersion:1.0.0";

@implementation CBXCurcubits

+ (NSString *)familyName {
return @"Curcubits";
}

+ (NSArray *)vegetables {
return @[@"squash", @"pumpkin", @"cucumber", @"melon"];
}

@end
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,15 @@ docs:
# Installs DeviceAgent onto your machine
#
# Builds DeviceAgent for Sim and Device, installs to
# ~/.calabash/DeviceAgent/simulator and
# ~/.calabash/DeviceAgent/simulator and
# ~/.calabash/DeviceAgent/device
install:
bin/install/device_agent.sh

# dylibs for testing dylib injection
gemuse:
bin/make/gemuse-libs.sh

# Below this line are rules that have been renamed.
app-unit:
echo "Replaced with 'make test-app'"
Expand All @@ -76,4 +80,3 @@ ipa-unit:
unit:
echo "Replaced with 'make unit-tests'"
exit 1

96 changes: 96 additions & 0 deletions bin/make/gemuse-libs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/usr/bin/env bash

source bin/log.sh
source bin/ditto.sh
source bin/simctl.sh

ensure_valid_core_sim_service

set -e

banner "Preparing"

hash xcpretty 2>/dev/null
if [ $? -eq 0 ] && [ "${XCPRETTY}" != "0" ]; then
XC_PIPE='xcpretty -c'
else
XC_PIPE='cat'
fi

if [ "${1}" = "--upload" ]; then
UPLOAD_TO_S3="1"
fi

XC_WORKSPACE="DeviceAgent.xcworkspace"
XC_CONFIG=Release

XC_BUILD_DIR="build/GemuseBouche"
ARM_PRODUCT_DIR="${XC_BUILD_DIR}/Build/Products/Release-iphoneos"
SIM_PRODUCT_DIR="${XC_BUILD_DIR}/Build/Products/Release-iphonesimulator"
mkdir -p "${ARM_PRODUCT_DIR}"
mkdir -p "${SIM_PRODUCT_DIR}"
info "Prepared build directory ${XC_BUILD_DIR}"

INSTALL_DIR="Products/lib/GemuseBouche"
rm -rf "${INSTALL_DIR}"
mkdir -p "${INSTALL_DIR}"
info "Prepared install directory ${INSTALL_DIR}"

banner "Building GemuseBouche"

function build_libs_for_arch {
if [ "${1}" = "sim" ]; then
local arches="i386 x86_64"
local sdk="iphonesimulator"
else
local arches="armv7 armv7s arm64"
local sdk="iphoneos"
fi

COMMAND_LINE_BUILD=1 xcrun xcodebuild \
-workspace "${XC_WORKSPACE}" \
-scheme "GemuseBouche" \
-derivedDataPath "${XC_BUILD_DIR}" \
-configuration "${XC_CONFIG}" \
-sdk "${sdk}" \
ARCHS="${arches}" \
VALID_ARCHS="${arches}" \
ONLY_ACTIVE_ARCH=NO \
build | $XC_PIPE

EXIT_CODE=${PIPESTATUS[0]}

if [ $EXIT_CODE != 0 ]; then
error "Building libraries failed."
exit $EXIT_CODE
fi
}

build_libs_for_arch "arm"
build_libs_for_arch "sim"

function fat_lib_with_lipo {
local arm_lib="${ARM_PRODUCT_DIR}/${1}.dylib"
local sim_lib="${SIM_PRODUCT_DIR}/${1}.dylib"
local fat_lib="${INSTALL_DIR}/${1}.dylib"
xcrun lipo -create "${arm_lib}" "${sim_lib}" \
-output "${fat_lib}"

"${HOME}/.calabash/calabash-codesign/apple/resign-dylib.sh" \
"${fat_lib}"

local version=$(xcrun strings "${fat_lib}" | \
grep -E 'kCBXLibVersion' | head -n1 | cut -f2- -d":")
info "Installed version $version to ${fat_lib}"

if [ "${UPLOAD_TO_S3}" = "1" ]; then
aws s3 cp "${fat_lib}" \
"s3://calabash-files/dylibs/to-test-injection/${1}.dylib"
fi
}

fat_lib_with_lipo "libCucurbits"
fat_lib_with_lipo "libBetaVulgaris"
fat_lib_with_lipo "libBrassica"

info "Done!"

0 comments on commit 8425d66

Please sign in to comment.