Skip to content

Comments

Test resuming a process#9

Merged
patnebe merged 3 commits intomainfrom
test-proc-resume
Aug 25, 2025
Merged

Test resuming a process#9
patnebe merged 3 commits intomainfrom
test-proc-resume

Conversation

@patnebe
Copy link
Owner

@patnebe patnebe commented Aug 25, 2025

Context

  • More tests

Changes

  • Update the move operators for the Process class to ensure the underlying process is not cleaned
    when the object moved out of is destructed.
  • Minor bugfixes

Test Plan

  • CI

Copilot AI review requested due to automatic review settings August 25, 2025 19:27
@patnebe patnebe enabled auto-merge (squash) August 25, 2025 19:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds tests for process resuming functionality and fixes move semantics for the Process class to prevent premature cleanup of underlying processes during object moves.

  • Implements proper move constructor and assignment operator for the Process class
  • Adds test coverage for process attachment and resuming functionality
  • Creates a test binary for use in process manipulation tests

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/testbin.m.cpp Simple test binary that sleeps for 5 seconds
test/sdb_process.t.cpp Adds tests for invalid PID attachment and process resuming
test/CMakeLists.txt Builds the test binary executable
src/sdb_process.cpp Implements move semantics and fixes process cleanup logic
src/sdb_pipe.cpp Minor cleanup removing redundant bitwise OR with 0
include/libsdb/sdb_process_state.h Adds stream operator declaration for ProcessState
include/libsdb/sdb_process.h Updates member variables to support move semantics
Comments suppressed due to low confidence (2)

src/sdb_process.cpp:107

  • This line appears to be test code (using ASSERT_EQ) in a production source file. Test assertions should not be in production code. This should be moved to the test file or replaced with appropriate error handling.
  proc->waitOnSignal();

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}

Process& Process::operator=(Process&& other)
{
Copy link

Copilot AI Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The move assignment operator doesn't handle self-assignment properly. If this == &other, the object will invalidate itself by setting other.d_pid = 0 and other.d_cleanupOnExit = false. Add a self-assignment check at the beginning of the function.

Suggested change
{
{
if (this == &other)
{
return *this;
}

Copilot uses AI. Check for mistakes.
std::stringstream ss;
ss << "Unable to continue proc with pid=" << d_pid << ", rc=" << rc
<< ". perror=";
perror(ss.str().c_str());
Copy link

Copilot AI Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using stringstream for simple string concatenation in error paths is inefficient. Consider using string concatenation with std::to_string() for better performance: std::string message = "Unable to continue proc with pid=" + std::to_string(d_pid) + ", rc=" + std::to_string(rc) + ". perror=";

Suggested change
perror(ss.str().c_str());
std::string message = "Unable to continue proc with pid=" + std::to_string(d_pid) +
", rc=" + std::to_string(rc) + ". perror=";
perror(message.c_str());

Copilot uses AI. Check for mistakes.
@patnebe patnebe merged commit 15e8e71 into main Aug 25, 2025
1 check passed
@patnebe patnebe deleted the test-proc-resume branch August 25, 2025 19:29
@patnebe patnebe mentioned this pull request Aug 25, 2025
patnebe added a commit that referenced this pull request Aug 25, 2025
#### Context
* Address review comments from #9

#### Changes
* Fix error message construction in the error path
* Handle self-assignment in the move assignment operator

#### Test Plan
* CI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant