12 #include "CUnit/CUnit.h"
13 #include "CUnit/Automated.h"
23 extern CU_SuiteInfo
suites[];
34 memset(
CMD,
'\0',
sizeof(
CMD));
35 user = malloc(20 *
sizeof(
char));
36 memset(user,
'\0', 20);
38 sprintf(
CMD,
"awk -F \"=\" '/user/ {print $2}' %s | tr -d '; '",
DBConfFile);
39 db_conf = popen(
CMD,
"r");
42 if(fgets(user,
sizeof(user)-1, db_conf) != NULL)
66 if(getcwd(cwd,
sizeof(cwd)) != NULL)
74 printf(
"Database initialize ERROR!\n");
82 memset(
CMD,
'\0',
sizeof(
CMD));
83 sprintf(
CMD,
"gunzip -c ../testdata/testdb_all.gz | psql -U %s -d %s >/dev/null", user, db_name);
89 if (WEXITSTATUS(rc) != 0)
91 printf(
"Database initialize ERROR!\n");
118 memset(
CMD,
'\0',
sizeof(
CMD));
123 printf(
"Repository Init ERROR!\n");
134 int main(
int argc,
char *argv[] )
136 return focunit_main(argc, argv,
"delagent_Tests",
suites);
int main(int argc, char *argv[])
main test function
char * getUser()
Helper function to get db owner.
int DelagentDBInit()
initialize db
int DelagentClean()
clean db
int DelagentInit()
init db and repo
CU_SuiteInfo suites[]
all test suites for delagent
cmdlist CMD[]
Global command table.
char * get_repodir()
get repo path just created by create_db_repo_sysconf()
char * get_dbconf()
get Db.conf path just created by create_db_repo_sysconf()
void drop_db_repo_sysconf(char *DBName)
drop db, sysconfig dir and repo
char * get_db_name()
get the DB name just created by create_db_repo_sysconf()
char * createTestConfDir(char *cwd, char *agentName)
create a dummy sysConfDir for a given agent
int create_db_repo_sysconf(int type, char *agent_name, char *sysconfdir)
char * DBConfFile
DB conf file location.