GM6000 Digital Heater Controller Build: 16 (Branch = develop)
SDX-1330
Shutdown_TS.h
Go to the documentation of this file.
1#ifndef Cpl_System_x_testsupport_Shutdown_TS_h_
2#define Cpl_System_x_testsupport_Shutdown_TS_h_
3/*-----------------------------------------------------------------------------
4* This file is part of the Colony.Core Project. The Colony.Core Project is an
5* open source project with a BSD type of licensing agreement. See the license
6* agreement (license.txt) in the top/ directory or on the Internet at
7* http://integerfox.com/colony.core/license.txt
8*
9* Copyright (c) 2014-2025 John T. Taylor
10*
11* Redistributions of the source code must retain the above copyright notice.
12*----------------------------------------------------------------------------*/
13/** @file */
14
15#include "colony_config.h"
16#include <stddef.h>
17
18/** Maximum number of allowed fatal errors before the application is
19 forced to exit. This is a safety mechanism to prevent the unit test
20 from getting into a 'runaway' error condition.
21
22 Note: The fatal error count is reset everytime getAndClearCounter()
23 is called.
24 */
25#ifndef OPTION_CPL_SYSTEM_SHUTDOWN_TS_MAX_FATAL_ERRORS
26#define OPTION_CPL_SYSTEM_SHUTDOWN_TS_MAX_FATAL_ERRORS 30
27#endif
28
29///
30namespace Cpl {
31///
32namespace System {
33
34
35/** This class provides methods to access the unit testing support
36 for the Cpl::System::Shutdown interface.
37
38 This class provides an implementation of Shutdown interface that
39 has the ability to count the number times the Shutdown interface
40 is/was called instead of exiting. It can also alter the application's
41 exit code.
42
43 Notes:
44 o The Shutdown implementation assumes/uses the C Library 'exit()'
45 method.
46 */
48{
49public:
50 /** This method zero's the exit counter and sets the shutdown behavior
51 to NOT exit when called - only count the calls. Note: This
52 interface starts in the 'counter mode' with the count set to
53 zero.
54 */
55 static void clearAndUseCounter( void );
56
57 /** This method returns the current call count AND clears the
58 call counter.
59 */
60 static size_t getAndClearCounter( void );
61
62
63public:
64 /** This method allows the application to exit - but always with
65 the specified 'new_exit_code' (i.e. ignoring the application
66 supplied exit code). This method is helpful during unit testing
67 for 'passing' and exit/failure use case.
68 */
69 static void setExitCode( int new_exit_code );
70
71 /** This method restores the exit/shutdown behavior to its 'non-test'
72 paradigm.
73 */
74 static void restore( void );
75
76};
77
78
79}; // end namespaces
80};
81#endif // end header latch
82
This class provides methods to access the unit testing support for the Cpl::System::Shutdown interfac...
Definition Shutdown_TS.h:48
static void restore(void)
This method restores the exit/shutdown behavior to its 'non-test' paradigm.
static void clearAndUseCounter(void)
This method zero's the exit counter and sets the shutdown behavior to NOT exit when called - only cou...
static size_t getAndClearCounter(void)
This method returns the current call count AND clears the call counter.
static void setExitCode(int new_exit_code)
This method allows the application to exit - but always with the specified 'new_exit_code' (i....
The 'Cpl' namespace is the root name space for the Colony.
Definition Api16.h:20