[VOL-3703] Performance Monitoring Attributes test
Currently test suite contains three test cases:
1. Test of pm data with default values
2. Test of pm data with user values
3. Test of pm data for disabled devices
Test 1 runs about 35 minutes.
Test 2 runs about  2 minutes.
Test 3 runs about  4 minutes

The suite is designed in a generic way. It collects all values to check by itself.
Further validation data can be passed via yaml file like ../data/pm-data.yaml
To have a determined state of devices a Sanity Check will be executed first.

Actually commands 'voltctl device pmconfig group list ...' printout the intvals without time unit.
Therefore some workarounds still included in this patch!

Change-Id: If115e85471221c321e8764cc890af583090189b2
diff --git a/libraries/utility.py b/libraries/utility.py
index 6faec6e..9da6a98 100755
--- a/libraries/utility.py
+++ b/libraries/utility.py
@@ -17,6 +17,7 @@
 from __future__ import print_function
 import inspect
 import os
+import operator
 
 # global definition of keys (find in given 'inventory_data')
 _NAME = 'name'
@@ -103,3 +104,35 @@
 def decode(data):
     decoded_data = data
     print(unique(), str(decoded_data))
+
+
+# Compares two values using a given operator. The values are converted to float first so that
+# numbers as strings are also accepted. Returns True or False.
+# operator: ==, !=, <, <=, >, >=
+# Example:
+# | ${result} | Compare | 100 | >  | 5  | # True |
+def compare(value1, op, value2):
+    ops = {"==": operator.eq,
+           "!=": operator.ne,
+           "<":  operator.lt,
+           "<=": operator.le,
+           ">":  operator.gt,
+           ">=": operator.ge}
+    return ops[op](float(value1), float(value2))
+
+
+# Validates two values using a given operator.
+# The values are converted to float first so that numbers as strings are also accepted.
+# Second value has to be a list in case of operator is 'in' or 'range'
+# Returns True or False.
+# operator: in, range, ==, !=, <, <=, >, >=
+# Example:
+# | ${result} | validate | 100 | >  | 5  | # True |
+# | ${result} | validate | 11  | in | ['11','264','329']  | # True |
+# | ${result} | validate | 1   | range | ['0','1']  | # True |
+def validate(value1, op, value2):
+    if op == "in":
+        return (float(value1) in [float(i) for i in value2])
+    if op == "range":
+        return ((compare(value1, ">=", value2[0])) and (compare(value1, "<=", value2[1])))
+    return compare(value1, op, value2)