@@ -74,7 +74,11 @@ class RecordNodeTests : public testing::Test {
7474 const std::string& basename,
7575 std::filesystem::path* path) {
7676 // Do verifications:
77- auto recordingDir = std::filesystem::directory_iterator (parentRecordingDir)->path ();
77+ auto dirIter = std::filesystem::directory_iterator (parentRecordingDir);
78+ if (dirIter == std::filesystem::directory_iterator ()) {
79+ return false ; // Directory is empty
80+ }
81+ auto recordingDir = dirIter->path ();
7882 std::stringstream ss;
7983 ss << " Record Node " << processor->getNodeId ();
8084 auto recordingDir2 = recordingDir / ss.str () / " experiment1" / " recording1" / subrecording_dirname;
@@ -220,14 +224,14 @@ class RecordNodeTests : public testing::Test {
220224
221225TEST_F (RecordNodeTests, TestInputOutput_Continuous_Single) {
222226 int numSamples = 100 ;
223- processor ->startAcquisition ();
227+ tester ->startAcquisition (true );
224228
225229 auto inputBuffer = createBuffer (1000.0 , 20.0 , numChannels, numSamples);
226230 writeBlock (inputBuffer);
227231
228232 // The record node always flushes its pending writes when stopping acquisition, so we don't need to sleep before
229233 // stopping.
230- processor ->stopAcquisition ();
234+ tester ->stopAcquisition ();
231235
232236 std::vector<int16_t > persistedData;
233237 loadContinuousDatFile (&persistedData);
@@ -245,7 +249,7 @@ TEST_F(RecordNodeTests, TestInputOutput_Continuous_Single) {
245249}
246250
247251TEST_F (RecordNodeTests, TestInputOutput_Continuous_Multiple) {
248- processor ->startAcquisition ();
252+ tester ->startAcquisition (true );
249253
250254 int numSamplesPerBlock = 100 ;
251255 int numBlocks = 8 ;
@@ -256,7 +260,7 @@ TEST_F(RecordNodeTests, TestInputOutput_Continuous_Multiple) {
256260 inputBuffers.push_back (inputBuffer);
257261 }
258262
259- processor ->stopAcquisition ();
263+ tester ->stopAcquisition ();
260264
261265 std::vector<int16_t > persistedData;
262266 loadContinuousDatFile (&persistedData);
@@ -277,8 +281,8 @@ TEST_F(RecordNodeTests, TestInputOutput_Continuous_Multiple) {
277281}
278282
279283TEST_F (RecordNodeTests, TestEmpty) {
280- processor ->startAcquisition ();
281- processor ->stopAcquisition ();
284+ tester ->startAcquisition (true );
285+ tester ->stopAcquisition ();
282286
283287 std::vector<int16_t > persistedData;
284288 loadContinuousDatFile (&persistedData);
@@ -287,7 +291,7 @@ TEST_F(RecordNodeTests, TestEmpty) {
287291
288292TEST_F (RecordNodeTests, TestClipsProperly) {
289293 int numSamples = 100 ;
290- processor ->startAcquisition ();
294+ tester ->startAcquisition (true );
291295
292296 // The min value is actually -32767, not -32768 like the "true" min
293297 std::vector<AudioBuffer<float >> inputBuffers;
@@ -301,7 +305,7 @@ TEST_F(RecordNodeTests, TestClipsProperly) {
301305 writeBlock (inputBuffer);
302306 inputBuffers.push_back (inputBuffer);
303307
304- processor ->stopAcquisition ();
308+ tester ->stopAcquisition ();
305309
306310 std::vector<int16_t > persistedData;
307311 loadContinuousDatFile (&persistedData);
@@ -341,10 +345,10 @@ class CustomBitVolts_RecordNodeTests : public RecordNodeTests {
341345
342346TEST_F (CustomBitVolts_RecordNodeTests, Test_RespectsBitVolts) {
343347 int numSamples = 100 ;
344- processor ->startAcquisition ();
348+ tester ->startAcquisition (true );
345349 auto inputBuffer = createBuffer (1000.0 , 20.0 , numChannels, numSamples);
346350 writeBlock (inputBuffer);
347- processor ->stopAcquisition ();
351+ tester ->stopAcquisition ();
348352
349353 std::vector<int16_t > persistedData;
350354 loadContinuousDatFile (&persistedData);
@@ -370,7 +374,7 @@ TEST_F(CustomBitVolts_RecordNodeTests, Test_RespectsBitVolts) {
370374}
371375
372376TEST_F (RecordNodeTests, Test_PersistsSampleNumbersAndTimestamps) {
373- processor ->startAcquisition ();
377+ tester ->startAcquisition (true );
374378
375379 int numSamples = 5 ;
376380 for (int i = 0 ; i < 3 ; i++) {
@@ -417,7 +421,7 @@ TEST_F(RecordNodeTests, Test_PersistsSampleNumbersAndTimestamps) {
417421}
418422
419423TEST_F (RecordNodeTests, Test_PersistsStructureOeBin) {
420- processor ->startAcquisition ();
424+ tester ->startAcquisition (true );
421425
422426 int numSamples = 5 ;
423427 for (int i = 0 ; i < 3 ; i++) {
@@ -427,7 +431,9 @@ TEST_F(RecordNodeTests, Test_PersistsStructureOeBin) {
427431 tester->stopAcquisition ();
428432
429433 // Do verifications:
430- auto recordingDir = std::filesystem::directory_iterator (parentRecordingDir)->path ();
434+ auto dirIter = std::filesystem::directory_iterator (parentRecordingDir);
435+ ASSERT_NE (dirIter, std::filesystem::directory_iterator ()) << " Recording directory is empty" ;
436+ auto recordingDir = dirIter->path ();
431437 std::stringstream ss;
432438 ss << " Record Node " << processor->getNodeId ();
433439 auto recordingDir2 = recordingDir / ss.str () / " experiment1" / " recording1" ;
@@ -479,7 +485,7 @@ TEST_F(RecordNodeTests, Test_PersistsEvents) {
479485 processor->setRecordEvents (true );
480486 processor->updateSettings ();
481487
482- processor ->startAcquisition ();
488+ tester ->startAcquisition (true );
483489 int numSamples = 5 ;
484490
485491 auto streamId = processor->getDataStreams ()[0 ]->getStreamId ();
@@ -492,7 +498,7 @@ TEST_F(RecordNodeTests, Test_PersistsEvents) {
492498 true );
493499 auto inputBuffer = createBuffer (1000.0 , 20.0 , numChannels, numSamples);
494500 writeBlock (inputBuffer, eventPtr.get ());
495- processor ->stopAcquisition ();
501+ tester ->stopAcquisition ();
496502
497503 std::filesystem::path sampleNumbersPath;
498504 ASSERT_TRUE (eventsPathFor (" sample_numbers.npy" , &sampleNumbersPath));
0 commit comments