<commit_before>#!/usr/bin/env python3
"""
High-level tests for the overall functionallity and things in kc.py
"""
import os
import unittest

from kerncraft import likwid_bench_auto as lba
from kerncraft.prefixedunit import PrefixedUnit


class TestLikwidBenchAuto(unittest.TestCase):
    @staticmethod
    def _find_file(name):
        testdir = os.path.dirname(__file__)
        name = os.path.join(testdir, 'test_files', name)
        assert os.path.exists(name)
        return name

    def test_get_machine_topology(self):
        # patch environment to include dummy likwid
        environ_orig = os.environ
        os.environ['PATH'] = self._find_file('dummy_likwid') + ':' + os.environ['PATH']

        self.maxDiff = None
        self.assertEqual(
            lba.get_machine_topology(cpuinfo_path=self._find_file('cpuinfo')),
            {'FLOPs per cycle': {'DP': {'ADD': 'INFORMATION_REQUIRED',
                                        'FMA': 'INFORMATION_REQUIRED',
                                        'MUL': 'INFORMATION_REQUIRED',
                                        'total': 'INFORMATION_REQUIRED'},
                                 'SP': {'ADD': 'INFORMATION_REQUIRED',
                                        'FMA': 'INFORMATION_REQUIRED',
                                        'MUL': 'INFORMATION_REQUIRED',
                                        'total': 'INFORMATION_REQUIRED'}},
             'NUMA domains per socket': 1.0,
             'cacheline size': 'INFORMATION_REQUIRED (in bytes, e.g. 64 B)',
             'clock': 'INFORMATION_REQUIRED (e.g., 2.7 GHz)',
             'compiler': {
                 'clang': ['INFORMATION_REQUIRED (e.g., -O3 -mavx, -D_POSIX_C_SOURCE=200112L'],
                 'gcc': ['INFORMATION_REQUIRED (e.g., -O3 -march=ivybridge)'],
                 'icc': ['INFORMATION_REQUIRED (e.g., -O3 -fno-alias -xAVX)']},
             'cores per NUMA domain': 10,<commit_msg>fixed likwid bench auto test case<commit_after>#!/usr/bin/env python3
"""
High-level tests for the overall functionallity and things in kc.py
"""
import os
import unittest

from kerncraft import likwid_bench_auto as lba
from kerncraft import __version__ as kerncraft_version
from kerncraft.prefixedunit import PrefixedUnit


class TestLikwidBenchAuto(unittest.TestCase):
    @staticmethod
    def _find_file(name):
        testdir = os.path.dirname(__file__)
        name = os.path.join(testdir, 'test_files', name)
        assert os.path.exists(name)
        return name

    def test_get_machine_topology(self):
        # patch environment to include dummy likwid
        environ_orig = os.environ
        os.environ['PATH'] = self._find_file('dummy_likwid') + ':' + os.environ['PATH']

        self.maxDiff = None
        self.assertEqual(
            lba.get_machine_topology(cpuinfo_path=self._find_file('cpuinfo')),
            {'kerncraft version': kerncraft_version,
             'FLOPs per cycle': {'DP': {'ADD': 'INFORMATION_REQUIRED',
                                        'FMA': 'INFORMATION_REQUIRED',
                                        'MUL': 'INFORMATION_REQUIRED',
                                        'total': 'INFORMATION_REQUIRED'},
                                 'SP': {'ADD': 'INFORMATION_REQUIRED',
                                        'FMA': 'INFORMATION_REQUIRED',
                                        'MUL': 'INFORMATION_REQUIRED',
                                        'total': 'INFORMATION_REQUIRED'}},
             'NUMA domains per socket': 1.0,
             'cacheline size': 'INFORMATION_REQUIRED (in bytes, e.g. 64 B)',
             'clock': 'INFORMATION_REQUIRED (e.g., 2.7 GHz)',
             'compiler': {
                 'clang': ['INFORMATION_REQUIRED (e.g., -O3 -mavx, -D_POSIX_C_SOURCE=200112L'],
                 'gcc': ['INFORMATION_REQUIRED (e.g., -O3 -march=ivybridge)'],
                 'icc': ['INFORMATION_REQUIRED (e.g., -O3 -fno-alias -xAVX)']},
             'cores per NUMA domain': 10,
{'fraction_non_alphanumeric': 0.11891620672353237, 'fraction_numerical': 0.009031610637230306, 'mean_word_length': 1.8933236574746009, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2991561', 'n_tokens_mistral': 1175, 'n_tokens_neox': 1145, 'n_words': 253}