summaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/functionalities/exec
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-08-20 18:01:57 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-08-20 18:01:57 +0000
commit88c643b6fec27eec436c8d138fee6346e92337d6 (patch)
tree82cd13b2f3cde1c9e5f79689ba4e6ba67694843f /packages/Python/lldbsuite/test/functionalities/exec
parent94994d372d014ce4c8758b9605d63fae651bd8aa (diff)
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities/exec')
-rw-r--r--packages/Python/lldbsuite/test/functionalities/exec/Makefile13
-rw-r--r--packages/Python/lldbsuite/test/functionalities/exec/TestExec.py123
-rw-r--r--packages/Python/lldbsuite/test/functionalities/exec/main.cpp76
-rw-r--r--packages/Python/lldbsuite/test/functionalities/exec/secondprog.cpp5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/exec/secondprog.mk6
5 files changed, 0 insertions, 223 deletions
diff --git a/packages/Python/lldbsuite/test/functionalities/exec/Makefile b/packages/Python/lldbsuite/test/functionalities/exec/Makefile
deleted file mode 100644
index 784a53da4776..000000000000
--- a/packages/Python/lldbsuite/test/functionalities/exec/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-LEVEL = ../../make
-
-CXX_SOURCES := main.cpp
-
-all: a.out secondprog
-
-include $(LEVEL)/Makefile.rules
-
-secondprog:
- $(MAKE) VPATH=$(VPATH) -f $(SRCDIR)/secondprog.mk
-
-clean::
- $(MAKE) -f $(SRCDIR)/secondprog.mk clean
diff --git a/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py b/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
deleted file mode 100644
index 2cec254acc0c..000000000000
--- a/packages/Python/lldbsuite/test/functionalities/exec/TestExec.py
+++ /dev/null
@@ -1,123 +0,0 @@
-"""
-Test some lldb command abbreviations.
-"""
-from __future__ import print_function
-
-
-import lldb
-import os
-import time
-from lldbsuite.support import seven
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-def execute_command(command):
- #print('%% %s' % (command))
- (exit_status, output) = seven.get_command_status_output(command)
- # if output:
- # print(output)
- #print('status = %u' % (exit_status))
- return exit_status
-
-
-class ExecTestCase(TestBase):
-
- NO_DEBUG_INFO_TESTCASE = True
-
- mydir = TestBase.compute_mydir(__file__)
-
- @skipUnlessDarwin
- @expectedFailureAll(archs=['i386'], bugnumber="rdar://28656532")
- @expectedFailureAll(oslist=["ios", "tvos", "watchos", "bridgeos"], bugnumber="rdar://problem/34559552") # this exec test has problems on ios systems
- @skipIfSanitized # rdar://problem/43756823
- def test_hitting_exec (self):
- self.do_test(False)
-
- @skipUnlessDarwin
- @expectedFailureAll(archs=['i386'], bugnumber="rdar://28656532")
- @expectedFailureAll(oslist=["ios", "tvos", "watchos", "bridgeos"], bugnumber="rdar://problem/34559552") # this exec test has problems on ios systems
- @skipIfSanitized # rdar://problem/43756823
- def test_skipping_exec (self):
- self.do_test(True)
-
- def do_test(self, skip_exec):
- self.build()
- exe = self.getBuildArtifact("a.out")
- secondprog = self.getBuildArtifact("secondprog")
-
- # Create the target
- target = self.dbg.CreateTarget(exe)
-
- # Create any breakpoints we need
- breakpoint1 = target.BreakpointCreateBySourceRegex(
- 'Set breakpoint 1 here', lldb.SBFileSpec("main.cpp", False))
- self.assertTrue(breakpoint1, VALID_BREAKPOINT)
- breakpoint2 = target.BreakpointCreateBySourceRegex(
- 'Set breakpoint 2 here', lldb.SBFileSpec("secondprog.cpp", False))
- self.assertTrue(breakpoint2, VALID_BREAKPOINT)
-
- # Launch the process
- process = target.LaunchSimple(
- None, None, self.get_process_working_directory())
- self.assertTrue(process, PROCESS_IS_VALID)
-
- if self.TraceOn():
- self.runCmd("settings show target.process.stop-on-exec", check=False)
- if skip_exec:
- self.dbg.HandleCommand("settings set target.process.stop-on-exec false")
- def cleanup():
- self.runCmd("settings set target.process.stop-on-exec false",
- check=False)
-
- # Execute the cleanup function during test case tear down.
- self.addTearDownHook(cleanup)
-
- # The stop reason of the thread should be breakpoint.
- self.assertTrue(process.GetState() == lldb.eStateStopped,
- STOPPED_DUE_TO_BREAKPOINT)
-
- threads = lldbutil.get_threads_stopped_at_breakpoint(
- process, breakpoint1)
- self.assertTrue(len(threads) == 1)
-
- # We had a deadlock tearing down the TypeSystemMap on exec, but only if some
- # expression had been evaluated. So make sure we do that here so the teardown
- # is not trivial.
-
- thread = threads[0]
- value = thread.frames[0].EvaluateExpression("1 + 2")
- self.assertTrue(
- value.IsValid(),
- "Expression evaluated successfully")
- int_value = value.GetValueAsSigned()
- self.assertTrue(int_value == 3, "Expression got the right result.")
-
- # Run and we should stop due to exec
- process.Continue()
-
- if not skip_exec:
- self.assertFalse(process.GetState() == lldb.eStateExited,
- "Process should not have exited!")
- self.assertTrue(process.GetState() == lldb.eStateStopped,
- "Process should be stopped at __dyld_start")
-
- threads = lldbutil.get_stopped_threads(
- process, lldb.eStopReasonExec)
- self.assertTrue(
- len(threads) == 1,
- "We got a thread stopped for exec.")
-
- # Run and we should stop at breakpoint in main after exec
- process.Continue()
-
- threads = lldbutil.get_threads_stopped_at_breakpoint(
- process, breakpoint2)
- if self.TraceOn():
- for t in process.threads:
- print(t)
- if t.GetStopReason() != lldb.eStopReasonBreakpoint:
- self.runCmd("bt")
- self.assertTrue(len(threads) == 1,
- "Stopped at breakpoint in exec'ed process.")
diff --git a/packages/Python/lldbsuite/test/functionalities/exec/main.cpp b/packages/Python/lldbsuite/test/functionalities/exec/main.cpp
deleted file mode 100644
index 92206b2d88ef..000000000000
--- a/packages/Python/lldbsuite/test/functionalities/exec/main.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-#include <errno.h>
-#include <mach/mach.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <spawn.h>
-#include <unistd.h>
-#include <libgen.h>
-#include <string>
-
-static void
-exit_with_errno (int err, const char *prefix)
-{
- if (err)
- {
- fprintf (stderr,
- "%s%s",
- prefix ? prefix : "",
- strerror(err));
- exit (err);
- }
-}
-
-static pid_t
-spawn_process (const char *progname,
- const char **argv,
- const char **envp,
- int &err)
-{
- pid_t pid = 0;
-
- const posix_spawn_file_actions_t *file_actions = NULL;
- posix_spawnattr_t attr;
- err = posix_spawnattr_init (&attr);
- if (err)
- return pid;
-
- short flags = POSIX_SPAWN_SETEXEC | POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK;
- err = posix_spawnattr_setflags (&attr, flags);
- if (err == 0)
- {
- // Use the default signal masks
- sigset_t no_signals;
- sigset_t all_signals;
- sigemptyset (&no_signals);
- sigfillset (&all_signals);
- posix_spawnattr_setsigmask(&attr, &no_signals);
- posix_spawnattr_setsigdefault(&attr, &all_signals);
-
- err = posix_spawn (&pid,
- progname,
- file_actions,
- &attr,
- (char * const *)argv,
- (char * const *)envp);
-
- posix_spawnattr_destroy(&attr);
- }
- return pid;
-}
-
-int
-main (int argc, char const **argv)
-{
- char *buf = (char*) malloc (strlen (argv[0]) + 12);
- strlcpy (buf, argv[0], strlen (argv[0]) + 1);
- std::string directory_name (::dirname (buf));
-
- std::string other_program = directory_name + "/secondprog";
- int err = 0; // Set breakpoint 1 here
- spawn_process (other_program.c_str(), argv, NULL, err);
- if (err)
- exit_with_errno (err, "posix_spawn x86_64 error");
- return 0;
-}
diff --git a/packages/Python/lldbsuite/test/functionalities/exec/secondprog.cpp b/packages/Python/lldbsuite/test/functionalities/exec/secondprog.cpp
deleted file mode 100644
index 5653471c1530..000000000000
--- a/packages/Python/lldbsuite/test/functionalities/exec/secondprog.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <stdio.h>
-int main ()
-{
- puts ("I am the second program."); // Set breakpoint 2 here
-}
diff --git a/packages/Python/lldbsuite/test/functionalities/exec/secondprog.mk b/packages/Python/lldbsuite/test/functionalities/exec/secondprog.mk
deleted file mode 100644
index 88f76b5113b4..000000000000
--- a/packages/Python/lldbsuite/test/functionalities/exec/secondprog.mk
+++ /dev/null
@@ -1,6 +0,0 @@
-LEVEL = ../../make
-
-CXX_SOURCES := secondprog.cpp
-EXE = secondprog
-
-include $(LEVEL)/Makefile.rules