-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read dawr with perf interface #2869
Open
akanksha216
wants to merge
1
commit into
avocado-framework-tests:master
Choose a base branch
from
akanksha216:perf_dawr_pr_resend
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
import shutil | ||
import pexpect | ||
from avocado import Test | ||
from avocado.utils import build, distro, genio | ||
from avocado.utils import build, distro, cpu, process | ||
from avocado.utils.software_manager.manager import SoftwareManager | ||
|
||
|
||
|
@@ -33,17 +33,15 @@ class Dawr(Test): | |
|
||
def setUp(self): | ||
''' | ||
Install the basic packages to support gdb | ||
Install the basic packages to support gdb and perf | ||
''' | ||
val = genio.read_file("/proc/cpuinfo") | ||
power_ver = ['POWER10', 'Power11'] | ||
if not any(x in val for x in power_ver): | ||
self.cancel("LPAR on Power10 and above is required for this test.") | ||
if "power10" not in cpu.get_family(): | ||
self.cancel("Test is supported only on IBM POWER10 platform") | ||
# Check for basic utilities | ||
smm = SoftwareManager() | ||
self.detected_distro = distro.detect() | ||
self.distro_name = self.detected_distro.name | ||
deps = ['gcc', 'make', 'gdb'] | ||
deps = ['gcc', 'make', 'gdb', 'perf'] | ||
for package in deps: | ||
if not smm.check_installed(package) and not smm.install(package): | ||
self.cancel('%s is needed for the test to be run' % package) | ||
|
@@ -55,6 +53,7 @@ def setUp(self): | |
os.path.join(self.teststmpdir, 'Makefile')) | ||
build.make(self.teststmpdir) | ||
os.chdir(self.teststmpdir) | ||
self.output_file = "perf.data" | ||
|
||
def run_cmd(self, bin_var): | ||
child = pexpect.spawn('gdb ./%s' % bin_var, encoding='utf-8') | ||
|
@@ -64,16 +63,35 @@ def run_cmd(self, bin_var): | |
return_value = [] | ||
return child, return_value | ||
|
||
def test_read_dawr_v1(self): | ||
def run_test(self, cmd): | ||
return process.run(cmd, shell=True) | ||
|
||
def perf_cmd(self, perf_record): | ||
process.run(perf_record, shell=True, ignore_status=True, | ||
verbose=True, ignore_bg_processes=True) | ||
report = "perf report --input=%s" % self.output_file | ||
self.run_test(report) | ||
if not os.stat(self.output_file).st_size: | ||
self.fail("%s sample not captured" % self.output_file) | ||
|
||
def address_v1(self): | ||
# Get memory address of single variable | ||
output = self.run_test('./dawr_v1') | ||
data = output.stdout.decode("utf-8") | ||
return data | ||
|
||
def address_v2(self): | ||
# Get memory address of two variables | ||
output = self.run_test('./dawr_v2') | ||
data = output.stdout.decode("utf-8").split(',') | ||
return data | ||
|
||
def test_read_dawr_v1_gdb(self): | ||
""" | ||
Setting Read/Write watchpoint on single variable using awatch and | ||
executing the program | ||
""" | ||
child, return_value = self.run_cmd('dawr_v1') | ||
i = 0 | ||
if self.distro_name == "fedora": | ||
child.sendline('set debuginfod enabled on') | ||
child.expect_exact([pexpect.TIMEOUT, '']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same. This will revert code added via trace: Add Fedora Support to trace testing. Can you rebase? |
||
child.sendline('awatch a') | ||
return_value.append(child.expect_exact(['watchpoint 1: a', | ||
pexpect.TIMEOUT])) | ||
|
@@ -87,16 +105,13 @@ def test_read_dawr_v1(self): | |
if i != 0: | ||
self.fail('Test case failed for 1 variable') | ||
|
||
def test_read_dawr_v2(self): | ||
def test_read_dawr_v2_gdb(self): | ||
""" | ||
Setting Read/Write watchpoints on two variables using awatch and | ||
executing the program | ||
""" | ||
child, return_value = self.run_cmd('dawr_v2') | ||
i = 0 | ||
if self.distro_name == "fedora": | ||
child.sendline('set debuginfod enabled on') | ||
child.expect_exact([pexpect.TIMEOUT, '']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
for value in ['a', 'b']: | ||
i = i+1 | ||
child.sendline('awatch %s' % value) | ||
|
@@ -115,7 +130,7 @@ def test_read_dawr_v2(self): | |
if i == 0: | ||
self.fail('Test case failed for 2 variables') | ||
|
||
def test_read_dawr_v3(self): | ||
def test_read_dawr_v3_gdb(self): | ||
""" | ||
Setting Read/Write watchpoints on three variables using awatch and | ||
executing the program | ||
|
@@ -134,3 +149,22 @@ def test_read_dawr_v3(self): | |
for i in return_value: | ||
if i == 0: | ||
self.fail('Test case failed for 3 variables') | ||
|
||
def test_read_dawr_v1_perf(self): | ||
# Read single dawr register with perf interface | ||
data = self.address_v1() | ||
perf_record = 'perf record -o %s -e mem:%s ./dawr_v1' % ( | ||
self.output_file, data) | ||
self.perf_cmd(perf_record) | ||
|
||
def test_read_dawr_v2_perf(self): | ||
# Read two dawr registers with perf interface | ||
data = self.address_v2() | ||
perf_record = 'perf record -o %s -e mem:%s -e mem:%s ./dawr_v2' % ( | ||
self.output_file, data[0], data[1][1:11]) | ||
self.perf_cmd(perf_record) | ||
|
||
def tearDown(self): | ||
# Delete the temporary file | ||
if os.path.isfile("perf.data"): | ||
process.run('rm -f perf.data') |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will revert the power11 support changes. Can you rebase the code?