summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2018-08-31 11:55:55 -0700
committerPatrick Venture <venture@google.com>2018-09-07 23:45:41 +0000
commit0b02be925a29357f69abbc9e9a58e7c5aaed2eab (patch)
treec1b39f817d98ffda7b987f9e3f864f576e3bf9ea /test
parent26f80ab2cc41deadc913190d906f71266c4ed224 (diff)
downloadphosphor-host-ipmid-0b02be925a29357f69abbc9e9a58e7c5aaed2eab.tar.gz
phosphor-host-ipmid-0b02be925a29357f69abbc9e9a58e7c5aaed2eab.zip
add .clang-format
Change-Id: I7c2a527b4751a560703a61fcbe9638b150546af5 Signed-off-by: Patrick Venture <venture@google.com>
Diffstat (limited to 'test')
-rw-r--r--test/oemrouter_unittest.cpp76
-rw-r--r--test/sample_unittest.cpp4
2 files changed, 41 insertions, 39 deletions
diff --git a/test/oemrouter_unittest.cpp b/test/oemrouter_unittest.cpp
index a5a79dd..b48798b 100644
--- a/test/oemrouter_unittest.cpp
+++ b/test/oemrouter_unittest.cpp
@@ -1,8 +1,10 @@
-#include "host-ipmid/ipmid-api.h"
#include "host-ipmid/oemrouter.hpp"
-#include "sample.h"
#include <cstring>
+
+#include "host-ipmid/ipmid-api.h"
+#include "sample.h"
+
#include <gtest/gtest.h>
// Watch for correct singleton behavior.
@@ -52,19 +54,18 @@ void RegisterWithRouter(Number oen, ipmi_cmd_t cmd, Handler cb)
singletonUnderTest->registerHandler(oen, cmd, cb);
}
-uint8_t msgPlain[] = { 0x56, 0x34, 0x12 };
-uint8_t replyPlain[] = { 0x56, 0x34, 0x12, 0x31, 0x41 };
-uint8_t msgPlus2[] = { 0x67, 0x45, 0x23, 0x10, 0x20 };
-uint8_t msgBadOen[] = { 0x57, 0x34, 0x12 };
+uint8_t msgPlain[] = {0x56, 0x34, 0x12};
+uint8_t replyPlain[] = {0x56, 0x34, 0x12, 0x31, 0x41};
+uint8_t msgPlus2[] = {0x67, 0x45, 0x23, 0x10, 0x20};
+uint8_t msgBadOen[] = {0x57, 0x34, 0x12};
-void RegisterTwoWays(ipmi_cmd_t *nextCmd)
+void RegisterTwoWays(ipmi_cmd_t* nextCmd)
{
- Handler f = [](ipmi_cmd_t cmd, const uint8_t* reqBuf,
- uint8_t* replyBuf, size_t* dataLen)
- {
+ Handler f = [](ipmi_cmd_t cmd, const uint8_t* reqBuf, uint8_t* replyBuf,
+ size_t* dataLen) {
// Check inputs
EXPECT_EQ(0x78, cmd);
- EXPECT_EQ(0, *dataLen); // Excludes OEN
+ EXPECT_EQ(0, *dataLen); // Excludes OEN
// Generate reply.
*dataLen = 2;
@@ -75,11 +76,10 @@ void RegisterTwoWays(ipmi_cmd_t *nextCmd)
*nextCmd = IPMI_CMD_WILDCARD;
Handler g = [nextCmd](ipmi_cmd_t cmd, const uint8_t* reqBuf,
- uint8_t* replyBuf, size_t* dataLen)
- {
+ uint8_t* replyBuf, size_t* dataLen) {
// Check inputs
EXPECT_EQ(*nextCmd, cmd);
- EXPECT_EQ(2, *dataLen); // Excludes OEN
+ EXPECT_EQ(2, *dataLen); // Excludes OEN
if (2 != *dataLen)
{
return 0xE0;
@@ -93,18 +93,21 @@ void RegisterTwoWays(ipmi_cmd_t *nextCmd)
};
RegisterWithRouter(0x234567, IPMI_CMD_WILDCARD, g);
}
-} // namespace
+} // namespace
-TEST(OemRouterTest, MakeRouterProducesConsistentSingleton) {
+TEST(OemRouterTest, MakeRouterProducesConsistentSingleton)
+{
MakeRouter();
}
-TEST(OemRouterTest, ActivateRouterSetsLastNetToOEMGROUP) {
+TEST(OemRouterTest, ActivateRouterSetsLastNetToOEMGROUP)
+{
lastNetFunction = 0;
ActivateRouter();
}
-TEST(OemRouterTest, VerifiesSpecificCommandMatches) {
+TEST(OemRouterTest, VerifiesSpecificCommandMatches)
+{
ipmi_cmd_t cmd;
uint8_t reply[256];
size_t dataLen;
@@ -112,9 +115,8 @@ TEST(OemRouterTest, VerifiesSpecificCommandMatches) {
RegisterTwoWays(&cmd);
dataLen = 3;
- EXPECT_EQ(0,
- wildHandler(NETFUN_OEM_GROUP, 0x78, msgPlain, reply,
- &dataLen, nullptr));
+ EXPECT_EQ(0, wildHandler(NETFUN_OEM_GROUP, 0x78, msgPlain, reply, &dataLen,
+ nullptr));
EXPECT_EQ(5, dataLen);
EXPECT_EQ(replyPlain[0], reply[0]);
EXPECT_EQ(replyPlain[1], reply[1]);
@@ -123,7 +125,8 @@ TEST(OemRouterTest, VerifiesSpecificCommandMatches) {
EXPECT_EQ(replyPlain[4], reply[4]);
}
-TEST(OemRouterTest, WildCardMatchesTwoRandomCodes) {
+TEST(OemRouterTest, WildCardMatchesTwoRandomCodes)
+{
ipmi_cmd_t cmd;
uint8_t reply[256];
size_t dataLen;
@@ -133,20 +136,19 @@ TEST(OemRouterTest, WildCardMatchesTwoRandomCodes) {
// Check two random command codes.
dataLen = 5;
cmd = 0x89;
- EXPECT_EQ(0,
- wildHandler(NETFUN_OEM_GROUP, cmd, msgPlus2, reply,
- &dataLen, nullptr));
+ EXPECT_EQ(0, wildHandler(NETFUN_OEM_GROUP, cmd, msgPlus2, reply, &dataLen,
+ nullptr));
EXPECT_EQ(3, dataLen);
dataLen = 5;
cmd = 0x67;
- EXPECT_EQ(0,
- wildHandler(NETFUN_OEM_GROUP, cmd, msgPlus2, reply,
- &dataLen, nullptr));
+ EXPECT_EQ(0, wildHandler(NETFUN_OEM_GROUP, cmd, msgPlus2, reply, &dataLen,
+ nullptr));
EXPECT_EQ(3, dataLen);
}
-TEST(OemRouterTest, CommandsAreRejectedIfInvalid) {
+TEST(OemRouterTest, CommandsAreRejectedIfInvalid)
+{
ipmi_cmd_t cmd;
uint8_t reply[256];
size_t dataLen;
@@ -156,20 +158,18 @@ TEST(OemRouterTest, CommandsAreRejectedIfInvalid) {
// Message too short to include whole OEN?
dataLen = 2;
EXPECT_EQ(IPMI_CC_REQ_DATA_LEN_INVALID,
- wildHandler(NETFUN_OEM_GROUP, 0x78, msgPlain, reply,
- &dataLen, nullptr));
+ wildHandler(NETFUN_OEM_GROUP, 0x78, msgPlain, reply, &dataLen,
+ nullptr));
// Wrong specific command?
dataLen = 3;
- EXPECT_EQ(IPMI_CC_INVALID,
- wildHandler(NETFUN_OEM_GROUP, 0x89, msgPlain, reply,
- &dataLen, nullptr));
+ EXPECT_EQ(IPMI_CC_INVALID, wildHandler(NETFUN_OEM_GROUP, 0x89, msgPlain,
+ reply, &dataLen, nullptr));
// Wrong OEN?
dataLen = 3;
- EXPECT_EQ(IPMI_CC_INVALID,
- wildHandler(NETFUN_OEM_GROUP, 0x78, msgBadOen, reply,
- &dataLen, nullptr));
+ EXPECT_EQ(IPMI_CC_INVALID, wildHandler(NETFUN_OEM_GROUP, 0x78, msgBadOen,
+ reply, &dataLen, nullptr));
}
-} // namespace oem
+} // namespace oem
diff --git a/test/sample_unittest.cpp b/test/sample_unittest.cpp
index 2a27279..e574173 100644
--- a/test/sample_unittest.cpp
+++ b/test/sample_unittest.cpp
@@ -1,6 +1,8 @@
#include "sample.h"
+
#include <gtest/gtest.h>
-TEST(FactorialTest, Zero) {
+TEST(FactorialTest, Zero)
+{
EXPECT_EQ(1, Factorial(0));
}
OpenPOWER on IntegriCloud