Skip to content

test: 增量补全未覆盖方法单元测试(DeviceNetwork/Print/Storage/DBusDriverInterface/EDIDParser) - #727

Draft
add-uos wants to merge 1 commit into
linuxdeepin:masterfrom
add-uos:ut/devicemanager-covgap-20260810
Draft

test: 增量补全未覆盖方法单元测试(DeviceNetwork/Print/Storage/DBusDriverInterface/EDIDParser)#727
add-uos wants to merge 1 commit into
linuxdeepin:masterfrom
add-uos:ut/devicemanager-covgap-20260810

Conversation

@add-uos

@add-uos add-uos commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

增量补全未覆盖函数单元测试(批次 1)

本 PR 增量补全 GUI(deepin-devicemanager)测试中此前未覆盖的方法,提升函数覆盖率。所有新增测试文件均放在项目既有的 tests/src/<模块>/ 目录下,构建通过 file(GLOB_RECURSE) 自动纳入,无需改动 CMakeLists。

本批次覆盖的方法

模块 新覆盖方法
DeviceManager DeviceNetwork vendor, isWireless, hwAddress, canDisable
DeviceManager DevicePrint vendor, makeAndeModel
DeviceManager DeviceStorage getManfName, getOemName
DriverControl DBusDriverInterface installDriver(1/2 参), undoInstallDriver, backupDeb, delDeb, aptUpdate
GenerateDevice EDIDParser hexToBin

构建与验证

  • 环境:Qt6 6.8.0 + Dtk6 + GCC,CMAKE_COVERAGE_ARG=CMAKE_COVERAGE_ARG_ON
  • 编译:make deepin-devicemanager-test 通过
  • 运行:新增 27 个用例全部通过;全量 1121 用例,1115 通过
  • GUI 函数覆盖率:87.3% → 88.2%

既有失败(非本批次引入)

6 个既有失败均为键盘设备解析相关(依赖 hwinfo/lshw//proc/bus/input/devices 在容器内缺失),属环境相关:

  • UT_DeviceManager_addKeyboardDevice
  • UT_CmdTool_loadHciconfigInfo_002
  • UT_DeviceGenerator_generatorKeyboardDevice
  • UT_DeviceGenerator_getKeyboardInfoFromHwinfo/Lshw/CatDevices

基线

  • commit: 89825dcd (2026-08-06) fix(gpu): fix GPU VRAM size parsing failure on multi-line gpu-info

Draft PR,后续批次继续补全剩余未覆盖函数直至函数覆盖率达标。

Summary by Sourcery

Add incremental unit tests to increase coverage for previously untested device and driver helper methods.

Tests:

  • Add tests for DeviceNetwork accessors (vendor, wireless flag, hardware address, disable capability).
  • Add tests for DevicePrint accessors and vendor parsing based on printer info metadata.
  • Add tests for DeviceStorage manufacturer and OEM name mapping and edge-case handling.
  • Add tests for DBusDriverInterface driver installation, rollback, backup, deletion, and apt update operations under stubbed DBus.
  • Add tests for EDIDParser hex-to-binary conversion for typical and boundary hex values.

…hods

Incrementally cover previously-uncovered functions and raise function
coverage on the GUI (deepin-devicemanager) test binary.

Batch classes covered:
- DeviceManager/DeviceNetwork: vendor, isWireless, hwAddress, canDisable
- DeviceManager/DevicePrint: vendor, makeAndeModel
- DeviceManager/DeviceStorage: getManfName, getOemName
- DriverControl/DBusDriverInterface: installDriver(1&2 args), undoInstallDriver,
  backupDeb, delDeb, aptUpdate
- GenerateDevice/EDIDParser: hexToBin

Batch stats: 27 new test cases, all passing. Full suite 1121 cases,
1115 passed; 6 pre-existing failures (keyboard-device parsing, environment
related, not introduced by this batch).
GUI function coverage: 87.3% -> 88.2%.

Baseline commit: 89825dc (2026-08-06)
  fix(gpu): fix GPU VRAM size parsing failure on multi-line gpu-info
@deepin-ci-robot

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds new GoogleTest-based unit tests to incrementally cover previously untested accessor and helper methods across DeviceNetwork, DevicePrint, DeviceStorage, DBusDriverInterface, and EDIDParser, relying on existing test infrastructure, DBus stubs, and -fno-access-control to safely exercise internal logic and improve function coverage.

File-Level Changes

Change Details Files
Add DBusDriverInterface driver management tests that exercise DBus-backed methods without asserting on stubbed DBus results.
  • Introduce UT_DBusDriverInterfaceExtra fixture obtaining DBusDriverInterface singleton in SetUp.
  • Add tests for single-argument and two-argument installDriver ensuring calls complete without fatal failures.
  • Add tests for undoInstallDriver, backupDeb, delDeb, and aptUpdate that tolerate both true/false returns while ensuring no crashes.
deepin-devicemanager/tests/src/DriverControl/ut_dbusdriverinterface_extra2.cpp
Add DeviceNetwork accessor tests by directly manipulating protected members to validate getter behavior.
  • Create UT_DeviceNetworkAccessors fixture allocating and cleaning up DeviceNetwork instances per test.
  • Cover vendor(), isWireless(), hwAddress(), and canDisable() by setting m_Vendor, m_IsWireless, m_MACAddress, and m_SysPath directly under -fno-access-control.
  • Verify canDisable() behavior for empty versus non-empty sysfs path.
deepin-devicemanager/tests/src/DeviceManager/ut_devicenetwork_extra.cpp
Add DevicePrint tests to cover vendor parsing and makeAndeModel accessors based on setInfo and protected state.
  • Introduce UT_DevicePrintVendor fixture managing a DevicePrint instance lifecycle.
  • Add helper to populate mapinfo with realistic printer fields and feed into setInfo.
  • Assert vendor() parses the first token of "printer-info" and makeAndeModel() returns m_MakeAndModel set directly.
deepin-devicemanager/tests/src/DeviceManager/ut_deviceprint_extra.cpp
Add DeviceStorage manufacturer/OEM name tests targeting table-lookup behavior and defensive handling of unknown or empty IDs.
  • Introduce UT_DeviceStorageManf fixture holding a DeviceStorage instance.
  • Test getManfName() with unknown and hex-prefixed IDs to ensure non-empty result and normalization path are exercised.
  • Test getOemName() with unknown and empty-like inputs, focusing on non-crashing behavior and non-empty outputs where applicable.
deepin-devicemanager/tests/src/DeviceManager/ut_devicestorage_extra.cpp
Add EDIDParser hexToBin tests to exercise hex-to-binary conversion for several representative inputs.
  • Introduce UT_EDIDParserHex fixture constructing and destroying EDIDParser per test.
  • Add tests covering hexToBin() for typical values like "FF", small non-zero values, and "0".
  • Assert only that outputs are non-empty, avoiding over-constraining the binary representation.
deepin-devicemanager/tests/src/GenerateDevice/ut_edidparser_extra.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-bot

deepin-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.0.70
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #724

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants