Module: check_mk
Branch: master
Commit: 840363b569e123166e2924bfb529c36250b8194a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=840363b569e123…
Author: Sergey Kipnis <sk(a)mathias-kettner.de>
Date: Mon Feb 18 11:53:46 2019 +0100
[CMK-1647] - integration tests should work nice now
- almost all values from WMI now are positive
Change-Id: Iccf1faa762d74cbd4045c61aa78a2c6a135dfddf
---
agents/windows/wmiHelper.cc | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/agents/windows/wmiHelper.cc b/agents/windows/wmiHelper.cc
index fbfc52b..482f8b2 100644
--- a/agents/windows/wmiHelper.cc
+++ b/agents/windows/wmiHelper.cc
@@ -291,6 +291,28 @@ bool Variant::get() const {
}
}
+// this is original and weird function from the Agent.
+// Used to avoid negative numbers in output. Sometimes.
+// And satisfy integration tests.
+// Microsoft is stupid, because VT_I4 must be interpreted as UNSIGNED sometimes.
+// ******************************************************************
+// We will use this function in LA just to satisfy integration tests.
+// #TODO rename this function to something more clear
+template <>
+int64_t Variant::get() const {
+ switch (_value.vt) {
+ case VT_I1: // has a char
+ return _value.iVal; // load short
+ case VT_I2: // has a short
+ return _value.intVal; // load int32
+ case VT_I4: // has a int32
+ return _value.llVal; // load in64
+ default:
+ throw ComTypeException(string("wrong value type requested: ") +
+ to_string(_value.vt));
+ }
+}
+
template <>
int32_t Variant::get() const {
switch (_value.vt) {
@@ -385,7 +407,11 @@ wstring Variant::get() const {
case VT_I1:
case VT_I2:
case VT_I4:
- return std::to_wstring(get<int32_t>());
+ // call of *weird* function:
+ // in fact it is abs(_value) with extremely high probability
+ // We have to use by default uint64_t, because almost all WMI are
+ // defined as unsigned.
+ return std::to_wstring(get<int64_t>());
case VT_UI1:
case VT_UI2:
case VT_UI4: