def test_str_with_boot_script(self):
     metadata = Metadata("ahwpack",
                         "4",
                         "armel",
                         format=HardwarePackFormatV2())
     metadata.add_v2_config(boot_script='boot.scr')
     expected_out = ("NAME=ahwpack\nVERSION=4\nARCHITECTURE=armel\n"
                     "BOOT_SCRIPT=boot.scr\n")
     self.assertEqual(expected_out, str(metadata))
 def test_str_with_initrd_file(self):
     metadata = Metadata("ahwpack",
                         "4",
                         "armel",
                         format=HardwarePackFormatV2())
     metadata.add_v2_config(initrd='boot/initrd.img-3.0.0-1002-linaro-omap')
     expected_out = ("NAME=ahwpack\nVERSION=4\nARCHITECTURE=armel\n"
                     "INITRD_FILE=boot/initrd.img-3.0.0-1002-linaro-omap\n")
     self.assertEqual(expected_out, str(metadata))
 def test_str_with_loader_min_size(self):
     metadata = Metadata("ahwpack",
                         "4",
                         "armel",
                         format=HardwarePackFormatV2())
     metadata.add_v2_config(loader_min_size='1')
     expected_out = ("NAME=ahwpack\nVERSION=4\nARCHITECTURE=armel\n"
                     "LOADER_MIN_SIZE=1\n")
     self.assertEqual(expected_out, str(metadata))
 def test_str_with_kernel_file(self):
     metadata = Metadata("ahwpack",
                         "4",
                         "armel",
                         format=HardwarePackFormatV2())
     metadata.add_v2_config(vmlinuz='boot/vmlinuz-3.0.0-1002-linaro-omap')
     expected_out = ("NAME=ahwpack\nVERSION=4\nARCHITECTURE=armel\n"
                     "KERNEL_FILE=boot/vmlinuz-3.0.0-1002-linaro-omap\n")
     self.assertEqual(expected_out, str(metadata))
 def test_str_with_mmc_id(self):
     metadata = Metadata("ahwpack",
                         "4",
                         "armel",
                         format=HardwarePackFormatV2())
     metadata.add_v2_config(mmc_id='1')
     expected_out = ("NAME=ahwpack\nVERSION=4\nARCHITECTURE=armel\n"
                     "MMC_ID=1\n")
     self.assertEqual(expected_out, str(metadata))
 def test_str_with_partition_layout(self):
     metadata = Metadata("ahwpack",
                         "4",
                         "armel",
                         format=HardwarePackFormatV2())
     metadata.add_v2_config(partition_layout='bootfs_rootfs')
     expected_out = ("NAME=ahwpack\nVERSION=4\nARCHITECTURE=armel\n"
                     "PARTITION_LAYOUT=bootfs_rootfs\n")
     self.assertEqual(expected_out, str(metadata))
 def test_str_with_wireless_interfaces(self):
     metadata = Metadata("ahwpack",
                         "4",
                         "armel",
                         format=HardwarePackFormatV2())
     metadata.add_v2_config(wireless_interfaces=['wlan0', 'wl0'])
     expected_out = ("NAME=ahwpack\nVERSION=4\nARCHITECTURE=armel\n"
                     "WIRELESS_INTERFACES=wlan0 wl0\n")
     self.assertEqual(expected_out, str(metadata))
 def test_str_with_dtb_addr(self):
     metadata = Metadata("ahwpack",
                         "4",
                         "armel",
                         format=HardwarePackFormatV2())
     metadata.add_v2_config(dtb_addr='0x80000000')
     expected_out = ("NAME=ahwpack\nVERSION=4\nARCHITECTURE=armel\n"
                     "DTB_ADDR=0x80000000\n")
     self.assertEqual(expected_out, str(metadata))
 def test_str_with_serial_tty(self):
     metadata = Metadata("ahwpack",
                         "4",
                         "armel",
                         format=HardwarePackFormatV2())
     metadata.add_v2_config(serial_tty='ttyO2')
     expected_out = ("NAME=ahwpack\nVERSION=4\nARCHITECTURE=armel\n"
                     "SERIAL_TTY=ttyO2\n")
     self.assertEqual(expected_out, str(metadata))
 def test_str_with_extra_serial_options(self):
     metadata = Metadata("ahwpack",
                         "4",
                         "armel",
                         format=HardwarePackFormatV2())
     metadata.add_v2_config(
         extra_serial_options='console=tty0 console=ttyO2,115200n8')
     expected_out = ("NAME=ahwpack\nVERSION=4\n"
                     "ARCHITECTURE=armel\nEXTRA_SERIAL_OPTIONS="
                     "console=tty0 console=ttyO2,115200n8\n")
     self.assertEqual(expected_out, str(metadata))
 def test_str_with_dtb_file(self):
     metadata = Metadata("ahwpack",
                         "4",
                         "armel",
                         format=HardwarePackFormatV2())
     metadata.add_v2_config(
         dtb_file='boot/dt-3.0.0-1002-linaro-omap/omap4-panda.dtb')
     expected_out = ("NAME=ahwpack\nVERSION=4\n"
                     "ARCHITECTURE=armel\nDTB_FILE="
                     "boot/dt-3.0.0-1002-linaro-omap/omap4-panda.dtb\n")
     self.assertEqual(expected_out, str(metadata))
 def test_str_with_extra_boot_options(self):
     metadata = Metadata("ahwpack",
                         "4",
                         "armel",
                         format=HardwarePackFormatV2())
     metadata.add_v2_config(extra_boot_options=(
         'earlyprintk fixrtc nocompcache vram=48M omapfb.vram=0:24M '
         'mem=456M@0x80000000 mem=512M@0xA0000000'))
     expected_out = ("NAME=ahwpack\nVERSION=4\nARCHITECTURE=armel\n"
                     "EXTRA_BOOT_OPTIONS=earlyprintk fixrtc nocompcache "
                     "vram=48M omapfb.vram=0:24M "
                     "mem=456M@0x80000000 mem=512M@0xA0000000\n")
     self.assertEqual(expected_out, str(metadata))
Exemplo n.º 13
0
    def format(self):
        """The format of the hardware pack. A subclass of HardwarePackFormat.
        """
        if isinstance(self.parser, ConfigParser.RawConfigParser):
            try:
                format_string = self.parser.get(self.MAIN_SECTION,
                                                FORMAT_FIELD)
            except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
                # Default to 1.0 to aviod breaking existing hwpack files.
                # When this code no longer supports 1.0, it effectively makes
                # explicitly specifying format in hwpack files mandatory.
                format_string = "1.0"
        else:
            format_string = self.parser.get(FORMAT_FIELD)

        if format_string == '1.0':
            return HardwarePackFormatV1()
        elif format_string == '2.0':
            return HardwarePackFormatV2()
        elif format_string == 3.0 or format_string == '3.0':
            return HardwarePackFormatV3()
        else:
            raise HwpackConfigError("Format version '%s' is not supported." %
                                    format_string)