Build save_data_memory_tests from the kyty_tests aggregate #798

Manually merged
github merged 1 commit from gh-pr/798/head into gh-pr/798/base 2026-11-26 09:32:48 +00:00
Owner

@⁠theantipopau on GitHub · 2026-09-24 06:00 UTC · original
theantipopau:test-aggregate-save-data → main · +1 −0 · 1 files · 1 commits · merged 2026-09-25 22:39 UTC

Problem

save_data_memory is registered with add_test(), but its executable
save_data_memory_tests is declared EXCLUDE_FROM_ALL and was not listed in the
kyty_tests aggregate. Building --target kyty_tests therefore never produced the
binary, so a full ctest run reports it as:

19/40 Test #19: save_data_memory ....................***Not Run   0.00 sec

The test is registered but can never actually run, which is why a save-data regression
would go unnoticed.

Change

One line: add save_data_memory_tests to add_custom_target(kyty_tests DEPENDS ...).

Verification

Windows, clang-cl + Ninja, Release:

  • cmake --build _Build/windows --target kyty_tests now builds and links
    save_data_memory_tests.exe (KYTY_TESTS_RC=0);
  • ctest -R "^save_data_memory$" → Passed 0.23 sec (previously Not Run).

No source or test behaviour changes.

**@⁠theantipopau** on GitHub · 2026-09-24 06:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/798) `theantipopau:test-aggregate-save-data` → `main` · +1 −0 · 1 files · 1 commits · merged 2026-09-25 22:39 UTC ## Problem `save_data_memory` is registered with `add_test()`, but its executable `save_data_memory_tests` is declared `EXCLUDE_FROM_ALL` and was not listed in the `kyty_tests` aggregate. Building `--target kyty_tests` therefore never produced the binary, so a full `ctest` run reports it as: ``` 19/40 Test #19: save_data_memory ....................***Not Run 0.00 sec ``` The test is registered but can never actually run, which is why a save-data regression would go unnoticed. ## Change One line: add `save_data_memory_tests` to `add_custom_target(kyty_tests DEPENDS ...)`. ## Verification Windows, clang-cl + Ninja, Release: * `cmake --build _Build/windows --target kyty_tests` now builds and links `save_data_memory_tests.exe` (`KYTY_TESTS_RC=0`); * `ctest -R "^save_data_memory$"` → `Passed 0.23 sec` (previously `Not Run`). No source or test behaviour changes.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:32:47 +00:00
github manually merged commit 8bdcf63f2e into gh-pr/798/base 2026-11-26 09:32:48 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-24 06:02 UTC · original · edited 2026-09-25 22:35 UTC

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: c139cba6-0ab8-4abf-b1ba-fac17afb444a

📥 Commits

Reviewing files that changed from the base of the PR and between 1c9c5c118fe211c67d7d0453a7bcf0d8dadd3bcd and 8bdcf63f2e.

📒 Files selected for processing (1)
  • CMakeLists.txt

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The kyty_tests aggregate target now includes save_data_memory_tests as a dependency.

Suggested reviewers: 6d4m

Priority: ⬇️ Low

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 8bdcf

The aggregate now builds the registered save-data memory test. The cited socket-test timing concern does not apply, and no concrete merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 2 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: building save_data_memory_tests from the kyty_tests aggregate target.
Description check ✅ Passed The description explains the missing build dependency, the one-line change, and the reported verification results. It is directly related to the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 2 files. (1 skipped: 1 unsupported.)


Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-24 06:02 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/798#issuecomment-5808632078) · edited 2026-09-25 22:35 UTC <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/798"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> Navigate logical layers of code changes, visualize relationships, and explore their blast radius. <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `c139cba6-0ab8-4abf-b1ba-fac17afb444a` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 1c9c5c118fe211c67d7d0453a7bcf0d8dadd3bcd and 8bdcf63f2e063ff3ca85f53c2213784c8db760fd. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `CMakeLists.txt` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The `kyty_tests` aggregate target now includes `save_data_memory_tests` as a dependency. **Suggested reviewers:** `6d4m` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬇️ Low <!-- change_assessment_commit:"8bdcf63f2e063ff3ca85f53c2213784c8db760fd" --> **Change:** Bug fix <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _⚪ Minimal_ · up to `8bdcf` <!-- final_review_risk_coverage:{"sourceCommitId":"8bdcf63f2e063ff3ca85f53c2213784c8db760fd","coveredCommitId":"8bdcf63f2e063ff3ca85f53c2213784c8db760fd","kind":"reviewed"} --> The aggregate now builds the registered save-data memory test. The cited socket-test timing concern does not apply, and no concrete merge-blocking risk remains. <!-- final_review_risk_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :----------------: | :--------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ⚠️ Warning | Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 2 files. (1 skipped: … | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ✅ Passed | The title clearly and concisely describes the main change: building save_data_memory_tests from the kyty_tests aggregate target. | | Description check | ✅ Passed | The description explains the missing build dependency, the one-line change, and the reported verification results. It is directly related to the changeset. | | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | </details> <details> <summary>Full details: Docstring Coverage</summary> **Explanation** Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 2 files. (1 skipped: 1 unsupported.) </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> --- <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-24 09:24 UTC · original · reviewed

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 6067a8a7-c722-462d-b911-30b5ee615ef2

📥 Commits

Reviewing files that changed from the base of the PR and between 266f6bb9e5812d55edd3a4097c01b7186cbc8eed and 1c9c5c118fe211c67d7d0453a7bcf0d8dadd3bcd.

📒 Files selected for processing (2)
  • src/libs/network.cpp
  • tests/KernelFileSystemTests.cpp

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-09-24 09:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/798#pullrequestreview-5302450552) · **reviewed** **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `6067a8a7-c722-462d-b911-30b5ee615ef2` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 266f6bb9e5812d55edd3a4097c01b7186cbc8eed and 1c9c5c118fe211c67d7d0453a7bcf0d8dadd3bcd. </details> <details> <summary>📒 Files selected for processing (2)</summary> * `src/libs/network.cpp` * `tests/KernelFileSystemTests.cpp` </details> **Included review availability:** Your plan provides up to 10 included reviews per hour; 7 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-09-24 09:24 UTC · original
On tests/KernelFileSystemTests.cpp line 490 (outdated):

@@ -454,19 +458,171 @@ void CheckSocketWakeup() {
         "guest PEEK and WAITALL preserve the wake bytes");
   Check(Net::Recv(reader, received.data(), received.size(), 0x40) == sizeof(payload),
         "consume wake bytes with guest WAITALL");
+
+  // A full message split across writes must still complete a WAITALL receive, and the
+  // peeked bytes have to survive for the following receive.
+  const char text[] = "fragment";
+  constexpr std::size_t text_length = 8;    // without the terminator
+  constexpr std::size_t prefix_length = 5;  // deliberately short of text_length
+  Check(Net::Send(writer, text, text_length / 2, 0) == text_length / 2,
+        "send the first fragment");
+  const char* const second_fragment = text + text_length / 2;
+  const std::size_t second_length   = text_length - text_length / 2;
+  std::thread peer([&writer, second_fragment, second_length] {
+    std::this_thread::sleep_for(std::chrono::milliseconds(50));
+    Net::Send(writer, second_fragment, second_length, 0);
+  });
+  std::array<char, text_length> message {};
+  Check(Net::Recv(reader, message.data(), message.size(), 0x42) == message.size() &&
+            std::memcmp(message.data(), text, text_length) == 0,
+        "guest PEEK and WAITALL waits for a fragmented message");
+  peer.join();
+  Check(Net::Recv(reader, message.data(), message.size(), 0) == message.size() &&
+            std::memcmp(message.data(), text, text_length) == 0,
+        "peeked bytes stay available for the following receive");
+  Check(Net::Recv(reader, message.data(), 0, 0x42) == 0,
+        "zero length guest PEEK and WAITALL succeeds");
+
+  // MSG_DONTWAIT must never wait for the rest of the message.
+  Check(Net::Send(writer, text, prefix_length, 0) == prefix_length,
+        "send bytes for the non-waiting peek");
+  Check(Net::Recv(reader, message.data(), message.size(), 0xc2) == prefix_length,
+        "guest MSG_DONTWAIT PEEK and WAITALL returns the buffered prefix");

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Wait for readability before non-waiting receives and accepts.

These checks run a non-waiting operation right after the peer acts:

  • Line 489: Recv(..., 0xc2) runs right after Send at Line 487.
  • Line 502: Recv(..., 0x42) on the guest nonblocking socket runs right after Send at Line 500.
  • Line 558: Accept on the nonblocking inherited_listener runs right after the blocking Connect.
  • Lines 563-566: the async Recv on the inherited nonblocking socket starts right after Send at Line 560.

A successful Send does not mean the bytes are already in the peer's receive buffer. A successful client Connect does not mean the server's accept queue already holds the connection. On Winsock loopback, both can complete asynchronously. If the data or connection is not there yet, the call returns -1/EWOULDBLOCK or a short count, and the Check aborts the test. Under CI scheduling pressure, the tests then fail even when the socket code is correct.

Before each non-waiting operation, call Net::Select with a deadline and wait until the descriptor is readable. For the receives, readable only means that some bytes arrived, not all of the prefix. The prefix is sent as a single segment with TCP_NODELAY on loopback, so it normally arrives in one piece. To remove all doubt, poll with a plain MSG_PEEK until prefix_length bytes are available.

💚 Proposed helper and usage
// Add near CheckSocketWakeup.
void WaitReadable(int fd, const char *text) {
  namespace Net = Libs::Network::Net;
  std::array<uint64_t, 16> set {};
  set[fd / 64] = uint64_t {1} << (fd % 64);
  const std::array<int64_t, 2> deadline {5, 0};
  Check(Net::Select(fd + 1, set.data(), nullptr, nullptr, deadline.data()) == 1, text);
}
   Check(Net::Send(writer, text, prefix_length, 0) == prefix_length,
         "send bytes for the non-waiting peek");
+  WaitReadable(reader, "non-waiting peek bytes arrived");
   Check(Net::Recv(reader, message.data(), message.size(), 0xc2) == prefix_length,
   Check(Net::Send(writer, text, prefix_length, 0) == prefix_length,
         "send bytes for the non-blocking socket peek");
+  WaitReadable(reader, "non-blocking socket peek bytes arrived");
   Check(Net::Recv(reader, message.data(), message.size(), 0x42) == prefix_length,
+  WaitReadable(inherited_listener, "accepted-mode connection is queued");
   const int inherited_reader = Net::Accept(inherited_listener, nullptr, nullptr);
   Check(inherited_reader >= 0, "accept nonblocking listener socket");
   Check(Net::Send(inherited_writer, text, prefix_length, 0) == prefix_length,
         "send accepted-mode prefix");
+  WaitReadable(inherited_reader, "accepted-mode prefix arrived");

Also applies to: 500-503, 558-568

**@⁠coderabbitai[bot]** on GitHub · 2026-09-24 09:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/798#discussion_r4091989192) On `tests/KernelFileSystemTests.cpp` line 490 (outdated): ```diff @@ -454,19 +458,171 @@ void CheckSocketWakeup() { "guest PEEK and WAITALL preserve the wake bytes"); Check(Net::Recv(reader, received.data(), received.size(), 0x40) == sizeof(payload), "consume wake bytes with guest WAITALL"); + + // A full message split across writes must still complete a WAITALL receive, and the + // peeked bytes have to survive for the following receive. + const char text[] = "fragment"; + constexpr std::size_t text_length = 8; // without the terminator + constexpr std::size_t prefix_length = 5; // deliberately short of text_length + Check(Net::Send(writer, text, text_length / 2, 0) == text_length / 2, + "send the first fragment"); + const char* const second_fragment = text + text_length / 2; + const std::size_t second_length = text_length - text_length / 2; + std::thread peer([&writer, second_fragment, second_length] { + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + Net::Send(writer, second_fragment, second_length, 0); + }); + std::array<char, text_length> message {}; + Check(Net::Recv(reader, message.data(), message.size(), 0x42) == message.size() && + std::memcmp(message.data(), text, text_length) == 0, + "guest PEEK and WAITALL waits for a fragmented message"); + peer.join(); + Check(Net::Recv(reader, message.data(), message.size(), 0) == message.size() && + std::memcmp(message.data(), text, text_length) == 0, + "peeked bytes stay available for the following receive"); + Check(Net::Recv(reader, message.data(), 0, 0x42) == 0, + "zero length guest PEEK and WAITALL succeeds"); + + // MSG_DONTWAIT must never wait for the rest of the message. + Check(Net::Send(writer, text, prefix_length, 0) == prefix_length, + "send bytes for the non-waiting peek"); + Check(Net::Recv(reader, message.data(), message.size(), 0xc2) == prefix_length, + "guest MSG_DONTWAIT PEEK and WAITALL returns the buffered prefix"); ``` _🩺 Stability & Availability_ | _🟡 Minor_ | _⚡ Quick win_ **Wait for readability before non-waiting receives and accepts.** These checks run a non-waiting operation right after the peer acts: - Line 489: `Recv(..., 0xc2)` runs right after `Send` at Line 487. - Line 502: `Recv(..., 0x42)` on the guest nonblocking socket runs right after `Send` at Line 500. - Line 558: `Accept` on the nonblocking `inherited_listener` runs right after the blocking `Connect`. - Lines 563-566: the async `Recv` on the inherited nonblocking socket starts right after `Send` at Line 560. A successful `Send` does not mean the bytes are already in the peer's receive buffer. A successful client `Connect` does not mean the server's accept queue already holds the connection. On Winsock loopback, both can complete asynchronously. If the data or connection is not there yet, the call returns `-1`/`EWOULDBLOCK` or a short count, and the `Check` aborts the test. Under CI scheduling pressure, the tests then fail even when the socket code is correct. Before each non-waiting operation, call `Net::Select` with a deadline and wait until the descriptor is readable. For the receives, readable only means that some bytes arrived, not all of the prefix. The prefix is sent as a single segment with `TCP_NODELAY` on loopback, so it normally arrives in one piece. To remove all doubt, poll with a plain `MSG_PEEK` until `prefix_length` bytes are available. <details> <summary>💚 Proposed helper and usage</summary> ```cpp // Add near CheckSocketWakeup. void WaitReadable(int fd, const char *text) { namespace Net = Libs::Network::Net; std::array<uint64_t, 16> set {}; set[fd / 64] = uint64_t {1} << (fd % 64); const std::array<int64_t, 2> deadline {5, 0}; Check(Net::Select(fd + 1, set.data(), nullptr, nullptr, deadline.data()) == 1, text); } ``` ```diff Check(Net::Send(writer, text, prefix_length, 0) == prefix_length, "send bytes for the non-waiting peek"); + WaitReadable(reader, "non-waiting peek bytes arrived"); Check(Net::Recv(reader, message.data(), message.size(), 0xc2) == prefix_length, ``` ```diff Check(Net::Send(writer, text, prefix_length, 0) == prefix_length, "send bytes for the non-blocking socket peek"); + WaitReadable(reader, "non-blocking socket peek bytes arrived"); Check(Net::Recv(reader, message.data(), message.size(), 0x42) == prefix_length, ``` ```diff + WaitReadable(inherited_listener, "accepted-mode connection is queued"); const int inherited_reader = Net::Accept(inherited_listener, nullptr, nullptr); Check(inherited_reader >= 0, "accept nonblocking listener socket"); Check(Net::Send(inherited_writer, text, prefix_length, 0) == prefix_length, "send accepted-mode prefix"); + WaitReadable(inherited_reader, "accepted-mode prefix arrived"); ``` </details> Also applies to: 500-503, 558-568 <!-- fingerprinting:phantom:medusa:pangolin --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:9319a412d1bbaa200aded0d0 --> <!-- This is an auto-generated comment by CodeRabbit -->
This discussion has been locked. Commenting is limited to contributors.
No description provided.