NetBurner 3.1
Throughput/TestStateData.h
1 /*NB_REVISION*/
2 
3 /*NB_COPYRIGHT*/
4 
5 #ifndef _TEST_STATE_DATA_H_
6 #define _TEST_STATE_DATA_H_
7 
8 #include <basicTypes.h>
9 #include "Constants.h"
10 
11 /*
12  * @brief This holds the cumulative results for a specific set of tests.
13  */
14 struct TestResults
15 {
16  uint32_t count = 0;
17  double avgTime = 0.0;
18  uint32_t failCount = 0;
19 };
20 
21 /*
22  * @brief This is the main object that will keep track of overall test progress and results.
23  */
24 class TestStateData
25 {
26 public:
27  TestStateData();
28  ~TestStateData(){}
29 
30  void Reset( bool fillBuffer, bool testInitiator );
31  void UpdateBufPtr();
32  void AdvanceState( bool testInitiator );
33  bool ValidateDataBuffer();
34  void ReportCurTestData();
35  bool UpdateCurTestComplete();
36  void ReportTotalTestData( TestStates state );
37  inline void IncrementTestTime( double incVal ){ totalTestTime += incVal; }
38 
39  char dataBuffer[ BUFFER_SIZE ]; // This is the buffer that should be used when sending data back and forth
40  char baseBuffer[ BUFFER_SIZE ]; // This buffer is used to valide successful data transfers
41  uint byteCount = 0; // The total count of bytes read for the current test
42  char* curBufPtr = nullptr; // Pointer to the spot in the buffer where we are currently reading/writing to
43  TestStates currentState = eTestInit; // Current state of the tests
44  double totalTestTime = 0.0; // How long have we been running this specific test
45 
46  // Reporting metrics for each series of tests
47  TestResults serialSendResults;
48  TestResults serialRecResults;
49  TestResults etherSendResults;
50  TestResults etherRecResults;
51 
52 private:
53  void InitBuffer( char* buf, bool fill );
54  TestResults* GetResultForState( TestStates state );
55 };
56 
57 #endif /* _TEST_STATE_DATA_H_ */
58 
This is the main object that will keep track of overall test progress and results.
Definition: SerialToEtherThroughput/TestStateData.h:34
bool UpdateCurTestComplete()
Updates the data and averages associated with the overall set of tests that have been run...
Definition: SerialToEtherThroughput/TestStateData.cpp:115
void ReportCurTestData()
Prints out data associated with the current test.
Definition: SerialToEtherThroughput/TestStateData.cpp:99
This holds the cumulative results for a specific set of tests.
Definition: SerialToEtherThroughput/TestStateData.h:16
bool ValidateDataBuffer()
Validates if the data buffer used to receive and send data from matches our base data buffer...
Definition: SerialToEtherThroughput/TestStateData.cpp:78
void UpdateBufPtr(BufferObj &bufferObj)
Updates the current buffer pointer to the location where we are reading/writing the data...
Definition: SerialToEtherThroughput/TestStateData.cpp:68
void ReportTotalTestData()
Prints out the cumulative data for a specific test type.
Definition: SerialToEtherThroughput/TestStateData.cpp:143