)]}'
{
  "commit": "db5b41216e14813591f4e56a12e92ee9182356ec",
  "tree": "e3e61224b9f8dd9122392111ef220a26c3e0b430",
  "parents": [
    "d64f85e0e0c8d95150ba864a86eee0e8fdf84c0a"
  ],
  "author": {
    "name": "Andrew Jeffery",
    "email": "andrew@codeconstruct.com.au",
    "time": "Tue May 14 14:40:01 2024 +0930"
  },
  "committer": {
    "name": "Hao Jiang",
    "email": "jianghao@google.com",
    "time": "Tue Jul 07 15:47:18 2026 -0700"
  },
  "message": "tests: Add NVMe-MI recovery test\n\nExercise the NVMeMi endpoint recovery implementation by exploiting the\nlink seam for libnvme{,-mi}.\n\nTo do this we first reuse the headers provided by libnvme with a\npartial-dependency declaration in the test. From there we provide our\nown (largely neutered) implementation of the APIs to link against.\n\nWith this in-place we can trivially recreate the error discussed in[1]\nby returning erroneous values from the libnvme APIs. The higher-level\nconsequence is we drive the NVMeMi implementation through the endpoint\nrecovery process while trying to optimize the connection. At that point\nwe can use the usual GMock APIs to define the behaviors we want from\nMctpDevice and MctpEndpoint during the recovery process.\n\n[1]: https://github.com/CodeConstruct/dbus-sensors/issues/14\n\nAn interesting future direction is to allow mocks to be injected behind\nthe libnvme{,-mi} link seam. Adding a method to inject mocks enables\ndescribing arbitrary NVMe scenarios in the usual gmock style, which has\nthe potential to drastically increase test code coverage for nvmesensor.\n\nReturning to the change at hand, note that the test case causes valgrind\nto report a leak, however this appears to be from the gmock error report\nitself. Given we\u0027re working to resolve the gmock error, the leak will\ndisappear with it:\n\n```\n...\nMock MCTP Device] MCTP connection is not established\nerror reading ctemp from subsystem, reason:Transport endpoint is not connected\nSensor bar reading error!\n../tests/test_nvme_mi_recovery.cpp:63: Failure\nMock function called more times than expected - returning directly.\n    Function call: recover()\n         Expected: to be called between 1 and 3 times\n           Actual: called 5 times - over-saturated and active\n\n[Mock MCTP Device] MCTP connection is not established\nerror reading ctemp from subsystem, reason:Transport endpoint is not connected\n../tests/test_nvme_mi_recovery.cpp:63: Failure\nMock function called more times than expected - returning directly.\n    Function call: recover()\n         Expected: to be called between 1 and 3 times\n           Actual: called 6 times - over-saturated and active\n\nstatus else\npoll loop has been canceled\n../tests/test_nvme_mi_recovery.cpp:90: Failure\nValue of: testing::Mock::VerifyAndClearExpectations(mctpEp.get())\n  Actual: false\nExpected: true\n\n[  FAILED  ] NVMeRecovery.optimisationFailure (8348 ms)\n[----------] 1 test from NVMeRecovery (8359 ms total)\n\n[----------] Global test environment tear-down\n[\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d\u003d] 1 test from 1 test suite ran. (8415 ms total)\n[  PASSED  ] 0 tests.\n[  FAILED  ] 1 test, listed below:\n[  FAILED  ] NVMeRecovery.optimisationFailure\n\n 1 FAILED TEST\n\u003d\u003d197574\u003d\u003d\n\u003d\u003d197574\u003d\u003d HEAP SUMMARY:\n\u003d\u003d197574\u003d\u003d     in use at exit: 8 bytes in 1 blocks\n\u003d\u003d197574\u003d\u003d   total heap usage: 7,500 allocs, 7,499 frees, 1,751,392 bytes allocated\n\u003d\u003d197574\u003d\u003d\n\u003d\u003d197574\u003d\u003d 8 bytes in 1 blocks are still reachable in loss record 1 of 1\n\u003d\u003d197574\u003d\u003d    at 0x4840F83: operator new(unsigned long) (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)\n\u003d\u003d197574\u003d\u003d    by 0xD157EF: testing::internal::GetFailureReporter() (gmock-internal-utils.cc:124)\n\u003d\u003d197574\u003d\u003d    by 0x9C16E3: testing::internal::Expect(bool, char const*, int, std::__cxx11::basic_string\u003cchar, std::char_traits\u003cchar\u003e, std::allocator\u003cchar\u003e \u003e const\u0026) (gmock-internal-utils.h:259)\n\u003d\u003d197574\u003d\u003d    by 0x9C2303: testing::internal::UntypedFunctionMockerBase::FailureCleanupHandler::~FailureCleanupHandler() (gmock-spec-builders.h:1427)\n\u003d\u003d197574\u003d\u003d    by 0x9D852C: testing::internal::FunctionMocker\u003cvoid ()\u003e::InvokeWith(std::tuple\u003c\u003e\u0026\u0026) (gmock-spec-builders.h:1898)\n\u003d\u003d197574\u003d\u003d    by 0x9CB22B: testing::internal::FunctionMocker\u003cvoid ()\u003e::Invoke() (gmock-spec-builders.h:1548)\n\u003d\u003d197574\u003d\u003d    by 0x9C2EF8: MockMctpEndpoint::recover() (test_nvme_mi_recovery.cpp:27)\n\u003d\u003d197574\u003d\u003d    by 0xAD57EB: NVMeMi::recover() (NVMeMi.cpp:192)\n\u003d\u003d197574\u003d\u003d    by 0xAD50B1: NVMeMi::epOptimize()::{lambda(boost::system::error_code)#1}::operator()(boost::system::error_code) const::{lambda(std::error_code const\u0026)#1}::operator()(std::error_code const\u0026) const (NVMeMi.cpp:167)\n\u003d\u003d197574\u003d\u003d    by 0xAFF26F: void std::__invoke_impl\u003cvoid, NVMeMi::epOptimize()::{lambda(boost::system::error_code)#1}::operator()(boost::system::error_code) const::{lambda(std::error_code const\u0026)#1}\u0026, std::error_code const\u0026\u003e(std::__invoke_other, NVMeMi::epOptimize()::{lambda(boost::system::error_code)#1}::operator()(boost::system::error_code) const::{lambda(std::error_code const\u0026)#1}\u0026, std::error_code const\u0026) (invoke.h:61)\n\u003d\u003d197574\u003d\u003d    by 0xAF3ED2: std::enable_if\u003cis_invocable_r_v\u003cvoid, NVMeMi::epOptimize()::{lambda(boost::system::error_code)#1}::operator()(boost::system::error_code) const::{lambda(std::error_code const\u0026)#1}\u0026, std::error_code const\u0026\u003e, void\u003e::type std::__invoke_r\u003cvoid, NVMeMi::epOptimize()::{lambda(boost::system::error_code)#1}::operator()(boost::system::error_code) const::{lambda(std::error_code const\u0026)#1}\u0026, std::error_code const\u0026\u003e(NVMeMi::epOptimize()::{lambda(boost::system::error_code)#1}::operator()(boost::system::error_code) const::{lambda(std::error_code const\u0026)#1}\u0026, std::error_code const\u0026) (invoke.h:111)\n\u003d\u003d197574\u003d\u003d    by 0xAEFE8F: std::_Function_handler\u003cvoid (std::error_code const\u0026), NVMeMi::epOptimize()::{lambda(boost::system::error_code)#1}::operator()(boost::system::error_code) const::{lambda(std::error_code const\u0026)#1}\u003e::_M_invoke(std::_Any_data const\u0026, std::error_code const\u0026) (std_function.h:290)\n\u003d\u003d197574\u003d\u003d\n\u003d\u003d197574\u003d\u003d LEAK SUMMARY:\n\u003d\u003d197574\u003d\u003d    definitely lost: 0 bytes in 0 blocks\n\u003d\u003d197574\u003d\u003d    indirectly lost: 0 bytes in 0 blocks\n\u003d\u003d197574\u003d\u003d      possibly lost: 0 bytes in 0 blocks\n\u003d\u003d197574\u003d\u003d    still reachable: 8 bytes in 1 blocks\n\u003d\u003d197574\u003d\u003d         suppressed: 0 bytes in 0 blocks\n\u003d\u003d197574\u003d\u003d\n\u003d\u003d197574\u003d\u003d For lists of detected and suppressed errors, rerun with: -s\n\u003d\u003d197574\u003d\u003d ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)\n```\n\nChange-Id: Idf3fb6d167a9e11ea1d554c4ab2f2c50d1489421\nSigned-off-by: Andrew Jeffery \u003candrew@codeconstruct.com.au\u003e\n",
  "tree_diff": [
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "171efab1710d8b41db54427c00b34bbbb11f11ab",
      "new_mode": 33188,
      "new_path": "tests/libnvme_mi_mock.cpp"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "1f14859126035524dfcceb70d734f957aa084f53",
      "new_mode": 33188,
      "new_path": "tests/libnvme_mock.cpp"
    },
    {
      "type": "modify",
      "old_id": "8221e3a372f352a1242a3ba442d55f57c35f41d2",
      "old_mode": 33188,
      "old_path": "tests/meson.build",
      "new_id": "199f3712658d321578007e84b677ebf3d738be78",
      "new_mode": 33188,
      "new_path": "tests/meson.build"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "00f471483881492e0b56e96462761144feaf0f74",
      "new_mode": 33188,
      "new_path": "tests/test_nvme_mi_recovery.cpp"
    }
  ]
}
