The Assimilation Project  based on Assimilation version 1.1.7.1474836767
gtest01.c File Reference
#include <projectcommon.h>
#include <sys/types.h>
#include <signal.h>
#include <string.h>
#include <glib.h>
#include <gmainfd.h>
#include <logsourcefd.h>
#include <configcontext.h>
#include <childprocess.h>
#include <resourcecmd.h>
#include <resourcelsb.h>
#include <resourcequeue.h>
Include dependency graph for gtest01.c:

Go to the source code of this file.

Data Structures

struct  ocf_expect
 

Macros

#define HELLOSTRING   ": Hello, world."
 
#define HELLOSTRING_NL   (HELLOSTRING "\n")
 
#define OCFCLASS   "\"" REQCLASSNAMEFIELD "\": \"ocf\""
 
#define LSBCLASS   "\"" REQCLASSNAMEFIELD "\": \"lsb\""
 
#define HBPROVIDER   "\"" REQPROVIDERNAMEFIELD "\": \"heartbeat\""
 
#define DUMMYTYPE   "\"" CONFIGNAME_TYPE "\": \"Dummy\""
 
#define NANOTYPE   "\"" CONFIGNAME_TYPE "\": \"nanoprobe\""
 
#define STARTOP   "\"" REQOPERATIONNAMEFIELD "\": \"start\""
 
#define STOPOP   "\"" REQOPERATIONNAMEFIELD "\": \"stop\""
 
#define MONOP   "\"" REQOPERATIONNAMEFIELD "\": \"monitor\""
 
#define METAOP   "\"" REQOPERATIONNAMEFIELD "\": \"meta-data\""
 
#define RESOURCENAME   "\"" CONFIGNAME_INSTANCE "\": \"DummyTestGTest01\""
 
#define NULLPARAMS   "\"" REQENVIRONNAMEFIELD "\": {}," "\"" REQCANCELONFAILFIELD "\": true"
 
#define REQID   "\"" REQIDENTIFIERNAMEFIELD "\": 42"
 
#define PREFIX   REQID "," OCFCLASS "," DUMMYTYPE "," RESOURCENAME "," HBPROVIDER
 
#define LSBPREFIX   REQID "," LSBCLASS "," NANOTYPE "," RESOURCENAME
 

Functions

FSTATIC void test_read_command_output_at_EOF (void)
 Test to run a command and verify that we can capture its output in a string in the gmainloop environment. More...
 
FSTATIC void test_log_command_output (void)
 A test for just testing our ability to log things we read from a pipe. More...
 
FSTATIC void test_save_command_output (void)
 
FSTATIC void test_childprocess_log_all (void)
 This test produces output which is logged. We verify the character and line counts. More...
 
FSTATIC void test_childprocess_false (void)
 This test exits with return code 1 (the false command) More...
 
FSTATIC void test_childprocess_timeout (void)
 This process just exceeds its timeout via a sleep. More...
 
FSTATIC void test_childprocess_save_command_output (void)
 This test outputs a string which is then saved. More...
 
FSTATIC void quit_at_child_exit (GPid pid, gint status, gpointer logsourcefd)
 Quit when the child exits - look for HELLOSTRING characters being logged. More...
 
FSTATIC void check_output_at_exit (GPid pid, gint status, gpointer gmainfd)
 Make sure we read our HELLOSTRING when the process exits. More...
 
FSTATIC void quit_at_childprocess_exit (ChildProcess *, enum HowDied, int rc, int signal, gboolean core_dumped)
 
FSTATIC void generic_childprocess_test (gchar **argv, ConfigContext *envmod, gboolean save_stdout, char *curdir, int timeout)
 A generic helper function for testing things about childprocess_new() More...
 
FSTATIC void test_childprocess_save_command_output_timeout (void)
 We produce some output, then exceed our timeout with a sleep. More...
 
FSTATIC void test_childprocess_save_command_output_signal (void)
 We produce some output, then kill ourselves with a signal. More...
 
FSTATIC void test_childprocess_stderr_logging (void)
 We produce some to stderr, and some to stdout Verify capturing the stdout, and the char counts of stderr. More...
 
FSTATIC void test_childprocess_modenv (void)
 
FSTATIC void test_safe_ocfops (void)
 
FSTATIC void test_safe_queue_lsbops (void)
 
FSTATIC void test_safe_queue_ocfops (void)
 
FSTATIC void expect_ocf_callback (ConfigContext *request, gpointer user_data, enum HowDied reason, int rc, int signal, gboolean coredump, const char *stringresult)
 
FSTATIC void test_all_freed (void)
 
int main (int argc, char **argv)
 Test main program ('/gtest01') using the glib test fixtures. More...
 

Variables

GMainLoop * mainloop
 gtest01.c - miscellaneous glib mainloop-based tests. More...
 
enum HowDied test_expected_death = EXITED_ZERO
 
int test_expected_exitcode = 0
 
int test_expected_signal = 0
 
int test_expected_linecount = 1
 
int test_expected_charcount = 0
 
int test_expected_stderr_linecount = 0
 
int test_expected_stderr_charcount = 0
 
const char * test_expected_string_return = NULL
 
gboolean no_dummy_RA = FALSE
 

Macro Definition Documentation

#define DUMMYTYPE   "\"" CONFIGNAME_TYPE "\": \"Dummy\""

Definition at line 440 of file gtest01.c.

Referenced by test_safe_ocfops(), and test_safe_queue_ocfops().

#define HBPROVIDER   "\"" REQPROVIDERNAMEFIELD "\": \"heartbeat\""

Definition at line 439 of file gtest01.c.

Referenced by test_safe_ocfops(), and test_safe_queue_ocfops().

#define LSBCLASS   "\"" REQCLASSNAMEFIELD "\": \"lsb\""

Definition at line 438 of file gtest01.c.

#define LSBPREFIX   REQID "," LSBCLASS "," NANOTYPE "," RESOURCENAME

Definition at line 648 of file gtest01.c.

Referenced by test_safe_queue_lsbops().

#define METAOP   "\"" REQOPERATIONNAMEFIELD "\": \"meta-data\""

Definition at line 445 of file gtest01.c.

Referenced by test_safe_ocfops(), test_safe_queue_lsbops(), and test_safe_queue_ocfops().

#define MONOP   "\"" REQOPERATIONNAMEFIELD "\": \"monitor\""

Definition at line 444 of file gtest01.c.

Referenced by test_safe_ocfops(), test_safe_queue_lsbops(), and test_safe_queue_ocfops().

#define NANOTYPE   "\"" CONFIGNAME_TYPE "\": \"nanoprobe\""

Definition at line 441 of file gtest01.c.

#define NULLPARAMS   "\"" REQENVIRONNAMEFIELD "\": {}," "\"" REQCANCELONFAILFIELD "\": true"

Definition at line 447 of file gtest01.c.

Referenced by test_safe_ocfops(), test_safe_queue_lsbops(), and test_safe_queue_ocfops().

#define OCFCLASS   "\"" REQCLASSNAMEFIELD "\": \"ocf\""

Definition at line 437 of file gtest01.c.

Referenced by test_safe_ocfops(), and test_safe_queue_ocfops().

#define PREFIX   REQID "," OCFCLASS "," DUMMYTYPE "," RESOURCENAME "," HBPROVIDER

Definition at line 560 of file gtest01.c.

Referenced by test_safe_queue_ocfops().

#define REQID   "\"" REQIDENTIFIERNAMEFIELD "\": 42"

Definition at line 448 of file gtest01.c.

Referenced by test_safe_queue_ocfops().

#define RESOURCENAME   "\"" CONFIGNAME_INSTANCE "\": \"DummyTestGTest01\""

Definition at line 446 of file gtest01.c.

Referenced by test_safe_ocfops(), and test_safe_queue_ocfops().

#define STARTOP   "\"" REQOPERATIONNAMEFIELD "\": \"start\""

Definition at line 442 of file gtest01.c.

Referenced by test_safe_ocfops(), test_safe_queue_lsbops(), and test_safe_queue_ocfops().

#define STOPOP   "\"" REQOPERATIONNAMEFIELD "\": \"stop\""

Definition at line 443 of file gtest01.c.

Referenced by test_safe_ocfops(), test_safe_queue_lsbops(), and test_safe_queue_ocfops().

Function Documentation

FSTATIC void check_output_at_exit ( GPid  pid,
gint  status,
gpointer  gmainfd 
)

Make sure we read our HELLOSTRING when the process exits.

Definition at line 93 of file gtest01.c.

References CASTTOCLASS, FSTATIC, HELLOSTRING, mainloop, and _GMainFd::textread.

Referenced by test_read_command_output_at_EOF().

Here is the caller graph for this function:

FSTATIC void expect_ocf_callback ( ConfigContext request,
gpointer  user_data,
enum HowDied  reason,
int  rc,
int  signal,
gboolean  coredump,
const char *  stringresult 
)
FSTATIC void generic_childprocess_test ( gchar **  argv,
ConfigContext envmod,
gboolean  save_stdout,
char *  curdir,
int  timeout 
)
FSTATIC void quit_at_child_exit ( GPid  pid,
gint  status,
gpointer  gmainfd 
)

Quit when the child exits - look for HELLOSTRING characters being logged.

Definition at line 149 of file gtest01.c.

References CASTTOCLASS, _LogSourceFd::charcount, FSTATIC, HELLOSTRING, _LogSourceFd::linecount, and mainloop.

Referenced by test_log_command_output().

Here is the caller graph for this function:

FSTATIC void quit_at_childprocess_exit ( ChildProcess self,
enum HowDied  notice,
int  rc,
int  signal,
gboolean  core_dumped 
)
FSTATIC void test_all_freed ( void  )

Definition at line 81 of file gtest01.c.

References FSTATIC, proj_class_dump_live_objects(), and proj_class_live_object_count().

Referenced by test_safe_ocfops(), test_safe_queue_lsbops(), and test_safe_queue_ocfops().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void test_childprocess_false ( void  )

This test exits with return code 1 (the false command)

Definition at line 296 of file gtest01.c.

References EXITED_NONZERO, FSTATIC, generic_childprocess_test(), test_expected_charcount, test_expected_death, test_expected_exitcode, test_expected_linecount, test_expected_signal, test_expected_stderr_charcount, test_expected_stderr_linecount, and test_expected_string_return.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void test_childprocess_log_all ( void  )

This test produces output which is logged. We verify the character and line counts.

Definition at line 277 of file gtest01.c.

References EXITED_ZERO, FSTATIC, generic_childprocess_test(), HELLOSTRING, test_expected_charcount, test_expected_death, test_expected_exitcode, test_expected_linecount, test_expected_signal, test_expected_stderr_charcount, test_expected_stderr_linecount, and test_expected_string_return.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void test_childprocess_save_command_output ( void  )

This test outputs a string which is then saved.

Definition at line 314 of file gtest01.c.

References EXITED_ZERO, FSTATIC, generic_childprocess_test(), HELLOSTRING, HELLOSTRING_NL, test_expected_charcount, test_expected_death, test_expected_exitcode, test_expected_linecount, test_expected_signal, test_expected_stderr_charcount, test_expected_stderr_linecount, and test_expected_string_return.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void test_childprocess_save_command_output_signal ( void  )

We produce some output, then kill ourselves with a signal.

The output is set up to be captured.

Definition at line 377 of file gtest01.c.

References EXITED_SIGNAL, FSTATIC, generic_childprocess_test(), HELLOSTRING, HELLOSTRING_NL, test_expected_charcount, test_expected_death, test_expected_exitcode, test_expected_linecount, test_expected_signal, test_expected_stderr_charcount, test_expected_stderr_linecount, and test_expected_string_return.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void test_childprocess_save_command_output_timeout ( void  )

We produce some output, then exceed our timeout with a sleep.

The output is set up to be captured.

Definition at line 356 of file gtest01.c.

References EXITED_TIMEOUT, FSTATIC, generic_childprocess_test(), HELLOSTRING, HELLOSTRING_NL, test_expected_charcount, test_expected_death, test_expected_exitcode, test_expected_linecount, test_expected_signal, test_expected_stderr_charcount, test_expected_stderr_linecount, and test_expected_string_return.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void test_childprocess_stderr_logging ( void  )

We produce some to stderr, and some to stdout Verify capturing the stdout, and the char counts of stderr.

Definition at line 398 of file gtest01.c.

References EXITED_ZERO, FSTATIC, generic_childprocess_test(), HELLOSTRING, HELLOSTRING_NL, test_expected_charcount, test_expected_death, test_expected_exitcode, test_expected_linecount, test_expected_signal, test_expected_stderr_charcount, test_expected_stderr_linecount, and test_expected_string_return.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void test_childprocess_timeout ( void  )

This process just exceeds its timeout via a sleep.

No output is produced.

Definition at line 420 of file gtest01.c.

References EXITED_TIMEOUT, generic_childprocess_test(), test_expected_charcount, test_expected_death, test_expected_exitcode, test_expected_linecount, test_expected_signal, test_expected_stderr_charcount, test_expected_stderr_linecount, and test_expected_string_return.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void test_log_command_output ( void  )

A test for just testing our ability to log things we read from a pipe.

Definition at line 195 of file gtest01.c.

References __FUNCTION__, _LogSourceFd::baseclass, _GMainFd::baseclass, FSTATIC, HELLOSTRING, logsourcefd_new(), mainloop, proj_class_dump_live_objects(), proj_class_live_object_count(), and quit_at_child_exit().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void test_read_command_output_at_EOF ( void  )

Test to run a command and verify that we can capture its output in a string in the gmainloop environment.

Definition at line 107 of file gtest01.c.

References _GMainFd::baseclass, check_output_at_exit(), FSTATIC, gmainfd_new(), HELLOSTRING, mainloop, proj_class_dump_live_objects(), and proj_class_live_object_count().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void test_safe_ocfops ( void  )

Definition at line 483 of file gtest01.c.

References __FUNCTION__, configcontext_new_JSON_string(), DIMOF, DUMMYTYPE, _ResourceCmd::execute, EXITED_NONZERO, EXITED_ZERO, expect_ocf_callback(), HBPROVIDER, mainloop, METAOP, MONOP, no_dummy_RA, NULLPARAMS, OCFCLASS, resourcecmd_new(), RESOURCENAME, STARTOP, STOPOP, test_all_freed(), and UNREF.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void test_safe_queue_lsbops ( void  )

Definition at line 651 of file gtest01.c.

References __FUNCTION__, configcontext_new_JSON_string(), DIMOF, EXITED_NONZERO, EXITED_ZERO, expect_ocf_callback(), LSB_ROOT, LSBPREFIX, mainloop, METAOP, MONOP, NULLPARAMS, _ResourceQueue::Qcmd, resourcequeue_new(), STARTOP, STOPOP, test_all_freed(), and UNREF.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void test_safe_queue_ocfops ( void  )

Definition at line 562 of file gtest01.c.

References __FUNCTION__, configcontext_new_JSON_string(), DIMOF, DUMMYTYPE, EXITED_NONZERO, EXITED_ZERO, expect_ocf_callback(), HBPROVIDER, mainloop, METAOP, MONOP, no_dummy_RA, NULLPARAMS, OCFCLASS, PREFIX, _ResourceQueue::Qcmd, REQID, RESOURCENAME, resourcequeue_new(), STARTOP, STOPOP, test_all_freed(), and UNREF.

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void test_save_command_output ( void  )

Variable Documentation

gboolean no_dummy_RA = FALSE

Definition at line 78 of file gtest01.c.

Referenced by test_safe_ocfops(), and test_safe_queue_ocfops().