Compare commits

..

9 Commits

Author SHA1 Message Date
Matthew Johnson 574198586b Release 1.1.7
* Improves test coverage for several modules
* Adds "autoupdate" flag for usage by third-party tools

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-11-20 09:55:44 -08:00
Matthew Johnson 3dd679b459 Add autoupdate flag to options.conf
This flag is a no-op for autospec itself, but allows humans to indicate
that a package is trusted enough to automatically release new updates of
the package. In practice this should be used by a tool that runs
autospec in an automated manner to push the package to a build server.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-11-17 15:06:42 -08:00
Matthew Johnson bbaade01c7 Add test for build.log missing file parsing
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-11-16 13:19:11 -08:00
Matthew Johnson ad2fa386a4 license: Add tests for complete coverage of license module
The additional test uncovered a syntax error in the print_fatal call in
license_from_copying_hash, which was fixed as well. An unnecessary mock
was removed from another test.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-11-16 13:11:53 -08:00
Matthew Johnson 07622d5770 Increase count.py test coverage
Also remove some never-hit regular expressions from count.py

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-11-16 13:11:07 -08:00
Matthew Johnson 0c74c918c1 Release v1.1.6
This release deprecates Makefile writing by autospec since per-package
Makefiles are not used by autospec.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-11-14 10:16:51 -08:00
Matthew Johnson 79246f925a Deprecate Makefile writing
The package metadata is now written to options.conf so the Makefile
writing is no longer needed.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-11-14 10:17:07 -08:00
Matthew Johnson a0bae50f72 Release v1.1.5
This release adds efivar and gnu-efi simple patterns.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-11-09 15:02:46 -08:00
William Douglas 8281fb1b97 Add efivar and gnu-efi simple patterns
Enable detecting missing efivar and gnu-efi build requirements (with
meson).
2017-11-09 15:02:45 -08:00
9 changed files with 139 additions and 83 deletions
+6 -2
View File
@@ -107,7 +107,9 @@ config_options = {
"nostrip": "disable stripping binaries",
"verify_required": "require package verification for build",
"security_sensitive": "set flags for security-sensitive builds",
"so_to_lib": "add .so files to the lib package instead of dev"}
"so_to_lib": "add .so files to the lib package instead of dev",
"autoupdate": "this package is trusted enough to automatically update "
"(used by other tools)"}
# simple_pattern_pkgconfig patterns
# contains patterns for parsing build.log for missing dependencies
@@ -158,7 +160,9 @@ simple_pats = [
(r"Package systemd was not found in the pkg-config search path.", "systemd-dev"),
(r"Unable to find the requested Boost libraries.", "boost-dev"),
(r"libproc not found. Please configure without procps", "procps-ng-dev"),
(r"configure: error: glib2", "glib-dev")]
(r"configure: error: glib2", "glib-dev"),
(r"C library 'efivar' not found", "efivar-dev"),
(r"Has header \"efi.h\": NO", "gnu-efi-dev")]
# failed_pattern patterns
# contains patterns for parsing build.log for missing dependencies
+2 -31
View File
@@ -211,7 +211,7 @@ def parse_log(log, pkgname=''):
# apr
# testatomic : SUCCESS
if re.search(r"\: SUCCESS$", line) and incheck:
if re.search(r": SUCCESS$", line) and incheck:
counted_pass += 1
continue
@@ -283,7 +283,7 @@ def parse_log(log, pkgname=''):
total_fail += convert_int(match.group(1))
continue
match = re.search(r"/== ([0-9]+) failed, ([0-9]+) passed, ([0-9]+) xfailed in ", line)
match = re.search(r"== ([0-9]+) failed, ([0-9]+) passed, ([0-9]+) xfailed in ", line)
if match and incheck:
total_pass += convert_int(match.group(2))
total_fail += convert_int(match.group(1))
@@ -967,13 +967,6 @@ def parse_log(log, pkgname=''):
counted_pass += 1
continue
# apr-util
# : SUCCESS
match = re.search(r": SUCCESS$", line)
if match and incheck:
counted_pass += 1
continue
# bash
# < Failed 126 of 1378 Unicode tests
match = re.search(r"^[<,>] Failed ([0-9]+) of ([0-9]+)", line)
@@ -1015,18 +1008,6 @@ def parse_log(log, pkgname=''):
counted_pass += 1
continue
# *** zlib test OK ***
# *** zlib 64-bit test OK ***
match = re.search(r"\*\*\* zlib .*test OK \*\*\*", line)
if match and incheck:
counted_pass += 1
continue
match = re.search(r"\*\*\* zlib .*test [A-Z!O][A-Z!K] \*\*\*", line)
if match and incheck:
counted_fail += 1
continue
# LVM2
# valgrind pool awareness ... fail
# dfa matching ... fail
@@ -1295,16 +1276,6 @@ def parse_log(log, pkgname=''):
total_skip += 1
continue
match = re.search(r"^Testing .+\ +\*FAILED\*$", line)
if match and incheck:
total_fail += 1
continue
match = re.search(r"^Verifying .+\ +\*FAILED\*$", line)
if match and incheck:
total_fail += 1
continue
# libconfig
# 3 tests; 3 passed, 0 failed
match = re.search(r"^([0-9]+) tests; ([0-9]+) passed\, ([0-9]+) failed", line)
+2 -2
View File
@@ -75,8 +75,8 @@ def license_from_copying_hash(copying):
try:
c.perform()
except Exception as excep:
print_fatal("Failed to fetch license from " + config.license_fetch,
excep)
print_fatal("Failed to fetch license from {}: {}"
.format(config.license_fetch, excep))
c.close()
sys.exit(1)
-18
View File
@@ -441,22 +441,6 @@ def find_extract(tar_path, tarfile):
return extract_cmd, tar_prefix
def write_makefile(archives):
"""
Write the new makefile with url, name, and archives
"""
with open(build.download_path + "/Makefile", "w") as f:
f.write("PKG_NAME := " + name + "\n")
f.write("URL := " + url + "\n")
sep = "ARCHIVES := "
for archive in archives:
f.write("{}{}".format(sep, archive))
sep = " " if sep != " " else " \\\n\t"
f.write("\n")
f.write("\n")
f.write("include ../common/Makefile.common\n")
def prepare_and_extract(extract_cmd):
"""
Prepare the directory and extract the tarball
@@ -532,8 +516,6 @@ def process(url_arg, name_arg, ver_arg, target, archives_arg, filemanager):
# Now that the metadata has been collected print the header
print_header()
# write out the Makefile with the name, url, and archives we found
# DEPRECATED, this will be removed in a future version
write_makefile(archives_arg)
# prepare directory and extract tarball
prepare_and_extract(extract_cmd)
# locate or download archives and move them into the right spot
+1 -1
View File
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import sys, os
version = "1.1.4"
version = "1.1.7"
def readme():
with open("README.rst") as f:
+35 -1
View File
@@ -236,7 +236,7 @@ class TestBuildpattern(unittest.TestCase):
self.assertIn('jdk-apache-parent', build.buildreq.buildreqs)
self.assertEqual(build.must_restart, 1)
def test_parse_build_resultsi_pkgconfig(self):
def test_parse_build_results_pkgconfig(self):
"""
Test parse_build_results with a test log indicating failure due to a
missing qmake package (pkgconfig error)
@@ -314,6 +314,40 @@ class TestBuildpattern(unittest.TestCase):
self.assertIn('testpkg-python', build.buildreq.buildreqs)
self.assertEqual(build.must_restart, 1)
def test_parse_build_results_files(self):
"""
Test parse_build_results with a test log indicating files are missing
"""
def mock_util_call(cmd):
del cmd
build.config.setup_patterns()
call_backup = build.util.call
build.util.call = mock_util_call
fm = files.FileManager()
open_name = 'build.open'
content = 'line 1\n' \
'Installed (but unpackaged) file(s) found:\n' \
'/usr/testdir/file\n' \
'/usr/testdir/file1\n' \
'/usr/testdir/file2\n' \
'RPM build errors\n' \
'errors here\n'
m_open = mock_open(read_data=content)
with patch(open_name, m_open, create=True):
build.parse_build_results('testname', 0, fm)
build.util.call = call_backup
self.assertEqual(fm.files,
['/usr/testdir/file',
'/usr/testdir/file1',
'/usr/testdir/file2'])
# one for each file added
self.assertEqual(build.must_restart, 3)
def test_get_mock_cmd_without_consolehelper(self):
"""
Test get_mock_cmd when /usr/bin/mock doesn't point to consolehelper
+25 -2
View File
@@ -36,6 +36,8 @@ pats = [
[332, 281, 38, 0, 13, 0, 0, 0, 0, 0]),
('===================== 5 failed, 318 passed in 1.06 seconds =====================',
[323, 318, 5, 0, 0, 0, 0, 0, 0, 0]),
('===================== 5 failed, 9 passed, 7 xfailed in 1.06 seconds ============',
[21, 9, 5, 7, 0, 0, 0, 0, 0, 0]),
('============= 1628 passed, 72 skipped, 4 xfailed in 146.26 seconds =============',
[1704, 1628, 0, 4, 72, 0, 0, 0, 0, 0]),
('=============== 119 passed, 2 skipped, 54 error in 2.19 seconds ================',
@@ -87,8 +89,9 @@ pats = [
('# of expected passes\t1144\n'
'# of expected failures\t57\n'
'# of untested testcases\t1\n'
'# of unsupported tests\t12',
[1213, 1144, 0, 57, 12, 0, 0, 0, 0, 0]),
'# of unsupported tests\t12\n'
'# of unexpected failures\t1\n',
[1214, 1144, 1, 57, 12, 0, 0, 0, 0, 0]),
# ccache
('PASSED: 448 assertions, 88 tests, 10 suites',
[88, 88, 0, 0, 0, 0, 0, 0, 0, 0]),
@@ -179,6 +182,13 @@ pats = [
'Failed with core: 0\n'
'Unknown status: 0',
[13042, 13036, 6, 0, 0, 1, 1, 0, 0, 0]),
# nss
('cert.sh: #101: Import chain-2-serverCA-ec CA -t u,u,u for localhost.localdomain (ext.) - FAILED\n'
'Passed: 13036\n'
'Failed: 6\n'
'Failed with core: 0\n'
'Unknown status: 0',
[13042, 13036, 6, 0, 0, 0, 0, 1, 0, 0]),
# rsync
(' 34 passed\n'
' 5 skipped',
@@ -191,6 +201,12 @@ pats = [
[30, 0, 6, 6, 18, 0, 0, 0, 0, 0]),
('FAILED (failures=1, errors=499, skipped=48)',
[548, 0, 1, 499, 48, 0, 0, 0, 0, 0]),
('FAILED (failures=1, errors=499)',
[500, 0, 1, 499, 0, 0, 0, 0, 0, 0]),
('FAILED (failures=1)',
[1, 0, 1, 0, 0, 0, 0, 0, 0, 0]),
('FAILED (errors=1)',
[1, 0, 0, 1, 0, 0, 0, 0, 0, 0]),
('OK (KNOWNFAIL=5, SKIP=15)',
[20, 0, 0, 5, 15, 0, 0, 0, 0, 0]),
# qpid-python
@@ -304,6 +320,9 @@ pats = [
# rubygem-ansi
('Executed 12 tests with 7 passing, 5 errors.',
[12, 7, 5, 0, 0, 0, 0, 0, 0, 0]),
# vim
('Executed 12 tests',
[12, 12, 0, 0, 0, 0, 0, 0, 0, 0]),
# rubygem-formatador
(' 9 succeeded in 0.00375661 seconds',
[9, 9, 0, 0, 0, 0, 0, 0, 0, 0]),
@@ -372,8 +391,12 @@ pats = [
# hdf5
('Testing h5repack h5repack_szip.h5 -f dset_szip:GZIP=1 -SKIP-',
[1, 0, 0, 0, 1, 0, 0, 0, 0, 0]),
('Verifying h5repack h5repack_szip.h5 -f dset_szip:GZIP=1 -SKIP-',
[1, 0, 0, 0, 1, 0, 0, 0, 0, 0]),
('Verifying h5dump output -f GZIP=1 -m 1024 *FAILED*',
[1, 0, 1, 0, 0, 0, 0, 0, 0, 0]),
('Testing h5dump output -f GZIP=1 -m 1024 *FAILED*',
[1, 0, 1, 0, 0, 0, 0, 0, 0, 0]),
('Testing h5repack --metadata_block_size=8192 PASSED',
[1, 1, 0, 0, 0, 0, 0, 0, 0, 0]),
('Verifying h5diff output h5repack_layout.h5 out-meta_long.h5repack_layo PASSED',
+68 -2
View File
@@ -65,6 +65,30 @@ class TestLicense(unittest.TestCase):
self.assertIn('GPL-3.0', license.licenses)
def test_license_from_copying_hash_no_license_show(self):
"""
Test license_from_copying_hash with invalid hash and no license_show
set
"""
# Calls out to tarball.get_sha1sum to get the hash of the license
# we might as well test that is returning what it should because it
# doesn't call any external resources, it just calculates the hash.
open_name = 'tarball.open'
with open('tests/COPYING_TEST', 'rb') as copyingf:
content = copyingf.read()
bkup_hash = license.config.license_hashes[license.tarball.get_sha1sum('tests/COPYING_TEST')]
# remove the hash from license_hashes
del(license.config.license_hashes[license.tarball.get_sha1sum('tests/COPYING_TEST')])
license.config.license_show = "license.show.url"
m_open = mock_open(read_data=content)
with patch(open_name, m_open, create=True):
license.license_from_copying_hash('copying.txt')
# restore the hash
license.config.license_hashes[license.tarball.get_sha1sum('tests/COPYING_TEST')] = bkup_hash
self.assertEquals(license.licenses, [])
def test_license_from_copying_hash_bad_license(self):
"""
Test license_from_copying_hash with invalid license file
@@ -83,6 +107,50 @@ class TestLicense(unittest.TestCase):
self.assertEquals(license.licenses, [])
@patch('pycurl.Curl')
def test_license_from_copying_hash_license_server_excep(self, mock_pycurl_curl):
"""
Test license_from_copying_hash with license server when pycurl raises
an exception.
"""
class MockCurl():
URL = None
WRITEDATA = None
POSTFIELDS = None
def setopt(_, __, ___):
pass
def perform(_):
raise Exception('Test Exception')
def close(_):
pass
# set the mock curl
license.pycurl.Curl = MockCurl
license.config.license_fetch = 'license.server.url'
with open('tests/COPYING_TEST', 'rb') as copyingf:
content = copyingf.read()
# Calls out to tarball.get_sha1sum to get the hash of the license
# we might as well test that is returning what it should because it
# doesn't call any external resources, it just calculates the hash.
# Also patch the open in license.py
m_open = mock_open(read_data=content)
with patch('tarball.open', m_open, create=True):
with patch('license.open', m_open, create=True):
# let's check that the proper thing is being printed as well
out = StringIO()
with redirect_stdout(out):
with self.assertRaises(SystemExit):
license.license_from_copying_hash('copying.txt')
self.assertIn('Failed to fetch license from ', out.getvalue())
# unset the manual mock
license.pycurl.Curl = pycurl.Curl
@patch('pycurl.Curl')
def test_license_from_copying_hash_license_server(self, mock_pycurl_curl):
"""
@@ -97,12 +165,10 @@ class TestLicense(unittest.TestCase):
return 'GPL-3.0'.encode('utf-8')
# set the mocks
mock_pycurl_curl.return_value = MagicMock()
license.BytesIO = MockBytesIO
license.config.license_fetch = 'license.server.url'
with open('tests/COPYING_TEST', 'rb') as copyingf:
# note the replace corrupting the file contents
content = copyingf.read()
# Calls out to tarball.get_sha1sum to get the hash of the license
-24
View File
@@ -168,30 +168,6 @@ class TestTarballVersionName(unittest.TestCase):
tarball.build_gem_unpack = build_gem_unpack_backup
tarball.build_untar = build_untar_backup
def test_write_makefile(self):
"""
Test write_makefile for correct archive format
"""
archives = ['archive1', 'dest1', 'archive2', 'dest2']
build.download_path = '.'
tarball.name = 'test'
tarball.url = 'url'
m_open = mock_open()
with patch('tarball.open', m_open, create=True):
tarball.write_makefile(archives)
exp_calls = [call().write('PKG_NAME := test\n'),
call().write('URL := url\n'),
call().write('ARCHIVES := archive1'),
call().write(' dest1'),
call().write(' \\\n\tarchive2'),
call().write(' dest2'),
call().write('\n'),
call().write('\n'),
call().write('include ../common/Makefile.common\n')]
for m_call in exp_calls:
self.assertIn(m_call, m_open.mock_calls)
TAR_OUT = 'libjpeg-turbo-1.5.1/\n' \
'libjpeg-turbo-1.5.1/md5/\n' \