diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..e70d41f8 --- /dev/null +++ b/.gitignore @@ -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/ diff --git a/unittest/deviceutils/device_api_gtest.cpp b/unittest/deviceutils/device_api_gtest.cpp index bc7a1c8d..a5c9322b 100644 --- a/unittest/deviceutils/device_api_gtest.cpp +++ b/unittest/deviceutils/device_api_gtest.cpp @@ -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); diff --git a/unittest/fwdl_interface_gtest.cpp b/unittest/fwdl_interface_gtest.cpp index 07b9ec36..d405a56c 100644 --- a/unittest/fwdl_interface_gtest.cpp +++ b/unittest/fwdl_interface_gtest.cpp @@ -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));