Patrick Venture | 6f17bd2 | 2018-08-07 13:24:17 -0700 | [diff] [blame] | 1 | #include "flash-ipmi.hpp" |
| 2 | |
| 3 | #include <cstdio> |
| 4 | #include <gtest/gtest.h> |
| 5 | #include <string> |
| 6 | |
| 7 | #define THIRTYTWO_MIB 33554432 |
| 8 | |
| 9 | TEST(FlashIpmiHashStartTest, OutofSequenceFails) |
| 10 | { |
| 11 | // Verify that the image must be started first. (can change). |
| 12 | |
| 13 | std::string name = std::tmpnam(nullptr); |
| 14 | std::string name2 = std::tmpnam(nullptr); |
| 15 | |
| 16 | FlashUpdate updater(name, name2); |
| 17 | EXPECT_FALSE(updater.startHash(THIRTYTWO_MIB)); |
| 18 | |
| 19 | (void)std::remove(name.c_str()); |
| 20 | (void)std::remove(name2.c_str()); |
| 21 | } |
| 22 | |
| 23 | TEST(FlashIpmiHashStartTest, VerifyHashFileCreated) |
| 24 | { |
| 25 | // Verify that it's happy. |
| 26 | |
| 27 | std::string name = std::tmpnam(nullptr); |
| 28 | std::string name2 = std::tmpnam(nullptr); |
| 29 | |
| 30 | FlashUpdate updater(name, name2); |
| 31 | EXPECT_TRUE(updater.start(THIRTYTWO_MIB)); |
| 32 | EXPECT_TRUE(updater.startHash(THIRTYTWO_MIB)); |
| 33 | |
| 34 | (void)std::remove(name.c_str()); |
| 35 | (void)std::remove(name2.c_str()); |
| 36 | } |