Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-114099 - Add iOS testbed, plus Makefile target to invoke it. #115930

Merged
merged 12 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,17 @@ Lib/test/data/*
/_bootstrap_python
/Makefile
/Makefile.pre
iOSTestbed.*
iOS/Frameworks/
iOS/Resources/Info.plist
iOS/testbed/build
iOS/testbed/Python.xcframework/ios-*/bin
iOS/testbed/Python.xcframework/ios-*/include
iOS/testbed/Python.xcframework/ios-*/lib
iOS/testbed/Python.xcframework/ios-*/Python.framework
iOS/testbed/iOSTestbed.xcodeproj/project.xcworkspace
iOS/testbed/iOSTestbed.xcodeproj/xcuserdata
iOS/testbed/iOSTestbed.xcodeproj/xcshareddata
Mac/Makefile
Mac/PythonLauncher/Info.plist
Mac/PythonLauncher/Makefile
Expand Down
44 changes: 43 additions & 1 deletion Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -1993,6 +1993,42 @@ testuniversal: all
$(RUNSHARED) /usr/libexec/oah/translate \
./$(BUILDPYTHON) -E -m test -j 0 -u all $(TESTOPTS)

# Run the test suite on the iOS simulator. Must be run on a macOS machine with
# a full Xcode install that has an iPhone SE (3rd edition) simulator available.
# This must be run *after* a `make install` has completed the build. The
# `--with-framework-name` argument *cannot* be used when configuring the build.
XCFOLDER=iOSTestbed.$(MULTIARCH).$(shell date +%s)
XCRESULT=$(XCFOLDER)/$(MULTIARCH).xcresult
.PHONY: testios
testios:
@if test "$(MACHDEP)" != "ios"; then \
echo "Cannot run the iOS testbed for a non-iOS build."; \
exit 1;\
fi
@if test "$(findstring -iphonesimulator,$(MULTIARCH))" != "-iphonesimulator"; then \
echo "Cannot run the iOS testbed for non-simulator builds."; \
exit 1;\
fi
@if test $(PYTHONFRAMEWORK) != "Python"; then \
echo "Cannot run the iOS testbed with a non-default framework name."; \
exit 1;\
fi
@if ! test -d $(PYTHONFRAMEWORKPREFIX); then \
echo "Cannot find a finalized iOS Python.framework. Have you run 'make install' to finalize the framework build?"; \
exit 1;\
fi
# Copy the testbed project into the build folder
cp -r $(srcdir)/iOS/testbed $(XCFOLDER)
# Copy the framework from the install location to the testbed project.
cp -r $(PYTHONFRAMEWORKPREFIX)/* $(XCFOLDER)/Python.xcframework/ios-arm64_x86_64-simulator
# Run the test suite for the Xcode project, targeting the iOS simulator.
# If the suite fails, extract and print the console output, then re-raise the failure
if ! xcodebuild test -project $(XCFOLDER)/iOSTestbed.xcodeproj -scheme "iOSTestbed" -destination "platform=iOS Simulator,name=iPhone SE (3rd Generation)" -resultBundlePath $(XCRESULT) ; then \
xcrun xcresulttool get --path $(XCRESULT) --id $$(xcrun xcresulttool get --path $(XCRESULT) --format json | $(PYTHON_FOR_BUILD) -c "import sys, json; result = json.load(sys.stdin); print(result['actions']['_values'][0]['actionResult']['logRef']['id']['_value'])"); \
echo ; \
ned-deily marked this conversation as resolved.
Show resolved Hide resolved
exit 1; \
fi

# Like test, but using --slow-ci which enables all test resources and use
# longer timeout. Run an optional pybuildbot.identify script to include
# information about the build environment.
Expand Down Expand Up @@ -2712,7 +2748,7 @@ frameworkinstallextras:
# subdirectory. The install has put these folders in the same folder as
# Python.framework; Move the headers to their final framework-compatible home.
.PHONY: frameworkinstallmobileheaders
frameworkinstallmobileheaders:
frameworkinstallmobileheaders: frameworkinstallunversionedstructure inclinstall
if test -d $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers; then \
echo "Removing old framework headers"; \
rm -rf $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers; \
Expand Down Expand Up @@ -2847,6 +2883,10 @@ clean-retain-profile: pycremoval
-find build -type f -a ! -name '*.gc??' -exec rm -f {} ';'
-rm -f Include/pydtrace_probes.h
-rm -f profile-gen-stamp
-rm -rf iOS/testbed/Python.xcframework/ios-*/bin
-rm -rf iOS/testbed/Python.xcframework/ios-*/lib
-rm -rf iOS/testbed/Python.xcframework/ios-*/include
-rm -rf iOS/testbed/Python.xcframework/ios-*/Python.framework

.PHONY: profile-removal
profile-removal:
Expand All @@ -2872,6 +2912,8 @@ clobber: clean
config.cache config.log pyconfig.h Modules/config.c
-rm -rf build platform
-rm -rf $(PYTHONFRAMEWORKDIR)
-rm -rf iOS/Frameworks
-rm -rf iOSTestbed.*
-rm -f python-config.py python-config
-rm -rf cross-build

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A testbed project was added to run the test suite on iOS.
11 changes: 7 additions & 4 deletions Modules/_testexternalinspection.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
# include <sys/mman.h>
#endif

#ifdef __APPLE__
#if defined(__APPLE__)
# include <TargetConditionals.h>
# if TARGET_OS_OSX
# include <libproc.h>
# include <mach-o/fat.h>
# include <mach-o/loader.h>
Expand All @@ -26,6 +28,7 @@
# include <sys/mman.h>
# include <sys/proc.h>
# include <sys/sysctl.h>
# endif
#endif

#include <errno.h>
Expand All @@ -50,7 +53,7 @@
# define HAVE_PROCESS_VM_READV 0
#endif

#ifdef __APPLE__
#if defined(__APPLE__) && TARGET_OS_OSX
static void*
analyze_macho64(mach_port_t proc_ref, void* base, void* map)
{
Expand Down Expand Up @@ -373,7 +376,7 @@ read_memory(pid_t pid, void* remote_address, size_t len, void* dst)
result += read;
} while ((size_t)read != local[0].iov_len);
total_bytes_read = result;
#elif defined(__APPLE__)
#elif defined(__APPLE__) && TARGET_OS_OSX
ssize_t result = -1;
kern_return_t kr = mach_vm_read_overwrite(
pid_to_task(pid),
Expand Down Expand Up @@ -429,7 +432,7 @@ get_py_runtime(pid_t pid)
{
#if defined(__linux__)
return get_py_runtime_linux(pid);
#elif defined(__APPLE__)
#elif defined(__APPLE__) && TARGET_OS_OSX
return get_py_runtime_macos(pid);
#else
return NULL;
Expand Down
150 changes: 98 additions & 52 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.