Skip to content

Instantly share code, notes, and snippets.

@smccarney
Created February 18, 2021 19:04
Show Gist options
  • Save smccarney/bd4e546a76ee05e4df939eb69e23daee to your computer and use it in GitHub Desktop.
Save smccarney/bd4e546a76ee05e4df939eb69e23daee to your computer and use it in GitHub Desktop.
Test Plan

Test Plan

  • SystemdJournal::getMessages()

    • Test where sd_journal_open() fails
    • Test where sd_journal_open() works
    • Verify JournalCloser closes the journal on normal function exit
    • Verify JournalCloser closes the journal when an exception is thrown
    • Verify match string has correct format
    • Test where sd_journal_add_match() fails
    • Test where sd_journal_add_match() works. Verify it filters entries.
    • Verify messages vector is set to reasonable capacity
      • When max is not specified
      • When max is specified
    • Verify SD_JOURNAL_FOREACH_BACKWARDS loops from newest to oldest entries
    • Test where entry does not contain all relevant fields
    • Test where entry contains all relevant fields
    • Verify that timestamp matches timestamp in journalctl output
    • Verify that message line format matches format in journalctl output
    • Verify messages stored from oldest to newest in output vector
    • Test where max number of messages is not specified
      • Test where some matching entries found
      • Test where no matching entries found
    • Test where max number of messages is specified
      • Test where no matching entries found
      • Test where matching entries found
        • Test where max number is found
        • Test where max number is not found
  • SystemdJournal::getFieldValue()

    • Test where sd_journal_get_data() fails
      • Return code is -ENOENT indicating field not present. Verify empty string returned.
      • Return code is not -ENOENT. Verify exception thrown.
    • Test where sd_journal_get_data() works
    • Verify format of field data returned by sd_journal_get_data()
    • Test with possible returned field data formats
      • ""
      • "a"
      • "a="
      • "aa="
      • "a=b"
      • "aa=bb"
  • SystemdJournal::getTimeStamp()

    • Test where sd_journal_get_realtime_usec() fails
    • Test where sd_journal_get_realtime_usec() works
    • Verify milliseconds value converted to seconds correctly
    • Test where localtime() fails
    • Test where localtime() works
    • Verify strftime() produces the expected date/time string
  • Regression test

    • Verify that systemd and phosphor-regulators journal messages are captured successfully when an error is logged.
      • JSON config file is invalid when application starts
      • JSON config file is invalid when application receives SIGHUP
      • JSON config file is invalid when chassis is powered on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment