test: don't crash if the expected files are not there

cute-signatures
Timo Teräs 2011-07-27 15:25:29 +03:00
parent 9cd57a8fc7
commit 034c02f0de
1 changed files with 8 additions and 4 deletions

View File

@ -104,16 +104,20 @@ static int test_main(void *pctx, struct apk_database *db, int argc, char **argv)
/* load installed db */ /* load installed db */
if (ctx->installed_db != NULL) { if (ctx->installed_db != NULL) {
bs = apk_bstream_from_file(AT_FDCWD, ctx->installed_db); bs = apk_bstream_from_file(AT_FDCWD, ctx->installed_db);
apk_db_index_read(db, bs, -1); if (bs != NULL) {
bs->close(bs, NULL); apk_db_index_read(db, bs, -1);
bs->close(bs, NULL);
}
} }
/* load additional indexes */ /* load additional indexes */
if (ctx->repos) { if (ctx->repos) {
for (i = 0; i < ctx->repos->num; i++) { for (i = 0; i < ctx->repos->num; i++) {
bs = apk_bstream_from_file(AT_FDCWD, ctx->repos->item[i]); bs = apk_bstream_from_file(AT_FDCWD, ctx->repos->item[i]);
apk_db_index_read(db, bs, i); if (bs != NULL) {
bs->close(bs, NULL); apk_db_index_read(db, bs, i);
bs->close(bs, NULL);
}
} }
} }