FOSSology  4.4.0
Open Source License Compliance by Open Source Software
testRun.c
Go to the documentation of this file.
1 /*
2  SPDX-FileCopyrightText: © 2011, 2012 Hewlett-Packard Development Company, L.P.
3 
4  SPDX-License-Identifier: GPL-2.0-only
5 */
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <assert.h>
15 #include <CUnit/CUnit.h>
16 #include <CUnit/Automated.h>
17 #include <gio/gio.h>
18 #include <glib.h>
19 
20 #include <libfossology.h>
21 #include <testRun.h>
22 
23 #include <agent.h>
24 #include <database.h>
25 #include <event.h>
26 #include <host.h>
27 #include <interface.h>
28 #include <logging.h>
29 #include <scheduler.h>
30 
31 /* ************************************************************************** */
32 /* **** suite initializations *********************************************** */
33 /* ************************************************************************** */
34 
35 char* testdb = NULL;
36 
43 int init_suite(void)
44 {
45  if(main_log)
47  main_log = log_new("./founit.log", "UNIT_TESTS", getpid());
48 
49  if(!testdb && (testdb = getenv("FOSSOLOGY_TESTCONFIG")) == NULL)
50  {
51  printf("ERROR: scheduler unit tests require a test database");
52  exit(1);
53  }
54 
55  return 0;
56 }
57 
65 int clean_suite(void)
66 {
67  if(main_log)
69 
70  main_log = NULL;
71  return 0;
72 }
73 
74 /* ************************************************************************** */
75 /* *** main and suite decl ************************************************** */
76 /* ************************************************************************** */
77 
78 /* create test suite */
80 CU_SuiteInfo suites[] =
81 {
82  {"Host", NULL, NULL, (CU_SetUpFunc)init_suite, (CU_TearDownFunc)clean_suite, tests_host },
83  {"Interface", NULL, NULL, (CU_SetUpFunc)init_suite, (CU_TearDownFunc)clean_suite, tests_interface },
84  {"InterfaceThread", NULL, NULL, (CU_SetUpFunc)init_suite, (CU_TearDownFunc)clean_suite, tests_interface_thread },
85  {"Database", NULL, NULL, (CU_SetUpFunc)init_suite, (CU_TearDownFunc)clean_suite, tests_database },
86  {"Email", NULL, NULL, (CU_SetUpFunc)init_suite, (CU_TearDownFunc)clean_suite, tests_email },
87  // {"Job" NULL, NULL, (CU_SetUpFunc)init_suite, (CU_TearDownFunc)clean_suite, tests_job },
88  {"Scheduler", NULL, NULL, (CU_SetUpFunc)init_suite, (CU_TearDownFunc)clean_suite, tests_scheduler },
89  {"MetaAgent", NULL, NULL, (CU_SetUpFunc)init_suite, (CU_TearDownFunc)clean_suite, tests_meta_agent },
90  {"Agent", NULL, NULL, (CU_SetUpFunc)init_suite, (CU_TearDownFunc)clean_suite, tests_agent },
91  {"Event", NULL, NULL, (CU_SetUpFunc)init_suite, (CU_TearDownFunc)clean_suite, tests_event },
92  CU_SUITE_INFO_NULL
93 };
94 
95 int main( int argc, char *argv[] )
96 {
97 #if !GLIB_CHECK_VERSION(2,35,0)
98  g_type_init ();
99  g_thread_init(NULL);
100 #endif
101 
102  return focunit_main(argc, argv, "scheduler_Tests", suites);
103 }
Header file with agent related operations.
int main(int argc, char *argv[])
main test function
Definition: testRun.c:134
CU_SuiteInfo suites[]
all test suites for delagent
Definition: testRun.h:36
Event handling operations.
The main FOSSology C library.
log_t * main_log
Definition: logging.c:33
log_t * log_new(gchar *log_name, gchar *pro_name, pid_t pro_pid)
Creates a new log.
Definition: logging.c:81
void log_destroy(log_t *log)
Free memory associated with the log file.
Definition: logging.c:150
Log related operations.
int init_suite(void)
Definition: testRun.c:43
int clean_suite(void)
Definition: testRun.c:65