diff options
author | Ubuntu <ubuntu@cert-jenkins-slave-1-201406-15260.maas> | 2021-10-13 08:30:45 +0000 |
---|---|---|
committer | Ubuntu <ubuntu@cert-jenkins-slave-1-201406-15260.maas> | 2021-10-13 08:30:45 +0000 |
commit | 32733a488fd63ce97ec1a60b0a2231051b170dd1 (patch) | |
tree | 9657fc8da08e923a4bdaa436a3d83671993c95a4 /bin | |
parent | 7919770b3a73150f67f226c356ceca78cf7dbd36 (diff) | |
parent | b498e8123e714b43339549a25485bfbabd7ac44f (diff) |
Merge #407622 from ~jocave/plainbox-provider-checkbox:dtb-mismatch-test
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/booted_dtb_tests.py | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/bin/booted_dtb_tests.py b/bin/booted_dtb_tests.py new file mode 100755 index 0000000..9ebe2e4 --- /dev/null +++ b/bin/booted_dtb_tests.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python3 +# +# This file is part of Checkbox. +# +# Copyright 2021 Canonical Ltd. +# Written by: +# Jonathan Cave <jonathan.cave@canonical.com> +# +# Checkbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3, +# as published by the Free Software Foundation. +# +# Checkbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Checkbox. If not, see <http://www.gnu.org/licenses/>. + +import filecmp +import sys +from os import walk +from os.path import join, relpath + +from checkbox_support.snap_utils.system import get_kernel_snap + + +if len(sys.argv) != 2: + raise SystemExit('ERROR: please specify the bootloader') + +dtb_dir = '/var/lib/snapd/hostfs/boot/{}'.format(sys.argv[1]) +print('Bootloader DTB location: {}'.format(dtb_dir)) + +kernel = get_kernel_snap() +if kernel is None: + raise SystemExit('ERROR: failed to get kernel snap') +snap_dtbs = '/snap/{}/current/dtbs'.format(kernel) +print('Kernel snap DTB location: {}'.format( + snap_dtbs), end='\n\n', flush=True) + +snap_files = [] +for (dirpath, dirs, files) in walk(snap_dtbs): + if dirpath == snap_dtbs: + snap_files.extend(files) + else: + snap_files.extend([join(relpath(dirpath, snap_dtbs), f) + for f in files]) + +match, mismatch, errors = filecmp.cmpfiles( + snap_dtbs, dtb_dir, snap_files, shallow=True) + +if match: + print('{} matching DTB files found'.format( + len(match)), end='\n\n', flush=True) + +if mismatch: + print('FAIL: DTB files shipped in kernel snap with mismatched versions' + ' in bootloader dir:', file=sys.stderr) + for f in mismatch: + print(f, file=sys.stderr) + print('', file=sys.stderr, flush=True) + +if errors: + print('FAIL: DTB files shipped in kernel snap which could not be' + ' found in bootloader dir:', file=sys.stderr) + for f in errors: + print(f, file=sys.stderr) + print('', file=sys.stderr, flush=True) + +if mismatch or errors: + raise SystemExit('Comparison failed') |