Exemple #1
0
    def test_is_updatable(self):
        """ Test node.is_updatable method """
        for node in self.nodes:
            max_size = 12288 - 60
            filename = random_file(max_size)
            images = [
                TestImage(filename, "SOC_ELF"),
                TestImage(filename, "CDB"),
                TestImage(filename, "UBOOTENV")
            ]

            # should pass
            package = FirmwarePackage()
            package.images = images
            self.assertTrue(node.is_updatable(package))

            # should fail if the firmware version is wrong
            package = FirmwarePackage()
            package.images = images
            package.version = "ECX-31415-v0.0.0"
            self.assertFalse(node.is_updatable(package))

            # should fail if we specify a socman version
            package = FirmwarePackage()
            package.images = images
            package.required_socman_version = "0.0.1"
            self.assertFalse(node.is_updatable(package))

            # should fail if we try to upload a slot2
            package = FirmwarePackage()
            package.images = images
            package.config = "slot2"
            self.assertFalse(node.is_updatable(package))

            # should fail if we upload an image that's too large
            package = FirmwarePackage()
            package.images = [TestImage(random_file(max_size + 1), "UBOOTENV")]
            self.assertFalse(node.is_updatable(package))

            # should fail if we upload to a CDB partition that's in use
            package = FirmwarePackage()
            package.images = images
            self.assertFalse(node.is_updatable(package, partition_arg="ACTIVE"))
Exemple #2
0
    def test_multiple_uploads():
        """ Test to make sure FDs are being closed """
        # Create image
        filename = random_file(1024)
        image = TestImage(filename, "RAW")

        for _ in xrange(2048):
            image.render_to_simg(0, 0)

        os.remove(filename)
Exemple #3
0
    def test_multiple_uploads():
        """ Test to make sure FDs are being closed """
        # Create image
        filename = random_file(1024)
        image = TestImage(filename, "RAW")

        for _ in xrange(2048):
            image.render_to_simg(0, 0)

        os.remove(filename)
Exemple #4
0
 def test_put_and_get(self):
     """Test the put_file(src, dest) function. Test the get_file(src,dest)
     function by movign local files around using the TFT Protocol.
     """
     # Create file
     filename = random_file(1024)
     contents = open(filename).read()
     # Upload and remove original file
     basename = os.path.basename(filename)
     self.etftp.put_file(src=filename, dest=basename)
     os.remove(filename)
     self.assertFalse(os.path.exists(filename))
     # Download
     self.etftp.get_file(src=basename, dest=filename)
     # Verify match
     self.assertEqual(open(filename).read(), contents)
     os.remove(filename)
Exemple #5
0
 def test_put_and_get(self):
     """Test the put_file(src, dest) function. Test the get_file(src,dest)
     function by movign local files around using the TFT Protocol.
     """
     # Create file
     filename = random_file(1024)
     contents = open(filename).read()
     # Upload and remove original file
     basename = os.path.basename(filename)
     self.etftp.put_file(src=filename, dest=basename)
     os.remove(filename)
     self.assertFalse(os.path.exists(filename))
     # Download
     self.etftp.get_file(src=basename, dest=filename)
     # Verify match
     self.assertEqual(open(filename).read(), contents)
     os.remove(filename)
Exemple #6
0
    def test_render_to_simg(self):
        """ Test image creation and upload """
        imglen = 1024
        priority = 1
        daddr = 12345

        # Create image
        filename = random_file(imglen)
        contents = open(filename).read()
        image = TestImage(filename, "RAW")

        # Render and examine image
        filename = image.render_to_simg(priority, daddr)
        simg = open(filename).read()
        header = get_simg_header(simg)
        self.assertEqual(header.priority, priority)
        self.assertEqual(header.imglen, imglen)
        self.assertEqual(header.daddr, daddr)
        self.assertEqual(simg[header.imgoff:], contents)
Exemple #7
0
    def test_render_to_simg(self):
        """ Test image creation and upload """
        imglen = 1024
        priority = 1
        daddr = 12345

        # Create image
        filename = random_file(imglen)
        contents = open(filename).read()
        image = TestImage(filename, "RAW")

        # Render and examine image
        filename = image.render_to_simg(priority, daddr)
        simg = open(filename).read()
        header = get_simg_header(simg)
        self.assertEqual(header.priority, priority)
        self.assertEqual(header.imglen, imglen)
        self.assertEqual(header.daddr, daddr)
        self.assertEqual(simg[header.imgoff:], contents)
Exemple #8
0
    def test_put_and_get(self):
        """ Test file transfers on an internal host """

        # Create file
        filename = random_file(1024)
        contents = open(filename).read()

        # Upload and remove
        basename = os.path.basename(filename)
        self.tftp1.put_file(filename, basename)
        os.remove(filename)
        self.assertFalse(os.path.exists(filename))

        # Download
        self.tftp1.get_file(basename, filename)

        # Verify match
        self.assertEqual(open(filename).read(), contents)
        os.remove(filename)
Exemple #9
0
    def test_put_and_get(self):
        """ Test file transfers on an internal host """

        # Create file
        filename = random_file(1024)
        contents = open(filename).read()

        # Upload and remove
        basename = os.path.basename(filename)
        self.tftp1.put_file(filename, basename)
        os.remove(filename)
        self.assertFalse(os.path.exists(filename))

        # Download
        self.tftp1.get_file(basename, filename)

        # Verify match
        self.assertEqual(open(filename).read(), contents)
        os.remove(filename)