Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Build artifacts
*.o
*.a
*.so
*.gcno
*.gcda
*.gcov
*.Po
*.la
*.lo

# Autotools generated files
aclocal.m4
autom4te.cache/
config.guess
config.log
config.status
config.sub
compile
configure
depcomp
install-sh
libtool
ltmain.sh
missing
Makefile
Makefile.in
.deps/

# Coverage reports
coverage/
57 changes: 57 additions & 0 deletions unittest/deviceutils/device_api_gtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,63 @@ TEST_F(DeviceApiTestFixture, TestName_isSecureDbgSrvUnlocked_Prod_LabsignedPrope
EXPECT_FALSE(isSecureDbgSrvUnlocked(ePROD));
}

/* eUNKNOWN build type → false (neither non-prod nor ePROD path triggers unlock) */
TEST_F(DeviceApiTestFixture, TestName_isSecureDbgSrvUnlocked_Unknown_Locked)
{
EXPECT_FALSE(isSecureDbgSrvUnlocked(eUNKNOWN));
}

/* eDEV build type → true (non-prod, always unlocked) */
TEST_F(DeviceApiTestFixture, TestName_isSecureDbgSrvUnlocked_Dev_Unlocked)
{
EXPECT_TRUE(isSecureDbgSrvUnlocked(eDEV));
}

/* eQA build type → true (non-prod, always unlocked) */
TEST_F(DeviceApiTestFixture, TestName_isSecureDbgSrvUnlocked_QA_Unlocked)
{
EXPECT_TRUE(isSecureDbgSrvUnlocked(eQA));
}

/* ePROD + labsigned=true + deviceType=prod + dbgServices=false → locked ("unable to enable debug services") */
TEST_F(DeviceApiTestFixture, TestName_isSecureDbgSrvUnlocked_Prod_Labsigned_DeviceTypeProd_Locked)
{
EXPECT_CALL(*g_DeviceUtilsMock, isDebugServicesEnabled()).Times(1).WillOnce(Return(false));
EXPECT_CALL(*g_DeviceUtilsMock, getDeviceTypeRFC(_, _))
.Times(1)
.WillOnce(Invoke([](char* deviceType, size_t size) {
strncpy(deviceType, "prod", size - 1);
deviceType[size - 1] = '\0';
}));
EXPECT_CALL(*g_DeviceUtilsMock, getDevicePropertyData(StrEq("LABSIGNED_ENABLED"), _, _))
.Times(1)
.WillOnce(Invoke([](const char* /*model*/, char* data, int size) {
strncpy(data, "true", size - 1);
data[size - 1] = '\0';
return 0;
}));
EXPECT_FALSE(isSecureDbgSrvUnlocked(ePROD));
}

/* ePROD + labsigned empty string → locked ("LABSIGNED_ENABLED not enabled" log path) */
TEST_F(DeviceApiTestFixture, TestName_isSecureDbgSrvUnlocked_Prod_LabsignedEmpty_Locked)
{
EXPECT_CALL(*g_DeviceUtilsMock, isDebugServicesEnabled()).Times(1).WillOnce(Return(true));
EXPECT_CALL(*g_DeviceUtilsMock, getDeviceTypeRFC(_, _))
.Times(1)
.WillOnce(Invoke([](char* deviceType, size_t size) {
strncpy(deviceType, "test", size - 1);
deviceType[size - 1] = '\0';
}));
EXPECT_CALL(*g_DeviceUtilsMock, getDevicePropertyData(StrEq("LABSIGNED_ENABLED"), _, _))
.Times(1)
.WillOnce(Invoke([](const char* /*model*/, char* data, int /*size*/) {
data[0] = '\0';
return 0;
}));
EXPECT_FALSE(isSecureDbgSrvUnlocked(ePROD));
}

TEST_F(DeviceApiTestFixture, TestName_GetServURL_Nullcheck)
{
EXPECT_EQ(GetServURL(NULL, 0), 0);
Expand Down
65 changes: 65 additions & 0 deletions unittest/fwdl_interface_gtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,71 @@ TEST_F(InterfaceTestFixture, TestName_getDeviceTypeRFCUnknown)
getDeviceTypeRFC(deviceType, sizeof(deviceType));
EXPECT_STREQ(deviceType, "unknown");
}
/* Case-insensitive match: "PROD" (uppercase) → "prod" */
TEST_F(InterfaceTestFixture, TestName_getDeviceTypeRFCProdUpperCase)
{
char deviceType[32] = {0};
EXPECT_CALL(*g_InterfaceMock, getRFCParameter(_, _, _))
.Times(1)
.WillOnce(Invoke([](char* /*type*/, const char* /*key*/, RFC_ParamData_t *param) {
snprintf(param->value, sizeof(param->value), "%s", "PROD");
return WDMP_SUCCESS;
}));
getDeviceTypeRFC(deviceType, sizeof(deviceType));
EXPECT_STREQ(deviceType, "prod");
}
/* Case-insensitive match: "TEST" (uppercase) → "test" */
TEST_F(InterfaceTestFixture, TestName_getDeviceTypeRFCTestUpperCase)
{
char deviceType[32] = {0};
EXPECT_CALL(*g_InterfaceMock, getRFCParameter(_, _, _))
.Times(1)
.WillOnce(Invoke([](char* /*type*/, const char* /*key*/, RFC_ParamData_t *param) {
snprintf(param->value, sizeof(param->value), "%s", "TEST");
return WDMP_SUCCESS;
}));
getDeviceTypeRFC(deviceType, sizeof(deviceType));
EXPECT_STREQ(deviceType, "test");
}
/* Case-insensitive match: "Prod" (mixed case) → "prod" */
TEST_F(InterfaceTestFixture, TestName_getDeviceTypeRFCProdMixedCase)
{
char deviceType[32] = {0};
EXPECT_CALL(*g_InterfaceMock, getRFCParameter(_, _, _))
.Times(1)
.WillOnce(Invoke([](char* /*type*/, const char* /*key*/, RFC_ParamData_t *param) {
snprintf(param->value, sizeof(param->value), "%s", "Prod");
return WDMP_SUCCESS;
}));
getDeviceTypeRFC(deviceType, sizeof(deviceType));
EXPECT_STREQ(deviceType, "prod");
}
/* Buffer size = 1 → empty NUL-terminated string (truncation edge case) */
TEST_F(InterfaceTestFixture, TestName_getDeviceTypeRFCBufferSizeOne)
{
char deviceType[1] = {'X'};
EXPECT_CALL(*g_InterfaceMock, getRFCParameter(_, _, _))
.Times(1)
.WillOnce(Invoke([](char* /*type*/, const char* /*key*/, RFC_ParamData_t *param) {
snprintf(param->value, sizeof(param->value), "%s", "prod");
return WDMP_SUCCESS;
}));
getDeviceTypeRFC(deviceType, 1);
EXPECT_EQ(deviceType[0], '\0');
}
/* Empty string from RFC → "unknown" */
TEST_F(InterfaceTestFixture, TestName_getDeviceTypeRFCEmptyString)
{
char deviceType[32] = {0};
EXPECT_CALL(*g_InterfaceMock, getRFCParameter(_, _, _))
.Times(1)
.WillOnce(Invoke([](char* /*type*/, const char* /*key*/, RFC_ParamData_t *param) {
snprintf(param->value, sizeof(param->value), "%s", "");
return WDMP_SUCCESS;
}));
getDeviceTypeRFC(deviceType, sizeof(deviceType));
EXPECT_STREQ(deviceType, "unknown");
}
TEST_F(InterfaceTestFixture, TestName_isIncremetalCDLEnableSuccess)
{
EXPECT_CALL(*g_InterfaceMock, getRFCParameter(_, _, _)).Times(1).WillOnce(Return(1));
Expand Down