Skip to content

Instantly share code, notes, and snippets.

@smccarney
Created November 9, 2021 02:07
Show Gist options
  • Save smccarney/8d203a40d9984402ac495dc3d689c12d to your computer and use it in GitHub Desktop.
Save smccarney/8d203a40d9984402ac495dc3d689c12d to your computer and use it in GitHub Desktop.
Test Plan

Test Plan

Tests for each changed method/function

  • tools/i2c/i2c_interface.hpp
    • create()
      • Verify busId data member set to correct value
      • Verify devAddr data member set to correct value
      • initialState parameter not specified
        • Verify default value is OPEN and device is opened
      • initialState parameter specified with value CLOSED
        • Verify does not open device
      • maxRetries parameter not specified
        • Verify maxRetries data member set to 0
      • maxRetries parameter specified
        • Verify maxRetries data member set to parameter value
  • tools/i2c/i2c.hpp
    • I2CDevice(uint8_t, uint8_t, InitialState, int)
      • Verify busId data member set to correct value
      • Verify devAddr data member set to correct value
      • initialState parameter not specified
        • Verify default value is OPEN and device is opened
      • initialState parameter specified with value CLOSED
        • Verify does not open device
      • maxRetries parameter not specified
        • Verify maxRetries data member set to 0
      • maxRetries parameter specified with non-zero value
        • Verify maxRetries data member set to parameter value
      • Verify busStr set to correct value
  • tools/i2c/i2c.cpp
    • getFuncs()
      • maxRetries set to 0
        • Test where works
        • Test where fails one time and exception thrown
      • maxRetries set to 1
        • Test where works
        • Test where fails one time and then works
        • Test where fails two times and exception thrown
      • maxRetries set to 3
        • Test where works
        • Test where fails one time and then works
        • Test where fails two times and then works
        • Test where fails three times and then works
        • Test where fails four times and exception thrown
    • checkReadFuncs(int type)
      • Test where read type is supported
      • Test where read type is not supported
        • Verify error message
    • checkWriteFuncs(int type)
      • Test where write type is supported
      • Test where write type is not supported
        • Verify error message
    • open()
      • ::open()
        • maxRetries set to 0
          • Test where works
          • Test where fails one time and exception thrown
        • maxRetries set to 1
          • Test where works
          • Test where fails one time and then works
          • Test where fails two times and exception thrown
        • maxRetries set to 3
          • Test where works
          • Test where fails one time and then works
          • Test where fails two times and then works
          • Test where fails three times and then works
          • Test where fails four times and exception thrown
      • ioctl()
        • maxRetries set to 0
          • Test where works
          • Test where fails one time and exception thrown
        • maxRetries set to 1
          • Test where works
          • Test where fails one time and then works
          • Test where fails two times and exception thrown
        • maxRetries set to 3
          • Test where works
          • Test where fails one time and then works
          • Test where fails two times and then works
          • Test where fails three times and then works
          • Test where fails four times and exception thrown
    • close()
      • maxRetries set to 0
        • Test where works
        • Test where fails one time and exception thrown
      • maxRetries set to 1
        • Test where works
        • Test where fails one time and then works
        • Test where fails two times and exception thrown
      • maxRetries set to 3
        • Test where works
        • Test where fails one time and then works
        • Test where fails two times and then works
        • Test where fails three times and then works
        • Test where fails four times and exception thrown
    • read(uint8_t& data)
      • maxRetries set to 0
        • Test where works
        • Test where fails one time and exception thrown
      • maxRetries set to 1
        • Test where works
        • Test where fails one time and then works
        • Test where fails two times and exception thrown
      • maxRetries set to 3
        • Test where works
        • Test where fails one time and then works
        • Test where fails two times and then works
        • Test where fails three times and then works
        • Test where fails four times and exception thrown
    • read(uint8_t addr, uint8_t& data)
      • maxRetries set to 0
        • Test where works
        • Test where fails one time and exception thrown
      • maxRetries set to 1
        • Test where works
        • Test where fails one time and then works
        • Test where fails two times and exception thrown
      • maxRetries set to 3
        • Test where works
        • Test where fails one time and then works
        • Test where fails two times and then works
        • Test where fails three times and then works
        • Test where fails four times and exception thrown
    • read(uint8_t addr, uint16_t& data)
      • maxRetries set to 0
        • Test where works
        • Test where fails one time and exception thrown
      • maxRetries set to 1
        • Test where works
        • Test where fails one time and then works
        • Test where fails two times and exception thrown
      • maxRetries set to 3
        • Test where works
        • Test where fails one time and then works
        • Test where fails two times and then works
        • Test where fails three times and then works
        • Test where fails four times and exception thrown
    • read(uint8_t addr, uint8_t& size, uint8_t* data, Mode mode)
      • Mode::SMBUS
        • maxRetries set to 0
          • Test where works
          • Test where fails one time and exception thrown
        • maxRetries set to 1
          • Test where works
          • Test where fails one time and then works
          • Test where fails two times and exception thrown
        • maxRetries set to 3
          • Test where works
          • Test where fails one time and then works
          • Test where fails two times and then works
          • Test where fails three times and then works
          • Test where fails four times and exception thrown
      • Mode::I2C
        • maxRetries set to 0
          • Test where works
          • Test where fails one time and exception thrown
            • -1 returned
            • Smaller number of bytes returned that what was requested
        • maxRetries set to 1
          • Test where works
          • Test where fails one time and then works
          • Test where fails two times and exception thrown
        • maxRetries set to 3
          • Test where works
          • Test where fails one time and then works
          • Test where fails two times and then works
          • Test where fails three times and then works
          • Test where fails four times and exception thrown
    • write(uint8_t data)
      • maxRetries set to 0
        • Test where works
        • Test where fails one time and exception thrown
      • maxRetries set to 1
        • Test where works
        • Test where fails one time and then works
        • Test where fails two times and exception thrown
      • maxRetries set to 3
        • Test where works
        • Test where fails one time and then works
        • Test where fails two times and then works
        • Test where fails three times and then works
        • Test where fails four times and exception thrown
    • write(uint8_t addr, uint8_t data)
      • maxRetries set to 0
        • Test where works
        • Test where fails one time and exception thrown
      • maxRetries set to 1
        • Test where works
        • Test where fails one time and then works
        • Test where fails two times and exception thrown
      • maxRetries set to 3
        • Test where works
        • Test where fails one time and then works
        • Test where fails two times and then works
        • Test where fails three times and then works
        • Test where fails four times and exception thrown
    • write(uint8_t addr, uint16_t data)
      • maxRetries set to 0
        • Test where works
        • Test where fails one time and exception thrown
      • maxRetries set to 1
        • Test where works
        • Test where fails one time and then works
        • Test where fails two times and exception thrown
      • maxRetries set to 3
        • Test where works
        • Test where fails one time and then works
        • Test where fails two times and then works
        • Test where fails three times and then works
        • Test where fails four times and exception thrown
    • write(uint8_t addr, uint8_t size, const uint8_t* data, Mode mode)
      • Mode::SMBUS
        • maxRetries set to 0
          • Test where works
          • Test where fails one time and exception thrown
        • maxRetries set to 1
          • Test where works
          • Test where fails one time and then works
          • Test where fails two times and exception thrown
        • maxRetries set to 3
          • Test where works
          • Test where fails one time and then works
          • Test where fails two times and then works
          • Test where fails three times and then works
          • Test where fails four times and exception thrown
      • Mode::I2C
        • maxRetries set to 0
          • Test where works
          • Test where fails one time and exception thrown
        • maxRetries set to 1
          • Test where works
          • Test where fails one time and then works
          • Test where fails two times and exception thrown
        • maxRetries set to 3
          • Test where works
          • Test where fails one time and then works
          • Test where fails two times and then works
          • Test where fails three times and then works
          • Test where fails four times and exception thrown
    • static create(uint8_t busId, uint8_t devAddr, InitialState initialState, int maxRetries)
      • Verify busId data member set to correct value
      • Verify devAddr data member set to correct value
      • initialState parameter not specified
        • Verify default value is OPEN and device is opened
      • initialState parameter specified with value CLOSED
        • Verify does not open device
      • maxRetries parameter not specified
        • Verify maxRetries data member set to 0
      • maxRetries parameter specified
        • Verify maxRetries data member set to parameter value
    • global create(uint8_t busId, uint8_t devAddr, InitialState initialState, int maxRetries)
      • Verify busId data member set to correct value
      • Verify devAddr data member set to correct value
      • initialState parameter not specified
        • Verify default value is OPEN and device is opened
      • initialState parameter specified with value CLOSED
        • Verify does not open device
      • maxRetries parameter not specified
        • Verify maxRetries data member set to 0
      • maxRetries parameter specified
        • Verify maxRetries data member set to parameter value
  • tools/i2c/test/mocked_i2c_interface.cpp
    • Call create function from a testcase without initialState or maxRetries parameter
      • Make sure builds successfully
    • Call create function from a testcase with initialState and maxRetries parameters
      • Make sure builds successfully

End-to-end tests

  • Power on chassis
    • Verify PMBus and I2C register writes occur
    • Verify sensor values are successfully read
    • Verify no errors logged
    • Verify no unexpected journal entries from regulators application
  • Power off chassis
    • Verify no errors logged
    • Verify no unexpected journal entries from regulators application
  • Modify JSON file to make one I2C address invalid
    • Create /etc/phosphor-regulators override directory
    • Copy shipped JSON file into override directory
    • Modify file
    • Send signal to phosphor-regulators application to reload JSON file
    • Power on system
    • Verify journal message written for bad I2C address
    • Verify no unexpected journal messages
    • Verify error logged for bad I2C address
    • Verify no unexpected errors logged
    • Power off system
    • Verify no unexpected journal messages
    • Verify no unexpected errors logged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment