diff options
author | 2020-08-03 14:33:06 +0000 | |
---|---|---|
committer | 2020-08-03 14:33:06 +0000 | |
commit | 061da546b983eb767bad15e67af1174fb0bcf31c (patch) | |
tree | 83c78b820819d70aa40c36d90447978b300078c5 /gnu/llvm/lldb/packages/Python/lldbsuite/test/macosx/find-app-in-bundle | |
parent | Import LLVM 10.0.0 release including clang, lld and lldb. (diff) | |
download | wireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.tar.xz wireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.zip |
Import LLVM 10.0.0 release including clang, lld and lldb.
ok hackroom
tested by plenty
Diffstat (limited to 'gnu/llvm/lldb/packages/Python/lldbsuite/test/macosx/find-app-in-bundle')
6 files changed, 117 insertions, 0 deletions
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/Makefile new file mode 100644 index 00000000000..68012d22f5b --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/Makefile @@ -0,0 +1,20 @@ +SRCDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/ +CC ?= clang + +ifeq "$(ARCH)" "" + ARCH = x86_64 +endif + +CFLAGS ?= -g -O0 -arch $(ARCH) + +all: TestApp.app/Contents/MacOS/TestApp + +TestApp.app/Contents/MacOS/TestApp: $(SRCDIR)/main.c + $(CC) $(CFLAGS) -o TestApp $< + rm -rf TestApp.app + cp -r $(SRCDIR)/TestApp.app . + mv TestApp TestApp.app/Contents/MacOS/TestApp + mv TestApp.dSYM TestApp.app.dSYM + +clean: + rm -rf TestApp.app/Contents/MacOS/TestApp TestApp.app.dSYM diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestApp.app/Contents/Info.plist b/gnu/llvm/lldb/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestApp.app/Contents/Info.plist new file mode 100644 index 00000000000..a47f72bb14d --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestApp.app/Contents/Info.plist @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>en</string> + <key>CFBundleExecutable</key> + <string>TestApp</string> + <key>CFBundleIdentifier</key> + <string>com.lldb.TestApp</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleName</key> + <string>TestApp</string> + <key>CFBundlePackageType</key> + <string>APPL</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleSupportedPlatforms</key> + <array> + <string>MacOSX</string> + </array> + <key>CFBundleVersion</key> + <string>1</string> + <key>LSMinimumSystemVersion</key> + <string>10.8</string> + <key>NSHumanReadableCopyright</key> + <string>Copyright © 2018 Jim Ingham. All rights reserved.</string> +</dict> +</plist> diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestApp.app/Contents/MacOS/.empty b/gnu/llvm/lldb/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestApp.app/Contents/MacOS/.empty new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestApp.app/Contents/MacOS/.empty diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestApp.app/Contents/Resources/.empty b/gnu/llvm/lldb/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestApp.app/Contents/Resources/.empty new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestApp.app/Contents/Resources/.empty diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestFindAppInBundle.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestFindAppInBundle.py new file mode 100644 index 00000000000..99d21f02208 --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/TestFindAppInBundle.py @@ -0,0 +1,58 @@ +""" +Make sure we can find the binary inside an app bundle. +""" + + + +import lldb +from lldbsuite.test.decorators import * +import lldbsuite.test.lldbutil as lldbutil +import lldbsuite.test.lldbplatformutil as lldbplatformutil +from lldbsuite.test.lldbtest import * + +@decorators.skipUnlessDarwin +class FindAppInMacOSAppBundle(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + NO_DEBUG_INFO_TESTCASE = True + + def test_find_app_in_bundle(self): + """There can be many tests in a test case - describe this test here.""" + self.build() + self.main_source_file = lldb.SBFileSpec("main.c") + self.find_app_in_bundle_test() + + def find_app_in_bundle_test(self): + """This reads in the .app, makes sure we get the right binary and can run it.""" + + # This function starts a process, "a.out" by default, sets a source + # breakpoint, runs to it, and returns the thread, process & target. + # It optionally takes an SBLaunchOption argument if you want to pass + # arguments or environment variables. + exe = self.getBuildArtifact("TestApp.app") + error = lldb.SBError() + target = self.dbg.CreateTarget(exe, None, None, False, error) + self.assertTrue(error.Success(), "Could not create target: %s"%(error.GetCString())) + self.assertTrue(target.IsValid(), "Target: TestApp.app is not valid.") + exe_module_spec = target.GetExecutable() + self.assertTrue(exe_module_spec.GetFilename(), "TestApp") + + bkpt = target.BreakpointCreateBySourceRegex("Set a breakpoint here", self.main_source_file) + self.assertTrue(bkpt.GetNumLocations() == 1, "Couldn't set a breakpoint in the main app") + + if lldbplatformutil.getPlatform() == "macosx": + launch_info = lldb.SBLaunchInfo(None) + launch_info.SetWorkingDirectory(self.get_process_working_directory()) + + error = lldb.SBError() + process = target.Launch(launch_info, error) + + self.assertTrue(process.IsValid(), "Could not create a valid process for TestApp: %s"%(error.GetCString())) + + # Frame #0 should be at our breakpoint. + threads = lldbutil.get_threads_stopped_at_breakpoint(process, bkpt) + + self.assertTrue(len(threads) == 1, "Expected 1 thread to stop at breakpoint, %d did."%(len(threads))) + + diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/main.c new file mode 100644 index 00000000000..27a0cdc01a9 --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/macosx/find-app-in-bundle/main.c @@ -0,0 +1,9 @@ +#include <stdio.h> + +int +main() +{ + printf("Set a breakpoint here.\n"); + return 0; +} + |