summaryrefslogtreecommitdiff
path: root/tools/python/xen/migration/tests.py
blob: fcf94b0bb2644901313df07c8a06794e6e304013 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: utf-8 -*-

"""
Unit tests for migration v2 streams
"""

import unittest

from struct import calcsize

from xen.migration import libxc, libxl

class TestLibxc(unittest.TestCase):

    def test_format_sizes(self):

        for fmt, sz in ( (libxc.IHDR_FORMAT, 24),
                         (libxc.DHDR_FORMAT, 16),
                         (libxc.RH_FORMAT, 8),

                         (libxc.PAGE_DATA_FORMAT, 8),
                         (libxc.X86_PV_INFO_FORMAT, 8),
                         (libxc.X86_PV_P2M_FRAMES_FORMAT, 8),
                         (libxc.X86_PV_VCPU_HDR_FORMAT, 8),
                         (libxc.X86_TSC_INFO_FORMAT, 24),
                         (libxc.HVM_PARAMS_ENTRY_FORMAT, 16),
                         (libxc.HVM_PARAMS_FORMAT, 8),
                         (libxc.X86_CPUID_POLICY_FORMAT, 24),
                         (libxc.X86_MSR_POLICY_FORMAT, 16),
                         ):
            self.assertEqual(calcsize(fmt), sz)


class TestLibxl(unittest.TestCase):

    def test_format_sizes(self):

        for fmt, sz in ( (libxl.HDR_FORMAT, 16),
                         (libxl.RH_FORMAT, 8),

                         (libxl.EMULATOR_HEADER_FORMAT, 8),
                         ):
            self.assertEqual(calcsize(fmt), sz)