FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
testRun.c
Go to the documentation of this file.
1 /*********************************************************************
2 Copyright (C) 2011, 2012 Hewlett-Packard Development Company, L.P.
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 version 2 as published by the Free Software Foundation.
7 
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License along
14 with this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 *********************************************************************/
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <assert.h>
26 #include <CUnit/CUnit.h>
27 #include <CUnit/Automated.h>
28 #include <gio/gio.h>
29 #include <glib.h>
30 
31 #include <libfossology.h>
32 #include <testRun.h>
33 
34 #include <agent.h>
35 #include <database.h>
36 #include <event.h>
37 #include <host.h>
38 #include <interface.h>
39 #include <logging.h>
40 #include <scheduler.h>
41 
42 /* ************************************************************************** */
43 /* **** suite initializations *********************************************** */
44 /* ************************************************************************** */
45 
46 char* testdb = NULL;
47 
54 int init_suite(void)
55 {
56  if(main_log)
58  main_log = log_new("./founit.log", "UNIT_TESTS", getpid());
59 
60  if(!testdb && (testdb = getenv("FOSSOLOGY_TESTCONFIG")) == NULL)
61  {
62  printf("ERROR: scheduler unit tests require a test database");
63  exit(1);
64  }
65 
66  return 0;
67 }
68 
76 int clean_suite(void)
77 {
78  if(main_log)
80 
81  main_log = NULL;
82  return 0;
83 }
84 
85 /* ************************************************************************** */
86 /* *** main and suite decl ************************************************** */
87 /* ************************************************************************** */
88 
89 /* create test suite */
90 #if CU_VERSION_P == 213
91 
92 CU_SuiteInfo suites[] =
93 {
94  {"Host", NULL, NULL, (CU_SetUpFunc)init_suite, (CU_TearDownFunc)clean_suite, tests_host },
95  {"Interface", NULL, NULL, (CU_SetUpFunc)init_suite, (CU_TearDownFunc)clean_suite, tests_interface },
96  {"InterfaceThread", NULL, NULL, (CU_SetUpFunc)init_suite, (CU_TearDownFunc)clean_suite, tests_interface_thread },
97  {"Database", NULL, NULL, (CU_SetUpFunc)init_suite, (CU_TearDownFunc)clean_suite, tests_database },
98  {"Email", NULL, NULL, (CU_SetUpFunc)init_suite, (CU_TearDownFunc)clean_suite, tests_email },
99  // {"Job" NULL, NULL, (CU_SetUpFunc)init_suite, (CU_TearDownFunc)clean_suite, tests_job },
100  {"Scheduler", NULL, NULL, (CU_SetUpFunc)init_suite, (CU_TearDownFunc)clean_suite, tests_scheduler },
101  {"MetaAgent", NULL, NULL, (CU_SetUpFunc)init_suite, (CU_TearDownFunc)clean_suite, tests_meta_agent },
102  {"Agent", NULL, NULL, (CU_SetUpFunc)init_suite, (CU_TearDownFunc)clean_suite, tests_agent },
103  {"Event", NULL, NULL, (CU_SetUpFunc)init_suite, (CU_TearDownFunc)clean_suite, tests_event },
104  CU_SUITE_INFO_NULL
105 };
106 #else
107 CU_SuiteInfo suites[] =
108 {
109  {"Host", init_suite, clean_suite, tests_host },
110  {"Interface", init_suite, clean_suite, tests_interface },
111  {"InterfaceThread", init_suite, clean_suite, tests_interface_thread },
112  {"Database",init_suite,clean_suite, tests_database },
113  {"Email",init_suite,clean_suite, tests_email },
114  // {"Job",init_suite,clean_suite, tests_job },
115  {"Scheduler", init_suite,clean_suite, tests_scheduler },
116  {"MetaAgent", init_suite, clean_suite, tests_meta_agent },
117  {"Agent", init_suite, clean_suite, tests_agent },
118  {"Event",init_suite,clean_suite, tests_event },
119  CU_SUITE_INFO_NULL
120 };
121 #endif
122 
123 int main( int argc, char *argv[] )
124 {
125 #if !GLIB_CHECK_VERSION(2,35,0)
126  g_type_init ();
127  g_thread_init(NULL);
128 #endif
129 
130  return focunit_main(argc, argv, "scheduler_Tests", suites);
131 }
int init_suite(void)
Definition: testRun.c:54
void log_destroy(log_t *log)
Free memory associated with the log file.
Definition: logging.c:161
CU_SuiteInfo suites[]
all test suites for delagent
Definition: testRun.h:54
Log related operations.
int main(int argc, char *argv[])
main test function
Definition: testRun.c:146
int clean_suite(void)
Definition: testRun.c:76
log_t * log_new(gchar *log_name, gchar *pro_name, pid_t pro_pid)
Creates a new log.
Definition: logging.c:92
log_t * main_log
Definition: logging.c:44
The main FOSSology C library.
Event handling operations.
Header file with agent related operations.