Skip to content

Instantly share code, notes, and snippets.

@smccarney
Created April 24, 2021 14:52
Show Gist options
  • Save smccarney/5ae989da1977162ae1a21c208d5302fc to your computer and use it in GitHub Desktop.
Save smccarney/5ae989da1977162ae1a21c208d5302fc to your computer and use it in GitHub Desktop.
Test plan for DBusSensor class

Test plan for DBusSensor class

  • src/sensors.hpp
    • Verify sizeof(SensorType) == 1
    • Verify toString(SensorType) still works (regression)
  • src/dbus_sensor.*
    • DBusSensor()
      • Verify 4 args to getTypeBasedProperties are returned successfully
        • objectPath
        • unit
        • minValue
        • maxValue
      • Verify that 2 associations are returned successfully
        • "chassis", "all_sensors",
        • "inventory", "sensors",
      • Verify that no signals are emitted until object is completely initialized
      • Verify value is set correctly
      • Verify maxValue is set correctly
      • Verify minValue is set correctly
      • Verify unit is set correctly
      • Verify functional is set to true
      • Verify available is set to true
      • Verify all associations are created successfully
        • /xyz/openbmc_project/sensors///chassis -> /xyz/openbmc_project/inventory/system/chassis
        • /xyz/openbmc_project/inventory/system/chassis/all_sensors -> /xyz/openbmc_project/sensors//
        • /xyz/openbmc_project/sensors///inventory -> /xyz/openbmc_project/inventory/system/chassis/<inventory_item>
        • /xyz/openbmc_project/inventory/system/chassis/<inventory_item>/sensors -> /xyz/openbmc_project/sensors//
      • Verify emits object_added at end. Verify it contains all interfaces and properties
        • xyz.openbmc_project.Sensor.Value
          • Value
          • MaxValue
          • MinValue
          • Unit
        • xyz.openbmc_project.State.Decorator.OperationalStatus
          • Functional
        • xyz.openbmc_project.State.Decorator.Availability
          • Available
        • xyz.openbmc_project.Association.Definitions
          • Associations
    • ~DBusSensor()
      • Verify the object removed signal is emitted. Verify contains all interfaces
        • xyz.openbmc_project.Sensor.Value
        • xyz.openbmc_project.State.Decorator.OperationalStatus
        • xyz.openbmc_project.State.Decorator.Availability
        • xyz.openbmc_project.Association.Definitions
    • disable()
      • Verify sets value to NaN
        • Verify PropertiesChanged signal emitted on first call
        • Verify PropertiesChanged signal not emitted on second call
      • Verify sets available to false
        • Verify PropertiesChanged signal emitted on first call
        • Verify PropertiesChanged signal not emitted on second call
    • getName()
      • Verify returns base name of sensor
    • getRail()
      • Verify returns unique ID of rail associated with sensor
    • getType()
      • Verify returns sensor type
    • setToErrorState()
      • Verify sets value to NaN
        • Verify PropertiesChanged signal emitted on first call
        • Verify PropertiesChanged signal not emitted on second call
      • Verify sets functional to false
        • Verify PropertiesChanged signal emitted on first call
        • Verify PropertiesChanged signal not emitted on second call
    • setValue()
      • Test where value should be updated
        • Verify value is changed
        • Verify PropertiesChanged signal is emitted
      • Test where value should be not be updated
        • Verify value is not changed
        • Verify PropertiesChanged signal is not emitted
      • Verify sets functional to true
        • Verify PropertiesChanged signal emitted on first call
        • Verify PropertiesChanged signal not emitted on second call
      • Verify sets available to true
        • Verify PropertiesChanged signal emitted on first call
        • Verify PropertiesChanged signal not emitted on second call
    • getAssociations()
      • Verify adds two tuples to vector
        • Tuple 1: "chassis", "all_sensors",
        • Tuple 2: "inventory", "sensors",
    • getTypeBasedProperties()
      • iout
        • typeNamespace = "current"
        • unit = Amperes
        • minValue = 0.0
        • maxValue = 500.0
        • updatePolicy = ValueUpdatePolicy::hysteresis
        • hysteresis = 1.0
        • objectPath = "/xyz/openbmc_project/sensors/current/"
      • iout_peak
        • typeNamespace = "current"
        • unit = Amperes
        • minValue = 0.0
        • maxValue = 500.0
        • updatePolicy = ValueUpdatePolicy::highest
        • hysteresis = 0.0
        • objectPath = "/xyz/openbmc_project/sensors/current/"
      • iout_valley
        • typeNamespace = "current"
        • unit = Amperes
        • minValue = 0.0
        • maxValue = 500.0
        • updatePolicy = ValueUpdatePolicy::lowest
        • hysteresis = 0.0
        • objectPath = "/xyz/openbmc_project/sensors/current/"
      • pout
        • typeNamespace = "power"
        • unit = Watts
        • minValue = 0.0
        • maxValue = 1000.0
        • updatePolicy = ValueUpdatePolicy::hysteresis
        • hysteresis = 1.0
        • objectPath = "/xyz/openbmc_project/sensors/power/"
      • temperature
        • typeNamespace = "temperature"
        • unit = DegreesC
        • minValue = -50.0
        • maxValue = 250.0
        • updatePolicy = ValueUpdatePolicy::hysteresis
        • hysteresis = 1.0
        • objectPath = "/xyz/openbmc_project/sensors/temperature/"
      • temperature_peak
        • typeNamespace = "temperature"
        • unit = DegreesC
        • minValue = -50.0
        • maxValue = 250.0
        • updatePolicy = ValueUpdatePolicy::highest
        • hysteresis = 0.0
        • objectPath = "/xyz/openbmc_project/sensors/temperature/"
      • vout
        • typeNamespace = "voltage"
        • unit = Volts
        • minValue = -15.0
        • maxValue = 15.0
        • updatePolicy = ValueUpdatePolicy::hysteresis
        • hysteresis = 0.001
        • objectPath = "/xyz/openbmc_project/sensors/voltage/"
      • vout_peak
        • typeNamespace = "voltage"
        • unit = Volts
        • minValue = -15.0
        • maxValue = 15.0
        • updatePolicy = ValueUpdatePolicy::highest
        • hysteresis = 0.0
        • objectPath = "/xyz/openbmc_project/sensors/voltage/"
      • vout_valley
        • typeNamespace = "voltage"
        • unit = Volts
        • minValue = -15.0
        • maxValue = 15.0
        • updatePolicy = ValueUpdatePolicy::lowest
        • hysteresis = 0.0
        • objectPath = "/xyz/openbmc_project/sensors/voltage/"
    • setValueToNaN()
      • Test where current value is not NaN
        • Verify value is changed to NaN
        • Verify PropertiesChanged signal is emitted
      • Test where current value is NaN
        • Verify value is not changed
        • Verify PropertiesChanged signal is not emitted
    • shouldUpdateValue()
      • Test where current value is NaN
        • Verify returns true
      • Test where current value is not NaN
        • Test where update policy is hysteresis
          • Test where difference is 0
            • Verify returns false
          • Test where difference is < hysteresis
            • Verify returns false
          • Test where difference is == hysteresis
            • Verify returns true
          • Test where difference is > hysteresis
            • Verify returns true
        • Test where update policy is highest
          • Test where new value < current value
            • Verify returns false
          • Test where new value == current value
            • Verify returns false
          • Test where new value > current value
            • Verify returns true
        • Test where update policy is lowest
          • Test where new value < current value
            • Verify returns true
          • Test where new value == current value
            • Verify returns false
          • Test where new value > current value
            • Verify returns false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment