20 #include "CUnit/CUnit.h" 47 for(i=0; i<20; i++) { sprintf(Fuid+0+i*2,
"%02X",
's'); }
49 for(i=0; i<16; i++) { sprintf(Fuid+41+i*2,
"%02X",
'm'); }
51 snprintf(Fuid+74,
sizeof(Fuid)-74,
"%Lu",(
long long unsigned int)100);
59 snprintf(SQL,MAXSQL,
"INSERT INTO pfile (pfile_sha1,pfile_md5,pfile_size) VALUES ('%.40s','%.32s','%s');",
60 Fuid,Fuid+41,Fuid+74);
64 printf(
"Perpare pfile information ERROR!\n");
69 memset(SQL,
'\0',MAXSQL);
70 snprintf(SQL,MAXSQL,
"SELECT pfile_pk FROM pfile WHERE pfile_sha1 = '%.40s' AND pfile_md5 = '%.32s' AND pfile_size = '%s';",
71 Fuid,Fuid+41,Fuid+74);
75 printf(
"Get pfile information ERROR!\n");
78 pi->
pFileFk = atoi(PQgetvalue(result, 0, 0));
96 pi->
depends = calloc(data_size,
sizeof(
char *));
97 for (j=0; j<data_size;j++){
98 pi->
depends[j] = malloc(MAXCMD);
99 strcpy(pi->
depends[j],
"Test depends");
105 printf(
"RecordMetadataDEB Result is:%d\n", Result);
108 memset(SQL,
'\0',MAXSQL);
109 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);
113 printf(
"Get pkg information ERROR!\n");
118 CU_ASSERT_STRING_EQUAL(PQgetvalue(result, 0, 1),
"Test Pkg");
119 CU_ASSERT_STRING_EQUAL(PQgetvalue(result, 0, 2),
"Test Arch");
120 CU_ASSERT_STRING_EQUAL(PQgetvalue(result, 0, 3),
"Test version");
121 CU_ASSERT_STRING_EQUAL(PQgetvalue(result, 0, 4),
"Test maintainer");
122 CU_ASSERT_STRING_EQUAL(PQgetvalue(result, 0, 5),
"Test description");
127 memset(SQL,
'\0',MAXSQL);
128 snprintf(SQL,MAXSQL,
"DELETE FROM pkg_deb_req WHERE pkg_fk IN (SELECT pkg_pk FROM pkg_deb WHERE pfile_fk = '%ld');", pi->
pFileFk);
132 printf(
"Clear pkg_deb_req test data ERROR!\n");
138 memset(SQL,
'\0',MAXSQL);
139 snprintf(SQL,MAXSQL,
"DELETE FROM pkg_deb WHERE pfile_fk = '%ld';", pi->
pFileFk);
143 printf(
"Clear pkg_deb test data ERROR!\n");
149 memset(SQL,
'\0',MAXSQL);
150 snprintf(SQL,MAXSQL,
"DELETE FROM pfile WHERE pfile_pk = '%ld'", pi->
pFileFk);
154 printf(
"Clear pfile test data ERROR!\n");
168 CU_ASSERT_EQUAL(Result, predictValue);
char ** depends
Package dependency list.
int installedSize
Size of package after install.
char maintainer[MAXCMD]
Package maintainer.
static int Result
Result of calls.
int fo_checkPQresult(PGconn *pgConn, PGresult *result, char *sql, char *FileID, int LineNumb)
Check the result status of a postgres SELECT.
char version[MAXCMD]
Package version.
char homepage[MAXCMD]
Package link.
long pFileFk
Package pfile in FOSSology.
int dep_size
Package dependency list size.
char standardsVersion[MAXCMD]
Package standards version.
char pkgArch[MAXCMD]
Package architecture.
Holds meta info of Debian packages.
char pkgName[MAXCMD]
Package name.
char summary[MAXCMD]
Package summary.
char description[MAXCMD]
Package description.
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...
char uploaders[MAXCMD]
Package contributors.
char SQL[256]
SQL query to execute.
PGconn * db_conn
The connection to Database.
char priority[MAXCMD]
Package priority.
char section[MAXCMD]
Package section.
char format[MAXCMD]
Package format.
int RecordMetadataDEB(struct debpkginfo *pi)
Store debian package info into database.
char source[MAXCMD]
Package source.
PGconn * fo_dbconnect(char *DBConfFile, char **ErrorBuf)
Connect to a database. The default is Db.conf.