Add --strict-failsafe-pwm compile flag

This build flag is used to set the fans strictly at the failsafe
percent when in failsafe mode, even when the calculated PWM is higher
than failsafe PWM. Without this enabled, the PWM is calculated and set
to the calculated PWM  the failsafe PWM, whichever is higher.

Added a unit test that can test this new build flag code path if the
compile flag is defined.

Tested:

Verified on an internal machine that by adding the following to the
bbappend:

EXTRA_OECONF:append = " --enable-strict-failsafe-pwm=yes"

With flag:
ipmitool sensor list
fan_pwm         | 89.768

Without flag:
ipmitool sensor list
fan_pwm         | 99.960

We can see that the fan pwm was limited to the failsafe percentage when
in failsafe mode with the flag. Without the flag, it ran at 100%

Bug-Id: openbmc/phosphor-pid-control#17
Signed-off-by: Brandon Kim <brandonkim@google.com>
Change-Id: I72a1e5aab8d3e5b0e3716f0b3720d704a6f05008
diff --git a/pid/fancontroller.cpp b/pid/fancontroller.cpp
index d7ac0e6..33e2d9f 100644
--- a/pid/fancontroller.cpp
+++ b/pid/fancontroller.cpp
@@ -130,11 +130,22 @@
     {
         if (_owner->getFailSafeMode())
         {
-            /* In case it's being set to 100% */
-            if (percent < _owner->getFailSafePercent())
+            double failsafePercent = _owner->getFailSafePercent();
+
+#ifdef STRICT_FAILSAFE_PWM
+            // Unconditionally replace the computed PWM with the
+            // failsafe PWM if STRICT_FAILSAFE_PWM is defined.
+            percent = failsafePercent;
+#else
+            // Ensure PWM is never lower than the failsafe PWM.
+            // The computed PWM is still allowed to rise higher than
+            // failsafe PWM if STRICT_FAILSAFE_PWM is NOT defined.
+            // This is the default behavior.
+            if (percent < failsafePercent)
             {
-                percent = _owner->getFailSafePercent();
+                percent = failsafePercent;
             }
+#endif
         }
     }