|
Packit Service |
7f3b24 |
# SPDX-License-Identifier: BSD-2-Clause
|
|
Packit Service |
7f3b24 |
# Copyright (C) 2016 - 2020 Intel Corporation.
|
|
Packit |
345191 |
|
|
Packit |
345191 |
import pytest
|
|
Packit |
345191 |
import os
|
|
Packit |
345191 |
import tempfile
|
|
Packit |
345191 |
import subprocess
|
|
Packit |
345191 |
from python_framework import CMD_helper
|
|
Packit |
345191 |
from python_framework import Huge_page_organizer
|
|
Packit |
345191 |
|
|
Packit |
345191 |
class Test_trace_mechanism(object):
|
|
Packit |
345191 |
binary = "../trace_mechanism_test_helper"
|
|
Packit |
345191 |
fail_msg = "Test failed with:\n {0}"
|
|
Packit |
345191 |
debug_env = "MEMKIND_DEBUG=1 "
|
|
Packit |
345191 |
cmd_helper = CMD_helper()
|
|
Packit |
345191 |
|
|
Packit |
345191 |
def test_TC_MEMKIND_logging_MEMKIND_HBW(self):
|
|
Packit |
345191 |
#This test executes trace_mechanism_test_helper and test if MEMKIND_INFO message occurs while calling MEMKIND_HBW
|
|
Packit |
345191 |
command = self.debug_env + self.cmd_helper.get_command_path(self.binary) + " MEMKIND_HBW"
|
|
Packit |
345191 |
print "Executing command: {0}".format(command)
|
|
Packit |
345191 |
output, retcode = self.cmd_helper.execute_cmd(command, sudo=False)
|
|
Packit |
345191 |
assert retcode == 0, self.fail_msg.format("\nError: trace_mechanism_test_helper returned {0} \noutput: {1}".format(retcode,output))
|
|
Packit |
345191 |
assert "MEMKIND_INFO: NUMA node" in output, self.fail_msg.format("\nError: trace mechanism in memkind doesn't show MEMKIND_INFO message \noutput: {0}").format(output)
|
|
Packit |
345191 |
|
|
Packit |
345191 |
def test_TC_MEMKIND_2MBPages_logging_MEMKIND_HUGETLB(self):
|
|
Packit |
345191 |
huge_page_organizer = Huge_page_organizer(8)
|
|
Packit |
345191 |
#This test executes trace_mechanism_test_helper and test if MEMKIND_INFO message occurs while calling MEMKIND_HUGETLB
|
|
Packit |
345191 |
command = self.debug_env + self.cmd_helper.get_command_path(self.binary) + " MEMKIND_HUGETLB"
|
|
Packit |
345191 |
print "Executing command: {0}".format(command)
|
|
Packit |
345191 |
output, retcode= self.cmd_helper.execute_cmd(command, sudo=False)
|
|
Packit |
345191 |
assert retcode == 0, self.fail_msg.format("\nError: trace_mechanism_test_helper returned {0} \noutput: {1}".format(retcode,output))
|
|
Packit |
345191 |
assert "MEMKIND_INFO: Number of" in output, self.fail_msg.format("\nError: trace mechanism in memkind doesn't show MEMKIND_INFO message \noutput: {0}").format(output)
|
|
Packit |
345191 |
assert "MEMKIND_INFO: Overcommit limit for" in output, self.fail_msg.format("\nError: trace mechanism in memkind doesn't show MEMKIND_INFO message \n output: {0}").format(output)
|
|
Packit |
345191 |
|
|
Packit |
345191 |
def test_TC_MEMKIND_logging_negative_MEMKIND_DEBUG_env(self):
|
|
Packit |
345191 |
#This test executes trace_mechanism_test_helper and test if setting MEMKIND_DEBUG to wrong value causes MEMKIND_WARNING message
|
|
Packit |
345191 |
command = "MEMKIND_DEBUG=-1 " + self.cmd_helper.get_command_path(self.binary) + " MEMKIND_HBW"
|
|
Packit |
345191 |
print "Executing command: {0}".format(command)
|
|
Packit |
345191 |
output, retcode = self.cmd_helper.execute_cmd(command, sudo=False)
|
|
Packit |
345191 |
assert retcode == 0, self.fail_msg.format("\nError: trace_mechanism_test_helper returned {0} \noutput: {1}".format(retcode,output))
|
|
Packit |
345191 |
assert "MEMKIND_WARNING: debug option" in output, self.fail_msg.format("\nError: setting wrong MEMKIND_DEBUG environment variable doesn't show MEMKIND_WARNING \noutput: {0})").format(output)
|