|
Packit |
534379 |
# Copyright(c) 2018, Intel Corporation
|
|
Packit |
534379 |
#
|
|
Packit |
534379 |
# Redistribution and use in source and binary forms, with or without
|
|
Packit |
534379 |
# modification, are permitted provided that the following conditions are met:
|
|
Packit |
534379 |
#
|
|
Packit |
534379 |
# * Redistributions of source code must retain the above copyright notice,
|
|
Packit |
534379 |
# this list of conditions and the following disclaimer.
|
|
Packit |
534379 |
# * Redistributions in binary form must reproduce the above copyright notice,
|
|
Packit |
534379 |
# this list of conditions and the following disclaimer in the documentation
|
|
Packit |
534379 |
# and/or other materials provided with the distribution.
|
|
Packit |
534379 |
# * Neither the name of Intel Corporation nor the names of its contributors
|
|
Packit |
534379 |
# may be used to endorse or promote products derived from this software
|
|
Packit |
534379 |
# without specific prior written permission.
|
|
Packit |
534379 |
#
|
|
Packit |
534379 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
Packit |
534379 |
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit |
534379 |
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
Packit |
534379 |
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
Packit |
534379 |
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
Packit |
534379 |
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
Packit |
534379 |
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
Packit |
534379 |
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
Packit |
534379 |
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
Packit |
534379 |
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
Packit |
534379 |
# POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
534379 |
import uuid
|
|
Packit |
534379 |
import unittest
|
|
Packit |
534379 |
NLB0 = "d8424dc4-a4a3-c413-f89e-433683f9040b"
|
|
Packit |
534379 |
|
|
Packit |
534379 |
# pylint: disable=E0602, E0603
|
|
Packit |
534379 |
|
|
Packit |
534379 |
class TestProperties(unittest.TestCase):
|
|
Packit |
534379 |
@classmethod
|
|
Packit |
534379 |
def setUpClass(cls):
|
|
Packit |
534379 |
cls.system = mockopae.test_system()
|
|
Packit |
534379 |
cls.platform = mockopae.test_platform.get("skx-p")
|
|
Packit |
534379 |
cls.system.initialize()
|
|
Packit |
534379 |
cls.system.prepare_sysfs(cls.platform)
|
|
Packit |
534379 |
opae.fpga.initialize(None)
|
|
Packit |
534379 |
|
|
Packit |
534379 |
@classmethod
|
|
Packit |
534379 |
def tearDownClass(cls):
|
|
Packit |
534379 |
cls.system.finalize()
|
|
Packit |
534379 |
|
|
Packit |
534379 |
def test_set_parent(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(type=opae.fpga.DEVICE)
|
|
Packit |
534379 |
toks = opae.fpga.enumerate([props])
|
|
Packit |
534379 |
assert len(toks) > 0
|
|
Packit |
534379 |
props2 = opae.fpga.properties(type=opae.fpga.ACCELERATOR,
|
|
Packit |
534379 |
parent=toks[0])
|
|
Packit |
534379 |
assert props2.parent
|
|
Packit |
534379 |
props2 = opae.fpga.properties(type=opae.fpga.ACCELERATOR)
|
|
Packit |
534379 |
props2.parent = toks[0]
|
|
Packit |
534379 |
assert props2.parent
|
|
Packit |
534379 |
|
|
Packit |
534379 |
def test_guid(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(guid=NLB0)
|
|
Packit |
534379 |
guid_str = props.guid
|
|
Packit |
534379 |
guid = uuid.UUID(guid_str)
|
|
Packit |
534379 |
assert str(guid).lower() == NLB0
|
|
Packit |
534379 |
props = opae.fpga.properties()
|
|
Packit |
534379 |
props.guid = NLB0
|
|
Packit |
534379 |
guid_str = props.guid
|
|
Packit |
534379 |
guid = uuid.UUID(guid_str)
|
|
Packit |
534379 |
assert str(guid).lower() == NLB0
|
|
Packit |
534379 |
|
|
Packit |
534379 |
def test_set_objtype_accelerator(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(type=opae.fpga.ACCELERATOR)
|
|
Packit |
534379 |
assert props.type == opae.fpga.ACCELERATOR
|
|
Packit |
534379 |
props = opae.fpga.properties(type=opae.fpga.DEVICE)
|
|
Packit |
534379 |
props.type = opae.fpga.ACCELERATOR
|
|
Packit |
534379 |
assert props.type == opae.fpga.ACCELERATOR
|
|
Packit |
534379 |
|
|
Packit |
534379 |
def test_set_objtype_device(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(type=opae.fpga.DEVICE)
|
|
Packit |
534379 |
assert props.type == opae.fpga.DEVICE
|
|
Packit |
534379 |
props = opae.fpga.properties(type=opae.fpga.ACCELERATOR)
|
|
Packit |
534379 |
props.type = opae.fpga.DEVICE
|
|
Packit |
534379 |
assert props.type == opae.fpga.DEVICE
|
|
Packit |
534379 |
|
|
Packit |
534379 |
def test_set_segment(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(segment=0x9090)
|
|
Packit |
534379 |
assert props.segment == 0x9090
|
|
Packit |
534379 |
props.segment = 0xA1A1
|
|
Packit |
534379 |
assert props.segment == 0xA1A1
|
|
Packit |
534379 |
|
|
Packit |
534379 |
def test_set_bus(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(bus=0x5e)
|
|
Packit |
534379 |
assert props.bus == 0x5e
|
|
Packit |
534379 |
props.bus = 0xbe
|
|
Packit |
534379 |
assert props.bus == 0xbe
|
|
Packit |
534379 |
|
|
Packit |
534379 |
def test_set_device(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(device=0xe)
|
|
Packit |
534379 |
assert props.device == 0xe
|
|
Packit |
534379 |
props.device = 0xf
|
|
Packit |
534379 |
assert props.device == 0xf
|
|
Packit |
534379 |
|
|
Packit |
534379 |
def test_set_function(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(function=0x7)
|
|
Packit |
534379 |
assert props.function == 0x7
|
|
Packit |
534379 |
props.function = 0x6
|
|
Packit |
534379 |
assert props.function == 0x6
|
|
Packit |
534379 |
|
|
Packit |
534379 |
def test_set_socket_id(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(socket_id=1)
|
|
Packit |
534379 |
assert props.socket_id == 1
|
|
Packit |
534379 |
props.socket_id = 0
|
|
Packit |
534379 |
assert props.socket_id == 0
|
|
Packit |
534379 |
|
|
Packit |
534379 |
def test_set_object_id(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(object_id=0xcafe)
|
|
Packit |
534379 |
assert props.object_id == 0xcafe
|
|
Packit |
534379 |
props.object_id = 0xfade
|
|
Packit |
534379 |
assert props.object_id == 0xfade
|
|
Packit |
534379 |
|
|
Packit |
534379 |
def test_set_num_errors(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(num_errors=8)
|
|
Packit |
534379 |
assert props.num_errors == 8
|
|
Packit |
534379 |
props.num_errors = 4
|
|
Packit |
534379 |
assert props.num_errors == 4
|
|
Packit |
534379 |
|
|
Packit |
534379 |
def test_set_num_slots(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(type=opae.fpga.DEVICE,
|
|
Packit |
534379 |
num_slots=3)
|
|
Packit |
534379 |
assert props.num_slots == 3
|
|
Packit |
534379 |
props.num_slots = 2
|
|
Packit |
534379 |
assert props.num_slots == 2
|
|
Packit |
534379 |
|
|
Packit |
534379 |
def test_set_bbs_id(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(type=opae.fpga.DEVICE,
|
|
Packit |
534379 |
bbs_id=0xc0c0cafe)
|
|
Packit |
534379 |
assert props.bbs_id == 0xc0c0cafe
|
|
Packit |
534379 |
props.bbs_id = 0xb0b0fade
|
|
Packit |
534379 |
assert props.bbs_id == 0xb0b0fade
|
|
Packit |
534379 |
|
|
Packit |
534379 |
def test_set_bbs_version(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(type=opae.fpga.DEVICE,
|
|
Packit |
534379 |
bbs_version=(0, 1, 2))
|
|
Packit |
534379 |
assert props.bbs_version == (0, 1, 2)
|
|
Packit |
534379 |
props.bbs_version = (1, 2, 3)
|
|
Packit |
534379 |
assert props.bbs_version == (1, 2, 3)
|
|
Packit |
534379 |
|
|
Packit |
534379 |
def test_set_vendor_id(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(vendor_id=0xfafa)
|
|
Packit |
534379 |
assert props.vendor_id == 0xfafa
|
|
Packit |
534379 |
props.vendor_id = 0xdada
|
|
Packit |
534379 |
assert props.vendor_id == 0xdada
|
|
Packit |
534379 |
|
|
Packit |
534379 |
def test_set_device_id(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(device_id=0xfa)
|
|
Packit |
534379 |
assert props.device_id == 0xfa
|
|
Packit |
534379 |
props.device_id = 0xda
|
|
Packit |
534379 |
assert props.device_id == 0xda
|
|
Packit |
534379 |
|
|
Packit |
534379 |
@unittest.skip("model not implemented yet")
|
|
Packit |
534379 |
def test_set_model(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(model="intel skxp")
|
|
Packit |
534379 |
assert props.model == "intel skxp"
|
|
Packit |
534379 |
props.model = "intel skxp 2"
|
|
Packit |
534379 |
assert props.model == "intel skxp 2"
|
|
Packit |
534379 |
|
|
Packit |
534379 |
@unittest.skip("local_memory_size not implemented yet")
|
|
Packit |
534379 |
def test_set_local_memory_size(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(local_memory_size=0xffff)
|
|
Packit |
534379 |
assert props.local_memory_size == 0xffff
|
|
Packit |
534379 |
props.local_memory_size = 0xaaaa
|
|
Packit |
534379 |
assert props.local_memory_size == 0xaaaa
|
|
Packit |
534379 |
|
|
Packit |
534379 |
@unittest.skip("capabilities not implemented yet")
|
|
Packit |
534379 |
def test_set_capabilities(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(capabilities=0xdeadbeef)
|
|
Packit |
534379 |
assert props.capabilities == 0xdeadbeef
|
|
Packit |
534379 |
props.capabilities = 0xfeebdaed
|
|
Packit |
534379 |
assert props.capabilities == 0xfeebdaed
|
|
Packit |
534379 |
|
|
Packit |
534379 |
def test_set_num_mmio(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(type=opae.fpga.ACCELERATOR,
|
|
Packit |
534379 |
num_mmio=4)
|
|
Packit |
534379 |
assert props.num_mmio == 4
|
|
Packit |
534379 |
props.num_mmio = 5
|
|
Packit |
534379 |
assert props.num_mmio == 5
|
|
Packit |
534379 |
|
|
Packit |
534379 |
def test_set_num_interrupts(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(type=opae.fpga.ACCELERATOR,
|
|
Packit |
534379 |
num_interrupts=9)
|
|
Packit |
534379 |
assert props.num_interrupts == 9
|
|
Packit |
534379 |
props.num_interrupts = 8
|
|
Packit |
534379 |
assert props.num_interrupts == 8
|
|
Packit |
534379 |
|
|
Packit |
534379 |
def test_set_accelerator_state(self):
|
|
Packit |
534379 |
props = opae.fpga.properties(
|
|
Packit |
534379 |
type=opae.fpga.ACCELERATOR,
|
|
Packit |
534379 |
accelerator_state=opae.fpga.ACCELERATOR_ASSIGNED)
|
|
Packit |
534379 |
assert props.accelerator_state == opae.fpga.ACCELERATOR_ASSIGNED
|
|
Packit |
534379 |
props.accelerator_state = opae.fpga.ACCELERATOR_UNASSIGNED
|
|
Packit |
534379 |
assert props.accelerator_state == opae.fpga.ACCELERATOR_UNASSIGNED
|
|
Packit |
534379 |
|
|
Packit |
534379 |
|