Exemple #1
0
def test_set_new_section_property():
    """Set a property that has no section (yet)"""

    value = '1'
    testutils.deploy_config_raw("")

    prop.set_prop('info', 'sdk', value)
    assert prop.get_prop('info', 'sdk') == value

    testutils.undeploy()

    return 0
Exemple #2
0
def test_set_new_property():
    """Attempt to set a new property (existing section)"""

    value = '1'
    contents = ("[info]\n" "real = not_real")

    testutils.deploy_config_raw(contents)

    prop.set_prop('info', 'sdk', value)
    assert prop.get_prop('info', 'sdk') == value

    testutils.undeploy()
Exemple #3
0
def test_set_property_casing():
    """Set a prop and try to retrieve with casing"""

    sdk = '1'
    testutils.deploy_config_raw("")

    prop.set_prop('INFO', 'sdk', sdk)
    assert prop.get_prop('info', 'sdk') == sdk
    assert prop.get_prop('Info', 'sdk') == sdk
    assert prop.get_prop('INFO', 'sdk') == sdk

    testutils.undeploy()

    return 0
Exemple #4
0
def test_set_existing_property():
    """Set a property that already exists"""

    value = 'new'

    contents = ("[Info]\n" "sdk = old")

    testutils.deploy_config_raw(contents)

    prop.set_prop('info', 'sdk', value)
    assert prop.get_prop('info', 'sdk') == value

    testutils.undeploy()

    return 0
Exemple #5
0
    def do_install(self):

        """Install the dtf client on device"""

        log.i(self.name, "Waiting for device to be connected...")
        self.adb.wait_for_device()

        log.i(self.name, "Removing old client if it exists...")
        self.adb.uninstall(DTF_CLIENT)

        log.i(self.name, "Installing dtf client...")

        self.adb.install(DTF_CLIENT_PATH)

        cmd = "am startservice -a com.dtf.action.name.INITIALIZE"
        self.adb.shell_command(cmd)

        busybox_path = "/data/data/%s/files/busybox" % DTF_CLIENT
        prop.set_prop("Info", "busybox", busybox_path)

        log.i(self.name, "dtf client installed.")

        return 0
Exemple #6
0
    def do_install(self):

        """Install the dtf client on device"""

        log.i(self.name, "Waiting for device to be connected...")
        self.adb.wait_for_device()

        log.i(self.name, "Removing old client if it exists...")
        self.adb.uninstall(DTF_CLIENT)

        log.i(self.name, "Installing dtf client...")

        self.adb.install(DTF_CLIENT_PATH)

        cmd = "am startservice -a com.dtf.action.name.INITIALIZE"
        self.adb.shell_command(cmd)

        busybox_path = "/data/data/%s/files/busybox" % DTF_CLIENT
        prop.set_prop('Info', 'busybox', busybox_path)

        log.i(self.name, "dtf client installed.")

        return 0
Exemple #7
0
    def do_set(self, args):
        """Set a property"""

        rtn = 0

        if len(args) < 3:
            log.e(self.name, "A section, prop, and value must be specified.")
            rtn = self.usage()

        else:
            section = args[0]
            prop_name = args[1]
            value = " ".join(args[2:])

            rtn = set_prop(section, prop_name, value)

        return rtn
Exemple #8
0
    def do_set(self, args):

        """Set a property"""

        rtn = 0

        if len(args) < 3:
            log.e(self.name, "A section, prop, and value must be specified.")
            rtn = self.usage()

        else:
            section = args[0]
            prop_name = args[1]
            value = " ".join(args[2:])

            rtn = set_prop(section, prop_name, value)

        return rtn
Exemple #9
0
    def initialize_device(self, device_serial):

        """Perform the actual initialization"""

        log.d(TAG, "Preparing device: %s" % device_serial)

        touch(utils.CONFIG_FILE_NAME)

        set_prop('Info', 'serial', device_serial)

        # Since we have a serial now, lets create a new DtfAdb instance
        self.adb = DtfAdb.DtfAdb()

        # Kernel
        self.adb.shell_command('cat /proc/version')
        kernel = self.adb.get_output()[0]
        log.d(TAG, "Kernel version: %s" % kernel)
        set_prop('Info', 'kernel', kernel)

        # SDK
        sdk = self.getprop('ro.build.version.sdk')
        log.d(TAG, "Using SDK API %s" % sdk)
        set_prop('Info', 'SDK', sdk)

        self.adb.shell_command('set')
        set_output = self.adb.get_output()

        # $PATH
        path = get_set_value(set_output, 'PATH')
        if path is None:
            log.e(TAG, "Unable to get $PATH variable!")
            self.do_shutdown(None, None)
        log.d(TAG, "PATH : %s" % path)
        set_prop('Info', 'path', path)

        # $BOOTCLASSPTH
        bootclasspath = get_set_value(set_output, 'BOOTCLASSPATH')
        if bootclasspath is None:
            log.e(TAG, "Unable to get $BOOTCLASSPATH variable!")
            self.do_shutdown(None, None)
        log.d(TAG, "BOOTCLASSPATH : %s" % bootclasspath)
        set_prop('Info', 'bootclasspath-jars', bootclasspath)

        # Version string
        version_string = self.generate_version_string()

        log.d(TAG, "Using version string: %s" % version_string)
        set_prop('Info', 'version-string', version_string)

        # Determine CPU bitness
        cpu_bits = self.determine_cpu_bits()
        if cpu_bits is None:
            self.do_shutdown(None, None)

        log.d(TAG, "Using %s-bit CPU" % cpu_bits)
        set_prop('Info', 'cpu-bits', cpu_bits)

        # Set the VM type (Dalvik|Art)
        vm_type = self.determine_vm_type(sdk, cpu_bits)
        if vm_type is None:
            self.do_shutdown(None, None)

        log.d(TAG, "Determined runtime: %s" % vm_type)
        set_prop('Info', 'vmtype', vm_type)

        # Make project directories
        mkdir(REPORTS_DIRECTORY)
        mkdir(DBS_DIRECTORY)
        mkdir(LOCAL_MODULES_DIRECTORY)

        set_prop('Local', 'reports-dir', REPORTS_DIRECTORY)
        set_prop('Local', 'db-dir', DBS_DIRECTORY)

        # Invoke client installation
        rtn = pkg.launch_builtin_module('client', ['install'])
        if rtn != 0:
            log.w(TAG, "Unable to install dtf client. Try manually.")

        return 0
Exemple #10
0
    def initialize_device(self, device_serial):
        """Perform the actual initialization"""

        log.d(TAG, "Preparing device: %s" % device_serial)

        touch(utils.CONFIG_FILE_NAME)

        set_prop('Info', 'serial', device_serial)

        # Since we have a serial now, lets create a new DtfAdb instance
        self.adb = DtfAdb.DtfAdb()

        # Kernel
        self.adb.shell_command('cat /proc/version')
        kernel = self.adb.get_output()[0]
        log.d(TAG, "Kernel version: %s" % kernel)
        set_prop('Info', 'kernel', kernel)

        # SDK
        sdk = self.getprop('ro.build.version.sdk')
        log.d(TAG, "Using SDK API %s" % sdk)
        set_prop('Info', 'SDK', sdk)

        self.adb.shell_command('set')
        set_output = self.adb.get_output()

        # $PATH
        path = get_set_value(set_output, 'PATH')
        if path is None:
            log.e(TAG, "Unable to get $PATH variable!")
            self.do_shutdown(None, None)
        log.d(TAG, "PATH : %s" % path)
        set_prop('Info', 'path', path)

        # $BOOTCLASSPTH
        bootclasspath = get_set_value(set_output, 'BOOTCLASSPATH')
        if bootclasspath is None:
            log.e(TAG, "Unable to get $BOOTCLASSPATH variable!")
            self.do_shutdown(None, None)
        log.d(TAG, "BOOTCLASSPATH : %s" % bootclasspath)
        set_prop('Info', 'bootclasspath-jars', bootclasspath)

        # Version string
        version_string = self.generate_version_string()

        log.d(TAG, "Using version string: %s" % version_string)
        set_prop('Info', 'version-string', version_string)

        # Determine CPU bitness
        cpu_bits = self.determine_cpu_bits()
        if cpu_bits is None:
            self.do_shutdown(None, None)

        log.d(TAG, "Using %s-bit CPU" % cpu_bits)
        set_prop('Info', 'cpu-bits', cpu_bits)

        # Set the VM type (Dalvik|Art)
        vm_type = self.determine_vm_type(sdk, cpu_bits)
        if vm_type is None:
            self.do_shutdown(None, None)

        log.d(TAG, "Determined runtime: %s" % vm_type)
        set_prop('Info', 'vmtype', vm_type)

        # Make project directories
        mkdir(REPORTS_DIRECTORY)
        mkdir(DBS_DIRECTORY)
        mkdir(LOCAL_MODULES_DIRECTORY)

        set_prop('Local', 'reports-dir', REPORTS_DIRECTORY)
        set_prop('Local', 'db-dir', DBS_DIRECTORY)

        # Invoke client installation
        rtn = pkg.launch_builtin_module('client', ['install'])
        if rtn != 0:
            log.w(TAG, "Unable to install dtf client. Try manually.")

        return 0
Exemple #11
0
    def initialize_device(self, init_device):
        """Perform the actual initialization"""

        device_serial = init_device['serial']

        log.d(TAG, "Preparing device: %s" % device_serial)

        utils.touch(utils.CONFIG_FILE_NAME)

        set_prop('Info', 'serial', device_serial)

        # Set the client section.
        set_prop('Client', 'mode', adb.MODE_USB)

        # Since we have a serial now, lets create a new DtfAdb instance
        self.adb = adb.DtfAdb()

        # Kernel
        self.adb.shell_command('cat /proc/version')
        kernel = self.adb.get_output()[0]
        log.d(TAG, "Kernel version: %s" % kernel)
        set_prop('Info', 'kernel', kernel)

        # SDK
        sdk = self.getprop('ro.build.version.sdk')
        log.d(TAG, "Using SDK API %s" % sdk)
        set_prop('Info', 'SDK', sdk)

        if int(sdk) > const.API_MAX:
            log.w(
                TAG,
                "API %s isn't supported by dtf (yet), results may vary!" % sdk)

        self.adb.shell_command('set')
        set_output = self.adb.get_output()

        # $PATH
        path = get_set_value(set_output, 'PATH')
        if path is None:
            log.e(TAG, "Unable to get $PATH variable!")
            self.do_shutdown(None, None)
        log.d(TAG, "PATH : %s" % path)
        set_prop('Info', 'path', path)

        # $BOOTCLASSPTH
        bootclasspath = get_set_value(set_output, 'BOOTCLASSPATH')
        if bootclasspath is None:
            log.e(TAG, "Unable to get $BOOTCLASSPATH variable!")
            self.do_shutdown(None, None)
        log.d(TAG, "BOOTCLASSPATH : %s" % bootclasspath)
        set_prop('Info', 'bootclasspath-jars', bootclasspath)

        # Version string
        version_string = self.generate_version_string()

        log.d(TAG, "Using version string: %s" % version_string)
        set_prop('Info', 'version-string', version_string)

        # Determine architecture and CPU bitness
        arch, cpu_bits = self.determine_cpu_arch()
        if cpu_bits is None:
            self.do_shutdown(None, None)

        log.d(TAG, "CPU Architecture: %s" % arch)
        set_prop("Info", "cpu-arch", arch)

        log.d(TAG, "Using %s-bit CPU" % cpu_bits)
        set_prop('Info', 'cpu-bits', cpu_bits)

        # Set the VM type (Dalvik|Art)
        vm_type = self.determine_vm_type(sdk, cpu_bits)
        if vm_type is None:
            self.do_shutdown(None, None)

        log.d(TAG, "Determined runtime: %s" % vm_type)
        set_prop('Info', 'vmtype', vm_type)

        # Determine SEAndroid
        se_state = self.determine_seandroid_state()

        log.d(TAG, "Determine SEAndroid state: %s" % se_state)
        set_prop('Info', 'seandroid-state', se_state)

        # Setup the directory structure
        self.make_project_directories()

        # Set directory related properties
        set_prop('Local', 'reports-dir', utils.REPORTS_DIRECTORY)
        set_prop('Local', 'db-dir', utils.DBS_DIRECTORY)

        # Invoke client installation
        rtn = pkg.launch_builtin_module('client', ['install'])
        if rtn != 0:
            log.w(TAG, "Unable to install dtf client. Try manually.")

        return 0