Skip to content

Instantly share code, notes, and snippets.

@smccarney
Created November 20, 2024 19:33
Show Gist options
  • Save smccarney/87bd821a6d317ec0915d1f162028ff01 to your computer and use it in GitHub Desktop.
Save smccarney/87bd821a6d317ec0915d1f162028ff01 to your computer and use it in GitHub Desktop.
Test plan for "Get model using command line tool"

Test Plan

Automated tests

  • Verify all automated tests build and run successfully

Manual tests based on code changes

  • meson.build
    • Verify string value of PSU_MODEL_UTIL is in generated config.h file
  • meson.options
    • Test where PSU_MODEL_UTIL is manually specified using a -D
      • Verify specified value is in config.h file
    • Test where PSU_MODEL_UTIL is not specified and the default value is used
      • Verify default value is in config.h file
  • src/activation.cpp
    • Activation::isCompatible()
      • Verify it runs the command line tool to get the model
      • Test where tool runs successfully and returns model with exit code 0
      • Test where tool runs unsuccessfully and returns "" with exit code 1
      • Verify model returned from tool is used in compatibility comparison
        • Test where models are equal and code update proceeds
        • Test where models are not equal and code update is skipped
  • src/item_updater.hpp
    • Comment and declaration changes. No code to test.
  • src/item_updater.cpp
    • ItemUpdater::addPsuToStatusMap()
      • Verify a listener is added for the Item interface
    • ItemUpdater::handlePSUPresenceChanged()
      • Test where psuStatusMap does not contain specified inventory path
      • Test where psuStatusMap does contain specified inventory path
      • Test where PSU is now present
        • Verify model is obtained using command line tool and stored in map
        • Verify version is obtained using command line tool
        • Test where version is empty
          • Verify createPsuObject() is not called
        • Test where psuPathActivationMap already contains inventory path
          • Verify createPsuObject() is not called
        • Test where createPsuObject() is called
      • Test where PSU is now missing
        • Verify model field is cleared in map
        • Test where psuPathActivationMap contains inventory path
          • Verify removePsuObject() is called
        • Test where psuPathActivationMap does not contain inventory path
          • Verify removePsuObject() is not called
    • ItemUpdater::onPsuInventoryChanged()
      • Test where no exception is thrown
      • Test where exception is thrown
        • Verify error message is written to journal
      • Test where psuStatusMap does not contain inventory path
        • Verify no action is taken
      • Test where Present property is not included in D-Bus message
        • Verify no action is taken
      • Test where present field in map is updated using value from D-Bus message
      • Verify handlePSUPresenceChanged() is called
      • Test where PSU is present
        • Verify processStoredImage() and syncToLatestImage() are called
      • Test where PSU is missing
        • Verify processStoredImage() and syncToLatestImage() are not called
    • ItemUpdater::processPSUImage()
      • Test where exception is thrown getting PSU paths
        • Verify error is ignored and no PSU information is stored
      • Test where able to get PSU paths
      • Test where exception is thrown while handling a single PSU
        • Verify error is ignored
        • Verify loop continues and processes the next PSU
      • Verify addPsuToStatusMap() is called
      • Verify Present property value is obtained and stored in map
      • Verify handlePSUPresenceChanged() is called
    • ItemUpdater::syncToLatestImage()
      • Test where PSU is not in psuStatusMap
        • Verify utils::isAssociated() is not called
      • Test where PSU is not present
        • Verify utils::isAssociated() is not called
      • Test where PSU is in psuStatusMap and is present
        • Verify utils::isAssociated() is called
          • Test where PSU is associated
            • Verify code update is not started
          • Test where PSU is not associated
            • Verify code update is started
    • ItemUpdater::onPSUInterfaceAdded()
      • Test where exception is thrown
        • Verify error message is written to the journal
      • Test where exception is not thrown
      • Test where message contains neither the PSU nor Item interface
      • Test where message contains the PSU interface
        • Verify PSU path is added to psuPaths set
      • Test where message contains the Item interface
        • Test where path is not in psuPaths set
          • Verify no action is taken
        • Test where path is in psuPaths set
        • Test where path is already in the psuStatusMap
          • Verify no action is taken
        • Test where path is not already in the psuStatusMap
          • Test where interface does not contain Present property
            • Verify no action is taken
          • Test where interface does contain Present property
            • Verify path is added to psuStatusMap
            • Verify Present property value is stored in status map
            • Verify handlePSUPresenceChanged() is called
            • Test where PSU is present
              • Verify processStoredImage() and syncToLatestImage() are called
            • Test where PSU is not present
              • Verify processStoredImage() and syncToLatestImage() are not called
      • Test where PSU and Item interfaces are in separate InterfacesAdded events
  • src/utils.hpp
    • utils::getModel()
      • Verify it calls Utils::getModel()
  • src/utils.cpp
    • Utils::getModel()
      • Verify it runs the command line tool with the correct inventory path
      • Test where tool exits with a 0 return code
        • Verify tool output is the correct model string
        • Verify model string is passed to the caller
      • Test where tool exits with a non-zero return code
        • Verify an empty string is passed to the caller

End to end tests

  • Test where all PSU information is available when application starts
    • Verify PSU image is found in file system
    • Verify code update is started if necessary
  • Test where no PSU information is available when application starts
    • Verify PSU information is later obtained via InterfacesAdded listener
    • Verify PSU image is found in file system
    • Verify code update is started if necessary
  • Test where PSU changes from missing to present
    • Verify the model and version is obtained
    • Verify PSU is added to version and activation data structures
    • Verify PSU image is found in file system if this is the first present PSU
    • Verify code update is started if necessary
  • Test where PSU changes from present to missing
    • Verify PSU is removed from version and activation data structures
    • Verify PSU code update is not started
  • Test where unable to get version information for PSU
    • Verify no errors occur
    • Verify it is added to the internal data structures
    • Verify it is code updated
  • Test where unable to get model information for PSU
    • Verify it is added to the internal data structures
    • Verify it is not code updated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment