PROFINET IO Controller Stack 1.0.0
Modern C++ implementation of a PROFINET IO Controller stack
Loading...
Searching...
No Matches
test_sanitizerConcurrency.cpp File Reference

Concurrency and lifetime regression tests for sanitizer builds. More...

#include <gtest/gtest.h>
#include <atomic>
#include <chrono>
#include <cstdint>
#include <memory>
#include <thread>
#include <vector>
#include "mocks/mockRawEthernetSocket.h"
#include "profinet/cyclic.h"
#include "profinet/rt.h"
+ Include dependency graph for test_sanitizerConcurrency.cpp:

Go to the source code of this file.

Functions

 TEST (SanitizerConcurrencyTest, ConcurrentStatisticsSnapshotIsRaceFree)
 
 TEST (SanitizerConcurrencyTest, ConcurrentOutputDataWritersAreRaceFree)
 
 TEST (SanitizerConcurrencyTest, RepeatedStartStopJoinsWorkers)
 
 TEST (SanitizerConcurrencyTest, DestructionAfterWorkerActivityIsClean)
 

Detailed Description

Concurrency and lifetime regression tests for sanitizer builds.

These tests exercise APIs documented as thread-safe and the cyclic worker lifecycle. They are intended primarily for ThreadSanitizer, but also stress object lifetime and allocation paths under AddressSanitizer.

Definition in file test_sanitizerConcurrency.cpp.

Function Documentation

◆ TEST() [1/4]

TEST ( SanitizerConcurrencyTest  ,
ConcurrentOutputDataWritersAreRaceFree   
)
Test:
Concurrent output-data writers do not race with each other.

SetOutputData is documented as thread-safe. Multiple writers stress the output-buffer synchronization and allocation paths.

Definition at line 114 of file test_sanitizerConcurrency.cpp.

References controller, and length.

◆ TEST() [2/4]

TEST ( SanitizerConcurrencyTest  ,
ConcurrentStatisticsSnapshotIsRaceFree   
)
Test:
Concurrent statistics snapshots remain race-free while workers update statistics.

The previous version called Reset() through the const Stats() API, which could never compile. This test instead exercises the public snapshot API concurrently with the real cyclic worker threads.

Definition at line 75 of file test_sanitizerConcurrency.cpp.

References controller, rx, and tx.

◆ TEST() [3/4]

TEST ( SanitizerConcurrencyTest  ,
DestructionAfterWorkerActivityIsClean   
)
Test:
Controller destruction after worker activity does not leave live threads.

Repetition increases the chance of exposing use-after-free and shutdown-ordering defects under ASan and TSan.

Definition at line 179 of file test_sanitizerConcurrency.cpp.

References controller, rx, and tx.

◆ TEST() [4/4]

TEST ( SanitizerConcurrencyTest  ,
RepeatedStartStopJoinsWorkers   
)
Test:
Repeated start and stop cycles cleanly join all worker threads.

Mock sockets keep this test independent of raw-Ethernet privileges.

Definition at line 156 of file test_sanitizerConcurrency.cpp.

References controller, rx, and tx.