From 487fd5e1fd6cede971ec47ca1b3e958119c31bc8 Mon Sep 17 00:00:00 2001 From: Juan Castillo Date: Tue, 3 Sep 2024 16:45:56 -0500 Subject: [PATCH] [SWDEV-482966/ SWDEV-482967] Removing pytest dependency + install path change Signed-off-by: Juan Castillo Change-Id: I7aace93fcad18d67443e6849c10a1fbbc65d0fa8 Signed-off-by: Juan Castillo [ROCm/amdsmi commit: ac593f9fa0fbcf4ca7be2190a8101945b6e32975] --- projects/amdsmi/CHANGELOG.md | 4 + projects/amdsmi/CMakeLists.txt | 4 +- projects/amdsmi/DEBIAN/postinst.in | 13 +- projects/amdsmi/DEBIAN/prerm.in | 13 ++ projects/amdsmi/RPM/post.in | 13 +- projects/amdsmi/RPM/preun.in | 11 ++ .../python_unittest}/CMakeLists.txt | 2 +- .../python_unittest}/README.md | 131 +++++++----------- .../python_unittest}/__init__.py | 0 .../python_unittest}/integration_test.py | 0 .../python_unittest}/unit_tests.py | 0 11 files changed, 80 insertions(+), 111 deletions(-) rename projects/amdsmi/{pytest => tests/python_unittest}/CMakeLists.txt (91%) rename projects/amdsmi/{pytest => tests/python_unittest}/README.md (90%) rename projects/amdsmi/{pytest => tests/python_unittest}/__init__.py (100%) rename projects/amdsmi/{pytest => tests/python_unittest}/integration_test.py (100%) rename projects/amdsmi/{pytest => tests/python_unittest}/unit_tests.py (100%) diff --git a/projects/amdsmi/CHANGELOG.md b/projects/amdsmi/CHANGELOG.md index 0a1c356156..59de456980 100644 --- a/projects/amdsmi/CHANGELOG.md +++ b/projects/amdsmi/CHANGELOG.md @@ -7,6 +7,10 @@ Full documentation for amd_smi_lib is available at [https://rocm.docs.amd.com/pr ## amd_smi_lib for ROCm 6.3.0 ### Changes +- **Moved python tests directory path install location.** + - `/opt//share/amd_smi/pytest/.. to /opt//share/amd_smi/tests/python_unittest/..` +- **On amd-smi-lib-tests uninstall, the amd_smi tests folder is removed.** +- **Removed pytest dependency, our python testing depends only on unittest framework.** - **Added more supported utilization count types to `amdsmi_get_utilization_count()`**. diff --git a/projects/amdsmi/CMakeLists.txt b/projects/amdsmi/CMakeLists.txt index ba28bf6324..0f4a40ab1e 100644 --- a/projects/amdsmi/CMakeLists.txt +++ b/projects/amdsmi/CMakeLists.txt @@ -185,12 +185,12 @@ if(BUILD_TESTS) set(TESTS_COMPONENT "tests") #add_subdirectory("tests/rocm_smi_test") add_subdirectory("tests/amd_smi_test") + add_subdirectory("tests/python_unittest") endif() # python interface, CLI, and py-test depend on shared libraries if(BUILD_SHARED_LIBS) add_subdirectory("py-interface") - add_subdirectory("pytest") if(BUILD_CLI) add_subdirectory("amdsmi_cli") endif() @@ -252,7 +252,7 @@ install( #Debian package specific variables set(CPACK_DEBIAN_PACKAGE_PROVIDES "amd-smi") -set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "python3-argcomplete, libdrm-dev, python3-yaml") +set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "python3-argcomplete, libdrm-dev, python3-PyYAML") set(CPACK_DEBIAN_ASAN_PACKAGE_RECOMMENDS ${CPACK_DEBIAN_PACKAGE_RECOMMENDS}) set(CPACK_DEBIAN_DEV_PACKAGE_RECOMMENDS ${CPACK_DEBIAN_PACKAGE_RECOMMENDS}) set(CPACK_DEBIAN_ASAN_PACKAGE_PROVIDES "${AMD_SMI_PACKAGE}-asan") diff --git a/projects/amdsmi/DEBIAN/postinst.in b/projects/amdsmi/DEBIAN/postinst.in index 474cebc1b8..45443b55a1 100755 --- a/projects/amdsmi/DEBIAN/postinst.in +++ b/projects/amdsmi/DEBIAN/postinst.in @@ -133,6 +133,7 @@ do_install_amdsmi_python_lib() { local PREVIOUS_PIP_BREAK_SYSTEM_PACKAGES="$PIP_BREAK_SYSTEM_PACKAGES" export PIP_BREAK_SYSTEM_PACKAGES=1 + # Remove old python library local pip_list_output pip_list_output=$(python3 -m pip list --format=columns --disable-pip-version-check) @@ -188,22 +189,10 @@ do_install_amdsmi_python_lib() { fi } -do_install_amdsmi_pytest() { - echo -n "Installing pytest... " - pip install -U pytest >/dev/null 2>&1 - if [ $? -ne 0 ]; then - echo "[WARNING] Detected pytest could not be installed. Running pytest may not work as documented." - else - echo -n "[SUCCESS]" - echo "" - fi - return -} case "$1" in ( configure ) do_install_amdsmi_python_lib - do_install_amdsmi_pytest do_ldconfig do_updatepciids do_configureLogrotate || exit 0 diff --git a/projects/amdsmi/DEBIAN/prerm.in b/projects/amdsmi/DEBIAN/prerm.in index 28af94f143..3decc72093 100755 --- a/projects/amdsmi/DEBIAN/prerm.in +++ b/projects/amdsmi/DEBIAN/prerm.in @@ -1,5 +1,7 @@ #!/bin/bash + +# Other prerm actions rm_ldconfig() { # left-hand term originates from ENABLE_LDCONFIG = ON/OFF at package build if [ "@ENABLE_LDCONFIG@" == "ON" ]; then @@ -8,6 +10,7 @@ rm_ldconfig() { fi } + rm_leftovers() { # remove pyc files generated by python rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/__pycache__" @@ -27,6 +30,15 @@ rm_logFolder() { rm -rf /var/log/amd_smi_lib } + +rm_rocm_tests_dir(){ + if [ -d "@CPACK_PACKAGING_INSTALL_PREFIX@/share/amd_smi/tests/" ]; then + rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/share/amd_smi/tests/" + echo "Removed ROCm tests directory." + fi +} + + return_logrotateToOrigConfig() { local logrotateConfFile=/etc/logrotate.d/amd_smi.conf if [ -f $logrotateConfFile ]; then @@ -86,6 +98,7 @@ case "$1" in rm_ldconfig rm_leftovers rm_logFolder + rm_rocm_tests_dir return_logrotateToOrigConfig ;; ( purge ) diff --git a/projects/amdsmi/RPM/post.in b/projects/amdsmi/RPM/post.in index 78c71864ed..e33e9c0de7 100755 --- a/projects/amdsmi/RPM/post.in +++ b/projects/amdsmi/RPM/post.in @@ -132,6 +132,7 @@ do_install_amdsmi_python_lib() { local PREVIOUS_PIP_BREAK_SYSTEM_PACKAGES="$PIP_BREAK_SYSTEM_PACKAGES" export PIP_BREAK_SYSTEM_PACKAGES=1 + # Remove old python library local pip_list_output pip_list_output=$(python3 -m pip list --format=columns --disable-pip-version-check) @@ -187,22 +188,10 @@ do_install_amdsmi_python_lib() { fi } -do_install_amdsmi_pytest() { - echo -n "Installing pytest... " - pip install -U pytest >/dev/null 2>&1 - if [ $? -ne 0 ]; then - echo "[WARNING] Detected pytest could not be installed. Running pytest may not work as documented." - else - echo -n "[SUCCESS]" - echo "" - fi - return -} # post install or upgrade, $i is 1 or 2 -> do these actions if [ "$1" -ge 1 ]; then do_install_amdsmi_python_lib - do_install_amdsmi_pytest do_ldconfig do_updatepciids do_configureLogrotate || exit 0 diff --git a/projects/amdsmi/RPM/preun.in b/projects/amdsmi/RPM/preun.in index bc2376161c..43e58c93f3 100755 --- a/projects/amdsmi/RPM/preun.in +++ b/projects/amdsmi/RPM/preun.in @@ -15,10 +15,20 @@ rm_leftovers() { fi } + rm_logFolder() { rm -rf /var/log/amd_smi_lib } + +rm_rocm_tests_dir(){ + if [ -d "@CPACK_PACKAGING_INSTALL_PREFIX@/share/amd_smi/tests/" ]; then + rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/share/amd_smi/tests/" + echo "Removed ROCm tests directory." + fi +} + + return_logrotateToOrigConfig() { local logrotateConfFile=/etc/logrotate.d/amd_smi.conf if [ -f $logrotateConfFile ]; then @@ -77,5 +87,6 @@ if [ "$1" -le 1 ]; then rm_python_lib rm_leftovers rm_logFolder + rm_rocm_tests_dir return_logrotateToOrigConfig fi diff --git a/projects/amdsmi/pytest/CMakeLists.txt b/projects/amdsmi/tests/python_unittest/CMakeLists.txt similarity index 91% rename from projects/amdsmi/pytest/CMakeLists.txt rename to projects/amdsmi/tests/python_unittest/CMakeLists.txt index 693d3b9f57..94bf6b93f9 100644 --- a/projects/amdsmi/pytest/CMakeLists.txt +++ b/projects/amdsmi/tests/python_unittest/CMakeLists.txt @@ -18,7 +18,7 @@ message("--------CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY: " ${CPACK_COMPONENT # copy python test files into shared directory install( DIRECTORY ./ - DESTINATION ${SHARE_INSTALL_PREFIX}/tests/pytest/ + DESTINATION ${SHARE_INSTALL_PREFIX}/tests/python_unittest/ COMPONENT dev USE_SOURCE_PERMISSIONS FILES_MATCHING diff --git a/projects/amdsmi/pytest/README.md b/projects/amdsmi/tests/python_unittest/README.md similarity index 90% rename from projects/amdsmi/pytest/README.md rename to projects/amdsmi/tests/python_unittest/README.md index aaee9d0852..26e9fb7dbd 100644 --- a/projects/amdsmi/pytest/README.md +++ b/projects/amdsmi/tests/python_unittest/README.md @@ -13,72 +13,35 @@ Follow our install/build guides to ensure the Python API is installed correctly ## How to Run ### Basic How To The 2 tests are in this PATH: -```/opt/rocm/share/amd_smi/tests/pytest/integration_test.py``` -```/opt/rocm/share/amd_smi/tests/pytest/unit_tests.py``` +```/opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py``` +```/opt/rocm/share/amd_smi/tests/python_unittest/unit_tests.py``` - -The recommended method to run the tests: -Pytest verbose -```python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/pytest/integration_test.py -s -v``` -```python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/pytest/unit_tests.py -s -v``` - -Pytest only (not verbose) -```python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/pytest/integration_test.py -v``` -```python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/pytest/unit_tests.py -v``` +The recommended method to run the tests: Unittest verbose -```/opt/rocm/share/amd_smi/tests/pytest/unit_tests.py -v``` -```/opt/rocm/share/amd_smi/tests/pytest/integration_test.py -v``` +```/opt/rocm/share/amd_smi/tests/python_unittest/unit_tests.py -v``` +```/opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py -v``` Unittest only (not verbose) -```/opt/rocm/share/amd_smi/tests/pytest/unit_tests.py -b -v``` -```/opt/rocm/share/amd_smi/tests/pytest/integration_test.py -b -v``` +```/opt/rocm/share/amd_smi/tests/python_unittest/unit_tests.py -b -v``` +```/opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py -b -v``` See sections below for more detailed options with examples. -### Unittest or Pytest Run -The Unittest Run calls the tests directly, assuming pytest is correctly installed in the PATH. -This is more straightforward and intuitive but with less control for options. For example, the cache provider will always be used. - -```/opt/rocm/share/amd_smi/tests/pytest/*``` - -options: - - -h, --help show this help message and exit - - -v, --verbose Verbose output - - -q, --quiet Quiet output - - -b, --buffer Buffer stdout and stderr during tests - - -k "TESTNAME" Only run tests which match the given substring - -The Pytest Run could be more reliable and consistent, especially if pytest is not in the PATH. -This offers more options and flexibility, such as the option to disable the cache provider, ensuring completely independent runs. - -```python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/pytest/*``` - -options: - - -h, --help show this help message and exit - - --co Collect and list tests - - -p no:cacheprovider Disable cache provider - - -v, --verbose Verbose output - - -q, --quiet Quiet output - - -s, --capture=no Disables output capturing, stdout output - - -k "TESTNAME" Only run tests which match the given substring - -The complete list of options can be accessed here [Pytest command-line flags](https://docs.pytest.org/en/latest/reference/reference.html#command-line-flags). - ## Unittest Run Options ### Unittest Run: Verbose on Helpful to see print outs of Python. -```/opt/rocm/share/amd_smi/tests/pytest/integration_test.py -v``` +```/opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py -v``` -```/opt/rocm/share/amd_smi/tests/pytest/unit_tests.py -v``` +```/opt/rocm/share/amd_smi/tests/python_unittest/unit_tests.py -v``` ex.
Click for example: Unittest run: verbose on ~~~shell -/opt/rocm/share/amd_smi/tests/pytest/integration_test.py -v +/opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py -v test_init (__main__.TestAmdSmiInit) ... ok test_bad_page_info (__main__.TestAmdSmiPythonInterface) ... ###Test amdsmi_get_gpu_bad_page_info @@ -403,16 +366,16 @@ OK ### Unittest Run: Verbose on + Filter (or exclude) a test -```/opt/rocm/share/amd_smi/tests/pytest/integration_test.py -k "test_walkthrough" -v``` +```/opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py -k "test_walkthrough" -v``` -```/opt/rocm/share/amd_smi/tests/pytest/integration_test.py -k "not test_walkthrough" -v``` +```/opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py -k "not test_walkthrough" -v``` ex.
Click for example: Unittest Run: Verbose on + Filter (or exclude) a Test ~~~shell -> /opt/rocm/share/amd_smi/tests/pytest/integration_test.py -k "test_bdf_device_id" -v +> /opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py -k "test_bdf_device_id" -v test_bdf_device_id (__main__.TestAmdSmiPythonInterface) ... ###Test Processor 0, bdf: 0000:08:00.0 ###Test amdsmi_get_gpu_vbios_info @@ -453,16 +416,16 @@ OK Runs all tests. Silence print statements to stdout. Lists tests results. This is also the best way to list all tests available. -```/opt/rocm/share/amd_smi/tests/pytest/integration_test.py -b -v``` +```/opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py -b -v``` -```/opt/rocm/share/amd_smi/tests/pytest/unit_tests.py -b -v``` +```/opt/rocm/share/amd_smi/tests/python_unittest/unit_tests.py -b -v``` ex.
Click for example: Unittest Run: Silence stdout (print statements) and run all tests ~~~shell -/opt/rocm/share/amd_smi/tests/pytest/unit_tests.py -b -v +/opt/rocm/share/amd_smi/tests/python_unittest/unit_tests.py -b -v test_check_res (__main__.TestAmdSmiPythonBDF) ... ok test_format_bdf (__main__.TestAmdSmiPythonBDF) ... ok test_parse_bdf (__main__.TestAmdSmiPythonBDF) ... ok @@ -477,16 +440,16 @@ OK ## Pytest Run Options ### Pytest: List tests -```python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/pytest/integration_test.py --co``` +```python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py --co``` -```python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/pytest/unit_tests.py --co``` +```python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/python_unittest/unit_tests.py --co``` ex.
Click for example: Pytest: List tests ~~~shell -python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/pytest/integration_test.py --co +python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py --co ===================================================== test session starts ===================================================== platform linux -- Python 3.8.10, pytest-8.2.2, pluggy-1.5.0 rootdir: /opt/rocm/share/amd_smi @@ -511,53 +474,53 @@ collected 6 items
### Pytest Run: Verbose on -```python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/pytest/integration_test.py -v``` +```python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py -v``` -```python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/pytest/unit_tests.py -v``` +```python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/python_unittest/unit_tests.py -v``` ex.
Click for example: Pytest Run: verbose on ~~~shell - python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/pytest/unit_tests.py -v + python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/python_unittest/unit_tests.py -v ===================================================== test session starts ===================================================== platform linux -- Python 3.8.10, pytest-8.2.2, pluggy-1.5.0 -- /usr/bin/python3 rootdir: /opt/rocm/share/amd_smi configfile: pyproject.toml collected 3 items -../../opt/rocm/share/amd_smi/tests/pytest/unit_tests.py::TestAmdSmiPythonBDF::test_check_res PASSED [ 33%] -../../opt/rocm/share/amd_smi/tests/pytest/unit_tests.py::TestAmdSmiPythonBDF::test_format_bdf PASSED [ 66%] -../../opt/rocm/share/amd_smi/tests/pytest/unit_tests.py::TestAmdSmiPythonBDF::test_parse_bdf PASSED [100%] +../../opt/rocm/share/amd_smi/tests/python_unittest/unit_tests.py::TestAmdSmiPythonBDF::test_check_res PASSED [ 33%] +../../opt/rocm/share/amd_smi/tests/python_unittest/unit_tests.py::TestAmdSmiPythonBDF::test_format_bdf PASSED [ 66%] +../../opt/rocm/share/amd_smi/tests/python_unittest/unit_tests.py::TestAmdSmiPythonBDF::test_parse_bdf PASSED [100%] ====================================================== 3 passed in 0.04s ====================================================== ~~~
### Pytest Run: Verbose on + stdout (print statements) -```python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/pytest/integration_test.py -s -v``` +```python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py -s -v``` -```python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/pytest/unit_tests.py -s -v``` +```python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/python_unittest/unit_tests.py -s -v``` ex.
Click for example: Pytest Run: verbose on + stdout (print statements) ~~~shell -python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/pytest/integration_test.py -s -v +python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py -s -v ===================================================== test session starts ===================================================== platform linux -- Python 3.8.10, pytest-8.2.2, pluggy-1.5.0 -- /usr/bin/python3 rootdir: /opt/rocm/share/amd_smi configfile: pyproject.toml collected 6 items -../../opt/rocm/share/amd_smi/tests/pytest/integration_test.py::TestAmdSmiInit::test_init PASSED -../../opt/rocm/share/amd_smi/tests/pytest/integration_test.py::TestAmdSmiPythonInterface::test_bad_page_info ###Test amdsmi_get_gpu_bad_page_info +../../opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py::TestAmdSmiInit::test_init PASSED +../../opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py::TestAmdSmiPythonInterface::test_bad_page_info ###Test amdsmi_get_gpu_bad_page_info **** [ERROR] | Test: test_bad_page_info | Caught AmdSmiLibraryException PASSED -../../opt/rocm/share/amd_smi/tests/pytest/integration_test.py::TestAmdSmiPythonInterface::test_bdf_device_id ###Test Processor 0, bdf: 0000:08:00.0 +../../opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py::TestAmdSmiPythonInterface::test_bdf_device_id ###Test Processor 0, bdf: 0000:08:00.0 ###Test amdsmi_get_gpu_vbios_info @@ -584,13 +547,13 @@ PASSED uuid is: 1fff73a3-0000-1000-8075-223e5e64eac1 PASSED -../../opt/rocm/share/amd_smi/tests/pytest/integration_test.py::TestAmdSmiPythonInterface::test_ecc ###Test Processor 0, bdf: 0000:08:00.0 +../../opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py::TestAmdSmiPythonInterface::test_ecc ###Test Processor 0, bdf: 0000:08:00.0 ###Test amdsmi_get_gpu_ras_feature_info **** [ERROR] | Test: test_ecc | Caught AmdSmiLibraryException PASSED -../../opt/rocm/share/amd_smi/tests/pytest/integration_test.py::TestAmdSmiPythonInterface::test_gpu_performance ###Test Processor 0, bdf: 0000:08:00.0 +../../opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py::TestAmdSmiPythonInterface::test_gpu_performance ###Test Processor 0, bdf: 0000:08:00.0 ###Test amdsmi_get_gpu_activity engine_usage['gfx_activity'] is: 1 % @@ -725,7 +688,7 @@ PASSED pcie_info['pcie_metric']['pcie_nak_sent_count'] is: N/A pcie_info['pcie_metric']['pcie_nak_received_count'] is: N/A PASSED -../../opt/rocm/share/amd_smi/tests/pytest/integration_test.py::TestAmdSmiPythonInterface::test_walkthrough ###Test amdsmi_get_processor_handles() +../../opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py::TestAmdSmiPythonInterface::test_walkthrough ###Test amdsmi_get_processor_handles() ###Test amdsmi_get_gpu_device_bdf() | START walk_through | processor i = 0 ###Test Processor 0, bdf: 0000:08:00.0 @@ -871,27 +834,27 @@ PASSED ### Pytest Run: Verbose on + Filter (or exclude) a Test Use [Pytest: List tests](###-Pytest:-List-tests) then either exclude (with "not") or only run the specified test. -```python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/pytest/integration_test.py -k "test_gpu_performance" -v``` +```python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py -k "test_gpu_performance" -v``` -```python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/pytest/integration_test.py -k "not test_gpu_performance" -v``` +```python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py -k "not test_gpu_performance" -v``` ex.
Click for example: Pytest Run: Verbose on + Filter (or exclude) a Test ~~~shell -python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/pytest/integration_test.py -k "not test_gpu_performance" -v +python3 -m pytest -p no:cacheprovider /opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py -k "not test_gpu_performance" -v ===================================================== test session starts ===================================================== platform linux -- Python 3.8.10, pytest-8.2.2, pluggy-1.5.0 -- /usr/bin/python3 rootdir: /opt/rocm/share/amd_smi configfile: pyproject.toml collected 6 items / 1 deselected / 5 selected -../../opt/rocm/share/amd_smi/tests/pytest/integration_test.py::TestAmdSmiInit::test_init PASSED [ 20%] -../../opt/rocm/share/amd_smi/tests/pytest/integration_test.py::TestAmdSmiPythonInterface::test_bad_page_info PASSED [ 40%] -../../opt/rocm/share/amd_smi/tests/pytest/integration_test.py::TestAmdSmiPythonInterface::test_bdf_device_id PASSED [ 60%] -../../opt/rocm/share/amd_smi/tests/pytest/integration_test.py::TestAmdSmiPythonInterface::test_ecc PASSED [ 80%] -../../opt/rocm/share/amd_smi/tests/pytest/integration_test.py::TestAmdSmiPythonInterface::test_walkthrough PASSED [100%] +../../opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py::TestAmdSmiInit::test_init PASSED [ 20%] +../../opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py::TestAmdSmiPythonInterface::test_bad_page_info PASSED [ 40%] +../../opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py::TestAmdSmiPythonInterface::test_bdf_device_id PASSED [ 60%] +../../opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py::TestAmdSmiPythonInterface::test_ecc PASSED [ 80%] +../../opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py::TestAmdSmiPythonInterface::test_walkthrough PASSED [100%] =============================================== 5 passed, 1 deselected in 0.09s =============================================== ~~~ @@ -902,14 +865,14 @@ collected 6 items / 1 deselected / 5 selected Please refer to Python's UnitTest documentation for better overview of commands to run. ```shell -python3 /opt/rocm/share/amd_smi/tests/pytest/unit_tests.py -v +python3 /opt/rocm/share/amd_smi/tests/python_unittest/unit_tests.py -v test_check_res (tests.amd_smi_test.py-test.unit_tests.TestAmdSmiPythonBDF) ... ok test_format_bdf (tests.amd_smi_test.py-test.unit_tests.TestAmdSmiPythonBDF) ... ok test_parse_bdf (tests.amd_smi_test.py-test.unit_tests.TestAmdSmiPythonBDF) ... ok ``` ```shell -python3 /opt/rocm/share/amd_smi/tests/pytest/integration_test.py -v +python3 /opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py -v test_init (__main__.TestAmdSmiInit) ... ok test_bad_page_info (__main__.TestAmdSmiPythonInterface) ... ###Test amdsmi_get_gpu_bad_page_info @@ -1229,7 +1192,7 @@ OK ``` ```shell -(Tue Jul-7 12:07:47am)-(CPU 0.3%:0:Net 18)-(charpoag@mlsetools2:/opt/rocm/share/amd_smi/tests/pytest)-(44K:3) +(Tue Jul-7 12:07:47am)-(CPU 0.3%:0:Net 18)-(charpoag@mlsetools2:/opt/rocm/share/amd_smi/tests/python_unittest)-(44K:3) > python3 -m pytest -s -ra -vvv -p no:cacheprovider ==================================== test session starts ===================================== platform linux -- Python 3.8.10, pytest-8.2.2, pluggy-1.5.0 -- /usr/bin/python3 @@ -1553,7 +1516,7 @@ PASSED ``` ```shell -$ python3 /opt/rocm/share/amd_smi/tests/pytest/integration_test.py -k "*test_init" -vvv +$ python3 /opt/rocm/share/amd_smi/tests/python_unittest/integration_test.py -k "*test_init" -vvv test_init (__main__.TestAmdSmiInit) ... ok ---------------------------------------------------------------------- @@ -1564,7 +1527,7 @@ OK ``` ```shell -(Tue Jul-7 12:10:10am)-(CPU 0.3%:0:Net 16)-(charpoag@mlsetools2:/opt/rocm/share/amd_smi/tests/pytest)-(44K:3) +(Tue Jul-7 12:10:10am)-(CPU 0.3%:0:Net 16)-(charpoag@mlsetools2:/opt/rocm/share/amd_smi/tests/python_unittest)-(44K:3) > python3 -m pytest -ra -vvv -p no:cacheprovider ==================================== test session starts ===================================== platform linux -- Python 3.8.10, pytest-8.2.2, pluggy-1.5.0 -- /usr/bin/python3 diff --git a/projects/amdsmi/pytest/__init__.py b/projects/amdsmi/tests/python_unittest/__init__.py similarity index 100% rename from projects/amdsmi/pytest/__init__.py rename to projects/amdsmi/tests/python_unittest/__init__.py diff --git a/projects/amdsmi/pytest/integration_test.py b/projects/amdsmi/tests/python_unittest/integration_test.py similarity index 100% rename from projects/amdsmi/pytest/integration_test.py rename to projects/amdsmi/tests/python_unittest/integration_test.py diff --git a/projects/amdsmi/pytest/unit_tests.py b/projects/amdsmi/tests/python_unittest/unit_tests.py similarity index 100% rename from projects/amdsmi/pytest/unit_tests.py rename to projects/amdsmi/tests/python_unittest/unit_tests.py