libpldmresponder: PDR: check config dir
Gracefully exist if PDR config directory doesn't exist.
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Change-Id: Iee4210469f275f574fc9c9b8da183003497bfb2d
diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp
index af89a94..88ddcf8 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -67,6 +67,11 @@
void Handler::generate(const std::string& dir, Repo& repo)
{
+ if (!fs::exists(dir))
+ {
+ return;
+ }
+
// A map of PDR type to a lambda that handles creation of that PDR type.
// The lambda essentially would parse the platform specific PDR JSONs to
// generate the PDR structures. This function iterates through the map to
diff --git a/test/libpldmresponder_pdr_effecter_test.cpp b/test/libpldmresponder_pdr_effecter_test.cpp
index 6e36b3b..a9afc6b 100644
--- a/test/libpldmresponder_pdr_effecter_test.cpp
+++ b/test/libpldmresponder_pdr_effecter_test.cpp
@@ -145,17 +145,6 @@
pldm_pdr_destroy(outPDRRepo);
}
-TEST(GeneratePDR, testNoJson)
-{
- auto pdrRepo = pldm_pdr_init();
-
- ASSERT_THROW(Handler("./pdr_jsons/not_there", "./event_jsons/not_there",
- pdrRepo, nullptr, nullptr),
- std::exception);
-
- pldm_pdr_destroy(pdrRepo);
-}
-
TEST(GeneratePDR, testMalformedJson)
{
auto inPDRRepo = pldm_pdr_init();