9 #include "CUnit/CUnit.h"
37 for(i=0; i<20; i++) { sprintf(Fuid+0+i*2,
"%02X",
's'); }
39 for(i=0; i<16; i++) { sprintf(Fuid+41+i*2,
"%02X",
'm'); }
41 snprintf(Fuid+74,
sizeof(Fuid)-74,
"%Lu",(
long long unsigned int)100);
49 snprintf(
SQL,MAXSQL,
"INSERT INTO pfile (pfile_sha1,pfile_md5,pfile_size) VALUES ('%.40s','%.32s','%s');",
50 Fuid,Fuid+41,Fuid+74);
54 printf(
"Perpare pfile information ERROR!\n");
60 memset(
SQL,
'\0',MAXSQL);
61 snprintf(
SQL,MAXSQL,
"SELECT pfile_pk FROM pfile WHERE pfile_sha1 = '%.40s' AND pfile_md5 = '%.32s' AND pfile_size = '%s';",
62 Fuid,Fuid+41,Fuid+74);
66 printf(
"Get pfile information ERROR!\n");
71 pi->
pFileFk = atoi(PQgetvalue(result, 0, 0));
83 strncpy(pi->
group,
"Test group",
sizeof(pi->
group));
84 strncpy(pi->
url,
"Test url",
sizeof(pi->
url));
90 pi->
requires = calloc(data_size,
sizeof(
char *));
91 for (j=0; j<data_size;j++){
93 strcpy(pi->
requires[j],
"Test requires");
99 printf(
"RecordMetadataRPM Result is:%d\n",
Result);
102 memset(
SQL,
'\0',MAXSQL);
103 snprintf(
SQL,MAXSQL,
"SELECT pkg_pk, pkg_name, pkg_arch, version, license, packager, release, vendor FROM pkg_rpm INNER JOIN pfile ON pfile_fk = '%ld' AND pfile_fk = pfile_pk;", pi->
pFileFk);
107 printf(
"Get pkg information ERROR!\n");
112 CU_ASSERT_STRING_EQUAL(PQgetvalue(result, 0, 1),
"Test Pkg");
113 CU_ASSERT_STRING_EQUAL(PQgetvalue(result, 0, 2),
"Test Arch");
114 CU_ASSERT_STRING_EQUAL(PQgetvalue(result, 0, 3),
"Test version");
115 CU_ASSERT_STRING_EQUAL(PQgetvalue(result, 0, 4),
"Test license");
116 CU_ASSERT_STRING_EQUAL(PQgetvalue(result, 0, 5),
"Test packager");
117 CU_ASSERT_STRING_EQUAL(PQgetvalue(result, 0, 6),
"Test release");
118 CU_ASSERT_STRING_EQUAL(PQgetvalue(result, 0, 7),
"Test vendor");
122 memset(
SQL,
'\0',MAXSQL);
123 snprintf(
SQL,MAXSQL,
"DELETE FROM pkg_rpm_req WHERE pkg_fk IN (SELECT pkg_pk FROM pkg_rpm WHERE pfile_fk = '%ld');", pi->
pFileFk);
127 printf(
"Clear pkg_rpm_req test data ERROR!\n");
133 memset(
SQL,
'\0',MAXSQL);
134 snprintf(
SQL,MAXSQL,
"DELETE FROM pkg_rpm WHERE pfile_fk = '%ld';", pi->
pFileFk);
138 printf(
"Clear pkg_rpm test data ERROR!\n");
142 memset(
SQL,
'\0',MAXSQL);
143 snprintf(
SQL,MAXSQL,
"DELETE FROM pfile WHERE pfile_pk = '%ld'", pi->
pFileFk);
147 printf(
"Clear pfile test data ERROR!\n");
161 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 RecordMetadataRPM(struct rpmpkginfo *pi)
Store rpm package info into database.
Holds meta info of rpm packages.
char buildDate[128]
Package build date.
char group[128]
Package group.
char version[64]
Package version.
char summary[MAXCMD]
Package summary.
char pkgName[256]
RPM package name.
char description[MAXCMD]
Package description.
char rpmFilename[256]
RPM file name.
char license[512]
RPM licenses.
char pkgArch[64]
Package architecture.
char sourceRPM[256]
Package source.
int req_size
Package dependency list size.
char pkgAlias[256]
Package alias.
char url[256]
Package link.
long pFileFk
Package pfile in FOSSology.
char release[64]
Package release.
char packager[1024]
Packager.
char ** requires
Package dependency list.
char vendor[128]
Package vendor.
static int Result
Result of calls.