bios.h
1 #pragma once
2 
3 #include <iostream>
4 #include <functional>
5 #include "command.h"
6 
7 #ifdef TESTING
8 #include <gtest/gtest.h>
9 #endif
10 
16 class Bios
17 {
18 
19 public:
20  Bios();
21  virtual ~Bios();
22  static bool updateBios(const std::string &zipLocation, bool removeFile = true);
23  static bool getCurrentVersion(std::string &current_version);
24  static void removeInstalleFiles(const std::string &path);
25 
26 private:
27  static bool getZipVersion(std::string &new_version, std::string &path);
28  static inline std::function<std::string(std::string)> mCmdFunc = Command::GetStdoutFromCommand;
29  static bool isSameVersion(const std::string & current_bios_version, const std::string & update_version);
30  static bool checkFirmwareFile(const std::string & current_bios_version, std::string & firmware_file);
31 
32 #ifdef TESTING
33 public:
34  friend class UpdateBIOS_test;
35  FRIEND_TEST(UpdateBIOS_test,getZipBiosVersionOK);
36  FRIEND_TEST(UpdateBIOS_test,getZipBiosVersionKO);
37  FRIEND_TEST(UpdateBIOS_test,getCurrentBiosVersionOK);
38  FRIEND_TEST(UpdateBIOS_test,getCurrentBiosVersionNotValid2Numbers);
39  FRIEND_TEST(UpdateBIOS_test,getCurrentBiosVersionNotValidVersionLetters);
40  FRIEND_TEST(UpdateBIOS_test,updateBiosUnzipError);
41  FRIEND_TEST(UpdateBIOS_test,updateBiosVersionsMatch);
42  FRIEND_TEST(UpdateBIOS_test,updateBiosDifferentVersionsOK);
43  FRIEND_TEST(UpdateBIOS_test,updateBiosNoSuchFileFwuImage);
44  FRIEND_TEST(Commander_Handlers_test,BIOS_version_error_not_reported);
45  FRIEND_TEST(Commander_Handlers_test,BIOS_version_reported_OK);
46  FRIEND_TEST(UpdateBIOS_test,isSameVersionBIOS);
47  FRIEND_TEST(UpdateBIOS_test,checkFirmwareFileBIOS);
48 
49 #endif //TESTING
50 };
Defines a class for executing commands and getting output.
Class that triggers a BIOS update.
Definition: bios.h:16