reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
"""
Test that loading of dependents works correctly for all the potential
combinations.
"""

from __future__ import print_function

import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil

@skipIfWindows # Windows deals differently with shared libs.
class TargetDependentsTestCase(TestBase):

    mydir = TestBase.compute_mydir(__file__)

    NO_DEBUG_INFO_TESTCASE = True

    def setUp(self):
        TestBase.setUp(self)
        self.build()

    def has_exactly_one_image(self, matching, msg=""):
        self.expect(
            "image list",
            "image list should contain at least one image",
            substrs=['[  0]'])
        should_match = not matching
        self.expect(
            "image list", msg, matching=should_match, substrs=['[  1]'])


    @expectedFailureAll(oslist=["linux"],
        triple=no_match(".*-android"))
        #linux does not support loading dependent files, but android does
    @expectedFailureNetBSD
    def test_dependents_implicit_default_exe(self):
        """Test default behavior"""
        exe = self.getBuildArtifact("a.out")
        self.runCmd("target create  " + exe, CURRENT_EXECUTABLE_SET)
        self.has_exactly_one_image(False)

    @expectedFailureAll(oslist=["linux"],
        triple=no_match(".*-android"))
        #linux does not support loading dependent files, but android does
    @expectedFailureNetBSD
    def test_dependents_explicit_default_exe(self):
        """Test default behavior"""
        exe = self.getBuildArtifact("a.out")
        self.runCmd("target create -ddefault " + exe, CURRENT_EXECUTABLE_SET)
        self.has_exactly_one_image(False)

    def test_dependents_explicit_true_exe(self):
        """Test default behavior"""
        exe = self.getBuildArtifact("a.out")
        self.runCmd("target create -dtrue " + exe, CURRENT_EXECUTABLE_SET)
        self.has_exactly_one_image(True)

    @expectedFailureAll(oslist=["linux"],
        triple=no_match(".*-android"))
        #linux does not support loading dependent files, but android does
    @expectedFailureNetBSD
    def test_dependents_explicit_false_exe(self):
        """Test default behavior"""
        exe = self.getBuildArtifact("a.out")
        self.runCmd("target create -dfalse " + exe, CURRENT_EXECUTABLE_SET)
        self.has_exactly_one_image(False)

    def test_dependents_implicit_false_exe(self):
        """Test default behavior"""
        exe = self.getBuildArtifact("a.out")
        self.runCmd("target create  -d " + exe, CURRENT_EXECUTABLE_SET)
        self.has_exactly_one_image(True)

    @expectedFailureAndroid # android will return mutiple images
    def test_dependents_implicit_default_lib(self):
        ctx = self.platformContext
        dylibName = ctx.shlib_prefix + 'load_a.' + ctx.shlib_extension
        lib = self.getBuildArtifact(dylibName)
        self.runCmd("target create " + lib, CURRENT_EXECUTABLE_SET)
        self.has_exactly_one_image(True)

    def test_dependents_explicit_default_lib(self):
        ctx = self.platformContext
        dylibName = ctx.shlib_prefix + 'load_a.' + ctx.shlib_extension
        lib = self.getBuildArtifact(dylibName)
        self.runCmd("target create -ddefault " + lib, CURRENT_EXECUTABLE_SET)
        self.has_exactly_one_image(True)

    def test_dependents_explicit_true_lib(self):
        ctx = self.platformContext
        dylibName = ctx.shlib_prefix + 'load_a.' + ctx.shlib_extension
        lib = self.getBuildArtifact(dylibName)
        self.runCmd("target create -dtrue " + lib, CURRENT_EXECUTABLE_SET)
        self.has_exactly_one_image(True)

    @expectedFailureAll(oslist=["linux"],
        triple=no_match(".*-android"))
        #linux does not support loading dependent files, but android does
    @expectedFailureNetBSD
    def test_dependents_explicit_false_lib(self):
        ctx = self.platformContext
        dylibName = ctx.shlib_prefix + 'load_a.' + ctx.shlib_extension
        lib = self.getBuildArtifact(dylibName)
        self.runCmd("target create -dfalse " + lib, CURRENT_EXECUTABLE_SET)
        self.has_exactly_one_image(False)

    def test_dependents_implicit_false_lib(self):
        ctx = self.platformContext
        dylibName = ctx.shlib_prefix + 'load_a.' + ctx.shlib_extension
        lib = self.getBuildArtifact(dylibName)
        self.runCmd("target create -d " + lib, CURRENT_EXECUTABLE_SET)
        self.has_exactly_one_image(True)