Skip to content

Commit

Permalink
Use debug build for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
sthenic committed Jun 8, 2024
1 parent 930da11 commit b7ce883
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 3 deletions.
6 changes: 6 additions & 0 deletions include/message_channels.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class MessageChannels
{
/* Message channels are always running, unless stopped manually by the
derived class. */
printf("Constructing MessageChannels\n");
StartMessageChannels();
printf("Constructed MessageChannels\n");
}

virtual ~MessageChannels()
Expand Down Expand Up @@ -154,15 +156,19 @@ class MessageChannels

int StartMessageChannels()
{
printf("Channels are starting.\n");
RETURN_CALL(m_read_message_queue.Start());
RETURN_CALL(m_write_message_queue.Start());
printf("Channels are started.\n");
return SCAPE_EOK;
}

int StopMessageChannels()
{
printf("Channels are stopping.\n");
RETURN_CALL(m_read_message_queue.Stop());
RETURN_CALL(m_write_message_queue.Stop());
printf("Channels are stopped.\n");
return SCAPE_EOK;
}

Expand Down
8 changes: 7 additions & 1 deletion include/message_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class MessageThread : public MessageChannels<T>
, m_should_stop()
, m_is_running(false)
, m_thread_exit_code(SCAPE_EINTERRUPTED)
{};
{
printf("Constructed MessageThread\n");
};

virtual ~MessageThread()
{
Expand All @@ -37,19 +39,22 @@ class MessageThread : public MessageChannels<T>
/* Start the thread. */
virtual int Start()
{
printf("Is starting.\n");
if (m_is_running)
return SCAPE_ENOTREADY;

m_signal_stop = std::promise<void>();
m_should_stop = m_signal_stop.get_future();
m_thread = std::thread([this]{ static_cast<C*>(this)->MainLoop(); });
m_is_running = true;
printf("Is started.\n");
return SCAPE_EOK;
}

/* Stop the thread. */
virtual int Stop()
{
printf("Is stopping.\n");
if (!m_is_running)
return SCAPE_ENOTREADY;

Expand All @@ -65,6 +70,7 @@ class MessageThread : public MessageChannels<T>

/* FIXME: This probably indicates wrong system design. Rethink? */
this->StartMessageChannels();
printf("Is stopped.\n");
return m_thread_exit_code;
}

Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ endif()

# Add a custom command do run the test suite as a CMake target.
add_custom_target(run_tests
COMMAND $<TARGET_FILE:${PROJECT_NAME}> -c -v -s
COMMAND $<TARGET_FILE:${PROJECT_NAME}> -c -v
USES_TERMINAL)

add_dependencies(run_tests ${PROJECT_NAME})
1 change: 1 addition & 0 deletions test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

int main(int ac, char** av)
{
printf("Main test runner\n");
return CommandLineTestRunner::RunAllTests(ac, av);
}
2 changes: 1 addition & 1 deletion test/tdata_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ TEST(DataProcessing, RepeatedStartStop)
{
std::shared_ptr<ProcessedRecord> record = NULL;
int result = processing->WaitForBuffer(record, 1000);
LONGS_EQUAL(SCAPE_EOK, result);
CHECK(record != NULL);
CHECK(result == SCAPE_EOK);

LONGS_EQUAL(nof_records_received, record->time_domain->header.record_number);
LONGS_EQUAL(RECORD_LENGTH, record->time_domain->header.record_length);
Expand Down
8 changes: 8 additions & 0 deletions test/tpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ TEST_GROUP(Python)

void setup()
{
printf("In setup\n");
std::ofstream ofs{PYADQ_PATH, std::ios::out};
ofs << MOCK_PYADQ;
ofs.close();
Expand All @@ -51,19 +52,24 @@ TEST_GROUP(Python)
ofs << WITHOUT_MAIN;
ofs.close();

printf("Starting\n");
thread.Start();
printf("Started\n");
}

void teardown()
{
printf("In teardown\n");
std::filesystem::remove(PYADQ_PATH);
std::filesystem::remove(WITH_MAIN_PATH);
std::filesystem::remove(WITHOUT_MAIN_PATH);
printf("Torn down\n");
}
};

TEST(Python, CheckAndCall)
{
printf("In CheckAndCall\n");
#ifdef EMBEDDED_PYTHON
/* First we interact with the static session object directly. */
LONGS_EQUAL(1, EmbeddedPython::IsInitialized());
Expand Down Expand Up @@ -100,6 +106,8 @@ TEST(Python, CheckAndCall)
STRCMP_CONTAINS("Called main() with '<pyadq.ADQ object at", out.c_str());
}
#else
printf("Checking EmbeddedPython::IsInitialized\n");
LONGS_EQUAL(0, EmbeddedPython::IsInitialized());
#endif
printf("Leaving CheckAndCall\n");
}

0 comments on commit b7ce883

Please sign in to comment.