blob: 3c7a0a4d5df66120fbd86106246f108273a90f5a [file] [log] [blame]
Brian Silvermaneeb62ca2013-09-11 15:08:03 -07001#ifndef AOS_COMMON_QUEUE_TESTUTILS_H_
2#define AOS_COMMON_QUEUE_TESTUTILS_H_
3
Brian Silverman14fd0fb2014-01-14 21:42:01 -08004#include "aos/linux_code/ipc_lib/shared_mem.h"
Brian Silvermaneeb62ca2013-09-11 15:08:03 -07005
6// This file has some general helper functions for dealing with testing things
7// that use shared memory etc.
brians343bc112013-02-10 01:53:46 +00008
9namespace aos {
10namespace common {
11namespace testing {
12
Brian Silvermaneeb62ca2013-09-11 15:08:03 -070013// Manages creating and cleaning up "shared memory" which works within this
14// process and any that it fork(2)s.
brians343bc112013-02-10 01:53:46 +000015class GlobalCoreInstance {
16 public:
Brian Silvermaneeb62ca2013-09-11 15:08:03 -070017 // Calls EnableTestLogging().
brians343bc112013-02-10 01:53:46 +000018 GlobalCoreInstance();
19 ~GlobalCoreInstance();
20
21 private:
22 struct aos_core global_core_data_;
23};
24
Brian Silvermanb3616972013-03-05 19:58:10 -080025// Enables the logging framework for use during a gtest test.
26// It will print out all WARNING and above messages all of the time. It will
27// also print out all log messages when a test fails.
28// This function only needs to be called once in each process (after gtest is
29// initialized), however it can be called more than that.
30void EnableTestLogging();
31
Brian Silvermaneeb62ca2013-09-11 15:08:03 -070032// Registers an exit handler (using atexit(3)) which will call _exit(2).
33// Intended to be called in a freshly fork(2)ed process where it will run before
34// any other exit handlers that were already registered and prevent them from
35// being run.
36void PreventExit();
37
brians343bc112013-02-10 01:53:46 +000038} // namespace testing
39} // namespace common
40} // namespace aos
Brian Silvermaneeb62ca2013-09-11 15:08:03 -070041
42#endif // AOS_COMMON_QUEUE_TESTUTILS_H_