FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
run_tests.c
Go to the documentation of this file.
1 /*********************************************************************
2 Copyright (C) 2010 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 "run_tests.h"
24 #include "../agent/ununpack_globals.h"
25 
26 #define AGENT_DIR "../../"
27 /* globals that mostly shouldn't be globals */
28 char *Filename = "";
29 char *NewDir = "./test-result";
30 int Recurse = -1;
31 int exists = 0;
32 char *DBConfFile = NULL;
33 
34 /* ************************************************************************** */
35 /* **** test suite ********************************************************** */
36 /* ************************************************************************** */
37 extern CU_TestInfo ExtractAR_testcases[];
38 extern CU_TestInfo ununpack_iso_testcases[];
39 extern CU_TestInfo ununpack_disk_testcases[];
40 extern CU_TestInfo CopyFile_testcases[];
41 extern CU_TestInfo FindCmd_testcases[];
42 extern CU_TestInfo Prune_testcases[];
43 extern CU_TestInfo RunCommand_testcases[];
44 extern CU_TestInfo Traverse_testcases[];
45 extern CU_TestInfo TraverseChild_testcases[];
46 extern CU_TestInfo TraverseStart_testcases[];
47 extern CU_TestInfo TaintString_testcases[];
48 extern CU_TestInfo IsFunctions_testcases[];
49 extern CU_TestInfo ContainerInfo_testcases[];
50 extern CU_TestInfo Checksum_testcases[];
51 extern CU_TestInfo PathCheck_testcases[];
52 extern CU_TestInfo DBInsertPfile_testcases[];
53 extern CU_TestInfo DBInsertUploadTree_testcases[];
54 
55 #if CU_VERSION_P == 213
56 CU_SuiteInfo suites[] =
57 {
58  // ununpack-ar.c
59  {"ExtractAR", NULL, NULL, NULL, NULL, ExtractAR_testcases},
60 
61  // ununpack-iso.c
62  {"ununpack-iso", NULL, NULL, NULL, NULL, ununpack_iso_testcases},
63 
64  // ununpack-disk.c
65  {"ununpack-disk", NULL, NULL, (CU_SetUpFunc)FatDiskNameInit, (CU_TearDownFunc)FatDiskNameClean, ununpack_disk_testcases},
66 
67  // utils.c
68  {"CopyFile", NULL, NULL, (CU_SetUpFunc)CopyFileInit, (CU_TearDownFunc)CopyFileClean, CopyFile_testcases},
70  {"Prune", NULL, NULL, (CU_SetUpFunc)PruneInit, (CU_TearDownFunc)PruneClean, Prune_testcases},
71  {"RunCommand", NULL, NULL, NULL, NULL, RunCommand_testcases},
72  {"TaintString", NULL, NULL, NULL, NULL, TaintString_testcases},
73  {"IsFunctions", NULL, NULL, NULL, NULL, IsFunctions_testcases},
74  {"ContainerInfo", NULL, NULL, NULL, NULL, ContainerInfo_testcases},
75  {"PathCheck", NULL, NULL, NULL, NULL, PathCheck_testcases},
76  //{"DBInsert", DBInsertInit, DBInsertClean, DBInsert_testcases},
77 
78  // traverse.c
79  {"Traverse", NULL, NULL, (CU_SetUpFunc)TraverseInit, (CU_TearDownFunc)TraverseClean, Traverse_testcases},
80  {"TraverseChild", NULL, NULL, (CU_SetUpFunc)TraverseChildInit, NULL, TraverseChild_testcases},
81  {"TraverseStart", NULL, NULL, (CU_SetUpFunc)TraverseStartInit, (CU_TearDownFunc)TraverseStartClean, TraverseStart_testcases},
82 
83  // checksum.c
84  {"checksum", NULL, NULL, NULL, NULL, Checksum_testcases},
85 
86  //utils.c
87  {"DBInsertPfile", NULL, NULL, (CU_SetUpFunc)DBInsertInit, (CU_TearDownFunc)DBInsertClean, DBInsertPfile_testcases},
88  {"DBInsertUploadTree", NULL, NULL, (CU_SetUpFunc)DBInsertInit, (CU_TearDownFunc)DBInsertClean, DBInsertUploadTree_testcases},
89 
90  CU_SUITE_INFO_NULL
91 };
92 #else
93 CU_SuiteInfo suites[] =
94 {
95  // ununpack-ar.c
96  {"ExtractAR", NULL, NULL, ExtractAR_testcases},
97 
98  // ununpack-iso.c
99  {"ununpack-iso", NULL, NULL, ununpack_iso_testcases},
100 
101  // ununpack-disk.c
103 
104  // utils.c
107  {"Prune", PruneInit, PruneClean, Prune_testcases},
108  {"RunCommand", NULL, NULL, RunCommand_testcases},
109  {"TaintString", NULL, NULL, TaintString_testcases},
110  {"IsFunctions", NULL, NULL, IsFunctions_testcases},
111  {"ContainerInfo", NULL, NULL, ContainerInfo_testcases},
112  {"PathCheck", NULL, NULL, PathCheck_testcases},
113  //{"DBInsert", DBInsertInit, DBInsertClean, DBInsert_testcases},
114 
115  // traverse.c
117  {"TraverseChild", TraverseChildInit, NULL, TraverseChild_testcases},
119 
120  // checksum.c
121  {"checksum", NULL, NULL, Checksum_testcases},
122 
123  //utils.c
125  {"DBInsertUploadTree", DBInsertInit, DBInsertClean, DBInsertUploadTree_testcases},
126 
127  CU_SUITE_INFO_NULL
128 };
129 #endif
130 
136 int file_dir_exists(char *path_name)
137 {
138  struct stat sts;
139  int exists = 1; // 0: not exists, 1: exists, default exists
140 
141  if ((stat (path_name, &sts)) == -1) exists = 0;
142  return exists;
143 }
144 
145 
146 /* ************************************************************************** */
147 /* **** main test functions ************************************************* */
148 /* ************************************************************************** */
149 
150 int main(int argc, char** argv)
151 {
152 
153  fo_dbManager* dbManager = createTestEnvironment(AGENT_DIR, "ununpack", 1);
154  if(!dbManager) {
155  printf("Unable to connect to test database\n");
156  return 1;
157  }
158 
160 
161  int rc = focunit_main(argc, argv, "ununpack_Tests", suites);
162  dropTestEnvironment(dbManager, AGENT_DIR, "ununpack");
163  return(rc);
164 }
CU_TestInfo FindCmd_testcases[]
FindCmd() test cases.
Definition: test_FindCmd.c:330
CU_TestInfo RunCommand_testcases[]
Run test cases.
CU_TestInfo Traverse_testcases[]
Traverse() test cases.
int file_dir_exists(char *path_name)
test if a file or directory exists
Definition: run_tests.c:136
int FatDiskNameInit()
initialize
CU_TestInfo ExtractAR_testcases[]
AR test cases.
int TraverseInit()
initialize
Definition: test_Traverse.c:30
int DBInsertClean()
clean the database
Definition: test_DBInsert.c:79
CU_TestInfo PathCheck_testcases[]
Pacth check test cases.
int TraverseStartInit()
initialize
CU_TestInfo TaintString_testcases[]
TaintString() test cases.
char * get_dbconf()
get Db.conf path just created by create_db_repo_sysconf()
int PruneClean()
clean env and others
Definition: test_Prune.c:41
int PruneInit()
initialize
Definition: test_Prune.c:32
int TraverseClean()
clean env and others
Definition: test_Traverse.c:46
int CopyFileClean()
clean env and others
Definition: test_CopyFile.c:43
int TraverseStartClean()
clean env and others
CU_SuiteInfo suites[]
all test suites for delagent
Definition: run_tests.c:65
char * DBConfFile
DB conf file location.
Definition: run_tests.c:32
CU_TestInfo Checksum_testcases[]
Checksum test cases.
CU_TestInfo DBInsertPfile_testcases[]
DB insertion test cases (pfile)
char * NewDir
Test result directory.
Definition: run_tests.c:29
CU_TestInfo TraverseChild_testcases[]
TraverseChild() test cases.
CU_TestInfo IsFunctions_testcases[]
Isxxx() test cases.
int FatDiskNameClean()
clean env and others
fo_dbManager * dbManager
fo_dbManager object
Definition: process.c:28
CU_TestInfo ContainerInfo_testcases[]
Container info test cases.
CU_TestInfo ununpack_disk_testcases[]
Disk image test cases.
CU_TestInfo ununpack_iso_testcases[]
ISO test cases.
CU_TestInfo CopyFile_testcases[]
Copy test cases.
int DBInsertInit()
initialize
Definition: test_DBInsert.c:32
char * Filename
Filename.
Definition: run_tests.c:28
int CopyFileInit()
initialize
Definition: test_CopyFile.c:34
int exists
Default not exists.
Definition: run_tests.c:31
int TraverseChildInit()
initialize
CU_TestInfo Prune_testcases[]
Prune() test cases.
Definition: test_Prune.c:110
int Recurse
Level of unpack recursion. Default to infinite.
Definition: run_tests.c:30
CU_TestInfo DBInsertUploadTree_testcases[]
DB insertion test cases (uploadtree)
CU_TestInfo TraverseStart_testcases[]
TraverseStart() test cases.