9 #include "CUnit/CUnit.h"
36 for(i=0; i<20; i++) { sprintf(Fuid+0+i*2,
"%02X",
's'); }
38 for(i=0; i<16; i++) { sprintf(Fuid+41+i*2,
"%02X",
'm'); }
40 snprintf(Fuid+74,
sizeof(Fuid)-74,
"%Lu",(
long long unsigned int)100);
48 snprintf(
SQL,MAXSQL,
"INSERT INTO pfile (pfile_sha1,pfile_md5,pfile_size) VALUES ('%.40s','%.32s','%s');",
49 Fuid,Fuid+41,Fuid+74);
53 printf(
"Perpare pfile information ERROR!\n");
58 memset(
SQL,
'\0',MAXSQL);
59 snprintf(
SQL,MAXSQL,
"SELECT pfile_pk FROM pfile WHERE pfile_sha1 = '%.40s' AND pfile_md5 = '%.32s' AND pfile_size = '%s';",
60 Fuid,Fuid+41,Fuid+74);
64 printf(
"Get pfile information ERROR!\n");
67 pi->
pFileFk = atoi(PQgetvalue(result, 0, 0));
85 pi->
depends = calloc(data_size,
sizeof(
char *));
86 for (j=0; j<data_size;j++){
87 pi->
depends[j] = malloc(MAXCMD);
88 strcpy(pi->
depends[j],
"Test depends");
94 printf(
"RecordMetadataDEB Result is:%d\n",
Result);
97 memset(
SQL,
'\0',MAXSQL);
98 snprintf(
SQL,MAXSQL,
"SELECT pkg_pk, pkg_name, pkg_arch, version, maintainer, description FROM pkg_deb INNER JOIN pfile ON pfile_fk = '%ld' AND pfile_fk = pfile_pk;", pi->
pFileFk);
102 printf(
"Get pkg information ERROR!\n");
107 CU_ASSERT_STRING_EQUAL(PQgetvalue(result, 0, 1),
"Test Pkg");
108 CU_ASSERT_STRING_EQUAL(PQgetvalue(result, 0, 2),
"Test Arch");
109 CU_ASSERT_STRING_EQUAL(PQgetvalue(result, 0, 3),
"Test version");
110 CU_ASSERT_STRING_EQUAL(PQgetvalue(result, 0, 4),
"Test maintainer");
111 CU_ASSERT_STRING_EQUAL(PQgetvalue(result, 0, 5),
"Test description");
116 memset(
SQL,
'\0',MAXSQL);
117 snprintf(
SQL,MAXSQL,
"DELETE FROM pkg_deb_req WHERE pkg_fk IN (SELECT pkg_pk FROM pkg_deb WHERE pfile_fk = '%ld');", pi->
pFileFk);
121 printf(
"Clear pkg_deb_req test data ERROR!\n");
127 memset(
SQL,
'\0',MAXSQL);
128 snprintf(
SQL,MAXSQL,
"DELETE FROM pkg_deb WHERE pfile_fk = '%ld';", pi->
pFileFk);
132 printf(
"Clear pkg_deb test data ERROR!\n");
138 memset(
SQL,
'\0',MAXSQL);
139 snprintf(
SQL,MAXSQL,
"DELETE FROM pfile WHERE pfile_pk = '%ld'", pi->
pFileFk);
143 printf(
"Clear pfile test data ERROR!\n");
157 CU_ASSERT_EQUAL(
Result, predictValue);
char SQL[256]
SQL query to execute.
PGconn * fo_dbconnect(char *DBConfFile, char **ErrorBuf)
Connect to a database. The default is Db.conf.
int fo_checkPQresult(PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb)
Check the result status of a postgres SELECT.
int fo_checkPQcommand(PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb)
Check the result status of a postgres commands (not select) If an error occured, write the error to s...
PGconn * db_conn
The connection to Database.
int RecordMetadataDEB(struct debpkginfo *pi)
Store debian package info into database.
Holds meta info of Debian packages.
char section[MAXCMD]
Package section.
char priority[MAXCMD]
Package priority.
char standardsVersion[MAXCMD]
Package standards version.
long pFileFk
Package pfile in FOSSology.
char ** depends
Package dependency list.
char summary[MAXCMD]
Package summary.
char version[MAXCMD]
Package version.
char format[MAXCMD]
Package format.
char uploaders[MAXCMD]
Package contributors.
char maintainer[MAXCMD]
Package maintainer.
int installedSize
Size of package after install.
char pkgArch[MAXCMD]
Package architecture.
char description[MAXCMD]
Package description.
int dep_size
Package dependency list size.
char source[MAXCMD]
Package source.
char pkgName[MAXCMD]
Package name.
char homepage[MAXCMD]
Package link.
static int Result
Result of calls.