-
Notifications
You must be signed in to change notification settings - Fork 1
Tests #2
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
base: dev_branch
Are you sure you want to change the base?
Tests #2
Conversation
tests/sdt-test.py
Outdated
| # Determine the address of the probe. | ||
| # The address is always found at the same place with reference to | ||
| # the start of the probe provider. | ||
| addr_start_idx = probe_index-(2*8*3) |
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.
please explain those numbers in a comment or declare them as variables
tests/sdt-test.py
Outdated
|
|
||
| def main(): | ||
| # Import libsdt-offset | ||
| current_dir = os.path.abspath(os.path.dirname(__file__)) |
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.
Could we use os.getcwd() to get the current working directory?
https://docs.python.org/3/library/os.html#os.getcwd
tests/sdt-test.py
Outdated
| import sys | ||
| import subprocess | ||
| import os.path | ||
| import collections |
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.
Since we only need namedtuple, let's use this format: from collections import namedtuple.
tests/sdt-test.py
Outdated
| function_name_bytes = None | ||
|
|
||
| offset = lib.elf_get_function_offset(fd, | ||
| c_char_p(function_name_bytes)) |
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.
Align with first argument of the fonction
tests/sdt-test.py
Outdated
| c_char_p(probe_name_byte_str)) | ||
|
|
||
| if offset == test1.expected_result: | ||
| print(str(test1.test_num) + " - " + test1.test_name + ": pass\n") |
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.
lets use single quote everywhere to define strings
tests/sdt-test.py
Outdated
|
|
||
| if process.returncode != 0: | ||
| print('Invalid file path or no .text section in binary.') | ||
| return -1 |
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.
Using exceptions here, would be more pythonic
tests/sdt-test.py
Outdated
| # Use objdump (command line tool) to get .text ELF section header | ||
| # info. | ||
| process = subprocess.Popen( | ||
| ['objdump', '--headers', '--section=.text', file_path], |
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.
Could you define this list in variable out of the function call?
tests/sdt-test.py
Outdated
| def get_sdt_note_section_hex_str(file_path, sdt_note_section): | ||
| # Use objdump (command line tool) to retrieve section header. | ||
| process = subprocess.Popen( | ||
| ['objdump', '--headers', '--section=.note.stapsdt', file_path], |
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.
Align with the function call.
tests/sdt-test.py
Outdated
| import re | ||
| import binascii | ||
| from ctypes import * | ||
|
|
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.
Here, explain our definition of offset and address and why we need this function.
Makefile is for building the binaries necessary for testing the library. Signed-off-by: Erica Bugden <erica.bugden@efficios.com>
Feedback concerning the completeness and the accuracy of the tests would be much appreciated.
Also maybe suggestions for how to make the error management in the Python more pythonic.