blob: 283640fc5de7762cc6d00bd245601bca04a4641b [file] [log] [blame]
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -05001#include "parser.hpp"
2#include "types.hpp"
3#include "utility/json_utility.hpp"
Rekha Aparnaca9a0862025-08-29 04:08:33 -05004#include "utility/vpd_specific_utility.hpp"
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -05005
6#include <iostream>
7
8#include <gtest/gtest.h>
9
10using namespace vpd;
11
12TEST(IsFruPowerOffOnlyTest, PositiveTestCase)
13{
Rekha Aparnaca9a0862025-08-29 04:08:33 -050014 uint16_t l_errCode = 0;
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -050015 const std::string l_jsonPath{"/usr/local/share/vpd/50001001.json"};
16 const std::string l_vpdPath{"/sys/bus/spi/drivers/at25/spi12.0/eeprom"};
Rekha Aparnaca9a0862025-08-29 04:08:33 -050017 const nlohmann::json l_parsedJson =
18 jsonUtility::getParsedJson(l_jsonPath, l_errCode);
19
20 if (l_errCode)
21 {
22 logging::logMessage(
23 "Failed to parse JSON file [" + l_jsonPath +
24 "], error : " + vpdSpecificUtility::getErrCodeMsg(l_errCode));
25 }
26
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -050027 const bool l_result =
28 jsonUtility::isFruPowerOffOnly(l_parsedJson, l_vpdPath);
29 EXPECT_TRUE(l_result);
30}
31
32TEST(IsFruPowerOffOnlyTest, NegativeTestCase)
33{
Rekha Aparnaca9a0862025-08-29 04:08:33 -050034 uint16_t l_errCode = 0;
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -050035 const std::string l_jsonPath{"/usr/local/share/vpd/50001001.json"};
36 const std::string l_vpdPath{"/sys/bus/i2c/drivers/at24/4-0050/eeprom"};
Rekha Aparnaca9a0862025-08-29 04:08:33 -050037 const nlohmann::json l_parsedJson =
38 jsonUtility::getParsedJson(l_jsonPath, l_errCode);
39
40 if (l_errCode)
41 {
42 logging::logMessage(
43 "Failed to parse JSON file [" + l_jsonPath +
44 "], error : " + vpdSpecificUtility::getErrCodeMsg(l_errCode));
45 }
46
Sunny Srivastavafa5e4d32023-03-12 11:59:49 -050047 const bool l_result =
48 jsonUtility::isFruPowerOffOnly(l_parsedJson, l_vpdPath);
49 EXPECT_FALSE(l_result);
50}