From 62f6934cd79a1312f98110bdeeeedab3f1284926 Mon Sep 17 00:00:00 2001 From: Pavla Kratochvilova Date: Thu, 21 Oct 2021 12:48:07 +0200 Subject: [PATCH] Update to 1.14.2 Resolves: rhbz#2006668 --- .gitignore | 1 + ...lask-with-httpserver-in-python-tests.patch | 551 ---- ...nc-fail-on-read-only-filesystem-RhBu.patch | 44 - ...can-warnings-and-fail_if-deprication.patch | 268 -- ...il_if-and-fail_unless-are-deprecated.patch | 2426 ----------------- librepo.spec | 13 +- sources | 2 +- 7 files changed, 9 insertions(+), 3296 deletions(-) delete mode 100644 0001-Replace-python3-flask-with-httpserver-in-python-tests.patch delete mode 100644 0002-Recover-from-fsync-fail-on-read-only-filesystem-RhBu.patch delete mode 100644 0003-Covscan-warnings-and-fail_if-deprication.patch delete mode 100644 0004-fail_if-and-fail_unless-are-deprecated.patch diff --git a/.gitignore b/.gitignore index 2b74f7f..f06987c 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,4 @@ /librepo-1.12.1.tar.gz /librepo-1.13.0.tar.gz /librepo-1.14.0.tar.gz +/librepo-1.14.2.tar.gz diff --git a/0001-Replace-python3-flask-with-httpserver-in-python-tests.patch b/0001-Replace-python3-flask-with-httpserver-in-python-tests.patch deleted file mode 100644 index 2cae8ca..0000000 --- a/0001-Replace-python3-flask-with-httpserver-in-python-tests.patch +++ /dev/null @@ -1,551 +0,0 @@ -From 8bba792da37142028f6b6e61137ec2988b5578ee Mon Sep 17 00:00:00 2001 -From: Pavla Kratochvilova -Date: Mon, 26 Apr 2021 09:42:15 +0200 -Subject: [PATCH] Replace python3-flask with http.server in python tests - ---- - README.md | 1 - - librepo.spec | 1 - - tests/README.rst | 36 ++++++++++-------------------------- - tests/python/tests/base.py | 24 ++++-------------------- - tests/python/tests/servermock/server.py | 31 +++++++++---------------------- - tests/python/tests/servermock/yum_mock/yum_mock.py | 279 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------ - tests/python/tests/test_yum_package_downloading.py | 9 +++------ - tests/python/tests/test_yum_repo_downloading.py | 5 ++--- - 8 files changed, 175 insertions(+), 211 deletions(-) - -diff --git a/README.md b/README.md -index ad6bc23..d9fb062 100644 ---- a/README.md -+++ b/README.md -@@ -19,7 +19,6 @@ Fedora/Ubuntu name - * openssl (http://www.openssl.org/) - openssl-devel/libssl-dev - * python (http://python.org/) - python3-devel/libpython3-dev - * **Test requires:** pygpgme (https://pypi.python.org/pypi/pygpgme/0.1) - python3-pygpgme/python3-gpgme --* **Test requires:** python3-flask (http://flask.pocoo.org/) - python-flask/python-flask - * **Test requires:** python3-pyxattr (https://github.com/xattr/xattr) - python3-pyxattr/python3-pyxattr - - ### Build from your checkout dir: -diff --git a/librepo.spec b/librepo.spec -index 6db1fc2..ed90a84 100644 ---- a/librepo.spec -+++ b/librepo.spec -@@ -51,7 +51,6 @@ Summary: Python 3 bindings for the librepo library - %{?python_provide:%python_provide python3-%{name}} - BuildRequires: python3-devel - BuildRequires: python3-gpg --BuildRequires: python3-flask - BuildRequires: python3-pyxattr - BuildRequires: python3-requests - BuildRequires: python3-sphinx -diff --git a/tests/README.rst b/tests/README.rst -index ea55c87..f7e6d03 100644 ---- a/tests/README.rst -+++ b/tests/README.rst -@@ -33,15 +33,13 @@ Files of C tests - * Test suites - - --Python tests with Flask --======================= -+Python tests http.server -+======================== - --Some python tests use **Flask** python framework (http://flask.pocoo.org/) -+Some python tests use **http.server** python standard library - to simulate web server. The server is started automatically during that tests. - --*TestCases with Flask inherit from TestCaseWithApp class.* -- --The Flask is then set as the app to the test case by 'application' class attribute. -+*TestCases with http.server inherit from TestCaseWithServer class.* - - If you want to start server manually:: - -@@ -57,27 +55,13 @@ http://127.0.0.1:5000/yum/badgpg/static/01/repodata/repomd.xml.asc - - etc.. - --Modularity of tests with Flask -------------------------------- -- --Flask tests are intended to be modular. -- --Modularity is provided by use of http://flask.pocoo.org/docs/blueprints/ --Currently there is only one module (blueprint) for yum repo mocking --in servermock/yum_mock. -- --Repos for test with Flask --------------------------- -- --Currently each module (blueprint) uses its own data (repositories, --packages, ..). -+Repos for test with http.server -+------------------------------- - --E.g. for yum mocking module: servermock/yum_mock/static/ -+All data (repositories, packages, ..) are in servermock/yum_mock/static/ - --Configuration and globals for tests with Flask ------------------------------------------------ -+Configuration and globals for tests with http.server -+---------------------------------------------------- - --Each module (blueprint) has its own configuration and globals which uses --and provides to tests which use the module. -+Configuration and globals used by these tests are in servermock/yum_mock/config.py - --E.g. for yum mocking module: servermock/yum_mock/config.py -diff --git a/tests/python/tests/base.py b/tests/python/tests/base.py -index 1d01c9d..ecabbb5 100644 ---- a/tests/python/tests/base.py -+++ b/tests/python/tests/base.py -@@ -5,7 +5,7 @@ import ctypes - import os.path - import requests - from multiprocessing import Process, Value --from tests.servermock.server import app -+from tests.servermock.server import start_server - try: - import unittest2 as unittest - except ImportError: -@@ -53,39 +53,23 @@ class TestCase(unittest.TestCase): - pass - - --class TestCaseWithApp(TestCase): -- application = NotImplemented -- -- @classmethod -- def setUpClass(cls): -- cls.server = Process(target=cls.application.run) -- cls.server.start() -- time.sleep(0.5) -- -- @classmethod -- def tearDownClass(cls): -- cls.server.terminate() -- cls.server.join() -- -- - def application(port): - """Sometimes, the port is used, in that case, use different port""" - - while True: - try: - port_val = port.value -- app._librepo_port = port_val # Store used port into Flask app -- app.run(port=port_val) -- except socket.error as e: -+ start_server(port=port_val) -+ except OSError as e: - if e.errno == 98: - # Address already in use - port.value += 1 - continue - raise - break - - --class TestCaseWithFlask(TestCase): -+class TestCaseWithServer(TestCase): - _TS_PORT = Value(ctypes.c_int, 5000) - MOCKURL = None - PORT = -1 -diff --git a/tests/python/tests/servermock/server.py b/tests/python/tests/servermock/server.py -index 6d17a0a..37ddb64 100644 ---- a/tests/python/tests/servermock/server.py -+++ b/tests/python/tests/servermock/server.py -@@ -1,42 +1,29 @@ --from flask import Flask -+from http.server import BaseHTTPRequestHandler, HTTPServer - from optparse import OptionParser - try: -- from yum_mock.yum_mock import yum_mock -+ from yum_mock.yum_mock import yum_mock_handler - except (ValueError, ImportError): -- from .yum_mock.yum_mock import yum_mock -+ from .yum_mock.yum_mock import yum_mock_handler - --app = Flask(__name__) --#app.register_blueprint(working_repo) --app.register_blueprint(yum_mock, url_prefix='/yum') - -+def start_server(port, host="127.0.0.1", handler=None): -+ if handler is None: -+ handler = yum_mock_handler(port) -+ with HTTPServer((host, port), handler) as server: -+ server.serve_forever() - - if __name__ == '__main__': - parser = OptionParser("%prog [options]") - parser.add_option( -- "-d", "--debug", -- action="store_true", -- ) -- parser.add_option( - "-p", "--port", - default=5000, - type="int", - ) - parser.add_option( - "-n", "--host", - default="127.0.0.1", - ) -- parser.add_option( -- "--passthrough_errors", -- action="store_true", -- ) - options, args = parser.parse_args() - -- kwargs = { -- "threaded": True, -- "debug": options.debug, -- "port": options.port, -- "host": options.host, -- "passthrough_errors": options.passthrough_errors, -- } -+ start_server(options.port, options.host) - -- app.run(**kwargs) -diff --git a/tests/python/tests/servermock/yum_mock/yum_mock.py b/tests/python/tests/servermock/yum_mock/yum_mock.py -index 826f7c8..dd5bda6 100644 ---- a/tests/python/tests/servermock/yum_mock/yum_mock.py -+++ b/tests/python/tests/servermock/yum_mock/yum_mock.py -@@ -1,137 +1,152 @@ -+import base64 -+from http.server import BaseHTTPRequestHandler, HTTPServer - import os --from flask import Blueprint, render_template, abort, send_file, request, Response --from flask import current_app --from functools import wraps -+import sys - - from .config import AUTH_USER, AUTH_PASS - --yum_mock = Blueprint('yum_mock', __name__, -- template_folder='templates', -- static_folder='static') -- --@yum_mock.route('/static/mirrorlist/') --def serve_mirrorlists_with_right_port(path): -- try: -- with yum_mock.open_resource('static/mirrorlist/'+path) as f: -- data = f.read() -- data = data.decode('utf-8') -- data = data.replace(":{PORT_PLACEHOLDER}", ":%d" % current_app._librepo_port) -- return data -- except IOError: -- # File probably doesn't exist or we can't read it -- abort(404) -- --@yum_mock.route('/static/metalink/') --def serve_metalinks_with_right_port(path): -- try: -- with yum_mock.open_resource('static/metalink/'+path) as f: -- data = f.read() -- data = data.decode('utf-8') -- data = data.replace(":{PORT_PLACEHOLDER}", ":%d" % current_app._librepo_port) -- return data -- except IOError: -- # File probably doesn't exist or we can't read it -- abort(404) -- --@yum_mock.route('/harm_checksum//') --def harm_checksum(keyword, path): -- """Append two newlines to content of a file (from the static dir) with -- specified keyword in the filename. If the filename doesn't contain -- the keyword, content of the file is returnen unchanged.""" -- -- if "static/" not in path: -- # Support changing only files from static directory -- abort(400) -- path = path[path.find("static/"):] -- -- try: -- with yum_mock.open_resource(path) as f: -- data = f.read() -- if keyword in os.path.basename(path): -- return "%s\n\n" %data -- return data -- except IOError: -- # File probably doesn't exist or we can't read it -- abort(404) -- --@yum_mock.route("/not_found//") --def not_found(keyword, path): -- """For each file containing keyword in the filename, http status -- code 404 will be returned""" -- -- if "static/" not in path: -- abort(400) -- path = path[path.find("static/"):] -- -- try: -- with yum_mock.open_resource(path) as f: -- data = f.read() -- if keyword in os.path.basename(path): -- abort(404) -- return data -- except IOError: -- # File probably doesn't exist or we can't read it -- abort(404) -- --@yum_mock.route("/badurl/") --def badurl(path): -- """Just return 404 for each url with this prefix""" -- abort(404) -- --@yum_mock.route("/badgpg/") --def badgpg(path): -- """Instead of /repomd.xml.asc returns -- content of /repomd.xml.asc.bad""" -- if "static/" not in path: -- abort(400) -- path = path[path.find("static/"):] -- if path.endswith("repomd.xml.asc"): -- path = path + ".bad" -- -- try: -- with yum_mock.open_resource(path) as f: -- return f.read() -- except IOError: -- # File probably doesn't exist or we can't read it -- abort(404) -- --# Basic Auth -- --def check_auth(username, password): -- """This function is called to check if a username / -- password combination is valid. -- """ -- return username == AUTH_USER and password == AUTH_PASS -- --def authenticate(): -- """Sends a 401 response that enables basic auth""" -- return Response( -- 'Could not verify your access level for that URL.\n' -- 'You have to login with proper credentials', 401, -- {'WWW-Authenticate': 'Basic realm="Login Required"'}) -- --def requires_auth(f): -- @wraps(f) -- def decorated(*args, **kwargs): -- auth = request.authorization -- if not auth or not check_auth(auth.username, auth.password): -- return authenticate() -- return f(*args, **kwargs) -- return decorated -- --@yum_mock.route("/auth_basic/") --@requires_auth --def secret_repo_basic_auth(path): -- """Page secured with basic HTTP auth -- User: admin Password: secret""" -- if "static/" not in path: -- abort(400) -- path = path[path.find("static/"):] -- -- try: -- with yum_mock.open_resource(path) as f: -- data = f.read() -- return data -- except IOError: -- abort(404) -+ -+def file_path(path): -+ return(os.path.join(os.path.dirname(os.path.abspath(__file__)), path)) -+ -+ -+def yum_mock_handler(port): -+ -+ class YumMockHandler(BaseHTTPRequestHandler): -+ _port = port -+ -+ def return_bad_request(self): -+ self.send_response(400) -+ self.end_headers() -+ -+ def return_not_found(self): -+ self.send_response(404) -+ self.end_headers() -+ -+ def return_ok_with_message(self, message, content_type='text/html'): -+ if content_type == 'text/html': -+ message = bytes(message, 'utf8') -+ self.send_response(200) -+ self.send_header('Content-type', content_type) -+ self.send_header('Content-Length', str(len(message))) -+ self.end_headers() -+ self.wfile.write(message) -+ -+ def parse_path(self, test_prefix='', keyword_expected=False): -+ path = self.path[len(test_prefix):] -+ if keyword_expected: -+ keyword, path = path.split('/', 1) -+ # Strip arguments -+ if '?' in path: -+ path = path[:path.find('?')] -+ if keyword_expected: -+ return keyword, path -+ return path -+ -+ def serve_file(self, path, harm_keyword=None): -+ if "static/" not in path: -+ # Support changing only files from static directory -+ return self.return_bad_request() -+ path = path[path.find("static/"):] -+ try: -+ with open(file_path(path), 'rb') as f: -+ data = f.read() -+ if harm_keyword is not None and harm_keyword in os.path.basename(file_path(path)): -+ data += b"\n\n" -+ return self.return_ok_with_message(data, 'application/octet-stream') -+ except IOError: -+ # File probably doesn't exist or we can't read it -+ return self.return_not_found() -+ -+ def authenticate(self): -+ """Sends a 401 response that enables basic auth""" -+ self.send_response(401) -+ self.send_header('Content-type', 'text/html') -+ self.send_header('WWW-Authenticate', 'Basic realm="Login Required') -+ self.end_headers() -+ message = ( -+ 'Could not verify your access level for that URL.\n' -+ 'You have to login with proper credentials' -+ ) -+ self.wfile.write(bytes(message, "utf8")) -+ -+ def check_auth(self): -+ if self.headers.get('Authorization') is None: -+ return False -+ expected_authorization = 'Basic {}'.format( -+ base64.b64encode('{}:{}'.format(AUTH_USER, AUTH_PASS).encode()).decode() -+ ) -+ if self.headers.get('Authorization') != expected_authorization: -+ return False -+ return True -+ -+ def serve_mirrorlist_or_metalink_with_right_port(self): -+ path = self.parse_path() -+ if "static/" not in path: -+ return self.return_bad_request() -+ path = path[path.find("static/"):] -+ try: -+ with open(file_path(path), 'r') as f: -+ data = f.read() -+ data = data.replace(":{PORT_PLACEHOLDER}", ":%d" % self._port) -+ return self.return_ok_with_message(data) -+ except IOError: -+ # File probably doesn't exist or we can't read it -+ return self.return_not_found() -+ -+ def serve_harm_checksum(self): -+ """Append two newlines to content of a file (from the static dir) with -+ specified keyword in the filename. If the filename doesn't contain -+ the keyword, content of the file is returnen unchanged.""" -+ keyword, path = self.parse_path('/yum/harm_checksum/', keyword_expected=True) -+ self.serve_file(path, harm_keyword=keyword) -+ -+ def serve_not_found(self): -+ """For each file containing keyword in the filename, http status -+ code 404 will be returned""" -+ keyword, path = self.parse_path('/yum/not_found/', keyword_expected=True) -+ if keyword in os.path.basename(file_path(path)): -+ return self.return_not_found() -+ self.serve_file(path) -+ -+ def serve_badurl(self): -+ """Just return 404 for each url with this prefix""" -+ return self.return_not_found() -+ -+ def serve_badgpg(self): -+ """Instead of /repomd.xml.asc returns content of /repomd.xml.asc.bad""" -+ path = self.parse_path('/yum/badgpg/') -+ if path.endswith("repomd.xml.asc"): -+ path += ".bad" -+ self.serve_file(path) -+ -+ def serve_auth_basic(self): -+ """Page secured with basic HTTP auth; User: admin Password: secret""" -+ if not self.check_auth(): -+ return self.authenticate() -+ path = self.parse_path('/yum/auth_basic/') -+ self.serve_file(path) -+ -+ def serve_static(self): -+ path = self.parse_path() -+ self.serve_file(path) -+ -+ def do_GET(self): -+ if self.path.startswith('/yum/static/mirrorlist/'): -+ return self.serve_mirrorlist_or_metalink_with_right_port() -+ if self.path.startswith('/yum/static/metalink/'): -+ return self.serve_mirrorlist_or_metalink_with_right_port() -+ if self.path.startswith('/yum/harm_checksum/'): -+ return self.serve_harm_checksum() -+ if self.path.startswith('/yum/not_found/'): -+ return self.serve_not_found() -+ if self.path.startswith('/badurl/'): -+ return self.serve_badurl() -+ if self.path.startswith('/yum/badgpg/'): -+ return self.serve_badgpg() -+ if self.path.startswith('/yum/auth_basic/'): -+ return self.serve_auth_basic() -+ return self.serve_static() -+ -+ return YumMockHandler - -diff --git a/tests/python/tests/test_yum_package_downloading.py b/tests/python/tests/test_yum_package_downloading.py -index 577a8ce..0364be0 100644 ---- a/tests/python/tests/test_yum_package_downloading.py -+++ b/tests/python/tests/test_yum_package_downloading.py -@@ -9,11 +9,10 @@ import xattr - - import tests.servermock.yum_mock.config as config - --from tests.base import TestCaseWithFlask --from tests.servermock.server import app -+from tests.base import TestCaseWithServer - - --class TestCaseYumPackageDownloading(TestCaseWithFlask): -+class TestCaseYumPackageDownloading(TestCaseWithServer): - - def setUp(self): - self.tmpdir = tempfile.mkdtemp(prefix="librepotest-", dir="./") -@@ -163,9 +162,7 @@ class TestCaseYumPackageDownloading(TestCaseWithFlask): - pkg = os.path.join(self.tmpdir, config.PACKAGE_01_01) - self.assertTrue(os.path.isfile(pkg)) - --class TestCaseYumPackagesDownloading(TestCaseWithFlask): -- application = app -- -+class TestCaseYumPackagesDownloading(TestCaseWithServer): - # @classmethod - # def setUpClass(cls): - # super(TestCaseYumPackageDownloading, cls).setUpClass() -diff --git a/tests/python/tests/test_yum_repo_downloading.py b/tests/python/tests/test_yum_repo_downloading.py -index 76b067c..4d56d1c 100644 ---- a/tests/python/tests/test_yum_repo_downloading.py -+++ b/tests/python/tests/test_yum_repo_downloading.py -@@ -7,13 +7,12 @@ import unittest - - import librepo - --from tests.base import Context, TestCaseWithFlask, TEST_DATA --from tests.servermock.server import app -+from tests.base import Context, TestCaseWithServer, TEST_DATA - import tests.servermock.yum_mock.config as config - - PUB_KEY = TEST_DATA+"/key.pub" - --class TestCaseYumRepoDownloading(TestCaseWithFlask): -+class TestCaseYumRepoDownloading(TestCaseWithServer): - - def setUp(self): - self.tmpdir = tempfile.mkdtemp(prefix="librepotest-") --- -libgit2 1.0.1 - diff --git a/0002-Recover-from-fsync-fail-on-read-only-filesystem-RhBu.patch b/0002-Recover-from-fsync-fail-on-read-only-filesystem-RhBu.patch deleted file mode 100644 index 637f081..0000000 --- a/0002-Recover-from-fsync-fail-on-read-only-filesystem-RhBu.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 33be80700bc594f34818ce697493c17e70430390 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= -Date: Mon, 17 May 2021 08:50:25 +0200 -Subject: [PATCH] Recover from fsync fail on read-only filesystem - (RhBug:1956361) - -When `fsync` fails due to the file not supporting synchronization just log -the problem instead of failing the whole dnf run. This happens for -example with filesystems mounted read-only in which case there is no -point to `fsync` anyway. - -Currently we also ignore return values from `FSETXATTR` which also fails -on read-only filesystem (so no checksum cache is set). This is fine however -since the checksum is recomputed when needed, dnf is just a bit slower. - -https://bugzilla.redhat.com/show_bug.cgi?id=1956361 ---- - librepo/checksum.c | 10 +++++++--- - 1 file changed, 7 insertions(+), 3 deletions(-) - -diff --git a/librepo/checksum.c b/librepo/checksum.c -index db37040..6bba53c 100644 ---- a/librepo/checksum.c -+++ b/librepo/checksum.c -@@ -266,9 +266,13 @@ lr_checksum_fd_compare(LrChecksumType type, - *matches = (strcmp(expected, checksum)) ? FALSE : TRUE; - - if (fsync(fd) != 0) { -- g_set_error(err, LR_CHECKSUM_ERROR, LRE_FILE, -- "fsync failed: %s", strerror(errno)); -- return FALSE; -+ if (errno == EROFS || errno == EINVAL) { -+ g_debug("fsync failed: %s", strerror(errno)); -+ } else { -+ g_set_error(err, LR_CHECKSUM_ERROR, LRE_FILE, -+ "fsync failed: %s", strerror(errno)); -+ return FALSE; -+ } - } - - if (caching && *matches && timestamp != -1) { --- -2.31.1 - diff --git a/0003-Covscan-warnings-and-fail_if-deprication.patch b/0003-Covscan-warnings-and-fail_if-deprication.patch deleted file mode 100644 index 8d04ef8..0000000 --- a/0003-Covscan-warnings-and-fail_if-deprication.patch +++ /dev/null @@ -1,268 +0,0 @@ -From fd9d39cf19084dd4244943a3b27ee0a33805f76d Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= -Date: Mon, 21 Jun 2021 15:04:51 +0200 -Subject: [PATCH 1/2] Fix important covscan warnings - -- covscan thinks we are leaking storage from `g_strndup` so be more -explicit that `g_strstrip` is in place. ---- - librepo/downloader.c | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/librepo/downloader.c b/librepo/downloader.c -index c5278fbc..f4e8ba2a 100644 ---- a/librepo/downloader.c -+++ b/librepo/downloader.c -@@ -494,7 +494,10 @@ lr_headercb(void *ptr, size_t size, size_t nmemb, void *userdata) - return lr_zckheadercb(ptr, size, nmemb, userdata); - #endif /* WITH_ZCHUNK */ - -- char *header = g_strstrip(g_strndup(ptr, size*nmemb)); -+ char *header = g_strndup(ptr, size*nmemb); -+ // strips in place -+ g_strstrip(header); -+ - gint64 expected = lrtarget->target->expectedsize; - - if (state == LR_HCS_DEFAULT) { - -From 5a9e9e99c64e2dc1d181fa14cf348c7f51611a7a Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= -Date: Mon, 21 Jun 2021 15:05:13 +0200 -Subject: [PATCH 2/2] Fix covscan warnings - -- remove unused code -- missing return value checks -- use mkstemp just like other tests ---- - librepo/handle.c | 12 +++++++++--- - tests/test_downloader.c | 40 ++++++++++++++++++++-------------------- - tests/test_repoconf.c | 22 +++------------------- - 3 files changed, 32 insertions(+), 42 deletions(-) - -diff --git a/librepo/handle.c b/librepo/handle.c -index 8ac7234c..2c23ed09 100644 ---- a/librepo/handle.c -+++ b/librepo/handle.c -@@ -628,7 +628,7 @@ lr_handle_setopt(LrHandle *handle, - "Value of LRO_LOWSPEEDTIME is too low."); - ret = FALSE; - } else { -- curl_easy_setopt(c_h, CURLOPT_LOW_SPEED_TIME, val_long); -+ c_rc = curl_easy_setopt(c_h, CURLOPT_LOW_SPEED_TIME, val_long); - handle->lowspeedtime = val_long; - } - -@@ -648,7 +648,7 @@ lr_handle_setopt(LrHandle *handle, - val_long, handle->maxspeed); - ret = FALSE; - } else { -- curl_easy_setopt(c_h, CURLOPT_LOW_SPEED_LIMIT, val_long); -+ c_rc = curl_easy_setopt(c_h, CURLOPT_LOW_SPEED_LIMIT, val_long); - handle->lowspeedlimit = val_long; - } - -@@ -885,7 +885,13 @@ lr_yum_download_url_retry(int attempts, LrHandle *lr_handle, const char *url, - - g_debug("%s: Attempt #%d to download %s failed: %s", - __func__, i, url, (*err)->message); -- ftruncate(fd, 0); -+ -+ if (ftruncate(fd, 0) < 0) { -+ g_set_error(err, LR_DOWNLOADER_ERROR, LRE_IO, -+ "ftruncate() failed: %s", g_strerror(errno)); -+ return FALSE; -+ } -+ - g_clear_error (err); - } - } -diff --git a/tests/test_downloader.c b/tests/test_downloader.c -index 3a1c60f4..e6155105 100644 ---- a/tests/test_downloader.c -+++ b/tests/test_downloader.c -@@ -46,7 +46,7 @@ START_TEST(test_downloader_single_file) - fail_if(handle == NULL); - - char *urls[] = {"http://www.google.com", NULL}; -- lr_handle_setopt(handle, NULL, LRO_URLS, urls); -+ fail_if(!lr_handle_setopt(handle, NULL, LRO_URLS, urls)); - lr_handle_prepare_internal_mirrorlist(handle, FALSE, &tmp_err); - fail_if(tmp_err); - -@@ -55,8 +55,7 @@ START_TEST(test_downloader_single_file) - - tmpfn1 = lr_pathconcat(test_globals.tmpdir, "single_file_XXXXXX", NULL); - -- mktemp(tmpfn1); -- fd1 = open(tmpfn1, O_RDWR|O_CREAT|O_TRUNC, 0666); -+ fd1 = mkstemp(tmpfn1); - lr_free(tmpfn1); - fail_if(fd1 < 0); - -@@ -86,6 +85,7 @@ START_TEST(test_downloader_single_file) - } - - g_slist_free_full(list, (GDestroyNotify) lr_downloadtarget_free); -+ close(fd1); - } - END_TEST - -@@ -102,8 +102,7 @@ START_TEST(test_downloader_single_file_2) - - tmpfn1 = lr_pathconcat(test_globals.tmpdir, "single_file_2_XXXXXX", NULL); - -- mktemp(tmpfn1); -- fd1 = open(tmpfn1, O_RDWR|O_CREAT|O_TRUNC, 0666); -+ fd1 = mkstemp(tmpfn1); - lr_free(tmpfn1); - fail_if(fd1 < 0); - -@@ -131,6 +130,7 @@ START_TEST(test_downloader_single_file_2) - } - - g_slist_free_full(list, (GDestroyNotify) lr_downloadtarget_free); -+ close(fd1); - } - END_TEST - -@@ -151,7 +151,7 @@ START_TEST(test_downloader_two_files) - fail_if(handle == NULL); - - char *urls[] = {"http://www.google.com", NULL}; -- lr_handle_setopt(handle, NULL, LRO_URLS, urls); -+ fail_if(!lr_handle_setopt(handle, NULL, LRO_URLS, urls)); - lr_handle_prepare_internal_mirrorlist(handle, FALSE, &tmp_err); - fail_if(tmp_err); - -@@ -160,10 +160,8 @@ START_TEST(test_downloader_two_files) - tmpfn1 = lr_pathconcat(test_globals.tmpdir, "single_file_1_XXXXXX", NULL); - tmpfn2 = lr_pathconcat(test_globals.tmpdir, "single_file_2_XXXXXX", NULL); - -- mktemp(tmpfn1); -- mktemp(tmpfn2); -- fd1 = open(tmpfn1, O_RDWR|O_CREAT|O_TRUNC, 0666); -- fd2 = open(tmpfn2, O_RDWR|O_CREAT|O_TRUNC, 0666); -+ fd1 = mkstemp(tmpfn1); -+ fd2 = mkstemp(tmpfn2); - lr_free(tmpfn1); - lr_free(tmpfn2); - fail_if(fd1 < 0); -@@ -200,6 +198,8 @@ START_TEST(test_downloader_two_files) - } - - g_slist_free_full(list, (GDestroyNotify) lr_downloadtarget_free); -+ close(fd1); -+ close(fd2); - } - END_TEST - -@@ -220,7 +220,7 @@ START_TEST(test_downloader_three_files_with_error) - fail_if(handle == NULL); - - char *urls[] = {"http://www.google.com", NULL}; -- lr_handle_setopt(handle, NULL, LRO_URLS, urls); -+ fail_if(!lr_handle_setopt(handle, NULL, LRO_URLS, urls)); - lr_handle_prepare_internal_mirrorlist(handle, FALSE, &tmp_err); - fail_if(tmp_err); - -@@ -230,12 +230,9 @@ START_TEST(test_downloader_three_files_with_error) - tmpfn2 = lr_pathconcat(test_globals.tmpdir, "single_file_2_XXXXXX", NULL); - tmpfn3 = lr_pathconcat(test_globals.tmpdir, "single_file_3_XXXXXX", NULL); - -- mktemp(tmpfn1); -- mktemp(tmpfn2); -- mktemp(tmpfn3); -- fd1 = open(tmpfn1, O_RDWR|O_CREAT|O_TRUNC, 0666); -- fd2 = open(tmpfn2, O_RDWR|O_CREAT|O_TRUNC, 0666); -- fd3 = open(tmpfn3, O_RDWR|O_CREAT|O_TRUNC, 0666); -+ fd1 = mkstemp(tmpfn1); -+ fd2 = mkstemp(tmpfn2); -+ fd3 = mkstemp(tmpfn3); - lr_free(tmpfn1); - lr_free(tmpfn2); - lr_free(tmpfn3); -@@ -290,6 +287,9 @@ START_TEST(test_downloader_three_files_with_error) - } - - g_slist_free_full(list, (GDestroyNotify) lr_downloadtarget_free); -+ close(fd1); -+ close(fd2); -+ close(fd3); - } - END_TEST - -@@ -331,7 +331,7 @@ START_TEST(test_downloader_checksum) - fail_if(handle == NULL); - - char *urls[] = {"file:///", NULL}; -- lr_handle_setopt(handle, NULL, LRO_URLS, urls); -+ fail_if(!lr_handle_setopt(handle, NULL, LRO_URLS, urls)); - lr_handle_prepare_internal_mirrorlist(handle, FALSE, &tmp_err); - fail_if(tmp_err); - -@@ -340,8 +340,7 @@ START_TEST(test_downloader_checksum) - - tmpfn1 = lr_pathconcat(test_globals.tmpdir, "single_file_XXXXXX", NULL); - -- mktemp(tmpfn1); -- fd1 = open(tmpfn1, O_RDWR|O_CREAT|O_TRUNC, 0666); -+ fd1 = mkstemp(tmpfn1); - lr_free(tmpfn1); - fail_if(fd1 < 0); - -@@ -382,6 +381,7 @@ START_TEST(test_downloader_checksum) - } - - g_slist_free_full(list, (GDestroyNotify) lr_downloadtarget_free); -+ close(fd1); - } - } - END_TEST -diff --git a/tests/test_repoconf.c b/tests/test_repoconf.c -index 8a56b666..5c85047e 100644 ---- a/tests/test_repoconf.c -+++ b/tests/test_repoconf.c -@@ -33,22 +33,6 @@ repoconf_assert_true(LrYumRepoConf *repoconf, - #define conf_assert_true(option) \ - repoconf_assert_true(conf, (option)) - --static void --repoconf_assert_false(LrYumRepoConf *repoconf, -- LrYumRepoConfOption option) --{ -- ck_assert(1); -- long val = 1L; -- _cleanup_error_free_ GError *tmp_err = NULL; -- gboolean ret = lr_yum_repoconf_getinfo(repoconf, &tmp_err, option, &val); -- ck_assert(!tmp_err); -- ck_assert(ret); -- ck_assert_msg(!val, "Not a 0 (False) value (Option %d)", option); --} -- --#define conf_assert_false(option) \ -- repoconf_assert_false(conf, (option)) -- - static void - repoconf_assert_na(LrYumRepoConf *repoconf, - LrYumRepoConfOption option) -@@ -509,7 +493,7 @@ END_TEST - - START_TEST(test_write_repoconf) - { -- _cleanup_fd_close_ int rc = -1; -+ _cleanup_fd_close_ int fd = -1; - gboolean ret; - LrYumRepoConfs *confs; - LrYumRepoConf * conf; -@@ -519,8 +503,8 @@ START_TEST(test_write_repoconf) - _cleanup_error_free_ GError *tmp_err = NULL; - - // Create a temporary file -- rc = mkstemp(tmpfn); -- fail_if(rc == -1); -+ fd = mkstemp(tmpfn); -+ fail_if(fd == -1); - - // Create reconfs with one repoconf with one id (one section) - confs = lr_yum_repoconfs_init(); diff --git a/0004-fail_if-and-fail_unless-are-deprecated.patch b/0004-fail_if-and-fail_unless-are-deprecated.patch deleted file mode 100644 index c3ca3fc..0000000 --- a/0004-fail_if-and-fail_unless-are-deprecated.patch +++ /dev/null @@ -1,2426 +0,0 @@ -From 3738ee93ebcc3552774b6361fccea2b8ab80e101 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= -Date: Tue, 22 Jun 2021 10:32:29 +0200 -Subject: [PATCH] `fail_if` and `fail_unless` are deprecated - -https://libcheck.github.io/check/doc/check_html/check_4.html#Convenience-Test-Functions - -It also fixes a couple of covscan warnings of the following type: -``` -Error: COMPILER_WARNING (CWE-685): -librepo-1.12.1/tests/fixtures.h:5: included_from: Included from here. -librepo-1.12.1/tests/test_checksum.c:15: included_from: Included from here. -librepo-1.12.1/tests/test_checksum.c: scope_hint: In function 'test_checksum' -librepo-1.12.1/tests/test_checksum.c:58:9: warning[-Wformat-extra-args]: too many arguments for format -\# 58 | "Checksum is %s instead of %s", checksum, expected); -\# | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -\# 56| fail_if(tmp_err); -\# 57| fail_if(strcmp(checksum, expected), -\# 58|-> "Checksum is %s instead of %s", checksum, expected); -\# 59| lr_free(checksum); -\# 60| close(fd); -``` ---- - tests/test_checksum.c | 88 +++---- - tests/test_downloader.c | 93 +++---- - tests/test_gpg.c | 32 +-- - tests/test_handle.c | 140 +++++----- - tests/test_lrmirrorlist.c | 114 ++++----- - tests/test_metalink.c | 438 ++++++++++++++++---------------- - tests/test_mirrorlist.c | 40 +-- - tests/test_package_downloader.c | 48 ++-- - tests/test_repo_zck.c | 20 +- - tests/test_repoconf.c | 24 +- - tests/test_repomd.c | 38 +-- - tests/test_url_substitution.c | 50 ++-- - tests/test_util.c | 146 +++++------ - tests/test_version.c | 24 +- - 14 files changed, 640 insertions(+), 655 deletions(-) - -diff --git a/tests/test_checksum.c b/tests/test_checksum.c -index d0aba365..cd28cd17 100644 ---- a/tests/test_checksum.c -+++ b/tests/test_checksum.c -@@ -38,8 +38,8 @@ build_test_file(const char *filename, const char *content) - { - FILE *fp = fopen(filename, "w"); - size_t len = strlen(content); -- fail_if(fp == NULL); -- fail_unless(fwrite(content, 1, len, fp) == len); -+ ck_assert_ptr_nonnull(fp); -+ ck_assert(fwrite(content, 1, len, fp) == len); - fclose(fp); - } - -@@ -51,11 +51,11 @@ test_checksum(const char *filename, LrChecksumType ch_type, char *expected) - GError *tmp_err = NULL; - - fd = open(filename, O_RDONLY); -- fail_if(fd < 0); -+ ck_assert_int_ge(fd, 0); - checksum = lr_checksum_fd(ch_type, fd, &tmp_err); -- fail_if(checksum == NULL); -- fail_if(tmp_err); -- fail_if(strcmp(checksum, expected), -+ ck_assert_ptr_nonnull(checksum); -+ ck_assert_ptr_null(tmp_err); -+ ck_assert_msg(!strcmp(checksum, expected), - "Checksum is %s instead of %s", checksum, expected); - lr_free(checksum); - close(fd); -@@ -85,7 +85,7 @@ START_TEST(test_checksum_fd) - test_checksum(file, LR_CHECKSUM_SHA384, CHKS_VAL_01_SHA384); - test_checksum(file, LR_CHECKSUM_SHA512, CHKS_VAL_01_SHA512); - -- fail_if(remove(file) != 0, "Cannot delete temporary test file"); -+ ck_assert_msg(remove(file) == 0, "Cannot delete temporary test file"); - lr_free(file); - } - END_TEST -@@ -107,28 +107,28 @@ START_TEST(test_cached_checksum_matches) - - filename = lr_pathconcat(test_globals.tmpdir, "/test_checksum_matches", NULL); - f = fopen(filename, "w"); -- fail_if(f == NULL); -+ ck_assert_ptr_nonnull(f); - fwrite("foo\nbar\n", 1, 8, f); - fclose(f); - - // Assert no cached checksum exists - attr_ret = GETXATTR(filename, timestamp_key, &buf, sizeof(buf)-1); -- fail_if(attr_ret != -1); // Cached timestamp should not exists -+ ck_assert(attr_ret == -1); // Cached timestamp should not exists - attr_ret = GETXATTR(filename, checksum_key, &buf, sizeof(buf)-1); -- fail_if(attr_ret != -1); // Cached checksum should not exists -+ ck_assert(attr_ret == -1); // Cached checksum should not exists - - // Calculate checksum - fd = open(filename, O_RDONLY); -- fail_if(fd < 0); -+ ck_assert_int_ge(fd, 0); - checksum_ret = lr_checksum_fd_cmp(LR_CHECKSUM_SHA256, - fd, - expected, - 1, - &matches, - &tmp_err); -- fail_if(tmp_err); -- fail_if(!checksum_ret); -- fail_if(!matches); -+ ck_assert_ptr_null(tmp_err); -+ ck_assert(checksum_ret); -+ ck_assert(matches); - close(fd); - - // Assert cached checksum exists -@@ -141,33 +141,33 @@ START_TEST(test_cached_checksum_matches) - goto exit_label; - } - // Any other errno means fail -- fail_if(attr_ret == -1); -+ ck_assert(attr_ret != -1); - } else { - buf[attr_ret] = 0; -- fail_if(strcmp(buf, expected)); -+ ck_assert_str_eq(buf, expected); - } - - // stored timestamp matches the file mtime - ret = stat(filename, &st); -- fail_if(ret != 0); -+ ck_assert_int_eq(ret, 0); - mtime_str = g_strdup_printf("%lli", (long long) st.st_mtime); - attr_ret = GETXATTR(filename, timestamp_key, &buf, sizeof(buf)-1); -- fail_if(attr_ret == -1); -+ ck_assert(attr_ret != -1); - buf[attr_ret] = 0; -- fail_if(strcmp(buf, mtime_str)); -+ ck_assert_str_eq(buf, mtime_str); - - // Calculate checksum again (cached shoud be used this time) - fd = open(filename, O_RDONLY); -- fail_if(fd < 0); -+ ck_assert_int_ge(fd, 0); - checksum_ret = lr_checksum_fd_cmp(LR_CHECKSUM_SHA256, - fd, - expected, - 1, - &matches, - &tmp_err); -- fail_if(tmp_err); -- fail_if(!checksum_ret); -- fail_if(!matches); -+ ck_assert_ptr_null(tmp_err); -+ ck_assert(checksum_ret); -+ ck_assert(matches); - close(fd); - - exit_label: -@@ -195,19 +195,19 @@ START_TEST(test_cached_checksum_value) - - filename = lr_pathconcat(test_globals.tmpdir, "/test_checksum_value", NULL); - f = fopen(filename, "w"); -- fail_if(f == NULL); -+ ck_assert_ptr_nonnull(f); - fwrite("foo\nbar\n", 1, 8, f); - fclose(f); - - // Assert no cached checksum exists - attr_ret = GETXATTR(filename, timestamp_key, &buf, sizeof(buf)-1); -- fail_if(attr_ret != -1); // Cached timestamp should not exists -+ ck_assert(attr_ret == -1); // Cached timestamp should not exists - attr_ret = GETXATTR(filename, checksum_key, &buf, sizeof(buf)-1); -- fail_if(attr_ret != -1); // Cached checksum should not exists -+ ck_assert(attr_ret == -1); // Cached checksum should not exists - - // Calculate checksum - fd = open(filename, O_RDONLY); -- fail_if(fd < 0); -+ ck_assert_int_ge(fd, 0); - checksum_ret = lr_checksum_fd_compare(LR_CHECKSUM_SHA256, - fd, - "", -@@ -215,20 +215,20 @@ START_TEST(test_cached_checksum_value) - &matches, - &calculated, - &tmp_err); -- fail_if(tmp_err); -- fail_if(!checksum_ret); -+ ck_assert_ptr_null(tmp_err); -+ ck_assert(checksum_ret); - // We pass in an empty string for expected, so we must not match. -- fail_if(matches); -+ ck_assert(!matches); - close(fd); -- fail_if(strcmp(calculated, expected)); -+ ck_assert_str_eq(calculated, expected); - - // Assert no cached checksum exists - // This assumes issue #235 is unresolved. Once it is, this code - // should fail and the test will need updated. - attr_ret = GETXATTR(filename, timestamp_key, &buf, sizeof(buf)-1); -- fail_if(attr_ret != -1); // Cached timestamp should not exists -+ ck_assert(attr_ret == -1); // Cached timestamp should not exists - attr_ret = GETXATTR(filename, checksum_key, &buf, sizeof(buf)-1); -- fail_if(attr_ret != -1); // Cached checksum should not exists -+ ck_assert(attr_ret == -1); // Cached checksum should not exists - - lr_free(calculated); - lr_free(filename); -@@ -252,42 +252,42 @@ START_TEST(test_cached_checksum_clear) - - filename = lr_pathconcat(test_globals.tmpdir, "/test_checksum_clear", NULL); - f = fopen(filename, "w"); -- fail_if(f == NULL); -+ ck_assert_ptr_nonnull(f); - fclose(f); - - // set extended attributes - fd = open(filename, O_RDONLY); -- fail_if(fd < 0); -+ ck_assert_int_ge(fd, 0); - attr_ret = FSETXATTR(fd, timestamp_key, value, strlen(value), 0); - if (attr_ret == -1) { - if (errno == ENOTSUP) { - goto cleanup; - } -- fail_if(attr_ret == -1); -+ ck_assert(attr_ret != -1); - } - attr_ret = FSETXATTR(fd, checksum_key, value, strlen(value), 0); -- fail_if(attr_ret == -1); -+ ck_assert(attr_ret != -1); - attr_ret = FSETXATTR(fd, other_key, value, strlen(value), 0); -- fail_if(attr_ret == -1); -+ ck_assert(attr_ret != -1); - - // verify that xattrs are set - attr_ret = GETXATTR(filename, timestamp_key, &buf, sizeof(buf)); -- fail_if(attr_ret == -1); -+ ck_assert(attr_ret != -1); - attr_ret = GETXATTR(filename, checksum_key, &buf, sizeof(buf)); -- fail_if(attr_ret == -1); -+ ck_assert(attr_ret != -1); - attr_ret = GETXATTR(filename, other_key, &buf, sizeof(buf)); -- fail_if(attr_ret == -1); -+ ck_assert(attr_ret != -1); - - lr_checksum_clear_cache(fd); - - // verify that checksum xattrs are removed - attr_ret = GETXATTR(filename, timestamp_key, &buf, sizeof(buf)); -- fail_if(attr_ret != -1); -+ ck_assert(attr_ret == -1); - attr_ret = GETXATTR(filename, checksum_key, &buf, sizeof(buf)); -- fail_if(attr_ret != -1); -+ ck_assert(attr_ret == -1); - // other then checksum related attributes are not removed - attr_ret = GETXATTR(filename, other_key, &buf, sizeof(buf)); -- fail_if(attr_ret == -1); -+ ck_assert(attr_ret != -1); - cleanup: - close(fd); - lr_free(filename); -diff --git a/tests/test_downloader.c b/tests/test_downloader.c -index e6155105..34958ab1 100644 ---- a/tests/test_downloader.c -+++ b/tests/test_downloader.c -@@ -20,18 +20,14 @@ - - START_TEST(test_downloader_no_list) - { -- int ret; - GError *err = NULL; -- -- ret = lr_download(NULL, FALSE, &err); -- fail_if(!ret); -- fail_if(err); -+ ck_assert(lr_download(NULL, FALSE, &err)); -+ ck_assert_ptr_null(err); - } - END_TEST - - START_TEST(test_downloader_single_file) - { -- int ret; - LrHandle *handle; - GSList *list = NULL; - GError *err = NULL; -@@ -43,12 +39,12 @@ START_TEST(test_downloader_single_file) - // Prepare handle - - handle = lr_handle_init(); -- fail_if(handle == NULL); -+ ck_assert_ptr_nonnull(handle); - - char *urls[] = {"http://www.google.com", NULL}; -- fail_if(!lr_handle_setopt(handle, NULL, LRO_URLS, urls)); -+ ck_assert(lr_handle_setopt(handle, NULL, LRO_URLS, urls)); - lr_handle_prepare_internal_mirrorlist(handle, FALSE, &tmp_err); -- fail_if(tmp_err); -+ ck_assert_ptr_null(tmp_err); - - - // Prepare list of download targets -@@ -57,20 +53,19 @@ START_TEST(test_downloader_single_file) - - fd1 = mkstemp(tmpfn1); - lr_free(tmpfn1); -- fail_if(fd1 < 0); -+ ck_assert_int_ge(fd1, 0); - - t1 = lr_downloadtarget_new(handle, "index.html", NULL, fd1, NULL, NULL, - 0, 0, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, - FALSE, FALSE); -- fail_if(!t1); -+ ck_assert_ptr_nonnull(t1); - - list = g_slist_append(list, t1); - - // Download - -- ret = lr_download(list, FALSE, &err); -- fail_if(!ret); -- fail_if(err); -+ ck_assert(lr_download(list, FALSE, &err)); -+ ck_assert_ptr_null(err); - - lr_handle_free(handle); - -@@ -91,7 +86,6 @@ END_TEST - - START_TEST(test_downloader_single_file_2) - { -- int ret; - GSList *list = NULL; - GError *err = NULL; - int fd1; -@@ -104,20 +98,19 @@ START_TEST(test_downloader_single_file_2) - - fd1 = mkstemp(tmpfn1); - lr_free(tmpfn1); -- fail_if(fd1 < 0); -+ ck_assert_int_ge(fd1, 0); - - t1 = lr_downloadtarget_new(NULL, "http://seznam.cz/index.html", NULL, - fd1, NULL, NULL, 0, 0, NULL, NULL, NULL, - NULL, NULL, 0, 0, NULL, FALSE, FALSE); -- fail_if(!t1); -+ ck_assert_ptr_nonnull(t1); - - list = g_slist_append(list, t1); - - // Download - -- ret = lr_download(list, FALSE, &err); -- fail_if(!ret); -- fail_if(err); -+ ck_assert(lr_download(list, FALSE, &err)); -+ ck_assert_ptr_null(err); - - // Check results - -@@ -136,7 +129,6 @@ END_TEST - - START_TEST(test_downloader_two_files) - { -- int ret; - LrHandle *handle; - GSList *list = NULL; - GError *err = NULL; -@@ -148,12 +140,12 @@ START_TEST(test_downloader_two_files) - // Prepare handle - - handle = lr_handle_init(); -- fail_if(handle == NULL); -+ ck_assert_ptr_nonnull(handle); - - char *urls[] = {"http://www.google.com", NULL}; -- fail_if(!lr_handle_setopt(handle, NULL, LRO_URLS, urls)); -+ ck_assert(lr_handle_setopt(handle, NULL, LRO_URLS, urls)); - lr_handle_prepare_internal_mirrorlist(handle, FALSE, &tmp_err); -- fail_if(tmp_err); -+ ck_assert_ptr_null(tmp_err); - - // Prepare list of download targets - -@@ -164,26 +156,25 @@ START_TEST(test_downloader_two_files) - fd2 = mkstemp(tmpfn2); - lr_free(tmpfn1); - lr_free(tmpfn2); -- fail_if(fd1 < 0); -- fail_if(fd2 < 0); -+ ck_assert_int_ge(fd1, 0); -+ ck_assert_int_ge(fd2, 0); - - t1 = lr_downloadtarget_new(handle, "index.html", NULL, fd1, NULL, - NULL, 0, 0, NULL, NULL, NULL, - NULL, NULL, 0, 0, NULL, FALSE, FALSE); -- fail_if(!t1); -+ ck_assert_ptr_nonnull(t1); - t2 = lr_downloadtarget_new(handle, "index.html", "http://seznam.cz", fd2, - NULL, NULL, 0, 0, NULL, NULL, NULL, - NULL, NULL, 0, 0, NULL, FALSE, FALSE); -- fail_if(!t2); -+ ck_assert_ptr_nonnull(t2); - - list = g_slist_append(list, t1); - list = g_slist_append(list, t2); - - // Download - -- ret = lr_download(list, FALSE, &err); -- fail_if(!ret); -- fail_if(err); -+ ck_assert(lr_download(list, FALSE, &err)); -+ ck_assert_ptr_null(err); - - lr_handle_free(handle); - -@@ -205,7 +196,6 @@ END_TEST - - START_TEST(test_downloader_three_files_with_error) - { -- int ret; - LrHandle *handle; - GSList *list = NULL; - GError *err = NULL; -@@ -217,12 +207,12 @@ START_TEST(test_downloader_three_files_with_error) - // Prepare handle - - handle = lr_handle_init(); -- fail_if(handle == NULL); -+ ck_assert_ptr_nonnull(handle); - - char *urls[] = {"http://www.google.com", NULL}; -- fail_if(!lr_handle_setopt(handle, NULL, LRO_URLS, urls)); -+ ck_assert(lr_handle_setopt(handle, NULL, LRO_URLS, urls)); - lr_handle_prepare_internal_mirrorlist(handle, FALSE, &tmp_err); -- fail_if(tmp_err); -+ ck_assert_ptr_null(tmp_err); - - // Prepare list of download targets - -@@ -236,25 +226,25 @@ START_TEST(test_downloader_three_files_with_error) - lr_free(tmpfn1); - lr_free(tmpfn2); - lr_free(tmpfn3); -- fail_if(fd1 < 0); -- fail_if(fd2 < 0); -- fail_if(fd3 < 0); -+ ck_assert_int_ge(fd1, 0); -+ ck_assert_int_ge(fd2, 0); -+ ck_assert_int_ge(fd3, 0); - - t1 = lr_downloadtarget_new(handle, "index.html", NULL, fd1, NULL, NULL, - 0, 0, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, - FALSE, FALSE); -- fail_if(!t1); -+ ck_assert_ptr_nonnull(t1); - - t2 = lr_downloadtarget_new(handle, "index.html", "http://seznam.cz", fd2, - NULL, NULL, 0, 0, NULL, NULL, NULL, NULL, - NULL, 0, 0, NULL, FALSE, FALSE); -- fail_if(!t2); -+ ck_assert_ptr_nonnull(t2); - - t3 = lr_downloadtarget_new(handle, "i_hope_this_page_doesnt_exists.html", - "http://google.com", fd3, NULL, NULL, - 0, 0, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, - FALSE, FALSE); -- fail_if(!t3); -+ ck_assert_ptr_nonnull(t3); - - list = g_slist_append(list, t1); - list = g_slist_append(list, t2); -@@ -262,9 +252,8 @@ START_TEST(test_downloader_three_files_with_error) - - // Download - -- ret = lr_download(list, FALSE, &err); -- fail_if(!ret); -- fail_if(err); -+ ck_assert(lr_download(list, FALSE, &err)); -+ ck_assert_ptr_null(err); - - lr_handle_free(handle); - -@@ -314,7 +303,6 @@ START_TEST(test_downloader_checksum) - int i; - - for (i = 0; tests[i].sha512; i++) { -- int ret; - LrHandle *handle; - GSList *list = NULL; - GError *err = NULL; -@@ -328,12 +316,12 @@ START_TEST(test_downloader_checksum) - // Prepare handle - - handle = lr_handle_init(); -- fail_if(handle == NULL); -+ ck_assert_ptr_nonnull(handle); - - char *urls[] = {"file:///", NULL}; -- fail_if(!lr_handle_setopt(handle, NULL, LRO_URLS, urls)); -+ ck_assert(lr_handle_setopt(handle, NULL, LRO_URLS, urls)); - lr_handle_prepare_internal_mirrorlist(handle, FALSE, &tmp_err); -- fail_if(tmp_err); -+ ck_assert_ptr_null(tmp_err); - - - // Prepare list of download targets -@@ -342,7 +330,7 @@ START_TEST(test_downloader_checksum) - - fd1 = mkstemp(tmpfn1); - lr_free(tmpfn1); -- fail_if(fd1 < 0); -+ ck_assert_int_ge(fd1, 0); - - checksum = lr_downloadtargetchecksum_new(LR_CHECKSUM_SHA512, - tests[i].sha512); -@@ -351,15 +339,14 @@ START_TEST(test_downloader_checksum) - t1 = lr_downloadtarget_new(handle, "dev/null", NULL, fd1, NULL, checksums, - 0, 0, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, - FALSE, FALSE); -- fail_if(!t1); -+ ck_assert_ptr_nonnull(t1); - - list = g_slist_append(list, t1); - - // Download - -- ret = lr_download(list, FALSE, &err); -- fail_if(!ret); -- fail_if(err); -+ ck_assert(lr_download(list, FALSE, &err)); -+ ck_assert_ptr_null(err); - - lr_handle_free(handle); - -diff --git a/tests/test_gpg.c b/tests/test_gpg.c -index 1f956d8b..fd322e38 100644 ---- a/tests/test_gpg.c -+++ b/tests/test_gpg.c -@@ -39,24 +39,24 @@ START_TEST(test_gpg_check_signature) - "repo_yum_01/repodata/repomd.xml_bad.asc", NULL); - - ret = lr_gpg_import_key(key_path, tmp_home_path, &tmp_err); -- fail_if(!ret); -- fail_if(tmp_err); -+ ck_assert(ret); -+ ck_assert_ptr_null(tmp_err); - - // Valid key and data - ret = lr_gpg_check_signature(signature_path, - data_path, - tmp_home_path, - &tmp_err); -- fail_if(!ret); -- fail_if(tmp_err); -+ ck_assert(ret); -+ ck_assert_ptr_null(tmp_err); - - // Bad signature signed with unknown key - ret = lr_gpg_check_signature(_signature_path, - data_path, - tmp_home_path, - &tmp_err); -- fail_if(ret); -- fail_if(!tmp_err); -+ ck_assert(!ret); -+ ck_assert_ptr_nonnull(tmp_err); - g_error_free(tmp_err); - tmp_err = NULL; - -@@ -65,31 +65,31 @@ START_TEST(test_gpg_check_signature) - _data_path, - tmp_home_path, - &tmp_err); -- fail_if(ret); -- fail_if(!tmp_err); -+ ck_assert(!ret); -+ ck_assert_ptr_nonnull(tmp_err); - g_error_free(tmp_err); - tmp_err = NULL; - - // Import the 2nd key - ret = lr_gpg_import_key(_key_path, tmp_home_path, &tmp_err); -- fail_if(!ret); -- fail_if(tmp_err); -+ ck_assert(ret); -+ ck_assert_ptr_null(tmp_err); - - // Valid key and data - ret = lr_gpg_check_signature(_signature_path, - _data_path, - tmp_home_path, - &tmp_err); -- fail_if(!ret); -- fail_if(tmp_err); -+ ck_assert(ret); -+ ck_assert_ptr_null(tmp_err); - - // Bad signature signed with known key - ret = lr_gpg_check_signature(_signature_path, - data_path, - tmp_home_path, - &tmp_err); -- fail_if(ret); -- fail_if(!tmp_err); -+ ck_assert(!ret); -+ ck_assert_ptr_nonnull(tmp_err); - g_error_free(tmp_err); - tmp_err = NULL; - -@@ -98,8 +98,8 @@ START_TEST(test_gpg_check_signature) - data_path, - tmp_home_path, - &tmp_err); -- fail_if(ret); -- fail_if(!tmp_err); -+ ck_assert(!ret); -+ ck_assert_ptr_nonnull(tmp_err); - g_error_free(tmp_err); - tmp_err = NULL; - -diff --git a/tests/test_handle.c b/tests/test_handle.c -index d8b3c3fe..a80df4eb 100644 ---- a/tests/test_handle.c -+++ b/tests/test_handle.c -@@ -22,42 +22,42 @@ START_TEST(test_handle) - GError *tmp_err = NULL; - - h = lr_handle_init(); -- fail_if(h == NULL); -+ ck_assert_ptr_nonnull(h); - lr_handle_free(h); - h = NULL; - - /* This test is meant to check memory leaks. (Use valgrind) */ - h = lr_handle_init(); - char *urls[] = {"foo", NULL}; -- fail_if(!lr_handle_setopt(h, &tmp_err, LRO_URLS, urls)); -- fail_if(tmp_err); -- fail_if(!lr_handle_setopt(h, &tmp_err, LRO_URLS, urls)); -- fail_if(tmp_err); -- fail_if(!lr_handle_setopt(h, &tmp_err, LRO_MIRRORLIST, "foo")); -- fail_if(tmp_err); -- fail_if(!lr_handle_setopt(h, &tmp_err, LRO_MIRRORLIST, "bar")); -- fail_if(tmp_err); -- fail_if(!lr_handle_setopt(h, NULL, LRO_USERPWD, "user:pwd")); -- fail_if(!lr_handle_setopt(h, NULL, LRO_PROXY, "proxy")); -- fail_if(!lr_handle_setopt(h, NULL, LRO_PROXYUSERPWD, "proxyuser:pwd")); -- fail_if(!lr_handle_setopt(h, NULL, LRO_DESTDIR, "foodir")); -- fail_if(!lr_handle_setopt(h, NULL, LRO_USERAGENT, "librepo/0.0")); -+ ck_assert(lr_handle_setopt(h, &tmp_err, LRO_URLS, urls)); -+ ck_assert_ptr_null(tmp_err); -+ ck_assert(lr_handle_setopt(h, &tmp_err, LRO_URLS, urls)); -+ ck_assert_ptr_null(tmp_err); -+ ck_assert(lr_handle_setopt(h, &tmp_err, LRO_MIRRORLIST, "foo")); -+ ck_assert_ptr_null(tmp_err); -+ ck_assert(lr_handle_setopt(h, &tmp_err, LRO_MIRRORLIST, "bar")); -+ ck_assert_ptr_null(tmp_err); -+ ck_assert(lr_handle_setopt(h, NULL, LRO_USERPWD, "user:pwd")); -+ ck_assert(lr_handle_setopt(h, NULL, LRO_PROXY, "proxy")); -+ ck_assert(lr_handle_setopt(h, NULL, LRO_PROXYUSERPWD, "proxyuser:pwd")); -+ ck_assert(lr_handle_setopt(h, NULL, LRO_DESTDIR, "foodir")); -+ ck_assert(lr_handle_setopt(h, NULL, LRO_USERAGENT, "librepo/0.0")); - char *dlist[] = {"primary", "filelists", NULL}; -- fail_if(!lr_handle_setopt(h, NULL, LRO_YUMDLIST, dlist)); -- fail_if(!lr_handle_setopt(h, NULL, LRO_YUMBLIST, dlist)); -+ ck_assert(lr_handle_setopt(h, NULL, LRO_YUMDLIST, dlist)); -+ ck_assert(lr_handle_setopt(h, NULL, LRO_YUMBLIST, dlist)); - LrUrlVars *vars = NULL; - vars = lr_urlvars_set(vars, "foo", "bar"); -- fail_if(!lr_handle_setopt(h, NULL, LRO_VARSUB, vars)); -- fail_if(!lr_handle_setopt(h, NULL, LRO_FASTESTMIRRORCACHE, -+ ck_assert(lr_handle_setopt(h, NULL, LRO_VARSUB, vars)); -+ ck_assert(lr_handle_setopt(h, NULL, LRO_FASTESTMIRRORCACHE, - "/var/cache/fastestmirror.librepo")); -- fail_if(!lr_handle_setopt(h, NULL, LRO_SSLCLIENTCERT, "/etc/cert.pem")); -- fail_if(!lr_handle_setopt(h, NULL, LRO_SSLCLIENTKEY, "/etc/cert.key")); -- fail_if(!lr_handle_setopt(h, NULL, LRO_SSLCACERT, "/etc/ca.pem")); -- fail_if(!lr_handle_setopt(h, NULL, LRO_PROXY_SSLCLIENTCERT, "/etc/proxy_cert.pem")); -- fail_if(!lr_handle_setopt(h, NULL, LRO_PROXY_SSLCLIENTKEY, "/etc/proxy_cert.key")); -- fail_if(!lr_handle_setopt(h, NULL, LRO_PROXY_SSLCACERT, "/etc/proxy_ca.pem")); -- fail_if(!lr_handle_setopt(h, NULL, LRO_HTTPAUTHMETHODS, LR_AUTH_NTLM)); -- fail_if(!lr_handle_setopt(h, NULL, LRO_PROXYAUTHMETHODS, LR_AUTH_DIGEST)); -+ ck_assert(lr_handle_setopt(h, NULL, LRO_SSLCLIENTCERT, "/etc/cert.pem")); -+ ck_assert(lr_handle_setopt(h, NULL, LRO_SSLCLIENTKEY, "/etc/cert.key")); -+ ck_assert(lr_handle_setopt(h, NULL, LRO_SSLCACERT, "/etc/ca.pem")); -+ ck_assert(lr_handle_setopt(h, NULL, LRO_PROXY_SSLCLIENTCERT, "/etc/proxy_cert.pem")); -+ ck_assert(lr_handle_setopt(h, NULL, LRO_PROXY_SSLCLIENTKEY, "/etc/proxy_cert.key")); -+ ck_assert(lr_handle_setopt(h, NULL, LRO_PROXY_SSLCACERT, "/etc/proxy_ca.pem")); -+ ck_assert(lr_handle_setopt(h, NULL, LRO_HTTPAUTHMETHODS, LR_AUTH_NTLM)); -+ ck_assert(lr_handle_setopt(h, NULL, LRO_PROXYAUTHMETHODS, LR_AUTH_DIGEST)); - lr_handle_free(h); - } - END_TEST -@@ -73,90 +73,90 @@ START_TEST(test_handle_getinfo) - h = lr_handle_init(); - - num = -1; -- fail_if(!lr_handle_getinfo(h, &tmp_err, LRI_UPDATE, &num)); -- fail_if(num != 0); -- fail_if(tmp_err); -+ ck_assert(lr_handle_getinfo(h, &tmp_err, LRI_UPDATE, &num)); -+ ck_assert(num == 0); -+ ck_assert_ptr_null(tmp_err); - - strlist = NULL; -- fail_if(!lr_handle_getinfo(h, &tmp_err, LRI_URLS, &strlist)); -- fail_if(strlist != NULL); -- fail_if(tmp_err); -+ ck_assert(lr_handle_getinfo(h, &tmp_err, LRI_URLS, &strlist)); -+ ck_assert_ptr_null(strlist); -+ ck_assert_ptr_null(tmp_err); - - str = NULL; -- fail_if(!lr_handle_getinfo(h, NULL, LRI_MIRRORLIST, &str)); -- fail_if(str != NULL); -+ ck_assert(lr_handle_getinfo(h, NULL, LRI_MIRRORLIST, &str)); -+ ck_assert_ptr_null(str); - - num = -1; -- fail_if(!lr_handle_getinfo(h, NULL, LRI_LOCAL, &num)); -- fail_if(num != 0); -+ ck_assert(lr_handle_getinfo(h, NULL, LRI_LOCAL, &num)); -+ ck_assert(num == 0); - - str = NULL; -- fail_if(!lr_handle_getinfo(h, NULL, LRI_DESTDIR, &str)); -- fail_if(str != NULL); -+ ck_assert(lr_handle_getinfo(h, NULL, LRI_DESTDIR, &str)); -+ ck_assert_ptr_null(str); - - num = -1; -- fail_if(!lr_handle_getinfo(h, NULL, LRI_REPOTYPE, &num)); -- fail_if(num != 0); -+ ck_assert(lr_handle_getinfo(h, NULL, LRI_REPOTYPE, &num)); -+ ck_assert(num == 0); - - str = NULL; -- fail_if(!lr_handle_getinfo(h, NULL, LRI_USERAGENT, &str)); -- fail_if(str != NULL); -+ ck_assert(lr_handle_getinfo(h, NULL, LRI_USERAGENT, &str)); -+ ck_assert_ptr_null(str); - - strlist = NULL; -- fail_if(!lr_handle_getinfo(h, NULL, LRI_YUMDLIST, &strlist)); -- fail_if(strlist != NULL); -+ ck_assert(lr_handle_getinfo(h, NULL, LRI_YUMDLIST, &strlist)); -+ ck_assert_ptr_null(strlist); - - strlist = NULL; -- fail_if(!lr_handle_getinfo(h, NULL, LRI_YUMBLIST, &strlist)); -- fail_if(strlist != NULL); -+ ck_assert(lr_handle_getinfo(h, NULL, LRI_YUMBLIST, &strlist)); -+ ck_assert_ptr_null(strlist); - - num = -1; -- fail_if(!lr_handle_getinfo(h, NULL, LRI_MAXMIRRORTRIES, &num)); -- fail_if(num != 0); -+ ck_assert(lr_handle_getinfo(h, NULL, LRI_MAXMIRRORTRIES, &num)); -+ ck_assert(num == 0); - - LrUrlVars *vars = NULL; -- fail_if(!lr_handle_getinfo(h, NULL, LRI_VARSUB, &vars)); -- fail_if(strlist != NULL); -+ ck_assert(lr_handle_getinfo(h, NULL, LRI_VARSUB, &vars)); -+ ck_assert_ptr_null(strlist); - - str = NULL; -- fail_if(!lr_handle_getinfo(h, NULL, LRI_FASTESTMIRRORCACHE, &str)); -- fail_if(str != NULL); -+ ck_assert(lr_handle_getinfo(h, NULL, LRI_FASTESTMIRRORCACHE, &str)); -+ ck_assert_ptr_null(str); - - num = -1; -- fail_if(!lr_handle_getinfo(h, NULL, LRI_FASTESTMIRRORMAXAGE, &num)); -- fail_if(num != LRO_FASTESTMIRRORMAXAGE_DEFAULT); -+ ck_assert(lr_handle_getinfo(h, NULL, LRI_FASTESTMIRRORMAXAGE, &num)); -+ ck_assert(num == LRO_FASTESTMIRRORMAXAGE_DEFAULT); - - str = NULL; -- fail_if(!lr_handle_getinfo(h, NULL, LRI_SSLCLIENTCERT, &str)); -- fail_if(str != NULL); -+ ck_assert(lr_handle_getinfo(h, NULL, LRI_SSLCLIENTCERT, &str)); -+ ck_assert_ptr_null(str); - - str = NULL; -- fail_if(!lr_handle_getinfo(h, NULL, LRI_SSLCLIENTKEY, &str)); -- fail_if(str != NULL); -+ ck_assert(lr_handle_getinfo(h, NULL, LRI_SSLCLIENTKEY, &str)); -+ ck_assert_ptr_null(str); - - str = NULL; -- fail_if(!lr_handle_getinfo(h, NULL, LRI_SSLCACERT, &str)); -- fail_if(str != NULL); -+ ck_assert(lr_handle_getinfo(h, NULL, LRI_SSLCACERT, &str)); -+ ck_assert_ptr_null(str); - - str = NULL; -- fail_if(!lr_handle_getinfo(h, NULL, LRI_PROXY_SSLCLIENTCERT, &str)); -- fail_if(str != NULL); -+ ck_assert(lr_handle_getinfo(h, NULL, LRI_PROXY_SSLCLIENTCERT, &str)); -+ ck_assert_ptr_null(str); - - str = NULL; -- fail_if(!lr_handle_getinfo(h, NULL, LRI_PROXY_SSLCLIENTKEY, &str)); -- fail_if(str != NULL); -+ ck_assert(lr_handle_getinfo(h, NULL, LRI_PROXY_SSLCLIENTKEY, &str)); -+ ck_assert_ptr_null(str); - - str = NULL; -- fail_if(!lr_handle_getinfo(h, NULL, LRI_PROXY_SSLCACERT, &str)); -- fail_if(str != NULL); -+ ck_assert(lr_handle_getinfo(h, NULL, LRI_PROXY_SSLCACERT, &str)); -+ ck_assert_ptr_null(str); - - LrAuth auth = LR_AUTH_NONE; -- fail_if(!lr_handle_getinfo(h, NULL, LRI_HTTPAUTHMETHODS, &auth)); -- fail_if(auth != LR_AUTH_BASIC); -+ ck_assert(lr_handle_getinfo(h, NULL, LRI_HTTPAUTHMETHODS, &auth)); -+ ck_assert(auth == LR_AUTH_BASIC); - - auth = LR_AUTH_NONE; -- fail_if(!lr_handle_getinfo(h, NULL, LRI_PROXYAUTHMETHODS, &auth)); -- fail_if(auth != LR_AUTH_BASIC); -+ ck_assert(lr_handle_getinfo(h, NULL, LRI_PROXYAUTHMETHODS, &auth)); -+ ck_assert(auth == LR_AUTH_BASIC); - - lr_handle_free(h); - } -diff --git a/tests/test_lrmirrorlist.c b/tests/test_lrmirrorlist.c -index 9c908026..70c73b2c 100644 ---- a/tests/test_lrmirrorlist.c -+++ b/tests/test_lrmirrorlist.c -@@ -29,16 +29,16 @@ START_TEST(test_lrmirrorlist_append_url) - lr_urlvars_free(vars); - - mirror = lr_lrmirrorlist_nth(iml, 0); -- fail_if(!mirror); -- fail_if(strcmp(mirror->url, "ftp://bar")); -+ ck_assert_ptr_nonnull(mirror); -+ ck_assert_str_eq(mirror->url, "ftp://bar"); - - mirror = lr_lrmirrorlist_nth(iml, 1); -- fail_if(!mirror); -- fail_if(strcmp(mirror->url, "http://foo")); -+ ck_assert_ptr_nonnull(mirror); -+ ck_assert_str_eq(mirror->url, "http://foo"); - - mirror = lr_lrmirrorlist_nth(iml, 2); -- fail_if(!mirror); -- fail_if(strcmp(mirror->url, "http://xyz/i386/")); -+ ck_assert_ptr_nonnull(mirror); -+ ck_assert_str_eq(mirror->url, "http://xyz/i386/"); - - lr_lrmirrorlist_free(iml); - } -@@ -56,30 +56,30 @@ START_TEST(test_lrmirrorlist_append_mirrorlist) - ml.urls = g_slist_prepend(ml.urls, "ftp://bar"); - ml.urls = g_slist_prepend(ml.urls, "http://foo"); - -- fail_if(g_slist_length(iml) != 0); -+ ck_assert(g_slist_length(iml) == 0); - iml = lr_lrmirrorlist_append_mirrorlist(iml, NULL, NULL); -- fail_if(g_slist_length(iml) != 0); -+ ck_assert(g_slist_length(iml) == 0); - - iml = lr_lrmirrorlist_append_mirrorlist(iml, &ml, NULL); -- fail_if(g_slist_length(iml) != 2); -+ ck_assert(g_slist_length(iml) == 2); - mirror = lr_lrmirrorlist_nth(iml, 0); -- fail_if(!mirror); -- fail_if(strcmp(mirror->url, "http://foo")); -- fail_if(mirror->preference != 100); -- fail_if(mirror->protocol != LR_PROTOCOL_HTTP); -+ ck_assert_ptr_nonnull(mirror); -+ ck_assert_str_eq(mirror->url, "http://foo"); -+ ck_assert(mirror->preference == 100); -+ ck_assert(mirror->protocol == LR_PROTOCOL_HTTP); - mirror = lr_lrmirrorlist_nth(iml, 1); -- fail_if(!mirror); -- fail_if(strcmp(mirror->url, "ftp://bar")); -- fail_if(mirror->preference != 100); -- fail_if(mirror->protocol != LR_PROTOCOL_FTP); -+ ck_assert_ptr_nonnull(mirror); -+ ck_assert_str_eq(mirror->url, "ftp://bar"); -+ ck_assert(mirror->preference == 100); -+ ck_assert(mirror->protocol == LR_PROTOCOL_FTP); - -- fail_if(g_slist_length(iml) != 2); -+ ck_assert(g_slist_length(iml) == 2); - - url = lr_lrmirrorlist_nth_url(iml, 0); -- fail_if(strcmp(url, "http://foo")); -+ ck_assert_str_eq(url, "http://foo"); - - url = lr_lrmirrorlist_nth_url(iml, 1); -- fail_if(strcmp(url, "ftp://bar")); -+ ck_assert_str_eq(url, "ftp://bar"); - - lr_lrmirrorlist_free(iml); - g_slist_free(ml.urls); -@@ -132,46 +132,46 @@ START_TEST(test_lrmirrorlist_append_metalink) - ml.urls = g_slist_prepend(ml.urls, &url2); - ml.urls = g_slist_prepend(ml.urls, &url1); - -- fail_if(g_slist_length(iml) != 0); -+ ck_assert(g_slist_length(iml) == 0); - iml = lr_lrmirrorlist_append_metalink(iml, NULL, NULL, NULL); -- fail_if(g_slist_length(iml) != 0); -+ ck_assert(g_slist_length(iml) == 0); - - iml = lr_lrmirrorlist_append_metalink(iml, &ml, "/repodata/repomd.xml", NULL); -- fail_if(g_slist_length(iml) != 2); // 2 because element with empty url shoud be skipped -+ ck_assert(g_slist_length(iml) == 2); // 2 because element with empty url shoud be skipped - - mirror = lr_lrmirrorlist_nth(iml, 0); -- fail_if(strcmp(mirror->url, "http://foo")); -- fail_if(mirror->preference != 100); -- fail_if(mirror->protocol != LR_PROTOCOL_HTTP); -+ ck_assert_str_eq(mirror->url, "http://foo"); -+ ck_assert(mirror->preference == 100); -+ ck_assert(mirror->protocol == LR_PROTOCOL_HTTP); - - mirror = lr_lrmirrorlist_nth(iml, 1); -- fail_if(strcmp(mirror->url, "ftp://bar")); -- fail_if(mirror->preference != 95); -- fail_if(mirror->protocol != LR_PROTOCOL_FTP); -+ ck_assert_str_eq(mirror->url, "ftp://bar"); -+ ck_assert(mirror->preference == 95); -+ ck_assert(mirror->protocol == LR_PROTOCOL_FTP); - -- fail_if(g_slist_length(iml) != 2); -+ ck_assert(g_slist_length(iml) == 2); - - url = lr_lrmirrorlist_nth_url(iml, 0); -- fail_if(strcmp(url, "http://foo")); -+ ck_assert_str_eq(url, "http://foo"); - - url = lr_lrmirrorlist_nth_url(iml, 1); -- fail_if(strcmp(url, "ftp://bar")); -+ ck_assert_str_eq(url, "ftp://bar"); - - lr_lrmirrorlist_free(iml); - - // Try append on list with existing element - iml = NULL; -- fail_if(g_slist_length(iml) != 0); -+ ck_assert(g_slist_length(iml) == 0); - iml = lr_lrmirrorlist_append_url(iml, "http://abc", NULL); -- fail_if(g_slist_length(iml) != 1); -+ ck_assert(g_slist_length(iml) == 1); - iml = lr_lrmirrorlist_append_metalink(iml, &ml, "/repodata/repomd.xml", NULL); -- fail_if(g_slist_length(iml) != 3); -+ ck_assert(g_slist_length(iml) == 3); - url = lr_lrmirrorlist_nth_url(iml, 0); -- fail_if(strcmp(url, "http://abc")); -+ ck_assert_str_eq(url, "http://abc"); - url = lr_lrmirrorlist_nth_url(iml, 1); -- fail_if(strcmp(url, "http://foo")); -+ ck_assert_str_eq(url, "http://foo"); - url = lr_lrmirrorlist_nth_url(iml, 2); -- fail_if(strcmp(url, "ftp://bar")); -+ ck_assert_str_eq(url, "ftp://bar"); - - lr_lrmirrorlist_free(iml); - g_slist_free(ml.urls); -@@ -189,48 +189,48 @@ START_TEST(test_lrmirrorlist_append_lrmirrorlist) - iml_2 = lr_lrmirrorlist_append_url(iml_2, NULL, NULL); - iml_2 = lr_lrmirrorlist_append_url(iml_2, "ftp://bar", NULL); - -- fail_if(g_slist_length(iml_2) != 2); -+ ck_assert(g_slist_length(iml_2) == 2); - -- fail_if(g_slist_length(iml) != 0); -+ ck_assert(g_slist_length(iml) == 0); - iml = lr_lrmirrorlist_append_lrmirrorlist(iml, NULL); -- fail_if(g_slist_length(iml) != 0); -+ ck_assert(g_slist_length(iml) == 0); - - iml = lr_lrmirrorlist_append_lrmirrorlist(iml, iml_2); -- fail_if(g_slist_length(iml) != 2); // 2 because element with empty url shoud be skipped -+ ck_assert(g_slist_length(iml) == 2); // 2 because element with empty url shoud be skipped - - mirror = lr_lrmirrorlist_nth(iml, 0); -- fail_if(strcmp(mirror->url, "http://foo")); -- fail_if(mirror->preference != 100); -- fail_if(mirror->protocol != LR_PROTOCOL_HTTP); -+ ck_assert_str_eq(mirror->url, "http://foo"); -+ ck_assert(mirror->preference == 100); -+ ck_assert(mirror->protocol == LR_PROTOCOL_HTTP); - - mirror = lr_lrmirrorlist_nth(iml, 1); -- fail_if(strcmp(mirror->url, "ftp://bar")); -- fail_if(mirror->preference != 100); -- fail_if(mirror->protocol != LR_PROTOCOL_FTP); -+ ck_assert_str_eq(mirror->url, "ftp://bar"); -+ ck_assert(mirror->preference == 100); -+ ck_assert(mirror->protocol == LR_PROTOCOL_FTP); - -- fail_if(g_slist_length(iml) != 2); -+ ck_assert(g_slist_length(iml) == 2); - - url = lr_lrmirrorlist_nth_url(iml, 0); -- fail_if(strcmp(url, "http://foo")); -+ ck_assert_str_eq(url, "http://foo"); - - url = lr_lrmirrorlist_nth_url(iml, 1); -- fail_if(strcmp(url, "ftp://bar")); -+ ck_assert_str_eq(url, "ftp://bar"); - - lr_lrmirrorlist_free(iml); - - // Try append on list with existing element - iml = NULL; -- fail_if(g_slist_length(iml) != 0); -+ ck_assert(g_slist_length(iml) == 0); - iml = lr_lrmirrorlist_append_url(iml, "http://abc", NULL); -- fail_if(g_slist_length(iml) != 1); -+ ck_assert(g_slist_length(iml) == 1); - iml = lr_lrmirrorlist_append_lrmirrorlist(iml, iml_2); -- fail_if(g_slist_length(iml) != 3); -+ ck_assert(g_slist_length(iml) == 3); - url = lr_lrmirrorlist_nth_url(iml, 0); -- fail_if(strcmp(url, "http://abc")); -+ ck_assert_str_eq(url, "http://abc"); - url = lr_lrmirrorlist_nth_url(iml, 1); -- fail_if(strcmp(url, "http://foo")); -+ ck_assert_str_eq(url, "http://foo"); - url = lr_lrmirrorlist_nth_url(iml, 2); -- fail_if(strcmp(url, "ftp://bar")); -+ ck_assert_str_eq(url, "ftp://bar"); - lr_lrmirrorlist_free(iml); - lr_lrmirrorlist_free(iml_2); - } -diff --git a/tests/test_metalink.c b/tests/test_metalink.c -index 69ebc236..e425742c 100644 ---- a/tests/test_metalink.c -+++ b/tests/test_metalink.c -@@ -29,7 +29,7 @@ START_TEST(test_metalink_init) - LrMetalink *ml = NULL; - - ml = lr_metalink_init(); -- fail_if(ml == NULL); -+ ck_assert_ptr_nonnull(ml); - lr_metalink_free(ml); - } - END_TEST -@@ -49,101 +49,101 @@ START_TEST(test_metalink_good_01) - "metalink_good_01", NULL); - fd = open(path, O_RDONLY); - lr_free(path); -- fail_if(fd < 0); -+ ck_assert_int_ge(fd, 0); - ml = lr_metalink_init(); -- fail_if(ml == NULL); -+ ck_assert_ptr_nonnull(ml); - ret = lr_metalink_parse_file(ml, fd, REPOMD, NULL, NULL, &tmp_err); -- fail_if(!ret); -- fail_if(tmp_err); -+ ck_assert(ret); -+ ck_assert_ptr_null(tmp_err); - close(fd); - -- fail_if(ml->filename == NULL); -- fail_if(strcmp(ml->filename, "repomd.xml")); -- fail_if(ml->timestamp != 1337942396); -- fail_if(ml->size != 4309); -- fail_if(g_slist_length(ml->hashes) != 4); -- fail_if(g_slist_length(ml->urls) != 106); -+ ck_assert_ptr_nonnull(ml->filename); -+ ck_assert_str_eq(ml->filename, "repomd.xml"); -+ ck_assert(ml->timestamp == 1337942396); -+ ck_assert(ml->size == 4309); -+ ck_assert(g_slist_length(ml->hashes) == 4); -+ ck_assert(g_slist_length(ml->urls) == 106); - - elem = g_slist_nth(ml->hashes, 0); -- fail_if(!elem); -+ ck_assert_ptr_nonnull(elem); - mlhash = elem->data; -- fail_if(!mlhash); -- fail_if(mlhash->type == NULL); -- fail_if(strcmp(mlhash->type, "md5")); -- fail_if(mlhash->value == NULL); -- fail_if(strcmp(mlhash->value, "20b6d77930574ae541108e8e7987ad3f")); -+ ck_assert_ptr_nonnull(mlhash); -+ ck_assert_ptr_nonnull(mlhash->type); -+ ck_assert_str_eq(mlhash->type, "md5"); -+ ck_assert_ptr_nonnull(mlhash->value); -+ ck_assert_str_eq(mlhash->value, "20b6d77930574ae541108e8e7987ad3f"); - - elem = g_slist_nth(ml->hashes, 1); -- fail_if(!elem); -+ ck_assert_ptr_nonnull(elem); - mlhash = elem->data; -- fail_if(!mlhash); -- fail_if(mlhash->type == NULL); -- fail_if(strcmp(mlhash->type, "sha1")); -- fail_if(mlhash->value == NULL); -- fail_if(strcmp(mlhash->value, "4a5ae1831a567b58e2e0f0de1529ca199d1d8319")); -+ ck_assert_ptr_nonnull(mlhash); -+ ck_assert_ptr_nonnull(mlhash->type); -+ ck_assert_str_eq(mlhash->type, "sha1"); -+ ck_assert_ptr_nonnull(mlhash->value); -+ ck_assert_str_eq(mlhash->value, "4a5ae1831a567b58e2e0f0de1529ca199d1d8319"); - - elem = g_slist_nth(ml->hashes, 2); -- fail_if(!elem); -+ ck_assert_ptr_nonnull(elem); - mlhash = elem->data; -- fail_if(!mlhash); -- fail_if(mlhash->type == NULL); -- fail_if(strcmp(mlhash->type, "sha256")); -- fail_if(mlhash->value == NULL); -- fail_if(strcmp(mlhash->value, "0076c44aabd352da878d5c4d794901ac87f66afac869488f6a4ef166de018cdf")); -+ ck_assert_ptr_nonnull(mlhash); -+ ck_assert_ptr_nonnull(mlhash->type); -+ ck_assert_str_eq(mlhash->type, "sha256"); -+ ck_assert_ptr_nonnull(mlhash->value); -+ ck_assert_str_eq(mlhash->value, "0076c44aabd352da878d5c4d794901ac87f66afac869488f6a4ef166de018cdf"); - - elem = g_slist_nth(ml->hashes, 3); -- fail_if(!elem); -+ ck_assert_ptr_nonnull(elem); - mlhash = elem->data; -- fail_if(!mlhash); -- fail_if(mlhash->type == NULL); -- fail_if(strcmp(mlhash->type, "sha512")); -- fail_if(mlhash->value == NULL); -- fail_if(strcmp(mlhash->value, "884dc465da67fee8fe3f11dab321a99d9a13b22ce97f84ceff210e82b6b1a8c635ccd196add1dd738807686714c3a0a048897e2d0650bc05302b3ee26de521fd")); -+ ck_assert_ptr_nonnull(mlhash); -+ ck_assert_ptr_nonnull(mlhash->type); -+ ck_assert_str_eq(mlhash->type, "sha512"); -+ ck_assert_ptr_nonnull(mlhash->value); -+ ck_assert_str_eq(mlhash->value, "884dc465da67fee8fe3f11dab321a99d9a13b22ce97f84ceff210e82b6b1a8c635ccd196add1dd738807686714c3a0a048897e2d0650bc05302b3ee26de521fd"); - - elem = g_slist_nth(ml->urls, 0); -- fail_if(!elem); -+ ck_assert_ptr_nonnull(elem); - mlurl = elem->data; -- fail_if(!mlurl); -- fail_if(mlurl->protocol == NULL); -- fail_if(strcmp(mlurl->protocol, "http")); -- fail_if(mlurl->type == NULL); -- fail_if(strcmp(mlurl->type, "http")); -- fail_if(mlurl->location == NULL); -- fail_if(strcmp(mlurl->location, "US")); -- fail_if(mlurl->preference != 99); -- fail_if(mlurl->url == NULL); -- fail_if(strcmp(mlurl->url, -- "http://mirror.pnl.gov/fedora/linux/releases/17/Everything/x86_64/os/repodata/repomd.xml")); -+ ck_assert_ptr_nonnull(mlurl); -+ ck_assert_ptr_nonnull(mlurl->protocol); -+ ck_assert_str_eq(mlurl->protocol, "http"); -+ ck_assert_ptr_nonnull(mlurl->type); -+ ck_assert_str_eq(mlurl->type, "http"); -+ ck_assert_ptr_nonnull(mlurl->location); -+ ck_assert_str_eq(mlurl->location, "US"); -+ ck_assert(mlurl->preference == 99); -+ ck_assert_ptr_nonnull(mlurl->url); -+ ck_assert_str_eq(mlurl->url, -+ "http://mirror.pnl.gov/fedora/linux/releases/17/Everything/x86_64/os/repodata/repomd.xml"); - - elem = g_slist_nth(ml->urls, 2); -- fail_if(!elem); -+ ck_assert_ptr_nonnull(elem); - mlurl = elem->data; -- fail_if(!mlurl); -- fail_if(mlurl->protocol == NULL); -- fail_if(strcmp(mlurl->protocol, "ftp")); -- fail_if(mlurl->type == NULL); -- fail_if(strcmp(mlurl->type, "ftp")); -- fail_if(mlurl->location == NULL); -- fail_if(strcmp(mlurl->location, "US")); -- fail_if(mlurl->preference != 98); -- fail_if(mlurl->url == NULL); -- fail_if(strcmp(mlurl->url, -- "ftp://mirrors.syringanetworks.net/fedora/releases/17/Everything/x86_64/os/repodata/repomd.xml")); -+ ck_assert_ptr_nonnull(mlurl); -+ ck_assert_ptr_nonnull(mlurl->protocol); -+ ck_assert_str_eq(mlurl->protocol, "ftp"); -+ ck_assert_ptr_nonnull(mlurl->type); -+ ck_assert_str_eq(mlurl->type, "ftp"); -+ ck_assert_ptr_nonnull(mlurl->location); -+ ck_assert_str_eq(mlurl->location, "US"); -+ ck_assert(mlurl->preference == 98); -+ ck_assert_ptr_nonnull(mlurl->url); -+ ck_assert_str_eq(mlurl->url, -+ "ftp://mirrors.syringanetworks.net/fedora/releases/17/Everything/x86_64/os/repodata/repomd.xml"); - - elem = g_slist_nth(ml->urls, 104); -- fail_if(!elem); -+ ck_assert_ptr_nonnull(elem); - mlurl = elem->data; -- fail_if(!mlurl); -- fail_if(mlurl->protocol == NULL); -- fail_if(strcmp(mlurl->protocol, "rsync")); -- fail_if(mlurl->type == NULL); -- fail_if(strcmp(mlurl->type, "rsync")); -- fail_if(mlurl->location == NULL); -- fail_if(strcmp(mlurl->location, "CA")); -- fail_if(mlurl->preference != 48); -- fail_if(mlurl->url == NULL); -- fail_if(strcmp(mlurl->url, -- "rsync://mirror.csclub.uwaterloo.ca/fedora-enchilada/linux/releases/17/Everything/x86_64/os/repodata/repomd.xml")); -+ ck_assert_ptr_nonnull(mlurl); -+ ck_assert_ptr_nonnull(mlurl->protocol); -+ ck_assert_str_eq(mlurl->protocol, "rsync"); -+ ck_assert_ptr_nonnull(mlurl->type); -+ ck_assert_str_eq(mlurl->type, "rsync"); -+ ck_assert_ptr_nonnull(mlurl->location); -+ ck_assert_str_eq(mlurl->location, "CA"); -+ ck_assert(mlurl->preference == 48); -+ ck_assert_ptr_nonnull(mlurl->url); -+ ck_assert_str_eq(mlurl->url, -+ "rsync://mirror.csclub.uwaterloo.ca/fedora-enchilada/linux/releases/17/Everything/x86_64/os/repodata/repomd.xml"); - - lr_metalink_free(ml); - } -@@ -161,35 +161,35 @@ START_TEST(test_metalink_good_02) - "metalink_good_02", NULL); - fd = open(path, O_RDONLY); - lr_free(path); -- fail_if(fd < 0); -+ ck_assert_int_ge(fd, 0); - ml = lr_metalink_init(); -- fail_if(ml == NULL); -+ ck_assert_ptr_nonnull(ml); - ret = lr_metalink_parse_file(ml, fd, REPOMD, NULL, NULL, &tmp_err); -- fail_if(!ret); -- fail_if(tmp_err); -+ ck_assert(ret); -+ ck_assert_ptr_null(tmp_err); - close(fd); - -- fail_if(ml->filename == NULL); -- fail_if(strcmp(ml->filename, "repomd.xml")); -- fail_if(ml->timestamp != 0); -- fail_if(ml->size != 0); -- fail_if(g_slist_length(ml->hashes) != 0); -- fail_if(g_slist_length(ml->urls) != 3); -+ ck_assert_ptr_nonnull(ml->filename); -+ ck_assert_str_eq(ml->filename, "repomd.xml"); -+ ck_assert(ml->timestamp == 0); -+ ck_assert(ml->size == 0); -+ ck_assert(g_slist_length(ml->hashes) == 0); -+ ck_assert(g_slist_length(ml->urls) == 3); - - GSList *list = g_slist_nth(ml->urls, 0); -- fail_if(!list); -+ ck_assert_ptr_nonnull(list); - LrMetalinkUrl *mlurl = list->data; -- fail_if(!mlurl); -- fail_if(mlurl->protocol == NULL); -- fail_if(strcmp(mlurl->protocol, "http")); -- fail_if(mlurl->type == NULL); -- fail_if(strcmp(mlurl->type, "http")); -- fail_if(mlurl->location == NULL); -- fail_if(strcmp(mlurl->location, "US")); -- fail_if(mlurl->preference != 97); -- fail_if(mlurl->url == NULL); -- fail_if(strcmp(mlurl->url, -- "http://mirror.pnl.gov/fedora/linux/releases/17/Everything/x86_64/os/repodata/repomd.xml")); -+ ck_assert_ptr_nonnull(mlurl); -+ ck_assert_ptr_nonnull(mlurl->protocol); -+ ck_assert_str_eq(mlurl->protocol, "http"); -+ ck_assert_ptr_nonnull(mlurl->type); -+ ck_assert_str_eq(mlurl->type, "http"); -+ ck_assert_ptr_nonnull(mlurl->location); -+ ck_assert_str_eq(mlurl->location, "US"); -+ ck_assert(mlurl->preference == 97); -+ ck_assert_ptr_nonnull(mlurl->url); -+ ck_assert_str_eq(mlurl->url, -+ "http://mirror.pnl.gov/fedora/linux/releases/17/Everything/x86_64/os/repodata/repomd.xml"); - - lr_metalink_free(ml); - } -@@ -207,20 +207,20 @@ START_TEST(test_metalink_good_03) - "metalink_good_03", NULL); - fd = open(path, O_RDONLY); - lr_free(path); -- fail_if(fd < 0); -+ ck_assert_int_ge(fd, 0); - ml = lr_metalink_init(); -- fail_if(ml == NULL); -+ ck_assert_ptr_nonnull(ml); - ret = lr_metalink_parse_file(ml, fd, REPOMD, NULL, NULL, &tmp_err); -- fail_if(!ret); -- fail_if(tmp_err); -+ ck_assert(ret); -+ ck_assert_ptr_null(tmp_err); - close(fd); - -- fail_if(ml->filename == NULL); -- fail_if(strcmp(ml->filename, "repomd.xml")); -- fail_if(ml->timestamp != 0); -- fail_if(ml->size != 0); -- fail_if(g_slist_length(ml->hashes) != 0); -- fail_if(g_slist_length(ml->urls) != 0); -+ ck_assert_ptr_nonnull(ml->filename); -+ ck_assert_str_eq(ml->filename, "repomd.xml"); -+ ck_assert(ml->timestamp == 0); -+ ck_assert(ml->size == 0); -+ ck_assert(g_slist_length(ml->hashes) == 0); -+ ck_assert(g_slist_length(ml->urls) == 0); - - lr_metalink_free(ml); - } -@@ -251,112 +251,110 @@ START_TEST(test_metalink_bad_01) - "metalink_bad_01", NULL); - fd = open(path, O_RDONLY); - lr_free(path); -- fail_if(fd < 0); -+ ck_assert_int_ge(fd, 0); - ml = lr_metalink_init(); -- fail_if(ml == NULL); -+ ck_assert_ptr_nonnull(ml); - int call_counter = 0; - ret = lr_metalink_parse_file(ml, fd, REPOMD, warning_cb, &call_counter, &tmp_err); -- fail_if(!ret); -- fail_if(tmp_err); -- fail_if(call_counter <= 0); -+ ck_assert(ret); -+ ck_assert_ptr_null(tmp_err); -+ ck_assert_int_gt(call_counter, 0); - close(fd); - -- fail_if(ml->filename == NULL); -- fail_if(strcmp(ml->filename, "repomd.xml")); -- fail_if(ml->timestamp != 0); -- fail_if(ml->size != 0); -- fail_if(g_slist_length(ml->hashes) != 4); -- fail_if(g_slist_length(ml->urls) != 4); -- fail_if(g_slist_length(ml->alternates) != 0); -+ ck_assert_ptr_nonnull(ml->filename); -+ ck_assert_str_eq(ml->filename, "repomd.xml"); -+ ck_assert(ml->timestamp == 0); -+ ck_assert(ml->size == 0); -+ ck_assert(g_slist_length(ml->hashes) == 4); -+ ck_assert(g_slist_length(ml->urls) == 4); -+ ck_assert(g_slist_length(ml->alternates) == 0); - - elem = g_slist_nth(ml->hashes, 0); -- fail_if(!elem); -+ ck_assert_ptr_nonnull(elem); - mlhash = elem->data; -- fail_if(!mlhash); -- fail_if(mlhash->type == NULL); -- fail_if(strcmp(mlhash->type, "md5")); -- fail_if(mlhash->value == NULL); -- fail_if(strcmp(mlhash->value, -- "20b6d77930574ae541108e8e7987ad3f")); -+ ck_assert_ptr_nonnull(mlhash); -+ ck_assert_ptr_nonnull(mlhash->type); -+ ck_assert_str_eq(mlhash->type, "md5"); -+ ck_assert_ptr_nonnull(mlhash->value); -+ ck_assert_str_eq(mlhash->value, "20b6d77930574ae541108e8e7987ad3f"); - - elem = g_slist_nth(ml->hashes, 1); -- fail_if(!elem); -+ ck_assert_ptr_nonnull(elem); - mlhash = elem->data; -- fail_if(!mlhash); -- fail_if(mlhash->type == NULL); -- fail_if(strcmp(mlhash->type, "foo")); -- fail_if(mlhash->value == NULL); -- fail_if(strcmp(mlhash->value, "")); -+ ck_assert_ptr_nonnull(mlhash); -+ ck_assert_ptr_nonnull(mlhash->type); -+ ck_assert_str_eq(mlhash->type, "foo"); -+ ck_assert_ptr_nonnull(mlhash->value); -+ ck_assert_str_eq(mlhash->value, ""); - - elem = g_slist_nth(ml->hashes, 2); -- fail_if(!elem); -+ ck_assert_ptr_nonnull(elem); - mlhash = elem->data; -- fail_if(!mlhash); -- fail_if(mlhash->type == NULL); -- fail_if(strcmp(mlhash->type, "sha256")); -- fail_if(mlhash->value == NULL); -- fail_if(strcmp(mlhash->value, -- "0076c44aabd352da878d5c4d794901ac87f66afac869488f6a4ef166de018cdf")); -+ ck_assert_ptr_nonnull(mlhash); -+ ck_assert_ptr_nonnull(mlhash->type); -+ ck_assert_str_eq(mlhash->type, "sha256"); -+ ck_assert_ptr_nonnull(mlhash->value); -+ ck_assert_str_eq(mlhash->value, "0076c44aabd352da878d5c4d794901ac87f66afac869488f6a4ef166de018cdf"); - - elem = g_slist_nth(ml->hashes, 3); -- fail_if(!elem); -+ ck_assert_ptr_nonnull(elem); - mlhash = elem->data; -- fail_if(!mlhash); -- fail_if(mlhash->type == NULL); -- fail_if(strcmp(mlhash->type, "sha512")); -- fail_if(mlhash->value == NULL); -- fail_if(strcmp(mlhash->value, -- "884dc465da67fee8fe3f11dab321a99d9a13b22ce97f84ceff210e82b6b1a8c635ccd196add1dd738807686714c3a0a048897e2d0650bc05302b3ee26de521fd")); -+ ck_assert_ptr_nonnull(mlhash); -+ ck_assert_ptr_nonnull(mlhash->type); -+ ck_assert_str_eq(mlhash->type, "sha512"); -+ ck_assert_ptr_nonnull(mlhash->value); -+ ck_assert_str_eq(mlhash->value, -+ "884dc465da67fee8fe3f11dab321a99d9a13b22ce97f84ceff210e82b6b1a8c635ccd196add1dd738807686714c3a0a048897e2d0650bc05302b3ee26de521fd"); - - elem = g_slist_nth(ml->urls, 0); -- fail_if(!elem); -+ ck_assert_ptr_nonnull(elem); - mlurl = elem->data; -- fail_if(!mlurl); -- fail_if(mlurl->protocol == NULL); -- fail_if(strcmp(mlurl->protocol, "http")); -- fail_if(mlurl->type == NULL); -- fail_if(strcmp(mlurl->type, "http")); -- fail_if(mlurl->location == NULL); -- fail_if(strcmp(mlurl->location, "US")); -- fail_if(mlurl->preference != 0); -- fail_if(mlurl->url == NULL); -- fail_if(strcmp(mlurl->url, -- "http://mirror.pnl.gov/fedora/linux/releases/17/Everything/x86_64/os/repodata/repomd.xml")); -+ ck_assert_ptr_nonnull(mlurl); -+ ck_assert_ptr_nonnull(mlurl->protocol); -+ ck_assert_str_eq(mlurl->protocol, "http"); -+ ck_assert_ptr_nonnull(mlurl->type); -+ ck_assert_str_eq(mlurl->type, "http"); -+ ck_assert_ptr_nonnull(mlurl->location); -+ ck_assert_str_eq(mlurl->location, "US"); -+ ck_assert(mlurl->preference == 0); -+ ck_assert_ptr_nonnull(mlurl->url); -+ ck_assert_str_eq(mlurl->url, -+ "http://mirror.pnl.gov/fedora/linux/releases/17/Everything/x86_64/os/repodata/repomd.xml"); - - elem = g_slist_nth(ml->urls, 1); -- fail_if(!elem); -+ ck_assert_ptr_nonnull(elem); - mlurl = elem->data; -- fail_if(!mlurl); -- fail_if(mlurl->protocol != NULL); -- fail_if(mlurl->type != NULL); -- fail_if(mlurl->location != NULL); -- fail_if(mlurl->preference < 0 || mlurl->preference > 100); -- fail_if(mlurl->url == NULL); -- fail_if(strcmp(mlurl->url, -- "ftp://mirrors.syringanetworks.net/fedora/releases/17/Everything/x86_64/os/repodata/repomd.xml")); -+ ck_assert_ptr_nonnull(mlurl); -+ ck_assert_ptr_null(mlurl->protocol); -+ ck_assert_ptr_null(mlurl->type); -+ ck_assert_ptr_null(mlurl->location); -+ ck_assert(mlurl->preference >= 0 && mlurl->preference <= 100); -+ ck_assert_ptr_nonnull(mlurl->url); -+ ck_assert_str_eq(mlurl->url, -+ "ftp://mirrors.syringanetworks.net/fedora/releases/17/Everything/x86_64/os/repodata/repomd.xml"); - - elem = g_slist_nth(ml->urls, 2); -- fail_if(!elem); -+ ck_assert_ptr_nonnull(elem); - mlurl = elem->data; -- fail_if(!mlurl); -- fail_if(mlurl->protocol != NULL); -- fail_if(mlurl->type != NULL); -- fail_if(mlurl->location != NULL); -- fail_if(mlurl->preference != 0); -- fail_if(mlurl->url == NULL); -- fail_if(strcmp(mlurl->url, -- "rsync://mirrors.syringanetworks.net/fedora/releases/17/Everything/x86_64/os/repodata/repomd.xml")); -+ ck_assert_ptr_nonnull(mlurl); -+ ck_assert_ptr_null(mlurl->protocol); -+ ck_assert_ptr_null(mlurl->type); -+ ck_assert_ptr_null(mlurl->location); -+ ck_assert(mlurl->preference == 0); -+ ck_assert_ptr_nonnull(mlurl->url); -+ ck_assert_str_eq(mlurl->url, -+ "rsync://mirrors.syringanetworks.net/fedora/releases/17/Everything/x86_64/os/repodata/repomd.xml"); - - elem = g_slist_nth(ml->urls, 3); -- fail_if(!elem); -+ ck_assert_ptr_nonnull(elem); - mlurl = elem->data; -- fail_if(!mlurl); -- fail_if(mlurl->protocol != NULL); -- fail_if(mlurl->type != NULL); -- fail_if(mlurl->location != NULL); -- fail_if(mlurl->preference != 0); -- fail_if(mlurl->url == NULL); -- fail_if(strcmp(mlurl->url, "")); -+ ck_assert_ptr_nonnull(mlurl); -+ ck_assert_ptr_null(mlurl->protocol); -+ ck_assert_ptr_null(mlurl->type); -+ ck_assert_ptr_null(mlurl->location); -+ ck_assert(mlurl->preference == 0); -+ ck_assert_ptr_nonnull(mlurl->url); -+ ck_assert_str_eq(mlurl->url, ""); - - lr_metalink_free(ml); - } -@@ -374,14 +372,14 @@ START_TEST(test_metalink_bad_02) - "metalink_bad_02", NULL); - fd = open(path, O_RDONLY); - lr_free(path); -- fail_if(fd < 0); -+ ck_assert_int_ge(fd, 0); - ml = lr_metalink_init(); -- fail_if(ml == NULL); -+ ck_assert_ptr_nonnull(ml); - ret = lr_metalink_parse_file(ml, fd, REPOMD, NULL, NULL, &tmp_err); -- fail_if(!ret); -- fail_if(tmp_err); -+ ck_assert(ret); -+ ck_assert_ptr_null(tmp_err); - close(fd); -- fail_if(g_slist_length(ml->urls) != 0); -+ ck_assert(g_slist_length(ml->urls) == 0); - lr_metalink_free(ml); - } - END_TEST -@@ -398,12 +396,12 @@ START_TEST(test_metalink_really_bad_01) - "metalink_really_bad_01", NULL); - fd = open(path, O_RDONLY); - lr_free(path); -- fail_if(fd < 0); -+ ck_assert_int_ge(fd, 0); - ml = lr_metalink_init(); -- fail_if(ml == NULL); -+ ck_assert_ptr_nonnull(ml); - ret = lr_metalink_parse_file(ml, fd, REPOMD, NULL, NULL, &tmp_err); -- fail_if(ret); -- fail_if(!tmp_err); -+ ck_assert(!ret); -+ ck_assert_ptr_nonnull(tmp_err); - g_error_free(tmp_err); - close(fd); - lr_metalink_free(ml); -@@ -422,12 +420,12 @@ START_TEST(test_metalink_really_bad_02) - "metalink_really_bad_02", NULL); - fd = open(path, O_RDONLY); - lr_free(path); -- fail_if(fd < 0); -+ ck_assert_int_ge(fd, 0); - ml = lr_metalink_init(); -- fail_if(ml == NULL); -+ ck_assert_ptr_nonnull(ml); - ret = lr_metalink_parse_file(ml, fd, REPOMD, NULL, NULL, &tmp_err); -- fail_if(ret); -- fail_if(!tmp_err); -+ ck_assert(!ret); -+ ck_assert_ptr_nonnull(tmp_err); - g_error_free(tmp_err); - close(fd); - lr_metalink_free(ml); -@@ -446,12 +444,12 @@ START_TEST(test_metalink_really_bad_03) - "metalink_really_bad_03", NULL); - fd = open(path, O_RDONLY); - lr_free(path); -- fail_if(fd < 0); -+ ck_assert_int_ge(fd, 0); - ml = lr_metalink_init(); -- fail_if(ml == NULL); -+ ck_assert_ptr_nonnull(ml); - ret = lr_metalink_parse_file(ml, fd, REPOMD, NULL, NULL, &tmp_err); -- fail_if(ret); -- fail_if(!tmp_err); -+ ck_assert(!ret); -+ ck_assert_ptr_nonnull(tmp_err); - g_error_free(tmp_err); - close(fd); - lr_metalink_free(ml); -@@ -473,41 +471,41 @@ START_TEST(test_metalink_with_alternates) - "metalink_with_alternates", NULL); - fd = open(path, O_RDONLY); - lr_free(path); -- fail_if(fd < 0); -+ ck_assert_int_ge(fd, 0); - ml = lr_metalink_init(); -- fail_if(ml == NULL); -+ ck_assert_ptr_nonnull(ml); - ret = lr_metalink_parse_file(ml, fd, REPOMD, NULL, NULL, &tmp_err); -- fail_if(!ret); -- fail_if(tmp_err); -+ ck_assert(ret); -+ ck_assert_ptr_null(tmp_err); - close(fd); - -- fail_if(ml->filename == NULL); -- fail_if(strcmp(ml->filename, "repomd.xml")); -- fail_if(g_slist_length(ml->hashes) != 4); -- fail_if(g_slist_length(ml->alternates) != 1); -+ ck_assert_ptr_nonnull(ml->filename); -+ ck_assert_str_eq(ml->filename, "repomd.xml"); -+ ck_assert(g_slist_length(ml->hashes) == 4); -+ ck_assert(g_slist_length(ml->alternates) == 1); - - elem = g_slist_nth(ml->hashes, 0); -- fail_if(!elem); -+ ck_assert_ptr_nonnull(elem); - mlhash = elem->data; -- fail_if(!mlhash); -- fail_if(mlhash->type == NULL); -- fail_if(strcmp(mlhash->type, "md5")); -- fail_if(mlhash->value == NULL); -- fail_if(strcmp(mlhash->value, "0ffcd7798421c9a6760f3e4202cc4675")); -+ ck_assert_ptr_nonnull(mlhash); -+ ck_assert_ptr_nonnull(mlhash->type); -+ ck_assert_str_eq(mlhash->type, "md5"); -+ ck_assert_ptr_nonnull(mlhash->value); -+ ck_assert_str_eq(mlhash->value, "0ffcd7798421c9a6760f3e4202cc4675"); - - elem = g_slist_nth(ml->alternates, 0); -- fail_if(!elem); -+ ck_assert_ptr_nonnull(elem); - malternate = elem->data; -- fail_if(malternate->timestamp != 1381706941); -- fail_if(malternate->size != 4761); -- fail_if(g_slist_length(malternate->hashes) != 4); -+ ck_assert(malternate->timestamp == 1381706941); -+ ck_assert(malternate->size == 4761); -+ ck_assert(g_slist_length(malternate->hashes) == 4); - elem = g_slist_nth(malternate->hashes, 0); - mlhash = elem->data; -- fail_if(!mlhash); -- fail_if(mlhash->type == NULL); -- fail_if(strcmp(mlhash->type, "md5")); -- fail_if(mlhash->value == NULL); -- fail_if(strcmp(mlhash->value, "0c5b64d395d5364633df7c8e97a07fd6")); -+ ck_assert_ptr_nonnull(mlhash); -+ ck_assert_ptr_nonnull(mlhash->type); -+ ck_assert_str_eq(mlhash->type, "md5"); -+ ck_assert_ptr_nonnull(mlhash->value); -+ ck_assert_str_eq(mlhash->value, "0c5b64d395d5364633df7c8e97a07fd6"); - - lr_metalink_free(ml); - } -diff --git a/tests/test_mirrorlist.c b/tests/test_mirrorlist.c -index 6ccf2537..cc00b7fc 100644 ---- a/tests/test_mirrorlist.c -+++ b/tests/test_mirrorlist.c -@@ -18,7 +18,7 @@ START_TEST(test_mirrorlist_init) - LrMirrorlist *ml = NULL; - - ml = lr_mirrorlist_init(); -- fail_if(ml == NULL); -+ ck_assert_ptr_nonnull(ml); - lr_mirrorlist_free(ml); - } - END_TEST -@@ -36,23 +36,23 @@ START_TEST(test_mirrorlist_01) - "mirrorlist_01", NULL); - fd = open(path, O_RDONLY); - lr_free(path); -- fail_if(fd < 0); -+ ck_assert_int_ge(fd, 0); - ml = lr_mirrorlist_init(); -- fail_if(ml == NULL); -+ ck_assert_ptr_nonnull(ml); - ret = lr_mirrorlist_parse_file(ml, fd, &tmp_err); - close(fd); -- fail_if(!ret); -- fail_if(tmp_err); -+ ck_assert(ret); -+ ck_assert_ptr_null(tmp_err); - -- fail_if(g_slist_length(ml->urls) != 2); -+ ck_assert(g_slist_length(ml->urls) == 2); - - elem = g_slist_nth(ml->urls, 0); -- fail_if(!elem); -- fail_if(g_strcmp0(elem->data, "http://foo.bar/fedora/linux/")); -+ ck_assert_ptr_nonnull(elem); -+ ck_assert_str_eq(elem->data, "http://foo.bar/fedora/linux/"); - - elem = g_slist_nth(ml->urls, 1); -- fail_if(!elem); -- fail_if(g_strcmp0(elem->data, "ftp://ftp.bar.foo/Fedora/17/")); -+ ck_assert_ptr_nonnull(elem); -+ ck_assert_str_eq(elem->data, "ftp://ftp.bar.foo/Fedora/17/"); - lr_mirrorlist_free(ml); - } - END_TEST -@@ -69,14 +69,14 @@ START_TEST(test_mirrorlist_02) - "mirrorlist_02", NULL); - fd = open(path, O_RDONLY); - lr_free(path); -- fail_if(fd < 0); -+ ck_assert_int_ge(fd, 0); - ml = lr_mirrorlist_init(); -- fail_if(ml == NULL); -+ ck_assert_ptr_nonnull(ml); - ret = lr_mirrorlist_parse_file(ml, fd, &tmp_err); - close(fd); -- fail_if(!ret); -- fail_if(tmp_err); -- fail_if(g_slist_length(ml->urls) != 0); -+ ck_assert(ret); -+ ck_assert_ptr_null(tmp_err); -+ ck_assert(g_slist_length(ml->urls) == 0); - lr_mirrorlist_free(ml); - } - END_TEST -@@ -93,14 +93,14 @@ START_TEST(test_mirrorlist_03) - "mirrorlist_03", NULL); - fd = open(path, O_RDONLY); - lr_free(path); -- fail_if(fd < 0); -+ ck_assert_int_ge(fd, 0); - ml = lr_mirrorlist_init(); -- fail_if(ml == NULL); -+ ck_assert_ptr_nonnull(ml); - ret = lr_mirrorlist_parse_file(ml, fd, &tmp_err); - close(fd); -- fail_if(!ret); -- fail_if(tmp_err); -- fail_if(g_slist_length(ml->urls) != 0); -+ ck_assert(ret); -+ ck_assert_ptr_null(tmp_err); -+ ck_assert(g_slist_length(ml->urls) == 0); - lr_mirrorlist_free(ml); - } - END_TEST -diff --git a/tests/test_package_downloader.c b/tests/test_package_downloader.c -index b384bef8..3263ba02 100644 ---- a/tests/test_package_downloader.c -+++ b/tests/test_package_downloader.c -@@ -25,19 +25,19 @@ START_TEST(test_package_downloader_new_and_free) - - target = lr_packagetarget_new(NULL, "url", NULL, 0, NULL, 0, NULL, FALSE, - NULL, NULL, &err); -- fail_if(!target); -- fail_if(err); -+ ck_assert_ptr_nonnull(target); -+ ck_assert_ptr_null(err); - -- fail_if(strcmp(target->relative_url, "url")); -- fail_if(target->dest); -- fail_if(target->base_url); -- fail_if(target->checksum_type != 0); -- fail_if(target->checksum); -- fail_if(target->resume != FALSE); -- fail_if(target->progresscb); -- fail_if(target->cbdata); -- fail_if(target->local_path); -- fail_if(target->err); -+ ck_assert_str_eq(target->relative_url, "url"); -+ ck_assert_ptr_null(target->dest); -+ ck_assert_ptr_null(target->base_url); -+ ck_assert(target->checksum_type == 0); -+ ck_assert_ptr_null(target->checksum); -+ ck_assert(target->resume == FALSE); -+ ck_assert(!target->progresscb); -+ ck_assert_ptr_null(target->cbdata); -+ ck_assert_ptr_null(target->local_path); -+ ck_assert_ptr_null(target->err); - - lr_packagetarget_free(target); - target = NULL; -@@ -47,19 +47,19 @@ START_TEST(test_package_downloader_new_and_free) - target = lr_packagetarget_new(NULL, "url", "dest", LR_CHECKSUM_SHA384, - "xxx", 0, "baseurl", TRUE, (LrProgressCb) 22, - (void *) 33, &err); -- fail_if(!target); -- fail_if(err); -+ ck_assert_ptr_nonnull(target); -+ ck_assert_ptr_null(err); - -- fail_if(strcmp(target->relative_url, "url")); -- fail_if(strcmp(target->dest, "dest")); -- fail_if(strcmp(target->base_url, "baseurl")); -- fail_if(target->checksum_type != LR_CHECKSUM_SHA384); -- fail_if(strcmp(target->checksum, "xxx")); -- fail_if(target->resume != TRUE); -- fail_if(target->progresscb != (LrProgressCb) 22); -- fail_if(target->cbdata != (void *) 33); -- fail_if(target->local_path); -- fail_if(target->err); -+ ck_assert_str_eq(target->relative_url, "url"); -+ ck_assert_str_eq(target->dest, "dest"); -+ ck_assert_str_eq(target->base_url, "baseurl"); -+ ck_assert(target->checksum_type == LR_CHECKSUM_SHA384); -+ ck_assert_str_eq(target->checksum, "xxx"); -+ ck_assert(target->resume == TRUE); -+ ck_assert(target->progresscb == (LrProgressCb) 22); -+ ck_assert_ptr_eq(target->cbdata, (void *) 33); -+ ck_assert_ptr_null(target->local_path); -+ ck_assert_ptr_null(target->err); - - lr_packagetarget_free(target); - target = NULL; -diff --git a/tests/test_repo_zck.c b/tests/test_repo_zck.c -index a2299a8d..e68b1442 100644 ---- a/tests/test_repo_zck.c -+++ b/tests/test_repo_zck.c -@@ -23,22 +23,22 @@ START_TEST(test_repo_zck_parsing) - "repo_yum_03/repodata/repomd.xml", - NULL); - repomd = lr_yum_repomd_init(); -- fail_if(!repomd); -+ ck_assert_ptr_nonnull(repomd); - fd = open(repomd_path, O_RDONLY); -- fail_if(fd < 0); -+ ck_assert_int_ge(fd, 0); - - ret = lr_yum_repomd_parse_file(repomd, fd, NULL, NULL, &tmp_err); - close(fd); - -- fail_if(!ret); -- fail_if(tmp_err); -- fail_if(g_slist_length(repomd->records) != 12); -- fail_if(!lr_yum_repomd_get_record(repomd, "primary")); -- fail_if(!lr_yum_repomd_get_record(repomd, "filelists")); -- fail_if(!lr_yum_repomd_get_record(repomd, "other")); -+ ck_assert(ret); -+ ck_assert_ptr_null(tmp_err); -+ ck_assert(g_slist_length(repomd->records) == 12); -+ ck_assert_ptr_nonnull(lr_yum_repomd_get_record(repomd, "primary")); -+ ck_assert_ptr_nonnull(lr_yum_repomd_get_record(repomd, "filelists")); -+ ck_assert_ptr_nonnull(lr_yum_repomd_get_record(repomd, "other")); - -- fail_if(lr_yum_repomd_get_record(repomd, "foo")); -- fail_if(lr_yum_repomd_get_record(repomd, "bar")); -+ ck_assert_ptr_null(lr_yum_repomd_get_record(repomd, "foo")); -+ ck_assert_ptr_null(lr_yum_repomd_get_record(repomd, "bar")); - - lr_yum_repomd_free(repomd); - lr_free(repomd_path); -diff --git a/tests/test_repoconf.c b/tests/test_repoconf.c -index 5c85047e..0036b500 100644 ---- a/tests/test_repoconf.c -+++ b/tests/test_repoconf.c -@@ -304,19 +304,19 @@ START_TEST(test_parse_repoconf_minimal) - path = lr_pathconcat(test_globals.testdata_dir, "repo-minimal.repo", NULL); - - confs = lr_yum_repoconfs_init(); -- fail_if(!confs); -+ ck_assert_ptr_nonnull(confs); - - ret = lr_yum_repoconfs_parse(confs, path, &tmp_err); -- fail_if(!ret); -+ ck_assert(ret); - - list = lr_yum_repoconfs_get_list(confs, &tmp_err); -- fail_if(!list); -- fail_if(g_slist_length(list) != 2); -+ ck_assert_ptr_nonnull(list); -+ ck_assert(g_slist_length(list) == 2); - - // Test content of first repo config - - conf = g_slist_nth_data(list, 0); -- fail_if(!conf); -+ ck_assert_ptr_nonnull(conf); - - conf_assert_str_eq(LR_YRC_ID, "minimal-repo-1"); - conf_assert_str_eq(LR_YRC_NAME, "Minimal repo 1 - $basearch"); -@@ -363,7 +363,7 @@ START_TEST(test_parse_repoconf_minimal) - // Test content of second repo config - - conf = g_slist_nth_data(list, 1); -- fail_if(!conf); -+ ck_assert_ptr_nonnull(conf); - - conf_assert_str_eq(LR_YRC_ID, "minimal-repo-2"); - conf_assert_str_eq(LR_YRC_NAME, "Minimal repo 2 - $basearch"); -@@ -423,17 +423,17 @@ START_TEST(test_parse_repoconf_big) - path = lr_pathconcat(test_globals.testdata_dir, "repo-big.repo", NULL); - - confs = lr_yum_repoconfs_init(); -- fail_if(!confs); -+ ck_assert_ptr_nonnull(confs); - - ret = lr_yum_repoconfs_parse(confs, path, &tmp_err); -- fail_if(!ret); -+ ck_assert(ret); - - list = lr_yum_repoconfs_get_list(confs, &tmp_err); -- fail_if(!list); -- fail_if(g_slist_length(list) != 1); -+ ck_assert_ptr_nonnull(list); -+ ck_assert(g_slist_length(list) == 1); - - conf = g_slist_nth_data(list, 0); -- fail_if(!conf); -+ ck_assert_ptr_nonnull(conf); - - conf_assert_str_eq(LR_YRC_ID, "big-repo"); - conf_assert_str_eq(LR_YRC_NAME, "Maxi repo - $basearch"); -@@ -504,7 +504,7 @@ START_TEST(test_write_repoconf) - - // Create a temporary file - fd = mkstemp(tmpfn); -- fail_if(fd == -1); -+ ck_assert_int_ne(fd, -1); - - // Create reconfs with one repoconf with one id (one section) - confs = lr_yum_repoconfs_init(); -diff --git a/tests/test_repomd.c b/tests/test_repomd.c -index 3dda8337..4c9300d6 100644 ---- a/tests/test_repomd.c -+++ b/tests/test_repomd.c -@@ -23,31 +23,31 @@ START_TEST(test_repomd_parsing) - "repo_yum_02/repodata/repomd.xml", - NULL); - repomd = lr_yum_repomd_init(); -- fail_if(!repomd); -+ ck_assert_ptr_nonnull(repomd); - fd = open(repomd_path, O_RDONLY); -- fail_if(fd < 0); -+ ck_assert_int_ge(fd, 0); - - ret = lr_yum_repomd_parse_file(repomd, fd, NULL, NULL, &tmp_err); - close(fd); - -- fail_if(!ret); -- fail_if(tmp_err); -- fail_if(g_slist_length(repomd->records) != 12); -- fail_if(!lr_yum_repomd_get_record(repomd, "primary")); -- fail_if(!lr_yum_repomd_get_record(repomd, "filelists")); -- fail_if(!lr_yum_repomd_get_record(repomd, "other")); -- fail_if(!lr_yum_repomd_get_record(repomd, "primary_db")); -- fail_if(!lr_yum_repomd_get_record(repomd, "filelists_db")); -- fail_if(!lr_yum_repomd_get_record(repomd, "other_db")); -- fail_if(!lr_yum_repomd_get_record(repomd, "group")); -- fail_if(!lr_yum_repomd_get_record(repomd, "group_gz")); -- fail_if(!lr_yum_repomd_get_record(repomd, "updateinfo")); -- fail_if(!lr_yum_repomd_get_record(repomd, "origin")); -- fail_if(!lr_yum_repomd_get_record(repomd, "prestodelta")); -- fail_if(!lr_yum_repomd_get_record(repomd, "deltainfo")); -+ ck_assert(ret); -+ ck_assert_ptr_null(tmp_err); -+ ck_assert(g_slist_length(repomd->records) == 12); -+ ck_assert_ptr_nonnull(lr_yum_repomd_get_record(repomd, "primary")); -+ ck_assert_ptr_nonnull(lr_yum_repomd_get_record(repomd, "filelists")); -+ ck_assert_ptr_nonnull(lr_yum_repomd_get_record(repomd, "other")); -+ ck_assert_ptr_nonnull(lr_yum_repomd_get_record(repomd, "primary_db")); -+ ck_assert_ptr_nonnull(lr_yum_repomd_get_record(repomd, "filelists_db")); -+ ck_assert_ptr_nonnull(lr_yum_repomd_get_record(repomd, "other_db")); -+ ck_assert_ptr_nonnull(lr_yum_repomd_get_record(repomd, "group")); -+ ck_assert_ptr_nonnull(lr_yum_repomd_get_record(repomd, "group_gz")); -+ ck_assert_ptr_nonnull(lr_yum_repomd_get_record(repomd, "updateinfo")); -+ ck_assert_ptr_nonnull(lr_yum_repomd_get_record(repomd, "origin")); -+ ck_assert_ptr_nonnull(lr_yum_repomd_get_record(repomd, "prestodelta")); -+ ck_assert_ptr_nonnull(lr_yum_repomd_get_record(repomd, "deltainfo")); - -- fail_if(lr_yum_repomd_get_record(repomd, "foo")); -- fail_if(lr_yum_repomd_get_record(repomd, "bar")); -+ ck_assert_ptr_null(lr_yum_repomd_get_record(repomd, "foo")); -+ ck_assert_ptr_null(lr_yum_repomd_get_record(repomd, "bar")); - - lr_yum_repomd_free(repomd); - lr_free(repomd_path); -diff --git a/tests/test_url_substitution.c b/tests/test_url_substitution.c -index e3d53a79..b0086a8c 100644 ---- a/tests/test_url_substitution.c -+++ b/tests/test_url_substitution.c -@@ -20,22 +20,22 @@ START_TEST(test_urlvars_set) - LrUrlVars *urlvars = NULL; - - urlvars = lr_urlvars_set(urlvars, "foo", "bar"); -- fail_if(urlvars == NULL); -- fail_if(strcmp(((LrVar *)urlvars->data)->var, "foo") != 0); -+ ck_assert_ptr_nonnull(urlvars); -+ ck_assert_str_eq(((LrVar *)urlvars->data)->var, "foo"); - - urlvars = lr_urlvars_set(urlvars, "foo1", "bar1"); -- fail_if(urlvars == NULL); -+ ck_assert_ptr_nonnull(urlvars); - - urlvars = lr_urlvars_set(urlvars, "foo", NULL); -- fail_if(urlvars == NULL); -- fail_if(strcmp(((LrVar *)urlvars->data)->var, "foo1") != 0); -+ ck_assert_ptr_nonnull(urlvars); -+ ck_assert_str_eq(((LrVar *)urlvars->data)->var, "foo1"); - - urlvars = lr_urlvars_set(urlvars, "foo1", NULL); -- fail_if(urlvars != NULL); -+ ck_assert_ptr_null(urlvars); - - urlvars = lr_urlvars_set(urlvars, "bar", "foo"); -- fail_if(urlvars == NULL); -- fail_if(strcmp(((LrVar *)urlvars->data)->var, "bar") != 0); -+ ck_assert_ptr_nonnull(urlvars); -+ ck_assert_str_eq(((LrVar *)urlvars->data)->var, "bar"); - - lr_urlvars_free(urlvars); - } -@@ -49,19 +49,19 @@ START_TEST(test_url_substitute_without_urlvars) - urlvars = lr_urlvars_set(urlvars, "foo", "bar"); - - url = lr_url_substitute("", urlvars); -- fail_if(strcmp(url, "")); -+ ck_assert_str_eq(url, ""); - lr_free(url); - - url = lr_url_substitute("http://foo", urlvars); -- fail_if(strcmp(url, "http://foo")); -+ ck_assert_str_eq(url, "http://foo"); - lr_free(url); - - url = lr_url_substitute("http://foo?id=$bar", urlvars); -- fail_if(strcmp(url, "http://foo?id=$bar")); -+ ck_assert_str_eq(url, "http://foo?id=$bar"); - lr_free(url); - - url = lr_url_substitute("http://foo?id=$foox", urlvars); -- fail_if(strcmp(url, "http://foo?id=$foox")); -+ ck_assert_str_eq(url, "http://foo?id=$foox"); - lr_free(url); - - lr_urlvars_free(urlvars); -@@ -78,31 +78,31 @@ START_TEST(test_url_substitute) - urlvars = lr_urlvars_set(urlvars, "bar", "repo"); - - url = lr_url_substitute("", urlvars); -- fail_if(strcmp(url, "")); -+ ck_assert_str_eq(url, ""); - lr_free(url); - - url = lr_url_substitute("http://foo", urlvars); -- fail_if(strcmp(url, "http://foo")); -+ ck_assert_str_eq(url, "http://foo"); - lr_free(url); - - url = lr_url_substitute("http://foo?id=$bar", urlvars); -- fail_if(strcmp(url, "http://foo?id=repo")); -+ ck_assert_str_eq(url, "http://foo?id=repo"); - lr_free(url); - - url = lr_url_substitute("http://$foo?id=$bar", urlvars); -- fail_if(strcmp(url, "http://version?id=repo")); -+ ck_assert_str_eq(url, "http://version?id=repo"); - lr_free(url); - - url = lr_url_substitute("http://$fo?id=$bar", urlvars); -- fail_if(strcmp(url, "http://ver?id=repo")); -+ ck_assert_str_eq(url, "http://ver?id=repo"); - lr_free(url); - - url = lr_url_substitute("http://$foo$bar", urlvars); -- fail_if(strcmp(url, "http://versionrepo")); -+ ck_assert_str_eq(url, "http://versionrepo"); - lr_free(url); - - url = lr_url_substitute("http://$foo$bar/", urlvars); -- fail_if(strcmp(url, "http://versionrepo/")); -+ ck_assert_str_eq(url, "http://versionrepo/"); - lr_free(url); - - lr_urlvars_free(urlvars); -@@ -119,27 +119,27 @@ START_TEST(test_url_substitute_braces) - urlvars = lr_urlvars_set(urlvars, "bar", "repo"); - - url = lr_url_substitute("http://foo?id=${bar}", urlvars); -- fail_if(strcmp(url, "http://foo?id=repo")); -+ ck_assert_str_eq(url, "http://foo?id=repo"); - lr_free(url); - - url = lr_url_substitute("http://${foo}?id=${bar}", urlvars); -- fail_if(strcmp(url, "http://version?id=repo")); -+ ck_assert_str_eq(url, "http://version?id=repo"); - lr_free(url); - - url = lr_url_substitute("http://${fo}?id=$bar", urlvars); -- fail_if(strcmp(url, "http://ver?id=repo")); -+ ck_assert_str_eq(url, "http://ver?id=repo"); - lr_free(url); - - url = lr_url_substitute("http://${fo?id=$bar", urlvars); -- fail_if(strcmp(url, "http://${fo?id=repo")); -+ ck_assert_str_eq(url, "http://${fo?id=repo"); - lr_free(url); - - url = lr_url_substitute("http://${foo${bar}", urlvars); -- fail_if(strcmp(url, "http://${foorepo")); -+ ck_assert_str_eq(url, "http://${foorepo"); - lr_free(url); - - url = lr_url_substitute("http://${foo}${bar}/", urlvars); -- fail_if(strcmp(url, "http://versionrepo/")); -+ ck_assert_str_eq(url, "http://versionrepo/"); - lr_free(url); - - lr_urlvars_free(urlvars); -diff --git a/tests/test_util.c b/tests/test_util.c -index b3b2b6dd..595b0fef 100644 ---- a/tests/test_util.c -+++ b/tests/test_util.c -@@ -18,7 +18,7 @@ START_TEST(test_malloc) - { - long long *num = NULL; - num = lr_malloc0(sizeof(long long)); -- fail_if(num == NULL); -+ ck_assert_ptr_nonnull(num); - lr_free(num); - } - END_TEST -@@ -27,8 +27,8 @@ START_TEST(test_malloc0) - { - long long *num = NULL; - num = lr_malloc0(sizeof(long long)); -- fail_if(num == NULL); -- fail_if(*num != 0LL); -+ ck_assert_ptr_nonnull(num); -+ ck_assert(*num == 0LL); - lr_free(num); - } - END_TEST -@@ -44,7 +44,7 @@ START_TEST(test_gettmpfile) - { - int fd = 0; - fd = lr_gettmpfile(); -- fail_if(fd < 0); -+ ck_assert_int_ge(fd, 0); - close(fd); - } - END_TEST -@@ -52,8 +52,8 @@ END_TEST - START_TEST(test_gettmpdir) - { - char *tmp_dir = lr_gettmpdir(); -- fail_if(tmp_dir == NULL); -- fail_if(rmdir(tmp_dir) != 0); -+ ck_assert_ptr_nonnull(tmp_dir); -+ ck_assert_int_eq(rmdir(tmp_dir), 0); - lr_free(tmp_dir); - } - END_TEST -@@ -63,47 +63,47 @@ START_TEST(test_pathconcat) - char *path = NULL; - - path = lr_pathconcat(NULL, NULL); -- fail_if(path != NULL); -+ ck_assert_ptr_null(path); - - path = lr_pathconcat("", NULL); -- fail_if(path == NULL); -- fail_if(strcmp(path, "")); -+ ck_assert_ptr_nonnull(path); -+ ck_assert_str_eq(path, ""); - lr_free(path); - path = NULL; - - path = lr_pathconcat("/tmp", "foo///", "bar", NULL); -- fail_if(path == NULL); -- fail_if(strcmp(path, "/tmp/foo/bar")); -+ ck_assert_ptr_nonnull(path); -+ ck_assert_str_eq(path, "/tmp/foo/bar"); - lr_free(path); - path = NULL; - - path = lr_pathconcat("foo", "bar/", NULL); -- fail_if(path == NULL); -- fail_if(strcmp(path, "foo/bar")); -+ ck_assert_ptr_nonnull(path); -+ ck_assert_str_eq(path, "foo/bar"); - lr_free(path); - path = NULL; - - path = lr_pathconcat("foo", "/bar/", NULL); -- fail_if(path == NULL); -- fail_if(strcmp(path, "foo/bar")); -+ ck_assert_ptr_nonnull(path); -+ ck_assert_str_eq(path, "foo/bar"); - lr_free(path); - path = NULL; - - path = lr_pathconcat("foo", "bar", "", NULL); -- fail_if(path == NULL); -- fail_if(strcmp(path, "foo/bar/")); -+ ck_assert_ptr_nonnull(path); -+ ck_assert_str_eq(path, "foo/bar/"); - lr_free(path); - path = NULL; - - path = lr_pathconcat("http://host.net", "path/to/somewhere", NULL); -- fail_if(path == NULL); -- fail_if(strcmp(path, "http://host.net/path/to/somewhere")); -+ ck_assert_ptr_nonnull(path); -+ ck_assert_str_eq(path, "http://host.net/path/to/somewhere"); - lr_free(path); - path = NULL; - - path = lr_pathconcat("http://host.net?hello=1", "path/to/", "somewhere", NULL); -- fail_if(path == NULL); -- fail_if(strcmp(path, "http://host.net/path/to/somewhere?hello=1")); -+ ck_assert_ptr_nonnull(path); -+ ck_assert_str_eq(path, "http://host.net/path/to/somewhere?hello=1"); - lr_free(path); - path = NULL; - } -@@ -116,16 +116,16 @@ START_TEST(test_remove_dir) - int fd, rc; - - tmp_dir = lr_gettmpdir(); -- fail_if(tmp_dir == NULL); -+ ck_assert_ptr_nonnull(tmp_dir); - tmp_file = lr_pathconcat(tmp_dir, "file_a", NULL); - fd = open(tmp_file, O_CREAT|O_TRUNC|O_RDWR, 0660); -- fail_if(fd < 0); -+ ck_assert_int_ge(fd, 0); - close(fd); - - rc = lr_remove_dir(tmp_dir); -- fail_if(rc != 0); -- fail_if(unlink(tmp_file) == 0); -- fail_if(rmdir(tmp_dir) == 0); -+ ck_assert_int_eq(rc, 0); -+ ck_assert_int_ne(unlink(tmp_file), 0); -+ ck_assert_int_ne(rmdir(tmp_dir), 0); - lr_free(tmp_dir); - lr_free(tmp_file); - } -@@ -136,65 +136,65 @@ START_TEST(test_url_without_path) - char *new_url = NULL; - - new_url = lr_url_without_path(NULL); -- fail_if(new_url != NULL); -+ ck_assert_ptr_null(new_url); - - new_url = lr_url_without_path(""); -- fail_if(new_url == NULL); -- fail_if(strcmp(new_url, "")); -+ ck_assert_ptr_nonnull(new_url); -+ ck_assert_str_eq(new_url, ""); - lr_free(new_url); - new_url = NULL; - - new_url = lr_url_without_path("hostname"); -- fail_if(new_url == NULL); -- fail_if(strcmp(new_url, "hostname")); -+ ck_assert_ptr_nonnull(new_url); -+ ck_assert_str_eq(new_url, "hostname"); - lr_free(new_url); - new_url = NULL; - - new_url = lr_url_without_path("hostname/foo/bar/"); -- fail_if(new_url == NULL); -- fail_if(strcmp(new_url, "hostname")); -+ ck_assert_ptr_nonnull(new_url); -+ ck_assert_str_eq(new_url, "hostname"); - lr_free(new_url); - new_url = NULL; - - new_url = lr_url_without_path("hostname:80"); -- fail_if(new_url == NULL); -- fail_if(strcmp(new_url, "hostname:80")); -+ ck_assert_ptr_nonnull(new_url); -+ ck_assert_str_eq(new_url, "hostname:80"); - lr_free(new_url); - new_url = NULL; - - new_url = lr_url_without_path("hostname:80/foo/bar"); -- fail_if(new_url == NULL); -- fail_if(strcmp(new_url, "hostname:80")); -+ ck_assert_ptr_nonnull(new_url); -+ ck_assert_str_eq(new_url, "hostname:80"); - lr_free(new_url); - new_url = NULL; - - new_url = lr_url_without_path("http://hostname:80/"); -- fail_if(new_url == NULL); -- fail_if(strcmp(new_url, "http://hostname:80")); -+ ck_assert_ptr_nonnull(new_url); -+ ck_assert_str_eq(new_url, "http://hostname:80"); - lr_free(new_url); - new_url = NULL; - - new_url = lr_url_without_path("http://hostname:80/foo/bar"); -- fail_if(new_url == NULL); -- fail_if(strcmp(new_url, "http://hostname:80")); -+ ck_assert_ptr_nonnull(new_url); -+ ck_assert_str_eq(new_url, "http://hostname:80"); - lr_free(new_url); - new_url = NULL; - - new_url = lr_url_without_path("ftp://foo.hostname:80/foo/bar"); -- fail_if(new_url == NULL); -- fail_if(strcmp(new_url, "ftp://foo.hostname:80")); -+ ck_assert_ptr_nonnull(new_url); -+ ck_assert_str_eq(new_url, "ftp://foo.hostname:80"); - lr_free(new_url); - new_url = NULL; - - new_url = lr_url_without_path("file:///home/foobar"); -- fail_if(new_url == NULL); -- fail_if(strcmp(new_url, "file://")); -+ ck_assert_ptr_nonnull(new_url); -+ ck_assert_str_eq(new_url, "file://"); - lr_free(new_url); - new_url = NULL; - - new_url = lr_url_without_path("file:/home/foobar"); -- fail_if(new_url == NULL); -- fail_if(strcmp(new_url, "file://")); -+ ck_assert_ptr_nonnull(new_url); -+ ck_assert_str_eq(new_url, "file://"); - lr_free(new_url); - new_url = NULL; - } -@@ -209,39 +209,39 @@ START_TEST(test_strv_dup) - gchar **copy = NULL; - - copy = lr_strv_dup(in0); -- fail_if(copy != NULL); -+ ck_assert_ptr_null(copy); - - copy = lr_strv_dup(in1); -- fail_if(!copy); -- fail_if(copy == in1); -- fail_if(copy[0] != NULL); -+ ck_assert(copy); -+ ck_assert_ptr_ne(copy, in1); -+ ck_assert_ptr_null(copy[0]); - g_strfreev(copy); - - copy = lr_strv_dup(in2); -- fail_if(!copy); -- fail_if(copy == in2); -- fail_if(g_strcmp0(copy[0], "foo")); -- fail_if(copy[0] == in2[0]); -- fail_if(copy[1] != NULL); -+ ck_assert(copy); -+ ck_assert_ptr_ne(copy, in2); -+ ck_assert_str_eq(copy[0], "foo"); -+ ck_assert_ptr_ne(copy[0], in2[0]); -+ ck_assert_ptr_null(copy[1]); - g_strfreev(copy); - } - END_TEST - - START_TEST(test_is_local_path) - { -- fail_if(!lr_is_local_path("/tmp")); -- fail_if(!lr_is_local_path("foo/bar")); -- fail_if(!lr_is_local_path("bar")); -- fail_if(!lr_is_local_path("/")); -- fail_if(!lr_is_local_path("file:///tmp")); -- fail_if(!lr_is_local_path("file:/tmp")); -- -- fail_if(lr_is_local_path(NULL)); -- fail_if(lr_is_local_path("")); -- fail_if(lr_is_local_path("http://foo.bar")); -- fail_if(lr_is_local_path("https://foo.bar/x")); -- fail_if(lr_is_local_path("ftp://foo.bar/foobar")); -- fail_if(lr_is_local_path("rsync://xyz")); -+ ck_assert(lr_is_local_path("/tmp")); -+ ck_assert(lr_is_local_path("foo/bar")); -+ ck_assert(lr_is_local_path("bar")); -+ ck_assert(lr_is_local_path("/")); -+ ck_assert(lr_is_local_path("file:///tmp")); -+ ck_assert(lr_is_local_path("file:/tmp")); -+ -+ ck_assert(!lr_is_local_path(NULL)); -+ ck_assert(!lr_is_local_path("")); -+ ck_assert(!lr_is_local_path("http://foo.bar")); -+ ck_assert(!lr_is_local_path("https://foo.bar/x")); -+ ck_assert(!lr_is_local_path("ftp://foo.bar/foobar")); -+ ck_assert(!lr_is_local_path("rsync://xyz")); - } - END_TEST - -@@ -250,19 +250,19 @@ START_TEST(test_prepend_url_protocol) - gchar *url = NULL; - - url = lr_prepend_url_protocol("/tmp"); -- fail_if(g_strcmp0(url, "file:///tmp")); -+ ck_assert_str_eq(url, "file:///tmp"); - g_free(url); - - url = lr_prepend_url_protocol("file:///tmp"); -- fail_if(g_strcmp0(url, "file:///tmp")); -+ ck_assert_str_eq(url, "file:///tmp"); - g_free(url); - - url = lr_prepend_url_protocol("http://tmp"); -- fail_if(g_strcmp0(url, "http://tmp")); -+ ck_assert_str_eq(url, "http://tmp"); - g_free(url); - - url = lr_prepend_url_protocol("file:/tmp"); -- fail_if(g_strcmp0(url, "file:/tmp")); -+ ck_assert_str_eq(url, "file:/tmp"); - g_free(url); - } - END_TEST -diff --git a/tests/test_version.c b/tests/test_version.c -index 235b4c6e..96e6ec69 100644 ---- a/tests/test_version.c -+++ b/tests/test_version.c -@@ -10,23 +10,23 @@ - - START_TEST(test_version_check_macro) - { -- fail_if(!(LR_VERSION_CHECK(LR_VERSION_MAJOR, -+ ck_assert(LR_VERSION_CHECK(LR_VERSION_MAJOR, - LR_VERSION_MINOR, -- LR_VERSION_PATCH))); -+ LR_VERSION_PATCH)); - -- fail_if(!(LR_VERSION_CHECK(0, 0, 0))); -+ ck_assert(LR_VERSION_CHECK(0, 0, 0)); - -- fail_if(LR_VERSION_CHECK(LR_VERSION_MAJOR, -- LR_VERSION_MINOR, -- LR_VERSION_PATCH+1)); -+ ck_assert(!(LR_VERSION_CHECK(LR_VERSION_MAJOR, -+ LR_VERSION_MINOR, -+ LR_VERSION_PATCH+1))); - -- fail_if(LR_VERSION_CHECK(LR_VERSION_MAJOR, -- LR_VERSION_MINOR+1, -- LR_VERSION_PATCH)); -+ ck_assert(!(LR_VERSION_CHECK(LR_VERSION_MAJOR, -+ LR_VERSION_MINOR+1, -+ LR_VERSION_PATCH))); - -- fail_if(LR_VERSION_CHECK(LR_VERSION_MAJOR+1, -- LR_VERSION_MINOR, -- LR_VERSION_PATCH)); -+ ck_assert(!(LR_VERSION_CHECK(LR_VERSION_MAJOR+1, -+ LR_VERSION_MINOR, -+ LR_VERSION_PATCH))); - } - END_TEST - diff --git a/librepo.spec b/librepo.spec index 3ef211c..5992046 100644 --- a/librepo.spec +++ b/librepo.spec @@ -11,17 +11,13 @@ %global dnf_conflict 2.8.8 Name: librepo -Version: 1.14.0 -Release: 6%{?dist} +Version: 1.14.2 +Release: 1%{?dist} Summary: Repodata downloading library License: LGPLv2+ URL: https://github.com/rpm-software-management/librepo Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz -Patch1: 0001-Replace-python3-flask-with-httpserver-in-python-tests.patch -Patch2: 0002-Recover-from-fsync-fail-on-read-only-filesystem-RhBu.patch -Patch3: 0003-Covscan-warnings-and-fail_if-deprication.patch -Patch4: 0004-fail_if-and-fail_unless-are-deprecated.patch BuildRequires: cmake BuildRequires: gcc @@ -100,6 +96,11 @@ Python 3 bindings for the librepo library. %{python3_sitearch}/%{name}/ %changelog +* Mon Oct 25 2021 Pavla Kratochvilova - 1.14.2-1 +- Update to 1.14.2 +- Reduce time to load metadata +- Fix resource leaks and memory leaks + * Mon Aug 09 2021 Mohan Boddu - 1.14.0-6 - Rebuilt for IMA sigs, glibc 2.34, aarch64 flags Related: rhbz#1991688 diff --git a/sources b/sources index 580fd0e..84d4986 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (librepo-1.14.0.tar.gz) = e6c2a98a5c57901ebd16f09fd627daaf45e56a95e1d91bb350f60d3d33ed154d05980f8d4ddba2b7204d2e980f79dc075a741ff1527388f540182ba6a6186c98 +SHA512 (librepo-1.14.2.tar.gz) = cbed7b6ab551366cc9cf9b5e8ac90cfc7395f6e79a1b44b1dcbf1e3ed6edcc644a339cca4efb4560d139355a893d00b6ac1b2e7116478f5bff3c8bfa5fdeb950