Skip to content

Commit

Permalink
pw_transfer: Fix transfer_thread_test initialization order
Browse files Browse the repository at this point in the history
The transfer service's contstructor depends on a value from a transfer
thread, so ensure that the thread is initialized first.

Change-Id: I989bced8f6d7f349155ca239067f376cedae2ee1
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/210352
Pigweed-Auto-Submit: Alexei Frolov <[email protected]>
Presubmit-Verified: CQ Bot Account <[email protected]>
Lint: Lint 🤖 <[email protected]>
Reviewed-by: Taylor Cramer <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
  • Loading branch information
frolv authored and CQ Bot Account committed May 17, 2024
1 parent 2e46e4a commit 969c75d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pw_transfer/transfer_thread_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,28 @@ thread::Options& TransferThreadOptions() {
class TransferThreadTest : public ::testing::Test {
public:
TransferThreadTest()
: ctx_(transfer_thread_, 512),
max_parameters_(chunk_buffer_.size(),
: max_parameters_(chunk_buffer_.size(),
chunk_buffer_.size(),
cfg::kDefaultExtendWindowDivisor),
transfer_thread_(chunk_buffer_, encode_buffer_),
system_thread_(TransferThreadOptions(), transfer_thread_) {}
system_thread_(TransferThreadOptions(), transfer_thread_),
ctx_(transfer_thread_, 512) {}

~TransferThreadTest() override {
transfer_thread_.Terminate();
system_thread_.join();
}

protected:
PW_RAW_TEST_METHOD_CONTEXT(TransferService, Read) ctx_;

std::array<std::byte, 64> chunk_buffer_;
std::array<std::byte, 64> encode_buffer_;

rpc::RawClientTestContext<> rpc_client_context_;
internal::TransferParameters max_parameters_;

transfer::Thread<1, 1> transfer_thread_;

thread::Thread system_thread_;
PW_RAW_TEST_METHOD_CONTEXT(TransferService, Read) ctx_;
};

class SimpleReadTransfer final : public ReadOnlyHandler {
Expand Down

0 comments on commit 969c75d

Please sign in to comment.