Skip to content

Commit 4aae670

Browse files
authored
donate-cpu: fixed #11276 (donate-cpu: Improve library detection) / respect --no-upload in "nodata" uploads (#5292)
We were only matching each library once as the entry was removed from the container stored in the class as we did not modify a copy but a reference.
1 parent 5ff8955 commit 4aae670

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

tools/donate-cpu.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,10 @@
218218
source_path, source_found = lib.unpack_package(work_path, tgz, skip_files=skip_files)
219219
if not source_found:
220220
print("No files to process")
221-
lib.upload_nodata(package)
222-
print('Sleep 5 seconds..')
223-
time.sleep(5)
221+
if do_upload:
222+
lib.upload_nodata(package)
223+
print('Sleep 5 seconds..')
224+
time.sleep(5)
224225
continue
225226
crash = False
226227
timeout = False

tools/donate_cpu_lib.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
import signal
1111
import tarfile
1212
import shlex
13+
import copy
1314

1415

1516
# Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/
1617
# Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic
1718
# changes)
18-
CLIENT_VERSION = "1.3.46"
19+
CLIENT_VERSION = "1.3.47"
1920

2021
# Timeout for analysis with Cppcheck in seconds
2122
CPPCHECK_TIMEOUT = 30 * 60
@@ -746,7 +747,8 @@ def get_libraries(self, folder):
746747
print('Detecting library usage...')
747748
libraries = ['posix', 'gnu']
748749

749-
library_includes_re = self.__library_includes_re
750+
# explicitly copy as assignments in python are references
751+
library_includes_re = copy.copy(self.__library_includes_re)
750752

751753
def has_include(filedata):
752754
lib_del = []

tools/test_donate_cpu_lib.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@
1818

1919
from donate_cpu_lib import *
2020

21-
def _test_library_includes(tmpdir, libs, content):
22-
library_includes = LibraryIncludes()
21+
def _test_library_includes(tmpdir, libs, content, libinc_obj=None):
22+
if libinc_obj is None:
23+
library_includes = LibraryIncludes()
24+
else:
25+
library_includes = libinc_obj
2326

2427
src_file = os.path.join(str(tmpdir), "file.cpp")
2528
with open(src_file, 'w') as f:
@@ -52,3 +55,10 @@ def test_library_includes(tmpdir):
5255
_test_library_includes(tmpdir, ['posix', 'gnu', 'opengl'], '#include\t <GL/glut.h>')
5356
_test_library_includes(tmpdir, ['posix', 'gnu', 'nspr'], '#include\t"prtypes.h"')
5457
_test_library_includes(tmpdir, ['posix', 'gnu', 'lua'], '#include \t<lua.h>')
58+
59+
def test_match_multiple_time(tmpdir):
60+
libinc = LibraryIncludes()
61+
62+
# there was a bug that we would only match each library once successfully
63+
_test_library_includes(tmpdir, ['posix', 'gnu', 'zlib'], '#include <zlib.h>', libinc)
64+
_test_library_includes(tmpdir, ['posix', 'gnu', 'zlib'], '#include <zlib.h>', libinc)

0 commit comments

Comments
 (0)