Skip to content

Commit

Permalink
Merge branch 'Fix_locate_connected_machine' of https://github.com/Spi…
Browse files Browse the repository at this point in the history
…NNakerManchester/SpiNNMan into Fix_locate_connected_machine
  • Loading branch information
rowleya committed Jun 23, 2021
2 parents be98bba + 6cb3a87 commit ec43bde
Show file tree
Hide file tree
Showing 24 changed files with 104 additions and 10 deletions.
4 changes: 2 additions & 2 deletions spinnman/config_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
BASE_CONFIG_FILE = "spinnman.cfg"


def reset_configs():
def unittest_setup():
"""
Resets the configs so only the local default config is included.
.. note::
This file should only be called from SpiNNMan/unittests
"""
clear_cfg_files()
clear_cfg_files(True)
add_spinnman_cfg()


Expand Down
5 changes: 5 additions & 0 deletions unittests/connection_tests/test_udp_boot_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@

import unittest
from spinnman.connections.udp_packet_connections import BootConnection
from spinnman.config_setup import unittest_setup


class MyTestCase(unittest.TestCase):

def setUp(self):
unittest_setup()

def test_something(self):
udp_connect = BootConnection()
self.assertIsNotNone(udp_connect)
Expand Down
4 changes: 4 additions & 0 deletions unittests/connection_tests/test_udp_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import unittest
from spinnman.connections.udp_packet_connections import SCAMPConnection
from spinnman.config_setup import unittest_setup
from spinnman.exceptions import SpinnmanTimeoutException
from spinnman.messages.scp.impl import GetVersion, ReadLink, ReadMemory
from spinnman.messages.scp.enums import SCPResult
Expand All @@ -26,6 +27,9 @@

class TestUDPConnection(unittest.TestCase):

def setUp(self):
unittest_setup()

def test_scp_version_request_and_response_board(self):
board_config.set_up_remote_board()
connection = SCAMPConnection(
Expand Down
2 changes: 2 additions & 0 deletions unittests/model_tests/test_abstract_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from spinnman.processes.abstract_single_connection_process import (
AbstractSingleConnectionProcess)
from spinnman.messages.scp.impl import ReadMemory
from spinnman.config_setup import unittest_setup
from spinnman.connections.udp_packet_connections import SCAMPConnection
from spinnman.exceptions import (
SpinnmanTimeoutException, SpinnmanGenericProcessException)
Expand All @@ -41,6 +42,7 @@ def receive_scp_response(self, timeout=1.0):


def test_error_print():
unittest_setup()
connection = MockConnection(0, 0)
process = MockProcess(RoundRobinConnectionSelector([connection]))
with pytest.raises(SpinnmanGenericProcessException):
Expand Down
5 changes: 5 additions & 0 deletions unittests/model_tests/test_core_subset_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@

import unittest
from spinn_machine import CoreSubset
from spinnman.config_setup import unittest_setup


class TestCoreSubset(unittest.TestCase):

def setUp(self):
unittest_setup()

def test_create_new_core_subset(self):
proc_list = [0, 1, 2, 3, 5, 8, 13]
cs = CoreSubset(0, 0, proc_list)
Expand Down
5 changes: 5 additions & 0 deletions unittests/model_tests/test_core_subsets_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@

import unittest
from spinn_machine import CoreSubset, CoreSubsets
from spinnman.config_setup import unittest_setup


class TestCoreSubsets(unittest.TestCase):

def setUp(self):
unittest_setup()

def test_create_new_default_core_subsets(self):
css = CoreSubsets()
self.assertIsNotNone(css, "must make instance of CoreSubsets")
Expand Down
5 changes: 5 additions & 0 deletions unittests/model_tests/test_io_buff_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@

import unittest
from spinnman.model import IOBuffer
from spinnman.config_setup import unittest_setup


class TestingIOBuf(unittest.TestCase):

def setUp(self):
unittest_setup()

def test_new_buf(self):
iobuf = IOBuffer(0, 1, 2, 'Everything failed on chip.')
self.assertIsNotNone(iobuf)
Expand Down
5 changes: 5 additions & 0 deletions unittests/model_tests/test_iptag_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@
import unittest
from spinn_machine.tags import IPTag
from board_test_configuration import BoardTestConfiguration
from spinnman.config_setup import unittest_setup

board_config = BoardTestConfiguration()


class TestIptag(unittest.TestCase):

def setUp(self):
unittest_setup()

def test_new_iptag(self):
board_config.set_up_remote_board()
ip = "8.8.8.8"
Expand Down
4 changes: 4 additions & 0 deletions unittests/model_tests/test_machine_dimensions_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@

import unittest
from spinnman.model import MachineDimensions
from spinnman.config_setup import unittest_setup


class TestMachineDimensionsModel(unittest.TestCase):

def setUp(self):
unittest_setup()

def test_new_iptag(self):
x_max = 253
y_max = 220
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@
import unittest
from spinnman.model.enums import MailboxCommand, CPUState, RunTimeError
from spinnman.constants import ROUTER_REGISTER_REGISTERS
from spinnman.config_setup import unittest_setup


class TestingEnums(unittest.TestCase):

def setUp(self):
unittest_setup()

def test_mailbox_command_enum(self):
self.assertEqual(MailboxCommand.SHM_IDLE.value, 0)
self.assertEqual(MailboxCommand.SHM_MSG.value, 1)
Expand Down
5 changes: 5 additions & 0 deletions unittests/model_tests/test_version_info_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@
import unittest
import struct
from spinnman.model import VersionInfo
from spinnman.config_setup import unittest_setup
from spinnman.exceptions import SpinnmanInvalidParameterException


class TestVersionInfo(unittest.TestCase):

def setUp(self):
unittest_setup()

def test_retrieving_bits_from_version_data(self):
p2p_adr = 0xf0a1
phys_cpu = 0xff
Expand Down
5 changes: 5 additions & 0 deletions unittests/scp_tests/test_count_state_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import unittest
from struct import pack
from spinnman.config_setup import unittest_setup
from spinnman.exceptions import SpinnmanUnexpectedResponseCodeException
from spinnman.messages.scp.impl.count_state_response import (
CountStateResponse)
Expand All @@ -23,6 +24,10 @@


class TestCPUStateResponse(unittest.TestCase):

def setUp(self):
unittest_setup()

def test_new_count_state_response(self):
response = CountStateResponse()
# SCP Stuff
Expand Down
5 changes: 5 additions & 0 deletions unittests/scp_tests/test_scp_check_ok_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@

import struct
import unittest
from spinnman.config_setup import unittest_setup
from spinnman.exceptions import SpinnmanUnexpectedResponseCodeException
from spinnman.messages.scp.impl import CheckOKResponse
from spinnman.messages.scp.enums import SCPResult
from spinnman.messages.sdp import SDPFlag


class TestOkResponse(unittest.TestCase):

def setUp(self):
unittest_setup()

def test_new_scp_check_ok_response(self):
CheckOKResponse("Testing operation", "Testing command")

Expand Down
5 changes: 5 additions & 0 deletions unittests/scp_tests/test_scp_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import unittest
from spinnman.config_setup import unittest_setup
from spinnman.messages.scp.enums import IPTagCommand
from spinnman.messages.scp.enums import SCPCommand
from spinnman.messages.scp.enums import SCPResult
Expand All @@ -22,6 +23,10 @@


class TestSCPEnums(unittest.TestCase):

def setUp(self):
unittest_setup()

def test_iptag(self):
self.assertEqual(IPTagCommand.NEW.value, 0)
self.assertEqual(IPTagCommand.SET.value, 1)
Expand Down
5 changes: 5 additions & 0 deletions unittests/scp_tests/test_scp_message_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import unittest
from spinnman.config_setup import unittest_setup
from spinnman.messages.scp import SCPRequestHeader
from spinnman.messages.scp.enums import SCPCommand
from spinnman.messages.scp.impl import GetVersion, ReadLink, ReadMemory


class TestSCPMessageAssembly(unittest.TestCase):

def setUp(self):
unittest_setup()

def test_create_new_scp_header(self):
header = SCPRequestHeader(SCPCommand.CMD_VER)

Expand Down
5 changes: 5 additions & 0 deletions unittests/scp_tests/test_scp_version_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import unittest
from spinnman.config_setup import unittest_setup
from spinnman.messages.scp.impl import GetVersion
from spinnman.messages.scp.enums import SCPCommand


class TestSCPVersionRequest(unittest.TestCase):

def setUp(self):
unittest_setup()

def test_new_version_request(self):
ver_request = GetVersion(0, 1, 2)
self.assertEqual(ver_request.scp_request_header.command,
Expand Down
5 changes: 5 additions & 0 deletions unittests/scp_tests/test_scp_version_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@

import unittest
from struct import pack
from spinnman.config_setup import unittest_setup
from spinnman.messages.scp.impl.get_version_response import GetVersionResponse
from spinnman.messages.scp.enums import SCPResult
from spinnman.messages.sdp import SDPFlag


class TestSCPVersionResponse(unittest.TestCase):

def setUp(self):
unittest_setup()

def test_new_scp_version_response(self):
GetVersionResponse()

Expand Down
5 changes: 5 additions & 0 deletions unittests/sdp_tests/test_sdp_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import unittest
from spinnman.config_setup import unittest_setup
from spinnman.messages.sdp.sdp_flag import SDPFlag


class TestSDPEnums(unittest.TestCase):

def setUp(self):
unittest_setup()

def test_sdp_flag(self):
self.assertEqual(SDPFlag.REPLY_NOT_EXPECTED.value, 0x7)
self.assertEqual(SDPFlag.REPLY_EXPECTED.value, 0x87)
Expand Down
5 changes: 5 additions & 0 deletions unittests/test_boot_message_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@

import unittest
import spinnman.messages.spinnaker_boot.spinnaker_boot_message as boot_msg
from spinnman.config_setup import unittest_setup
from spinnman.messages.spinnaker_boot import SpinnakerBootOpCode


class TestSpiNNakerBootMessage(unittest.TestCase):

def setUp(self):
unittest_setup()

def test_create_new_boot_message(self):
msg = boot_msg.SpinnakerBootMessage(SpinnakerBootOpCode.HELLO, 0, 0, 0)
self.assertEqual(msg.data, None)
Expand Down
7 changes: 3 additions & 4 deletions unittests/test_cfg_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
import os
import unittest
from spinn_utilities.config_holder import run_config_checks
from spinnman.config_setup import reset_configs
from spinnman.config_setup import unittest_setup


class TestCfgChecker(unittest.TestCase):

@classmethod
def setUpClass(cls):
reset_configs()
def setUp(self):
unittest_setup()

def test_config_checks(self):
unittests = os.path.dirname(__file__)
Expand Down
2 changes: 2 additions & 0 deletions unittests/test_import_all_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

class ImportAllModule(unittest.TestCase):

# no unittest_setup to check all imports work without it

def test_import_all(self):
if os.environ.get('CONTINUOUS_INTEGRATION', 'false').lower() == 'true':
package_loader.load_module("spinnman", remove_pyc_files=False)
Expand Down
5 changes: 5 additions & 0 deletions unittests/test_multicast_message_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import unittest
from spinnman.config_setup import unittest_setup
import spinnman.messages.multicast_message as multicast_msg


class TestMulticastMessage(unittest.TestCase):

def setUp(self):
unittest_setup()

def test_create_new_multicast_message_without_payload(self):
msg = multicast_msg.MulticastMessage(1)
self.assertEqual(msg.key, 1)
Expand Down
7 changes: 3 additions & 4 deletions unittests/test_transceiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import unittest
import struct
from spinn_machine import virtual_machine
from spinnman.config_setup import reset_configs
from spinnman.config_setup import unittest_setup
from spinnman.transceiver import Transceiver
from spinnman import constants
from spinnman.messages.spinnaker_boot.system_variable_boot_values import (
Expand Down Expand Up @@ -55,9 +55,8 @@ def write_memory(

class TestTransceiver(unittest.TestCase):

@classmethod
def setUpClass(cls):
reset_configs()
def setUp(self):
unittest_setup()

def test_create_new_transceiver_to_board(self):
board_config.set_up_remote_board()
Expand Down
4 changes: 4 additions & 0 deletions unittests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
import spinn_machine
from spinnman.transceiver import Transceiver, _SCAMP_VERSION
import spinnman
from spinnman.config_setup import unittest_setup


class Test(unittest.TestCase):
""" Tests for the SCAMP version comparison
"""

def setUp(self):
unittest_setup()

def test_version_same(self):
self.assertTrue(Transceiver.is_scamp_version_compabible((
_SCAMP_VERSION[0], _SCAMP_VERSION[1], _SCAMP_VERSION[2])))
Expand Down

0 comments on commit ec43bde

Please sign in to comment.