Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
class_topology_unit_test.py
Go to the documentation of this file.
1 # Andrew Gloster
2 # Summer 2016
3 # Python Version of Communication Model Implementation
4 # Unit Testing of Topology Class
5 
6 #------------------------------------
7 # Import relevant modules
8 #------------------------------------
9 
10 import unittest
11 
12 #------------------------------------
13 # Import relevant classes
14 #------------------------------------
15 
16 from class_topology import Topology
17 
18 #------------------------------------
19 # Test Cases
20 #------------------------------------
21 
22 class Testing(unittest.TestCase):
23 
24 # Check we get the correct total processes
25  def test0(self):
26  test_case = Topology(5, 4, 10, 2)
27  self.assertEqual(test_case.PROC_TOT, 20)
28 
29 # Check for correct basic core labeling
30  def test1(self):
31  test_case = Topology(2, 5, 10, 2)
32  self.assertEqual(test_case.Core, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
33 
34 # Check for basic socket labeling
35  def test2(self):
36  test_case = Topology(2, 5, 5, 1)
37  self.assertEqual(test_case.Socket, [0, 0, 0, 0, 0, 1, 1, 1, 1, 1])
38 
39 # Check for basic node labeling
40  def test3(self):
41  test_case = Topology(2, 5, 2, 1)
42  self.assertEqual(test_case.Node, [0, 0, 1, 1, 2, 2, 3, 3, 4, 4])
43 
44 # Check neighbours that are identical
45  def test4(self):
46  test_case = Topology(2, 5, 5, 1)
47  self.assertEqual(test_case.Check_Neighbour(0, 0), 0)
48 
49 # Check neighbours that are on same socket
50  def test5(self):
51  test_case = Topology(2, 5, 5, 2)
52  self.assertEqual(test_case.Check_Neighbour(0, 1), 1)
53 
54 # Check neighbours that are on same node
55  def test6(self):
56  test_case = Topology(2, 5, 5, 2)
57  self.assertEqual(test_case.Check_Neighbour(0, 8), 2)
58 
59 # Check neighbours that are on different nodes
60  def test8(self):
61  test_case = Topology(4, 5, 2, 2)
62  self.assertEqual(test_case.Check_Neighbour(0, 9), 3)
63 
64