Module: check_mk
Branch: master
Commit: d0e60a30a20ed75349ea192a6200fc0c7501dc1a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d0e60a30a20ed7…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Thu Jul 27 14:26:19 2017 +0200
WinAgent: Call WinAPI through adaptor interface
The target is to clean dependencies to Win API and to place them behind
an adaptor interface. This is necessary for unit testing, among others.
Use basic dependency injection: pass reference to adaptor instance
instead of calling windows API directly.
Additional fixes for portability and mocking:
* Use int64_t and uint64_t instead of Windows-specific (unsigned) __int64.
* Some win_error.* preprocessor _WIN32 defines were broken: they did not
compile without MINGW (that apparently always had _WIN32 on).
* CreateService from WinAPI has 13 (!) parameters, anything above 10
cannot be properly mocked with Google Mock. We never use the last 5
parameters (always zeroes), so they could be left out of WinApiAdaptor
and be filled in at the last step.
Additionally, refactor Environment in order to clear valgrind errors:
* Use const string members that are initialized in constructor member
initializer list.
* Use std::vector<char> as char buffer instead of manually
heap-allocated buffer.
Change-Id: I6a9503ab837c900d1f928c9d86cc711869c2e139
---
agents/windows/Configurable.h | 28 +-
agents/windows/Configuration.cc | 7 +-
agents/windows/Configuration.h | 6 +-
agents/windows/CrashHandler.cc | 80 +--
agents/windows/CrashHandler.h | 35 +-
agents/windows/Crypto.cc | 140 ++--
agents/windows/Crypto.h | 13 +-
agents/windows/Environment.cc | 167 +++--
agents/windows/Environment.h | 51 +-
agents/windows/EventLog.cc | 294 ++++----
agents/windows/EventLog.h | 79 +-
agents/windows/EventLogVista.cc | 144 +++-
agents/windows/EventLogVista.h | 102 ++-
agents/windows/ExternalCmd.cc | 84 ++-
agents/windows/ExternalCmd.h | 19 +-
agents/windows/IEventLog.cc | 11 +-
agents/windows/IEventLog.h | 9 +-
agents/windows/ListenSocket.cc | 72 +-
agents/windows/ListenSocket.h | 12 +-
agents/windows/Logger.cc | 49 +-
agents/windows/Logger.h | 13 +-
agents/windows/LoggerAdaptor.h | 11 +-
agents/windows/Makefile | 2 +-
agents/windows/OHMMonitor.cc | 51 +-
agents/windows/OHMMonitor.h | 6 +-
agents/windows/OutputProxy.cc | 28 +-
agents/windows/OutputProxy.h | 10 +-
agents/windows/PerfCounter.cc | 279 ++++----
agents/windows/PerfCounter.h | 31 +-
agents/windows/PerfCounterCommon.cc | 24 +-
agents/windows/PerfCounterCommon.h | 10 +-
agents/windows/PerfCounterPdh.cc | 3 +-
agents/windows/PerfCounterPdh.h | 1 -
agents/windows/Section.cc | 11 +-
agents/windows/Section.h | 7 +-
agents/windows/SectionManager.cc | 133 ++--
agents/windows/SectionManager.h | 8 +-
agents/windows/Thread.cc | 18 +-
agents/windows/Thread.h | 7 +-
agents/windows/WinApi.cc | 870 +++++++++++++++++++++++
agents/windows/WinApi.h | 429 +++++++++++
agents/windows/WinApiAdaptor.h | 460 ++++++++++++
agents/windows/build_version | 2 +-
agents/windows/check_mk_agent-64.exe | Bin 1372160 -> 1382912 bytes
agents/windows/check_mk_agent-64.unstripped.exe | Bin 17176174 -> 17449197 bytes
agents/windows/check_mk_agent-64.unversioned.exe | Bin 1372160 -> 1382912 bytes
agents/windows/check_mk_agent.cc | 216 +++---
agents/windows/check_mk_agent.exe | Bin 1354240 -> 1359872 bytes
agents/windows/check_mk_agent.msi | Bin 2997248 -> 3013632 bytes
agents/windows/check_mk_agent.unstripped.exe | Bin 14999417 -> 15247150 bytes
agents/windows/check_mk_agent.unversioned.exe | Bin 1354240 -> 1359872 bytes
agents/windows/crash.exe | Bin 358864 -> 358864 bytes
agents/windows/dynamic_func.h | 18 +-
agents/windows/install_agent-64.exe | Bin 604756 -> 606728 bytes
agents/windows/install_agent.exe | Bin 604190 -> 605804 bytes
agents/windows/nowin.exe | Bin 361000 -> 361000 bytes
agents/windows/plugins/citrix_xenapp.ps1 | 2 +-
agents/windows/plugins/mk_jolokia.exe | Bin 10088473 -> 10106814 bytes
agents/windows/sections/SectionCheckMK.cc | 47 +-
agents/windows/sections/SectionCheckMK.h | 9 +-
agents/windows/sections/SectionCrashDebug.cc | 12 +-
agents/windows/sections/SectionCrashDebug.h | 7 +-
agents/windows/sections/SectionDF.cc | 57 +-
agents/windows/sections/SectionDF.h | 6 +-
agents/windows/sections/SectionEventlog.cc | 72 +-
agents/windows/sections/SectionEventlog.h | 15 +-
agents/windows/sections/SectionFileinfo.cc | 85 +--
agents/windows/sections/SectionFileinfo.h | 15 +-
agents/windows/sections/SectionGroup.cc | 25 +-
agents/windows/sections/SectionGroup.h | 6 +-
agents/windows/sections/SectionLogwatch.cc | 107 ++-
agents/windows/sections/SectionLogwatch.h | 26 +-
agents/windows/sections/SectionMRPE.cc | 41 +-
agents/windows/sections/SectionMRPE.h | 9 +-
agents/windows/sections/SectionMem.cc | 17 +-
agents/windows/sections/SectionMem.h | 5 +-
agents/windows/sections/SectionOHM.cc | 17 +-
agents/windows/sections/SectionOHM.h | 9 +-
agents/windows/sections/SectionPS.cc | 113 +--
agents/windows/sections/SectionPS.h | 18 +-
agents/windows/sections/SectionPerfcounter.cc | 28 +-
agents/windows/sections/SectionPerfcounter.h | 7 +-
agents/windows/sections/SectionPluginGroup.cc | 259 +++----
agents/windows/sections/SectionPluginGroup.h | 59 +-
agents/windows/sections/SectionServices.cc | 60 +-
agents/windows/sections/SectionServices.h | 27 +-
agents/windows/sections/SectionSkype.cc | 23 +-
agents/windows/sections/SectionSkype.h | 7 +-
agents/windows/sections/SectionSpool.cc | 35 +-
agents/windows/sections/SectionSpool.h | 7 +-
agents/windows/sections/SectionSystemtime.cc | 7 +-
agents/windows/sections/SectionSystemtime.h | 5 +-
agents/windows/sections/SectionUptime.cc | 19 +-
agents/windows/sections/SectionUptime.h | 8 +-
agents/windows/sections/SectionWMI.cc | 25 +-
agents/windows/sections/SectionWMI.h | 10 +-
agents/windows/sections/SectionWinperf.cc | 26 +-
agents/windows/sections/SectionWinperf.h | 5 +-
agents/windows/stringutil.cc | 51 +-
agents/windows/stringutil.h | 18 +-
agents/windows/types.cc | 34 +-
agents/windows/types.h | 69 +-
agents/windows/win_error.cc | 56 ++
agents/windows/win_error.h | 45 ++
agents/windows/wmiHelper.cc | 164 +++--
agents/windows/wmiHelper.h | 33 +-
106 files changed, 4038 insertions(+), 1819 deletions(-)
Diff:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=d0e60a30a2…