Index: test/lldbtest.py =================================================================== --- test/lldbtest.py +++ test/lldbtest.py @@ -431,21 +431,30 @@ stdout, stderr = p.communicate() return p.returncode, stdout, stderr +def target_is_android(): + if not hasattr(target_is_android, 'result'): + triple = self.dbg.GetSelectedPlatform().GetTriple() + match = re.match(".*-.*-.*-android", triple) + target_is_android.result = match is not None + return target_is_android.result + def android_device_api(): - assert lldb.platform_url is not None - device_id = None - parsed_url = urlparse.urlparse(lldb.platform_url) - if parsed_url.scheme == "adb": - device_id = parsed_url.netloc.split(":")[0] - retcode, stdout, stderr = run_adb_command( - ["shell", "getprop", "ro.build.version.sdk"], device_id) - if retcode == 0: - return int(stdout) - else: - raise LookupError( - ">>> Unable to determine the API level of the Android device.\n" - ">>> stdout:\n%s\n" - ">>> stderr:\n%s\n" % (stdout, stderr)) + if not hasattr(android_device_api, 'result'): + assert lldb.platform_url is not None + device_id = None + parsed_url = urlparse.urlparse(lldb.platform_url) + if parsed_url.scheme == "adb": + device_id = parsed_url.netloc.split(":")[0] + retcode, stdout, stderr = run_adb_command( + ["shell", "getprop", "ro.build.version.sdk"], device_id) + if retcode == 0: + android_device_api.result = int(stdout) + else: + raise LookupError( + ">>> Unable to determine the API level of the Android device.\n" + ">>> stdout:\n%s\n" + ">>> stderr:\n%s\n" % (stdout, stderr)) + return android_device_api.result # # Decorators for categorizing test cases. @@ -690,9 +699,7 @@ for which a test is expected to fail. """ def fn(self): - triple = self.dbg.GetSelectedPlatform().GetTriple() - match = re.match(".*-.*-.*-android", triple) - if match: + if target_is_android(): if not api_levels: return True device_api = android_device_api() @@ -1036,8 +1043,7 @@ def wrapper(*args, **kwargs): from unittest2 import case self = args[0] - triple = self.dbg.GetSelectedPlatform().GetTriple() - if re.match(".*-.*-.*-android", triple): + if target_is_android(): if api_levels: device_api = android_device_api() if device_api and (device_api in api_levels): @@ -1982,6 +1988,10 @@ if lldb.skip_build_and_cleanup: return module = builder_module() + if target_is_android(): + dictionary["OS"] = "Android" + if android_device_api() > 14: + dictionary["PIE"] = 1 if not module.buildDwarf(self, architecture, compiler, dictionary, clean): raise Exception("Don't know how to build binary with dwarf") Index: test/make/Makefile.rules =================================================================== --- test/make/Makefile.rules +++ test/make/Makefile.rules @@ -251,7 +251,9 @@ # Android specific options #---------------------------------------------------------------------- ifeq "$(OS)" "Android" - LDFLAGS += -pie + ifdef PIE + LDFLAGS += -pie + endif replace_with = $(if $(findstring clang,$(1)), \ $(subst clang,$(2),$(1)), \ $(if $(findstring gcc,$(1)), \