24 #include "CUnit/CUnit.h" 25 #include "CUnit/Automated.h" 35 extern CU_SuiteInfo
suites[];
46 memset(CMD,
'\0',
sizeof(CMD));
47 user = malloc(20 *
sizeof(
char));
48 memset(user,
'\0', 20);
50 sprintf(CMD,
"awk -F \"=\" '/user/ {print $2}' %s | tr -d '; '",
DBConfFile);
51 db_conf = popen(CMD,
"r");
54 if(fgets(user,
sizeof(user)-1, db_conf) != NULL)
78 if(getcwd(cwd,
sizeof(cwd)) != NULL)
86 printf(
"Database initialize ERROR!\n");
94 memset(CMD,
'\0',
sizeof(CMD));
95 sprintf(CMD,
"gunzip -c ../testdata/testdb_all.gz | psql -U %s -d %s >/dev/null", user, db_name);
101 if (WEXITSTATUS(rc) != 0)
103 printf(
"Database initialize ERROR!\n");
130 memset(CMD,
'\0',
sizeof(CMD));
131 sprintf(CMD,
"sh testInitRepo.sh %s",
get_repodir());
135 printf(
"Repository Init ERROR!\n");
146 int main(
int argc,
char *argv[] )
148 return focunit_main(argc, argv,
"delagent_Tests",
suites);
char * DBConfFile
DB conf file location.
int DelagentDBInit()
initialize db
int create_db_repo_sysconf(int type, char *agent_name, char *sysconfdir)
char * createTestConfDir(char *cwd, char *agentName)
create a dummy sysConfDir for a given agent
CU_SuiteInfo suites[]
all test suites for delagent
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
int main(int argc, char *argv[])
main test function
cmdlist CMD[]
Global command table.
int DelagentInit()
init db and repo
int DelagentClean()
clean db
char * get_db_name()
get the DB name just created by create_db_repo_sysconf()
char * getUser()
Helper function to get db owner.
char * get_repodir()
get repo path just created by create_db_repo_sysconf()