summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorci test bot <citestbot@example.com>2015-12-04 21:55:29 -0600
committerAndy Doan <andy.doan+gerrit@linaro.org>2015-12-15 21:24:40 +0000
commiteba4fc7f0a949a67ec705637c5dbb0939fa909ad (patch)
tree37c9758a36189a4d935fccd6a59a55b850651940 /tests
parentc42c1cb18bb138d518ccb0d53ad399b47159debf (diff)
linaro-metrics: handle patches with no list-id
The linaro-pathmetrics fork of patchwork has a modified version of the find_project function that attempts to find the project based on the To and CC fields in the event no list-id header is in place. This was causing us to mis-place patches in the "no-project" project like the test patch used for validating this fix. NOTE: In the event there are more than one mailing lists in the TO field, we'll attribute it to the first one we find a project for. I should probably try and get this enhancement into patchwork as it seems like a generally useful thing. Change-Id: Ib33fa78f5d0455ab9bddf237792493f6423d620f
Diffstat (limited to 'tests')
-rw-r--r--tests/data/no-list-id.mbox218
-rw-r--r--tests/test_import_emails.py14
2 files changed, 232 insertions, 0 deletions
diff --git a/tests/data/no-list-id.mbox b/tests/data/no-list-id.mbox
new file mode 100644
index 0000000..f5a4650
--- /dev/null
+++ b/tests/data/no-list-id.mbox
@@ -0,0 +1,218 @@
+From patchwork Thu Dec 3 22:24:39 2015
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [v2,2/3] hw/sd/pxa2xx_mmci: Convert to VMStateDescription
+From: Peter Maydell <peter.maydell@linaro.org>
+X-Patchwork-Id: 57695
+Message-Id: <1449181480-22209-3-git-send-email-peter.maydell@linaro.org>
+To: qemu-devel@nongnu.org
+Cc: patches@linaro.org, qemu-arm@nongnu.org,
+ Markus Armbruster <armbru@redhat.com>,
+ Peter Crosthwaite <crosthwaitepeter@gmail.com>
+Date: Thu, 3 Dec 2015 22:24:39 +0000
+
+Convert the pxa2xx_mmci device from manual save/load
+functions to a VMStateDescription structure.
+
+This is a migration compatibility break.
+
+Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
+---
+ hw/sd/pxa2xx_mmci.c | 149 ++++++++++++++++++++--------------------------------
+ 1 file changed, 57 insertions(+), 92 deletions(-)
+
+--
+1.9.1
+
+diff --git a/hw/sd/pxa2xx_mmci.c b/hw/sd/pxa2xx_mmci.c
+index 39ca309..fd76ffe 100644
+--- a/hw/sd/pxa2xx_mmci.c
++++ b/hw/sd/pxa2xx_mmci.c
+@@ -37,27 +37,72 @@ typedef struct PXA2xxMMCIState {
+ uint32_t cmdat;
+ uint32_t resp_tout;
+ uint32_t read_tout;
+- int blklen;
+- int numblk;
++ int32_t blklen;
++ int32_t numblk;
+ uint32_t intmask;
+ uint32_t intreq;
+- int cmd;
++ int32_t cmd;
+ uint32_t arg;
+
+- int active;
+- int bytesleft;
++ int32_t active;
++ int32_t bytesleft;
+ uint8_t tx_fifo[64];
+- int tx_start;
+- int tx_len;
++ uint32_t tx_start;
++ uint32_t tx_len;
+ uint8_t rx_fifo[32];
+- int rx_start;
+- int rx_len;
++ uint32_t rx_start;
++ uint32_t rx_len;
+ uint16_t resp_fifo[9];
+- int resp_len;
++ uint32_t resp_len;
+
+- int cmdreq;
++ int32_t cmdreq;
+ } PXA2xxMMCIState;
+
++static bool pxa2xx_mmci_vmstate_validate(void *opaque, int version_id)
++{
++ PXA2xxMMCIState *s = opaque;
++
++ return s->tx_start < sizeof(s->tx_fifo)
++ && s->rx_start < sizeof(s->rx_fifo)
++ && s->tx_len <= sizeof(s->tx_fifo)
++ && s->rx_len <= sizeof(s->rx_fifo)
++ && s->resp_len <= sizeof(s->resp_fifo);
++}
++
++
++static const VMStateDescription vmstate_pxa2xx_mmci = {
++ .name = "pxa2xx-mmci",
++ .version_id = 2,
++ .minimum_version_id = 2,
++ .fields = (VMStateField[]) {
++ VMSTATE_UINT32(status, PXA2xxMMCIState),
++ VMSTATE_UINT32(clkrt, PXA2xxMMCIState),
++ VMSTATE_UINT32(spi, PXA2xxMMCIState),
++ VMSTATE_UINT32(cmdat, PXA2xxMMCIState),
++ VMSTATE_UINT32(resp_tout, PXA2xxMMCIState),
++ VMSTATE_UINT32(read_tout, PXA2xxMMCIState),
++ VMSTATE_INT32(blklen, PXA2xxMMCIState),
++ VMSTATE_INT32(numblk, PXA2xxMMCIState),
++ VMSTATE_UINT32(intmask, PXA2xxMMCIState),
++ VMSTATE_UINT32(intreq, PXA2xxMMCIState),
++ VMSTATE_INT32(cmd, PXA2xxMMCIState),
++ VMSTATE_UINT32(arg, PXA2xxMMCIState),
++ VMSTATE_INT32(cmdreq, PXA2xxMMCIState),
++ VMSTATE_INT32(active, PXA2xxMMCIState),
++ VMSTATE_INT32(bytesleft, PXA2xxMMCIState),
++ VMSTATE_UINT32(tx_start, PXA2xxMMCIState),
++ VMSTATE_UINT32(tx_len, PXA2xxMMCIState),
++ VMSTATE_UINT32(rx_start, PXA2xxMMCIState),
++ VMSTATE_UINT32(rx_len, PXA2xxMMCIState),
++ VMSTATE_UINT32(resp_len, PXA2xxMMCIState),
++ VMSTATE_VALIDATE("fifo size incorrect", pxa2xx_mmci_vmstate_validate),
++ VMSTATE_UINT8_ARRAY(tx_fifo, PXA2xxMMCIState, 64),
++ VMSTATE_UINT8_ARRAY(rx_fifo, PXA2xxMMCIState, 32),
++ VMSTATE_UINT16_ARRAY(resp_fifo, PXA2xxMMCIState, 9),
++ VMSTATE_END_OF_LIST()
++ }
++};
++
+ #define MMC_STRPCL 0x00 /* MMC Clock Start/Stop register */
+ #define MMC_STAT 0x04 /* MMC Status register */
+ #define MMC_CLKRT 0x08 /* MMC Clock Rate register */
+@@ -399,84 +444,6 @@ static const MemoryRegionOps pxa2xx_mmci_ops = {
+ .endianness = DEVICE_NATIVE_ENDIAN,
+ };
+
+-static void pxa2xx_mmci_save(QEMUFile *f, void *opaque)
+-{
+- PXA2xxMMCIState *s = (PXA2xxMMCIState *) opaque;
+- int i;
+-
+- qemu_put_be32s(f, &s->status);
+- qemu_put_be32s(f, &s->clkrt);
+- qemu_put_be32s(f, &s->spi);
+- qemu_put_be32s(f, &s->cmdat);
+- qemu_put_be32s(f, &s->resp_tout);
+- qemu_put_be32s(f, &s->read_tout);
+- qemu_put_be32(f, s->blklen);
+- qemu_put_be32(f, s->numblk);
+- qemu_put_be32s(f, &s->intmask);
+- qemu_put_be32s(f, &s->intreq);
+- qemu_put_be32(f, s->cmd);
+- qemu_put_be32s(f, &s->arg);
+- qemu_put_be32(f, s->cmdreq);
+- qemu_put_be32(f, s->active);
+- qemu_put_be32(f, s->bytesleft);
+-
+- qemu_put_byte(f, s->tx_len);
+- for (i = 0; i < s->tx_len; i ++)
+- qemu_put_byte(f, s->tx_fifo[(s->tx_start + i) & 63]);
+-
+- qemu_put_byte(f, s->rx_len);
+- for (i = 0; i < s->rx_len; i ++)
+- qemu_put_byte(f, s->rx_fifo[(s->rx_start + i) & 31]);
+-
+- qemu_put_byte(f, s->resp_len);
+- for (i = s->resp_len; i < 9; i ++)
+- qemu_put_be16s(f, &s->resp_fifo[i]);
+-}
+-
+-static int pxa2xx_mmci_load(QEMUFile *f, void *opaque, int version_id)
+-{
+- PXA2xxMMCIState *s = (PXA2xxMMCIState *) opaque;
+- int i;
+-
+- qemu_get_be32s(f, &s->status);
+- qemu_get_be32s(f, &s->clkrt);
+- qemu_get_be32s(f, &s->spi);
+- qemu_get_be32s(f, &s->cmdat);
+- qemu_get_be32s(f, &s->resp_tout);
+- qemu_get_be32s(f, &s->read_tout);
+- s->blklen = qemu_get_be32(f);
+- s->numblk = qemu_get_be32(f);
+- qemu_get_be32s(f, &s->intmask);
+- qemu_get_be32s(f, &s->intreq);
+- s->cmd = qemu_get_be32(f);
+- qemu_get_be32s(f, &s->arg);
+- s->cmdreq = qemu_get_be32(f);
+- s->active = qemu_get_be32(f);
+- s->bytesleft = qemu_get_be32(f);
+-
+- s->tx_len = qemu_get_byte(f);
+- s->tx_start = 0;
+- if (s->tx_len >= sizeof(s->tx_fifo) || s->tx_len < 0)
+- return -EINVAL;
+- for (i = 0; i < s->tx_len; i ++)
+- s->tx_fifo[i] = qemu_get_byte(f);
+-
+- s->rx_len = qemu_get_byte(f);
+- s->rx_start = 0;
+- if (s->rx_len >= sizeof(s->rx_fifo) || s->rx_len < 0)
+- return -EINVAL;
+- for (i = 0; i < s->rx_len; i ++)
+- s->rx_fifo[i] = qemu_get_byte(f);
+-
+- s->resp_len = qemu_get_byte(f);
+- if (s->resp_len > 9 || s->resp_len < 0)
+- return -EINVAL;
+- for (i = s->resp_len; i < 9; i ++)
+- qemu_get_be16s(f, &s->resp_fifo[i]);
+-
+- return 0;
+-}
+-
+ PXA2xxMMCIState *pxa2xx_mmci_init(MemoryRegion *sysmem,
+ hwaddr base,
+ BlockBackend *blk, qemu_irq irq,
+@@ -513,9 +480,6 @@ static void pxa2xx_mmci_instance_init(Object *obj)
+ sysbus_init_irq(sbd, &s->irq);
+ sysbus_init_irq(sbd, &s->rx_dma);
+ sysbus_init_irq(sbd, &s->tx_dma);
+-
+- register_savevm(NULL, "pxa2xx_mmci", 0, 0,
+- pxa2xx_mmci_save, pxa2xx_mmci_load, s);
+ }
+
+ static void pxa2xx_mmci_realize(DeviceState *dev, Error **errp)
+@@ -541,6 +505,7 @@ static void pxa2xx_mmci_class_init(ObjectClass *klass, void *data)
+
+ dc->realize = pxa2xx_mmci_realize;
+ dc->props = pxa2xx_mmci_properties;
++ dc->vmsd = &vmstate_pxa2xx_mmci;
+ }
+
+ static const TypeInfo pxa2xx_mmci_info = {
diff --git a/tests/test_import_emails.py b/tests/test_import_emails.py
index fd4a8a3..4846bfa 100644
--- a/tests/test_import_emails.py
+++ b/tests/test_import_emails.py
@@ -169,3 +169,17 @@ class TestImportEmail(TestCase):
self.assertEqual(1, Patch.objects.all().count())
tcs = [x.team for x in TeamCredit.objects.all()]
self.assertEqual(teams, tcs)
+
+ @mock.patch('linaro_metrics.parsemail.Crowd')
+ def test_monkey_patch_no_listid(self, crowd):
+ Project.objects.all().delete()
+ qemu = Project.objects.create(
+ name='qemu-devel', linkname='qemu-devel',
+ listemail='qemu-devel@nongnu.org', listid='qemu-devel.nongnu.org')
+
+ crowd().get_user_no_cache.return_value = {'display-name': 'User Name'}
+
+ with import_emails.get_monkey_patcher()(import_emails.parsemail):
+ self._import_patch('no-list-id.mbox')
+ self.assertEqual(1, Patch.objects.all().count())
+ self.assertEqual(qemu, Patch.objects.all()[0].project)