Update to 1.14.2

Resolves: rhbz#2006668
This commit is contained in:
Pavla Kratochvilova 2021-10-21 12:48:07 +02:00
parent 0e1d1b1aa8
commit 62f6934cd7
7 changed files with 9 additions and 3296 deletions

1
.gitignore vendored
View File

@ -59,3 +59,4 @@
/librepo-1.12.1.tar.gz /librepo-1.12.1.tar.gz
/librepo-1.13.0.tar.gz /librepo-1.13.0.tar.gz
/librepo-1.14.0.tar.gz /librepo-1.14.0.tar.gz
/librepo-1.14.2.tar.gz

View File

@ -1,551 +0,0 @@
From 8bba792da37142028f6b6e61137ec2988b5578ee Mon Sep 17 00:00:00 2001
From: Pavla Kratochvilova <pkratoch@redhat.com>
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/<path:path>')
-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/<path:path>')
-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/<keyword>/<path:path>')
-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/<keyword>/<path:path>")
-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/<path:path>")
-def badurl(path):
- """Just return 404 for each url with this prefix"""
- abort(404)
-
-@yum_mock.route("/badgpg/<path:path>")
-def badgpg(path):
- """Instead of <path>/repomd.xml.asc returns
- content of <path>/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/<path:path>")
-@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 <path>/repomd.xml.asc returns content of <path>/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

View File

@ -1,44 +0,0 @@
From 33be80700bc594f34818ce697493c17e70430390 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
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

View File

@ -1,268 +0,0 @@
From fd9d39cf19084dd4244943a3b27ee0a33805f76d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= <amatej@redhat.com>
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?= <amatej@redhat.com>
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();

File diff suppressed because it is too large Load Diff

View File

@ -11,17 +11,13 @@
%global dnf_conflict 2.8.8 %global dnf_conflict 2.8.8
Name: librepo Name: librepo
Version: 1.14.0 Version: 1.14.2
Release: 6%{?dist} Release: 1%{?dist}
Summary: Repodata downloading library Summary: Repodata downloading library
License: LGPLv2+ License: LGPLv2+
URL: https://github.com/rpm-software-management/librepo URL: https://github.com/rpm-software-management/librepo
Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz 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: cmake
BuildRequires: gcc BuildRequires: gcc
@ -100,6 +96,11 @@ Python 3 bindings for the librepo library.
%{python3_sitearch}/%{name}/ %{python3_sitearch}/%{name}/
%changelog %changelog
* Mon Oct 25 2021 Pavla Kratochvilova <pkratoch@redhat.com> - 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 <mboddu@redhat.com> - 1.14.0-6 * Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 1.14.0-6
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags - Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688 Related: rhbz#1991688

View File

@ -1 +1 @@
SHA512 (librepo-1.14.0.tar.gz) = e6c2a98a5c57901ebd16f09fd627daaf45e56a95e1d91bb350f60d3d33ed154d05980f8d4ddba2b7204d2e980f79dc075a741ff1527388f540182ba6a6186c98 SHA512 (librepo-1.14.2.tar.gz) = cbed7b6ab551366cc9cf9b5e8ac90cfc7395f6e79a1b44b1dcbf1e3ed6edcc644a339cca4efb4560d139355a893d00b6ac1b2e7116478f5bff3c8bfa5fdeb950