mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 12:49:00 +02:00

Add the following from the patchtest repo: - patchtest: core patch testing tool - patchtest-get-branch: determine the target branch of a patch - patchtest-get-series: pull patch series from Patchwork - patchtest-send-results: send test results to selected mailing list - patchtest-setup-sharedir: create sharedir for use with patchtest guest mode - patchtest.README: instructions for using patchtest based on the README in the original repository Note that the patchtest script was modified slightly from the repo version to retain compatibility with the oe-core changes. patchtest-send-results and patchtest-setup-sharedir are also primarily intended for automated testing in guest mode, but are added for consistency. (From OE-Core rev: cf318c3c05fc050b8c838c04f28797325c569c5c) Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
94 lines
3.4 KiB
Python
Executable File
94 lines
3.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# ex:ts=4:sw=4:sts=4:et
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
#
|
|
# patchtest: execute all unittest test cases discovered for a single patch
|
|
# Note that this script is currently under development and has been
|
|
# hard-coded with default values for testing purposes. This script
|
|
# should not be used without changing the default recipient, at minimum.
|
|
#
|
|
# Copyright (C) 2023 BayLibre Inc.
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License version 2 as
|
|
# published by the Free Software Foundation.
|
|
#
|
|
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
#
|
|
# Author: Trevor Gamblin <tgamblin@baylibre.com>
|
|
#
|
|
|
|
import argparse
|
|
import boto3
|
|
import configparser
|
|
import mailbox
|
|
import os
|
|
import sys
|
|
|
|
greeting = """Thank you for your submission. Patchtest identified one
|
|
or more issues with the patch. Please see the log below for
|
|
more information:\n\n---\n"""
|
|
|
|
suggestions = """\n---\n\nPlease address the issues identified and
|
|
submit a new revision of the patch, or alternatively, reply to this
|
|
email with an explanation of why the patch format should be accepted.
|
|
Note that patchtest may report failures in the merge-on-head test for
|
|
patches that are part of a series if they rely on changes from
|
|
preceeding entries.
|
|
|
|
If you believe these results are due to an error in patchtest, please
|
|
submit a bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest'
|
|
category under 'Yocto Project Subprojects'). Thank you!"""
|
|
|
|
parser = argparse.ArgumentParser(description="Send patchtest results to a submitter for a given patch")
|
|
parser.add_argument("-p", "--patch", dest="patch", required=True, help="The patch file to summarize")
|
|
args = parser.parse_args()
|
|
|
|
if not os.path.exists(args.patch):
|
|
print(f"Patch '{args.patch}' not found - did you provide the right path?")
|
|
sys.exit(1)
|
|
elif not os.path.exists(args.patch + ".testresult"):
|
|
print(f"Found patch '{args.patch}' but '{args.patch}.testresult' was not present. Have you run patchtest on the patch?")
|
|
sys.exit(1)
|
|
|
|
result_file = args.patch + ".testresult"
|
|
result_basename = os.path.basename(args.patch)
|
|
testresult = None
|
|
|
|
with open(result_file, "r") as f:
|
|
testresult = f.read()
|
|
|
|
reply_contents = greeting + testresult + suggestions
|
|
subject_line = f"Patchtest results for {result_basename}"
|
|
|
|
if "FAIL" in testresult:
|
|
ses_client = boto3.client('ses', region_name='us-west-2')
|
|
response = ses_client.send_email(
|
|
Source='patchtest@automation.yoctoproject.org',
|
|
Destination={
|
|
'ToAddresses': ['test-list@lists.yoctoproject.org'],
|
|
},
|
|
ReplyToAddresses=['test-list@lists.yoctoproject.org'],
|
|
Message={
|
|
'Subject': {
|
|
'Data': subject_line,
|
|
'Charset': 'utf-8'
|
|
},
|
|
'Body': {
|
|
'Text': {
|
|
'Data': reply_contents,
|
|
'Charset': 'utf-8'
|
|
}
|
|
}
|
|
}
|
|
)
|
|
else:
|
|
print(f"No failures identified for {args.patch}.")
|