Add unit tests for isSecureDbgSrvUnlocked and getDeviceTypeRFC to increase line coverage#227
Draft
Copilot wants to merge 3 commits into
Draft
Add unit tests for isSecureDbgSrvUnlocked and getDeviceTypeRFC to increase line coverage#227Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
Co-authored-by: KTirumalaSrihari <102281309+KTirumalaSrihari@users.noreply.github.com>
Co-authored-by: KTirumalaSrihari <102281309+KTirumalaSrihari@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add additional unit tests for new functions
Add unit tests for isSecureDbgSrvUnlocked and getDeviceTypeRFC to increase line coverage
Mar 18, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR #205 introduced
isSecureDbgSrvUnlockedandgetDeviceTypeRFCbut left several branches uncovered. This adds 10 targeted tests across both test files to close those gaps.isSecureDbgSrvUnlocked—unittest/deviceutils/device_api_gtest.cppeUNKNOWN→false(skips both branches entirely)eDEV→true(non-prod fast path)eQA→true(non-prod fast path)ePROD+ labsigned=true+ deviceType=prod→false(hitselse"unable to enable debug services" branch; prior tests only covered deviceType=testwith dbgServices=false)ePROD+ labsigned=""→false(hits "LABSIGNED_ENABLED not enabled" log path with empty string vs prior"false")getDeviceTypeRFC—unittest/fwdl_interface_gtest.cpp"PROD"/"TEST"/"Prod"→"prod"/"test"/"prod"(exercisesstrncasecmpcase-insensitivity; existing tests only used lowercase)""(verifiesstrncpy(dst, type, 0)+ forced NUL atdst[0])"unknown"(neitherstrncasecmpbranch matches)Housekeeping
.gitignorecovering autotools and gcov build artifacts (*.Po,*.gcno,Makefile,configure,autom4te.cache/, etc.)Original prompt
Overview
PR #205 introduces two new functions:
isSecureDbgSrvUnlocked(BUILDTYPE eBuildType)insrc/deviceutils/device_api.c— determines whether secure debug services may be enabled for the given build type.getDeviceTypeRFC(char *deviceType, size_t size)insrc/rfcInterface/rfcinterface.c— reads the device type RFC value and copies it into the provided buffer.PR #205 already includes some unit tests for these, but coverage is incomplete. The task is to add additional unit tests to maximize line coverage of these two new functions and the modified
GetServURL()function.Source code to be tested
isSecureDbgSrvUnlockedinsrc/deviceutils/device_api.c(lines 55-100):getDeviceTypeRFCinsrc/rfcInterface/rfcinterface.c(lines 298-323):Modified
GetServURLinsrc/deviceutils/device_api.cnow callsisSecureDbgSrvUnlocked(eBuildType)instead of the old(eBuildType != ePROD) || (dbgServices == true)pattern.Existing test infrastructure
Test file for device_api:
unittest/deviceutils/device_api_gtest.cppDeviceApiTestFixturetest fixture classg_DeviceUtilsMockof typeDeviceUtilsMock*isSecureDbgSrvUnlockedcovering: eVBN (non-prod), ePROD with various labsigned/deviceType/dbgServices combos, and getDevicePropertyData failure caseGetServURLtests with new mock expectationsTest file for rfcinterface:
unittest/fwdl_interface_gtest.cppInterfaceTestFixturetest fixture classg_InterfaceMockof typeFwDlInterfaceMock*getDeviceTypeRFCcovering: NULL args, read failure, prod, test, unknown/stagingMock class:
unittest/mocks/deviceutils_mock.hDeviceUtilsMockhas these relevant mock methods:MOCK_METHOD(bool, isDebugServicesEnabled, (), ())MOCK_METHOD(void, getDeviceTypeRFC, (char*, size_t), ())MOCK_METHOD(int, getDevicePropertyData, (const char *model, char *data, int size), ())MOCK_METHOD(void, t2ValNotify, (char *marker, char* value), ())MOCK_METHOD(bool, isInStateRed, (), ())MOCK_METHOD(int, filePresentCheck, (const char *filename), ())MOCK_METHOD(int, read_RFCProperty, (char* type, const char* key, char *out_value, size_t datasize), ())Build types available:
eUNKNOWN, eDEV, eVBN, ePROD, eQARequirements
Add additional tests to
unittest/deviceutils/device_api_gtest.cppto increase line coverage for the new code. Specifically, add the following missing test scenarios:For
isSecureDbgSrvUnlocked:false(neither non-p...This pull request was created from Copilot chat.
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.