# Path: ma/xml_loader/asm_to_ppc.py
# class AssemblyReplacer(object):
#     """Class to assembly replacer for MA.
#     This class get information stored in XML file
#     into a python module"""
#     def __init__(self):
#         self.replacer = {}
#         self.load_xml(LOCAL_XML_ASM)
# 
#     def load_xml(self, file_name):
#         '''Method to load ASM replace strings.
#         This method open XML file and load info inside a
#         dictionary data structure'''
#         tree = elemTree.parse(file_name)
#         root = tree.getroot()
#         for asm in root.iter('asm'):
#             self.replacer[asm.attrib['target']] = [asm.attrib['type'],
#                                                    asm.attrib['replacer']]
# 
#     def get_replace(self, target):
#         '''Method to get the replace for selected target'''
#         return self.replacer[target][1]
# 
#     def get_type(self, target):
#         '''Method to get the type for selected target'''
#         return self.replacer[target][0]


import unittest
from ma.xml_loader.asm_to_ppc import AssemblyReplacer
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

    Contributors:
        * Diego Fernandez-Merjildo <merjildo@br.ibm.com>
"""



class AssemblyReplacerTest(unittest.TestCase):
    """ Test cases for the Assembly replacer """

    def get_replace_test(self):
        '''This test aim to check correct replace value return from
        get_replace() method in AssemblyReplacer class'''
        asm_replacer = AssemblyReplacer()
        self.assertTrue(asm_replacer.get_replace('lock;xchgl;') ==
                        "__atomic_test_and_set(/*void *ptr, int memmodel*/);")
        self.assertTrue(asm_replacer.get_replace('lock;orl;') ==
                        "__atomic_fetch_or(/*type *ptr, type val, int memmodel*/);")
        self.assertTrue(asm_replacer.get_replace('pause;') == "\"or 27,27,27; isync\"")

    def get_type_test(self):
        '''This test aim to check correct type return from
        get_type() method in AssemblyReplacer class'''

# Path: ma/xml_loader/asm_to_ppc.py
# class AssemblyReplacer(object):
#     """Class to assembly replacer for MA.
#     This class get information stored in XML file
#     into a python module"""
#     def __init__(self):
#         self.replacer = {}
#         self.load_xml(LOCAL_XML_ASM)
# 
#     def load_xml(self, file_name):
#         '''Method to load ASM replace strings.
#         This method open XML file and load info inside a
#         dictionary data structure'''
#         tree = elemTree.parse(file_name)
#         root = tree.getroot()
#         for asm in root.iter('asm'):
#             self.replacer[asm.attrib['target']] = [asm.attrib['type'],
#                                                    asm.attrib['replacer']]
# 
#     def get_replace(self, target):
#         '''Method to get the replace for selected target'''
#         return self.replacer[target][1]
# 
#     def get_type(self, target):
#         '''Method to get the type for selected target'''
#         return self.replacer[target][0]


# Path: tests/asm_to_pc_test.py
import unittest
from ma.xml_loader.asm_to_ppc import AssemblyReplacer

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

    Contributors:
        * Diego Fernandez-Merjildo <merjildo@br.ibm.com>
"""



class AssemblyReplacerTest(unittest.TestCase):
    """ Test cases for the Assembly replacer """

    def get_replace_test(self):
        '''This test aim to check correct replace value return from
        get_replace() method in AssemblyReplacer class'''
        asm_replacer = AssemblyReplacer()
        self.assertTrue(asm_replacer.get_replace('lock;xchgl;') ==
                        "__atomic_test_and_set(/*void *ptr, int memmodel*/);")
        self.assertTrue(asm_replacer.get_replace('lock;orl;') ==
                        "__atomic_fetch_or(/*type *ptr, type val, int memmodel*/);")
        self.assertTrue(asm_replacer.get_replace('pause;') == "\"or 27,27,27; isync\"")

    def get_type_test(self):
        '''This test aim to check correct type return from
        get_type() method in AssemblyReplacer class'''

        asm_replacer = AssemblyReplacer()