canonical / checkbox

Checkbox is a testing framework used to validate device compatibility with Ubuntu Linux. It’s the testing tool developed for the purposes of the Ubuntu Certification program.
https://checkbox.readthedocs.io
GNU General Public License v3.0
33 stars 49 forks source link

Fixing index & type errors in prime_offload_tester.py (Bugfix) #1588

Open tomli380576 opened 1 week ago

tomli380576 commented 1 week ago

Description

This PR fixes the issue in the Resolved Issues section and replaced some type annotations with ones supported in python 3.5

Resolved issues

If prime_offload_tester.py was run with arguments like python3 prime_offload_tester.py -d i915 -p 0000:00:02.0 and the command to check is glxgears, the test always passes because it was checking if "glxgears"[0] is one of the clients of this GPU. Since "glxgears"[0] == 'g', it always matches the g in "tgid" in /sys/kernel/debug/dri/<card_pci_id>/clients.

command  tgid dev master a   uid      magic
systemd-logind  1124   1   y    y     0          0
      Xwayland  3014 128   n    n  1000          0
 gsd-xsettings  3403 128   n    n  1000          0
          code  4943 128   n    n  1000          0
          code  4943 128   n    n  1000          0
          code  4943 128   n    n  1000          0
xdg-desktop-por  3317 128   n    n  1000          0

Now it will check if the entire string "glxgears" appears in the file

Documentation

Tests

Unit tests Ran the script on 202408-34290 with -d i915 -p 0000:00:02.0 (Intel + NVIDIA desktop, expected to fail) and it correctly reports that prime offload didn't work

codecov[bot] commented 1 week ago

Codecov Report

Attention: Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.

Project coverage is 48.00%. Comparing base (76d8f30) to head (81fe325). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
providers/base/bin/prime_offload_tester.py 93.75% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1588 +/- ## ======================================= Coverage 48.00% 48.00% ======================================= Files 371 371 Lines 39833 39837 +4 Branches 6730 6730 ======================================= + Hits 19121 19125 +4 Misses 19994 19994 Partials 718 718 ``` | [Flag](https://app.codecov.io/gh/canonical/checkbox/pull/1588/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=canonical) | Coverage Δ | | |---|---|---| | [provider-base](https://app.codecov.io/gh/canonical/checkbox/pull/1588/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=canonical) | `24.73% <93.75%> (+0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=canonical#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.