~linaro-image-tools/linaro-image-tools/trunk

« back to all changes in this revision

Viewing changes to linaro_image_tools/media_create/tests/test_media_create.py

  • Committer: Mattias Backman
  • Date: 2011-08-23 10:48:46 UTC
  • mfrom: (417.2.4 bug-829220)
  • Revision ID: mattias.backman@linaro.org-20110823104846-tc8z4neur5rya6r3
Allow Snowball startfiles.cfg to specify full path to each individual startfile. If an absolute path is not specified, the files are assumed to be in /boot of the chroot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
716
716
            i += 1
717
717
        return expected
718
718
 
 
719
    def test_get_file_info_relative_path(self):
 
720
        # Create a config file
 
721
        cfg_file = os.path.join(self.temp_bootdir_path,
 
722
                      boards.SnowballEmmcConfig.SNOWBALL_STARTUP_FILES_CONFIG)
 
723
        uboot_file = 'u-boot.bin'
 
724
        with open(cfg_file, 'w') as f:
 
725
                f.write('%s %s %i %#x %s\n' % ('NORMAL', uboot_file, 0,
 
726
                                               0xBA0000, '9'))
 
727
        with open(os.path.join(self.temp_bootdir_path, uboot_file), 'w') as f:
 
728
            file_info = boards.SnowballEmmcConfig.get_file_info(
 
729
                self.tempdir)
 
730
        self.assertEquals(file_info[0]['filename'],
 
731
                          os.path.join(self.temp_bootdir_path, uboot_file))
 
732
 
 
733
    def test_get_file_info_abs_path(self):
 
734
        # Create a config file
 
735
        cfg_file = os.path.join(self.temp_bootdir_path,
 
736
                      boards.SnowballEmmcConfig.SNOWBALL_STARTUP_FILES_CONFIG)
 
737
        uboot_dir = tempfile.mkdtemp(dir=self.tempdir)
 
738
        uboot_file = os.path.join(uboot_dir, 'u-boot.bin')
 
739
        uboot_relative_file = uboot_file.replace(self.tempdir, '')
 
740
        with open(cfg_file, 'w') as f:
 
741
                f.write('%s %s %i %#x %s\n' % ('NORMAL', uboot_relative_file, 0,
 
742
                                               0xBA0000, '9'))
 
743
        with open(uboot_file, 'w') as f:
 
744
            file_info = boards.SnowballEmmcConfig.get_file_info(
 
745
                self.tempdir)
 
746
        self.assertEquals(file_info[0]['filename'], uboot_file)
 
747
 
 
748
    def test_get_file_info_raises(self):
 
749
        # Create a config file
 
750
        cfg_file = os.path.join(self.temp_bootdir_path,
 
751
                      boards.SnowballEmmcConfig.SNOWBALL_STARTUP_FILES_CONFIG)
 
752
        with open(cfg_file, 'w') as f:
 
753
                f.write('%s %s %i %#x %s\n' % ('NORMAL', 'u-boot.bin', 0,
 
754
                                               0xBA0000, '9'))
 
755
        self.assertRaises(AssertionError, boards.SnowballEmmcConfig.get_file_info,
 
756
                          self.tempdir)
 
757
 
719
758
    def test_file_name_size(self):
720
759
        ''' Test using a to large toc file '''
721
760
        _, toc_filename = tempfile.mkstemp()
829
868
    def test_normal_case(self):
830
869
        expected = self.setupFiles()
831
870
        actual = boards.SnowballEmmcConfig.get_file_info(
832
 
            self.temp_bootdir_path)
 
871
            self.tempdir)
833
872
        self.assertEquals(expected, actual)
834
873
 
835
874