|
|
00273d |
From 1e0f8f66f6ff30e177c41be7d72330d5eccf2ff8 Mon Sep 17 00:00:00 2001
|
|
|
00273d |
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
|
|
|
00273d |
Date: Wed, 9 Feb 2022 13:24:06 +0100
|
|
|
00273d |
Subject: [PATCH 30/34] Update unittest to test the new private dnf solvfile
|
|
|
00273d |
API
|
|
|
00273d |
|
|
|
00273d |
---
|
|
|
00273d |
tests/hawkey/test_iutil.cpp | 34 ++++++++++++++++++++++------------
|
|
|
00273d |
1 file changed, 22 insertions(+), 12 deletions(-)
|
|
|
00273d |
|
|
|
00273d |
diff --git a/tests/hawkey/test_iutil.cpp b/tests/hawkey/test_iutil.cpp
|
|
|
00273d |
index 8d00cc94..f3c04782 100644
|
|
|
00273d |
--- a/tests/hawkey/test_iutil.cpp
|
|
|
00273d |
+++ b/tests/hawkey/test_iutil.cpp
|
|
|
00273d |
@@ -24,6 +24,8 @@
|
|
|
00273d |
|
|
|
00273d |
|
|
|
00273d |
#include <solv/pool.h>
|
|
|
00273d |
+#include <solv/repo.h>
|
|
|
00273d |
+#include <solv/repo_write.h>
|
|
|
00273d |
|
|
|
00273d |
|
|
|
00273d |
#include "libdnf/hy-util.h"
|
|
|
00273d |
@@ -97,28 +99,36 @@ START_TEST(test_checksum)
|
|
|
00273d |
}
|
|
|
00273d |
END_TEST
|
|
|
00273d |
|
|
|
00273d |
-START_TEST(test_checksum_write_read)
|
|
|
00273d |
+START_TEST(test_dnf_solvfile_userdata)
|
|
|
00273d |
{
|
|
|
00273d |
char *new_file = solv_dupjoin(test_globals.tmpdir,
|
|
|
00273d |
- "/test_checksum_write_read", NULL);
|
|
|
00273d |
+ "/test_dnf_solvfile_userdata", NULL);
|
|
|
00273d |
build_test_file(new_file);
|
|
|
00273d |
|
|
|
00273d |
unsigned char cs_computed[CHKSUM_BYTES];
|
|
|
00273d |
- unsigned char cs_read[CHKSUM_BYTES];
|
|
|
00273d |
- FILE *fp = fopen(new_file, "r");
|
|
|
00273d |
+ FILE *fp = fopen(new_file, "r+");
|
|
|
00273d |
checksum_fp(cs_computed, fp);
|
|
|
00273d |
- // fails, file opened read-only:
|
|
|
00273d |
- fail_unless(checksum_write(cs_computed, fp) == 1);
|
|
|
00273d |
- fclose(fp);
|
|
|
00273d |
- fp = fopen(new_file, "r+");
|
|
|
00273d |
- fail_if(checksum_write(cs_computed, fp));
|
|
|
00273d |
+
|
|
|
00273d |
+ SolvUserdata solv_userdata;
|
|
|
00273d |
+ fail_if(solv_userdata_fill(&solv_userdata, cs_computed, NULL));
|
|
|
00273d |
+
|
|
|
00273d |
+ Pool *pool = pool_create();
|
|
|
00273d |
+ Repo *repo = repo_create(pool, "test_repo");
|
|
|
00273d |
+ Repowriter *writer = repowriter_create(repo);
|
|
|
00273d |
+ repowriter_set_userdata(writer, &solv_userdata, solv_userdata_size);
|
|
|
00273d |
+ fail_if(repowriter_write(writer, fp));
|
|
|
00273d |
+ repowriter_free(writer);
|
|
|
00273d |
fclose(fp);
|
|
|
00273d |
+
|
|
|
00273d |
fp = fopen(new_file, "r");
|
|
|
00273d |
- fail_if(checksum_read(cs_read, fp));
|
|
|
00273d |
- fail_if(checksum_cmp(cs_computed, cs_read));
|
|
|
00273d |
+ std::unique_ptr<SolvUserdata> dnf_solvfile = solv_userdata_read(fp);
|
|
|
00273d |
+ fail_unless(dnf_solvfile);
|
|
|
00273d |
+ fail_unless(solv_userdata_verify(dnf_solvfile.get(), cs_computed));
|
|
|
00273d |
fclose(fp);
|
|
|
00273d |
|
|
|
00273d |
g_free(new_file);
|
|
|
00273d |
+ repo_free(repo, 0);
|
|
|
00273d |
+ pool_free(pool);
|
|
|
00273d |
}
|
|
|
00273d |
END_TEST
|
|
|
00273d |
|
|
|
00273d |
@@ -181,7 +191,7 @@ iutil_suite(void)
|
|
|
00273d |
TCase *tc = tcase_create("Main");
|
|
|
00273d |
tcase_add_test(tc, test_abspath);
|
|
|
00273d |
tcase_add_test(tc, test_checksum);
|
|
|
00273d |
- tcase_add_test(tc, test_checksum_write_read);
|
|
|
00273d |
+ tcase_add_test(tc, test_dnf_solvfile_userdata);
|
|
|
00273d |
tcase_add_test(tc, test_mkcachedir);
|
|
|
00273d |
tcase_add_test(tc, test_version_split);
|
|
|
00273d |
suite_add_tcase(s, tc);
|
|
|
00273d |
--
|
|
|
00273d |
2.31.1
|
|
|
00273d |
|