Files
xen/tools/python/xen/migration/tests.py
T
Andrew Cooper fd8fecb97b tools/python: Improve unit test handling
* Add X86_{CPUID,MSR}_POLICY_FORMAT checks which were missed previously.
 * Drop test_suite().  It hasn't been necessary since the Py2.3 era.
 * Drop the __main__ logic.  This can't be used without manually adjusting the
   include path, and `make test` knows how to do the right thing.
 * For `make test`, use `-v` to see which tests have been discovered and run.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
2023-03-17 10:44:16 +00:00

45 lines
1.3 KiB
Python

#!/usr/bin/env python
# -*- 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)