From patchwork Tue Jul 30 21:05:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Hassick X-Patchwork-Id: 1966761 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=iol.unh.edu header.i=@iol.unh.edu header.a=rsa-sha256 header.s=unh-iol header.b=KDb9CRqY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WYSRQ5SV3z1ybV for ; Wed, 31 Jul 2024 07:05:06 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=iol.unh.edu header.i=@iol.unh.edu header.a=rsa-sha256 header.s=unh-iol header.b=KDb9CRqY; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4WYSRQ4h2Tz3d8Y for ; Wed, 31 Jul 2024 07:05:06 +1000 (AEST) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=iol.unh.edu Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=iol.unh.edu header.i=@iol.unh.edu header.a=rsa-sha256 header.s=unh-iol header.b=KDb9CRqY; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=iol.unh.edu (client-ip=2607:f8b0:4864:20::c2a; helo=mail-oo1-xc2a.google.com; envelope-from=ahassick@iol.unh.edu; receiver=lists.ozlabs.org) Received: from mail-oo1-xc2a.google.com (mail-oo1-xc2a.google.com [IPv6:2607:f8b0:4864:20::c2a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4WYSQq3Grbz3d40 for ; Wed, 31 Jul 2024 07:04:35 +1000 (AEST) Received: by mail-oo1-xc2a.google.com with SMTP id 006d021491bc7-5d5c8c1006eso2861894eaf.3 for ; Tue, 30 Jul 2024 14:04:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1722373472; x=1722978272; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qMcyJrxKjL+1wTb3FOFdQInuj5cVqczmH0OO7/8hbl0=; b=KDb9CRqYZyrUhQclMZV5zRrbd7UDIzT4AnLHll7/8my1zBJb6eelAmt+Ix2UxyJ9xd hXt1BItPEkAK4ZdPEFplQpfgYy0Ls5CqRxfgXjyO0zDyvqAez5e94hlZYW6JTmwU20f0 34Swe/FR9R19+MT3jw5c6Fkxc5i+nomsZWJqY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722373472; x=1722978272; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qMcyJrxKjL+1wTb3FOFdQInuj5cVqczmH0OO7/8hbl0=; b=EsfiAgqmro7ZQxn+GvNtMgPxHRPuW50/Ub7EnEN8LOEbxPWWgLyky++805rXNQSEE6 ysaVlsZny84L/ikzuPjmJ2lIi+Ebk6Yp2SivojvnmajkOOZWRgnn1CXpkA60yw1Xd+oy 1ERVoR4dPnHcIpRf/3zetc5ymUJe6B7PKW8Ts2l+3kci/HeZDRkjZlA3bDJAoaQOWCJm wq+3vk3p+nPaCVRTJ78dSkrFOhyCh8zzZEJPHWM0P//a7tLfPLlybpLkqn1MsfYs8pJf LSGwBconfQq96Qc3wim3i9Ougdy2m0nunahXdDmo0DMILAOUr5/6jUbv/0OSQVs8HdHF clzA== X-Gm-Message-State: AOJu0YyMR0wTMIZuLpIa6Z7JVvKBEc6onM6x1+EzHf+83R2aCyPpy0FY zt6zApGxw9Qq475mYlqN3V7n0VJuWuLwx7JIY0ND/InE6x3UKBfhOKyX6viU7jRAssLK0LjXxHZ 73eqExzAJ+DjgR3xpO9m/GGM+AsogPaQgOUxesiY09BPGR4Rt9rLSHS1nQGkQWA9vV3QFszQVQs JlzYhkBDhP1EaD1Ne5EjPL7BVRR1cOyuxuc84wBvOUET7inA== X-Google-Smtp-Source: AGHT+IE0K5QKiRG/BV46Q2GpKcoRMfwdU6XyrFnmw/CFSwtDcTtJkS9J8KJum99uxYVdqr0K9Eo4sg== X-Received: by 2002:a05:6358:7f89:b0:1ac:f058:f714 with SMTP id e5c5f4694b2df-1adc06ca6f7mr1723636855d.21.1722373471868; Tue, 30 Jul 2024 14:04:31 -0700 (PDT) Received: from bubs.iol.unh.edu ([2606:4100:3880:1271:27d2:9af4:4b7f:fdb5]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bb3f8dc20fsm67411046d6.4.2024.07.30.14.04.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 14:04:31 -0700 (PDT) From: Adam Hassick To: patchwork@lists.ozlabs.org Subject: [PATCH v2 4/7] tests: Add tests for new functionality Date: Tue, 30 Jul 2024 17:05:18 -0400 Message-ID: <20240730210523.313101-5-ahassick@iol.unh.edu> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240730210523.313101-1-ahassick@iol.unh.edu> References: <20240730210523.313101-1-ahassick@iol.unh.edu> MIME-Version: 1.0 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" v1: * Add tests for the API and parser changes. * Add new test mbox files. * Add new patch series tests. Signed-off-by: Adam Hassick Reviewed-by: Stephen Finucane --- patchwork/tests/api/test_series.py | 33 ++- .../tests/series/dependency-base-patch.mbox | 102 +++++++ .../series/dependency-multi-2.mbox.template | 110 +++++++ .../series/dependency-multi.mbox.template | 109 +++++++ .../series/dependency-one-cover.mbox.template | 128 +++++++++ .../dependency-one-first-patch.mbox.template | 125 ++++++++ patchwork/tests/test_parser.py | 52 ++++ patchwork/tests/test_series.py | 271 ++++++++++++++++++ 8 files changed, 929 insertions(+), 1 deletion(-) create mode 100644 patchwork/tests/series/dependency-base-patch.mbox create mode 100644 patchwork/tests/series/dependency-multi-2.mbox.template create mode 100644 patchwork/tests/series/dependency-multi.mbox.template create mode 100644 patchwork/tests/series/dependency-one-cover.mbox.template create mode 100644 patchwork/tests/series/dependency-one-first-patch.mbox.template diff --git a/patchwork/tests/api/test_series.py b/patchwork/tests/api/test_series.py index 730678a..86954b0 100644 --- a/patchwork/tests/api/test_series.py +++ b/patchwork/tests/api/test_series.py @@ -44,6 +44,20 @@ class TestSeriesAPI(utils.APITestCase): self.assertIn(series_obj.get_mbox_url(), series_json['mbox']) self.assertIn(series_obj.get_absolute_url(), series_json['web_url']) + for dep, item in zip( + series_obj.dependencies.all(), series_json['dependencies'] + ): + self.assertIn( + reverse('api-series-detail', kwargs={'pk': dep.id}), item + ) + + for dep, item in zip( + series_obj.dependents.all(), series_json['dependents'] + ): + self.assertIn( + reverse('api-series-detail', kwargs={'pk': dep.id}), item + ) + # nested fields self.assertEqual(series_obj.project.id, series_json['project']['id']) @@ -95,6 +109,21 @@ class TestSeriesAPI(utils.APITestCase): series_rsp = resp.data[0] self.assertSerialized(series, series_rsp) + def test_dependencies(self): + project_obj = create_project(linkname='myproject') + person_obj = create_person(email='test@example.com') + series1 = create_series(project=project_obj, submitter=person_obj) + create_cover(series=series1) + create_patch(series=series1) + series2 = create_series(project=project_obj, submitter=person_obj) + create_cover(series=series2) + create_patch(series=series2) + series1.add_dependencies([series2]) + resp = self.client.get(self.api_url()) + self.assertEqual(2, len(resp.data)) + self.assertSerialized(series2, resp.data[1]) + self.assertSerialized(series1, resp.data[0]) + def test_list_filter_project(self): """Filter series by project.""" series = self._create_series() @@ -152,7 +181,7 @@ class TestSeriesAPI(utils.APITestCase): create_cover(series=series_obj) create_patch(series=series_obj) - with self.assertNumQueries(6): + with self.assertNumQueries(8): self.client.get(self.api_url()) @utils.store_samples('series-detail') @@ -175,6 +204,8 @@ class TestSeriesAPI(utils.APITestCase): self.assertNotIn('web_url', resp.data['cover_letter']) self.assertNotIn('mbox', resp.data['cover_letter']) self.assertNotIn('web_url', resp.data['patches'][0]) + self.assertNotIn('dependents', resp.data) + self.assertNotIn('dependencies', resp.data) def test_detail_non_existent(self): """Ensure we get a 404 for a non-existent series.""" diff --git a/patchwork/tests/series/dependency-base-patch.mbox b/patchwork/tests/series/dependency-base-patch.mbox new file mode 100644 index 0000000..e7f9e94 --- /dev/null +++ b/patchwork/tests/series/dependency-base-patch.mbox @@ -0,0 +1,102 @@ +From ahassick@iol.unh.edu Mon Jun 10 21:09:07 2024 +Return-Path: +From: Adam Hassick +To: Adam.Hassick@unh.edu +Subject: [PATCH v1 0/2] Add test files for testing +Date: Mon, 10 Jun 2024 17:09:07 -0400 +Message-ID: <20240610210912.161735-1-ahassick@iol.unh.edu> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit + +Add a test program and a makefile. +Big surprise here, but this is all for testing. + +Adam Hassick (2): + Add test program + Add a Makefile + + Makefile | 9 +++++++++ + test.c | 8 ++++++++ + 2 files changed, 17 insertions(+) + create mode 100644 Makefile + create mode 100644 test.c + +-- +2.45.2 + + +From ahassick@iol.unh.edu Mon Jun 10 21:09:09 2024 +Return-Path: +From: Adam Hassick +To: Adam.Hassick@unh.edu +Subject: [PATCH v1 1/2] Add test program +Date: Mon, 10 Jun 2024 17:09:09 -0400 +Message-ID: <20240610210912.161735-3-ahassick@iol.unh.edu> +In-Reply-To: <20240610210912.161735-1-ahassick@iol.unh.edu> +References: <20240610210912.161735-1-ahassick@iol.unh.edu> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit + + + +Signed-off-by: Adam Hassick +--- + test.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + create mode 100644 test.c + +diff --git a/test.c b/test.c +new file mode 100644 +index 0000000..5096204 +--- /dev/null ++++ b/test.c +@@ -0,0 +1,8 @@ ++ ++#include ++ ++int main() { ++ printf("HELLOOOOO!!!! Hi there!"); ++ return 0; ++} ++ +-- +2.45.2 + + +From ahassick@iol.unh.edu Mon Jun 10 21:09:11 2024 +Return-Path: +From: Adam Hassick +To: Adam.Hassick@unh.edu +Subject: [PATCH v1 2/2] Add a Makefile +Date: Mon, 10 Jun 2024 17:09:11 -0400 +Message-ID: <20240610210912.161735-5-ahassick@iol.unh.edu> +In-Reply-To: <20240610210912.161735-1-ahassick@iol.unh.edu> +References: <20240610210912.161735-1-ahassick@iol.unh.edu> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit + +How are people supposed to build this without a Makefile? + +Signed-off-by: Adam Hassick +--- + Makefile | 9 +++++++++ + 1 file changed, 9 insertions(+) + create mode 100644 Makefile + +diff --git a/Makefile b/Makefile +new file mode 100644 +index 0000000..2126a0e +--- /dev/null ++++ b/Makefile +@@ -0,0 +1,9 @@ ++ ++CC=gcc ++ ++test: test.c ++ $(CC) -O2 -march=native -mtune=native test.c -o test ++ ++test-debug: test.c ++ $(CC) -O0 -g test.c -o test ++ +-- +2.45.2 diff --git a/patchwork/tests/series/dependency-multi-2.mbox.template b/patchwork/tests/series/dependency-multi-2.mbox.template new file mode 100644 index 0000000..42296f4 --- /dev/null +++ b/patchwork/tests/series/dependency-multi-2.mbox.template @@ -0,0 +1,110 @@ +From ahassick@iol.unh.edu Wed Jun 12 20:40:05 2024 +Return-Path: +From: Adam Hassick +To: Adam.Hassick@unh.edu +Cc: Adam Hassick +Subject: [PATCH v1 0/2] More changes +Date: Wed, 12 Jun 2024 16:40:05 -0400 +Message-ID: <20240612204019.364820-1-ahassick@iol.unh.edu> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit + +Tests. + +Adam Hassick (2): + test: Change the test function + Fix Makefile + + Makefile | 2 +- + test.c | 10 ++++++++-- + 2 files changed, 9 insertions(+), 3 deletions(-) + +-- +2.45.2 + + +From ahassick@iol.unh.edu Wed Jun 12 20:40:06 2024 +Return-Path: +From: Adam Hassick +To: Adam.Hassick@unh.edu +Cc: Adam Hassick +Subject: [PATCH v1 1/2] test: Change the test function +Date: Wed, 12 Jun 2024 16:40:06 -0400 +Message-ID: <20240612204019.364820-2-ahassick@iol.unh.edu> +In-Reply-To: <20240612204019.364820-1-ahassick@iol.unh.edu> +References: <20240612204019.364820-1-ahassick@iol.unh.edu> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit + +I don't like what it did before. Let's make it do something more +interesting this time. + +Depends-on: {depends_token_1} +Signed-off-by: Adam Hassick +--- + test.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/test.c b/test.c +index f6cd16e..a868311 100644 +--- a/test.c ++++ b/test.c +@@ -1,11 +1,17 @@ + + #include ++#include + #include + + // This function does things. + void thingymabob(char *string) {{ +- printf("Here's your argument: %s\n", string); +- printf("Here is the length of your argument: %li\n", strlen(string)); ++ double f = atof(string); ++ ++ if (f > 5.0) {{ ++ printf("I'm satisfied.\n"); ++ }} else {{ ++ fprintf(stderr, "I'm not satisfied.\n"); ++ }} + }} + + // Entry point. +-- +2.45.2 + + +From ahassick@iol.unh.edu Wed Jun 12 20:40:07 2024 +Return-Path: +From: Adam Hassick +To: Adam.Hassick@unh.edu +Cc: Adam Hassick +Subject: [PATCH v1 2/2] Fix Makefile +Date: Wed, 12 Jun 2024 16:40:07 -0400 +Message-ID: <20240612204019.364820-3-ahassick@iol.unh.edu> +X-Mailer: git-send-email 2.45.2 +In-Reply-To: <20240612204019.364820-1-ahassick@iol.unh.edu> +References: <20240612204019.364820-1-ahassick@iol.unh.edu> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit + +The test-debug target did not generate the correct file. + +Depends-on: {depends_token_2} +Signed-off-by: Adam Hassick +--- + Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index 3583b93..78a2bf0 100644 +--- a/Makefile ++++ b/Makefile +@@ -9,5 +9,5 @@ test: test.c + $(CC) -O2 -march=native -mtune=native -Wall -Werror -pedantic test.c -o test + + test-debug: test.c +- $(CC) -O0 -g test.c -Wall -Werror -pedantic -o test ++ $(CC) -O0 -g test.c -Wall -Werror -pedantic -o test-debug + +-- +2.45.2 diff --git a/patchwork/tests/series/dependency-multi.mbox.template b/patchwork/tests/series/dependency-multi.mbox.template new file mode 100644 index 0000000..40fba59 --- /dev/null +++ b/patchwork/tests/series/dependency-multi.mbox.template @@ -0,0 +1,109 @@ +From ahassick@iol.unh.edu Wed Jun 12 20:40:05 2024 +Return-Path: +From: Adam Hassick +To: ach1062@usnh.edu +Cc: Adam Hassick +Subject: [PATCH v1 0/2] More changes +Date: Wed, 12 Jun 2024 16:40:05 -0400 +Message-ID: <20240612204019.364820-1-ahassick@iol.unh.edu> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit + +Tests. + +Depends-on: {depends_token_1} +Depends-on: {depends_token_2} +Adam Hassick (2): + test: Change the test function + Fix Makefile + + Makefile | 2 +- + test.c | 10 ++++++++-- + 2 files changed, 9 insertions(+), 3 deletions(-) + +-- +2.45.2 + + +From ahassick@iol.unh.edu Wed Jun 12 20:40:06 2024 +Return-Path: +From: Adam Hassick +To: ach1062@usnh.edu +Cc: Adam Hassick +Subject: [PATCH v1 1/2] test: Change the test function +Date: Wed, 12 Jun 2024 16:40:06 -0400 +Message-ID: <20240612204019.364820-2-ahassick@iol.unh.edu> +In-Reply-To: <20240612204019.364820-1-ahassick@iol.unh.edu> +References: <20240612204019.364820-1-ahassick@iol.unh.edu> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit + +I don't like what it did before. Let's make it do something more +interesting this time. + +Signed-off-by: Adam Hassick +--- + test.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/test.c b/test.c +index f6cd16e..a868311 100644 +--- a/test.c ++++ b/test.c +@@ -1,11 +1,17 @@ + + #include ++#include + #include + + // This function does things. + void thingymabob(char *string) {{ +- printf("Here's your argument: %s\n", string); +- printf("Here is the length of your argument: %li\n", strlen(string)); ++ double f = atof(string); ++ ++ if (f > 5.0) {{ ++ printf("I'm satisfied.\n"); ++ }} else {{ ++ fprintf(stderr, "I'm not satisfied.\n"); ++ }} + }} + + // Entry point. +-- +2.45.2 + + +From ahassick@iol.unh.edu Wed Jun 12 20:40:07 2024 +Return-Path: +From: Adam Hassick +To: ach1062@usnh.edu +Cc: Adam Hassick +Subject: [PATCH v1 2/2] Fix Makefile +Date: Wed, 12 Jun 2024 16:40:07 -0400 +Message-ID: <20240612204019.364820-3-ahassick@iol.unh.edu> +In-Reply-To: <20240612204019.364820-1-ahassick@iol.unh.edu> +References: <20240612204019.364820-1-ahassick@iol.unh.edu> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit + +The test-debug target did not generate the correct file. + +Signed-off-by: Adam Hassick +--- + Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Makefile b/Makefile +index 3583b93..78a2bf0 100644 +--- a/Makefile ++++ b/Makefile +@@ -9,5 +9,5 @@ test: test.c + $(CC) -O2 -march=native -mtune=native -Wall -Werror -pedantic test.c -o test + + test-debug: test.c +- $(CC) -O0 -g test.c -Wall -Werror -pedantic -o test ++ $(CC) -O0 -g test.c -Wall -Werror -pedantic -o test-debug + +-- +2.45.2 diff --git a/patchwork/tests/series/dependency-one-cover.mbox.template b/patchwork/tests/series/dependency-one-cover.mbox.template new file mode 100644 index 0000000..8817e69 --- /dev/null +++ b/patchwork/tests/series/dependency-one-cover.mbox.template @@ -0,0 +1,128 @@ +From ahassick@iol.unh.edu Tue Jun 11 16:08:46 2024 +Return-Path: +From: Adam Hassick +To: Adam.Hassick@unh.edu +Cc: Adam Hassick +Subject: [PATCH v1 0/2] Improvements to the test project +Date: Tue, 11 Jun 2024 12:08:46 -0400 +Message-ID: <20240611160854.192806-1-ahassick@iol.unh.edu> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit + +Various improvements to the test project. +Guy Manson hasn't merged my other patches yet. That sack of lazy bones! +We will have to depend on the first series to get this to pass the CI. + +Depends-on: {depends_token} +Adam Hassick (2): + Makefile: Improve the makefile + test: Improve the test application + + Makefile | 8 ++++++-- + test.c | 22 +++++++++++++++++++--- + 2 files changed, 25 insertions(+), 5 deletions(-) + +-- +2.45.2 + + +From ahassick@iol.unh.edu Tue Jun 11 16:08:47 2024 +Return-Path: +From: Adam Hassick +To: Adam.Hassick@unh.edu +Cc: Adam Hassick +Subject: [PATCH v1 1/2] Makefile: Improve the makefile +Date: Tue, 11 Jun 2024 12:08:47 -0400 +Message-ID: <20240611160854.192806-2-ahassick@iol.unh.edu> +In-Reply-To: <20240611160854.192806-1-ahassick@iol.unh.edu> +References: <20240611160854.192806-1-ahassick@iol.unh.edu> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit + +We weren't checking for errors very well before. Let's fix that. +The test-debug target did not generate the correct file. + +Signed-off-by: Adam Hassick +--- + Makefile | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/Makefile b/Makefile +index 2126a0e..3583b93 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,9 +1,13 @@ + + CC=gcc + ++.PHONY: all ++ ++all: test test-debug ++ + test: test.c +- $(CC) -O2 -march=native -mtune=native test.c -o test ++ $(CC) -O2 -march=native -mtune=native -Wall -Werror -pedantic test.c -o test + + test-debug: test.c +- $(CC) -O0 -g test.c -o test ++ $(CC) -O0 -g test.c -Wall -Werror -pedantic -o test + +-- +2.45.2 + + +From ahassick@iol.unh.edu Tue Jun 11 16:08:48 2024 +Return-Path: +From: Adam Hassick +To: Adam.Hassick@unh.edu +Cc: Adam Hassick +Subject: [PATCH v1 2/2] test: Improve the test application +Date: Tue, 11 Jun 2024 12:08:48 -0400 +Message-ID: <20240611160854.192806-3-ahassick@iol.unh.edu> +In-Reply-To: <20240611160854.192806-1-ahassick@iol.unh.edu> +References: <20240611160854.192806-1-ahassick@iol.unh.edu> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit + +The test application before wasn't very interesting. +Let's make it do something with an invariant this time. + +Signed-off-by: Adam Hassick +--- + test.c | 22 +++++++++++++++++++--- + 1 file changed, 19 insertions(+), 3 deletions(-) + +diff --git a/test.c b/test.c +index 5096204..f6cd16e 100644 +--- a/test.c ++++ b/test.c +@@ -1,8 +1,24 @@ + + #include ++#include + +-int main() {{ +- printf("HELLOOOOO!!!! Hi there!"); +- return 0; ++// This function does things. ++void thingymabob(char *string) {{ ++ printf("Here's your argument: %s\n", string); ++ printf("Here is the length of your argument: %li\n", strlen(string)); + }} + ++// Entry point. ++int main(int argc, char **argv) {{ ++ ++ // Make sure we get exactly one argument. ++ if (argc != 2) {{ ++ fprintf(stderr, "I want exactly one argument please!\n"); ++ return 1; ++ }} ++ ++ // Do something with it. ++ thingymabob(argv[1]); ++ ++ return 0; ++}} +-- +2.45.2 diff --git a/patchwork/tests/series/dependency-one-first-patch.mbox.template b/patchwork/tests/series/dependency-one-first-patch.mbox.template new file mode 100644 index 0000000..d03ef7d --- /dev/null +++ b/patchwork/tests/series/dependency-one-first-patch.mbox.template @@ -0,0 +1,125 @@ +From ahassick@iol.unh.edu Tue Jun 11 16:08:46 2024 +Return-Path: +From: Adam Hassick +To: Adam.Hassick@unh.edu +Cc: Adam Hassick +Subject: [PATCH v1 0/2] Improvements to the test project +Date: Tue, 11 Jun 2024 12:08:46 -0400 +Message-ID: <20240611160854.192806-1-ahassick@iol.unh.edu> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit + +Various improvements to the test project. + +Depends-on: {depends_token} +Adam Hassick (2): + Makefile: Improve the makefile + test: Improve the test application + + Makefile | 8 ++++++-- + test.c | 22 +++++++++++++++++++--- + 2 files changed, 25 insertions(+), 5 deletions(-) + +-- +2.45.2 + + +From ahassick@iol.unh.edu Tue Jun 11 16:08:47 2024 +Return-Path: +From: Adam Hassick +To: Adam.Hassick@unh.edu +Cc: Adam Hassick +Subject: [PATCH v1 1/2] Makefile: Improve the makefile +Date: Tue, 11 Jun 2024 12:08:47 -0400 +Message-ID: <20240611160854.192806-2-ahassick@iol.unh.edu> +In-Reply-To: <20240611160854.192806-1-ahassick@iol.unh.edu> +References: <20240611160854.192806-1-ahassick@iol.unh.edu> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit + +We weren't checking for errors very well before. Let's fix that. + +Signed-off-by: Adam Hassick +--- + Makefile | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/Makefile b/Makefile +index 2126a0e..3583b93 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,9 +1,13 @@ + + CC=gcc + ++.PHONY: all ++ ++all: test test-debug ++ + test: test.c +- $(CC) -O2 -march=native -mtune=native test.c -o test ++ $(CC) -O2 -march=native -mtune=native -Wall -Werror -pedantic test.c -o test + + test-debug: test.c +- $(CC) -O0 -g test.c -o test ++ $(CC) -O0 -g test.c -Wall -Werror -pedantic -o test + +-- +2.45.2 + + +From ahassick@iol.unh.edu Tue Jun 11 16:08:48 2024 +Return-Path: +From: Adam Hassick +To: Adam.Hassick@unh.edu +Cc: Adam Hassick +Subject: [PATCH v1 2/2] test: Improve the test application +Date: Tue, 11 Jun 2024 12:08:48 -0400 +Message-ID: <20240611160854.192806-3-ahassick@iol.unh.edu> +In-Reply-To: <20240611160854.192806-1-ahassick@iol.unh.edu> +References: <20240611160854.192806-1-ahassick@iol.unh.edu> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit + +The test application before wasn't very interesting. +Let's make it do something with an invariant this time. + +Signed-off-by: Adam Hassick +--- + test.c | 22 +++++++++++++++++++--- + 1 file changed, 19 insertions(+), 3 deletions(-) + +diff --git a/test.c b/test.c +index 5096204..f6cd16e 100644 +--- a/test.c ++++ b/test.c +@@ -1,8 +1,24 @@ + + #include ++#include + +-int main() {{ +- printf("HELLOOOOO!!!! Hi there!"); +- return 0; ++// This function does things. ++void thingymabob(char *string) {{ ++ printf("Here's your argument: %s\n", string); ++ printf("Here is the length of your argument: %li\n", strlen(string)); + }} + ++// Entry point. ++int main(int argc, char **argv) {{ ++ ++ // Make sure we get exactly one argument. ++ if (argc != 2) {{ ++ fprintf(stderr, "I want exactly one argument please!\n"); ++ return 1; ++ }} ++ ++ // Do something with it. ++ thingymabob(argv[1]); ++ ++ return 0; ++}} +-- +2.45.2 diff --git a/patchwork/tests/test_parser.py b/patchwork/tests/test_parser.py index 919f9f4..1411ef0 100644 --- a/patchwork/tests/test_parser.py +++ b/patchwork/tests/test_parser.py @@ -1518,3 +1518,55 @@ class TestCommentCorrelation(TestCase): result = parser.find_cover_for_comment(project, [msgid]) self.assertEqual(cover, result) + + +class TestParseDependsOn(TestCase): + def setUp(self): + self.project = create_project() + self.series1 = create_series(project=self.project) + self.series2 = create_series(project=self.project) + self.patch = create_patch(project=self.project, series=self.series1) + self.cover = create_cover(project=self.project, series=self.series2) + + def test_parse_depends_on_garbage_ref_1(self): + self.assertFalse( + parser.parse_depends_on('Depends-on: not-an-id-or-url') + ) + + def test_parse_depends_on_garbage_ref_2(self): + self.assertFalse( + parser.parse_depends_on('Depends-on: ') + ) + + def test_parse_depends_on_garbage_url(self): + content = f'Depends-on: http://patchwork.dpdk.org/projects/{self.project.linkname}/list' + self.assertFalse(parser.parse_depends_on(content)) + + def test_parse_depends_on_msgid(self): + self.assertIn( + self.series1, + parser.parse_depends_on(f'Depends-on: {self.patch.msgid}'), + ) + self.assertIn( + self.series2, + parser.parse_depends_on(f'Depends-on: {self.cover.msgid}'), + ) + + content = ( + f'Depends-on: {self.patch.msgid}\nDepends-on: {self.cover.msgid}' + ) + result = parser.parse_depends_on(content) + self.assertIn(self.series1, result) + self.assertIn(self.series2, result) + + def test_parse_depends_on_url(self): + content1 = f'Depends-on: http://test{self.series1.get_absolute_url()}' + content2 = f'Depends-on: http://test{self.patch.get_absolute_url()}' + content3 = f'Depends-on: http://test{self.series2.get_absolute_url()}' + self.assertIn(self.series1, parser.parse_depends_on(content1)) + self.assertIn(self.series1, parser.parse_depends_on(content2)) + self.assertIn(self.series2, parser.parse_depends_on(content3)) + + result = parser.parse_depends_on('\n'.join([content2, content3])) + self.assertIn(self.series1, result) + self.assertIn(self.series2, result) diff --git a/patchwork/tests/test_series.py b/patchwork/tests/test_series.py index ce11404..8ae3f0a 100644 --- a/patchwork/tests/test_series.py +++ b/patchwork/tests/test_series.py @@ -6,6 +6,7 @@ import mailbox import os import unittest +import tempfile from django.test import TestCase @@ -804,3 +805,273 @@ class SeriesNameTestCase(TestCase): self.assertEqual(series.name, series_name) mbox.close() + + +class SeriesDependencyTestCase(TestCase): + def setUp(self): + self.project = utils.create_project() + utils.create_state() + + def _load_mbox_template(self, name, **kwargs): + """ + This function is necessary for this test so that we can template in + the series or patch ID that we want to depend on. + """ + with open(os.path.join(TEST_SERIES_DIR, name), 'r') as mbox_file: + mbox_content = mbox_file.read() + + # Write the templated mbox file to a temp file. + tmpfile = tempfile.mktemp() + + with open(tmpfile, 'w') as mbox_opt_file: + mbox_opt_file.write(mbox_content.format(**kwargs)) + + # Load the mbox. + mbox = mailbox.mbox(tmpfile, create=False) + + # Then, remove the temp file (to avoid leaking resources). + os.remove(tmpfile) + + return mbox + + def _load_mbox(self, name): + return mailbox.mbox(os.path.join(TEST_SERIES_DIR, name), create=False) + + def _parse_mbox(self, mbox, project_override=None): + return list( + map( + lambda mail: parser.parse_mail( + mail, + project_override.listid + if project_override + else self.project.listid, + ), + mbox, + ) + ) + + def test_dependency_by_series_url(self): + mbox1 = self._load_mbox('dependency-base-patch.mbox') + _, series1_patch1, _ = self._parse_mbox(mbox1) + mbox1.close() + + series1 = series1_patch1.series + + mbox2 = self._load_mbox_template( + 'dependency-one-cover.mbox.template', + depends_token=f'http://test{series1.get_absolute_url()}', + ) + _, series2_patch1, _ = self._parse_mbox(mbox2) + mbox2.close() + + series2 = series2_patch1.series + + self.assertIn(series2, series1.dependents.all()) + self.assertIn(series1, series2.dependencies.all()) + + def test_dependency_by_patch_url(self): + mbox1 = self._load_mbox('dependency-base-patch.mbox') + _, series1_patch1, _ = self._parse_mbox(mbox1) + mbox1.close() + + series1 = series1_patch1.series + + mbox2 = self._load_mbox_template( + 'dependency-one-cover.mbox.template', + depends_token=f'http://test{series1_patch1.get_absolute_url()}', + ) + _, series2_patch1, _ = self._parse_mbox(mbox2) + mbox2.close() + + series2 = series2_patch1.series + + self.assertIn(series2, series1.dependents.all()) + self.assertIn(series1, series2.dependencies.all()) + + def test_dependency_by_patch_msgid(self): + mbox1 = self._load_mbox('dependency-base-patch.mbox') + _, series1_patch1, _ = self._parse_mbox(mbox1) + mbox1.close() + + series1 = series1_patch1.series + + mbox2 = self._load_mbox_template( + 'dependency-one-first-patch.mbox.template', + depends_token=series1_patch1.msgid, + ) + _, series2_patch1, _ = self._parse_mbox(mbox2) + mbox2.close() + + series2 = series2_patch1.series + + self.assertIn(series2, series1.dependents.all()) + self.assertIn(series1, series2.dependencies.all()) + + def test_dependency_by_cover_msgid(self): + mbox1 = self._load_mbox('dependency-base-patch.mbox') + series1_cover, series1_patch1, _ = self._parse_mbox(mbox1) + mbox1.close() + + mbox2 = self._load_mbox_template( + 'dependency-one-first-patch.mbox.template', + depends_token=series1_cover.msgid, + ) + _, series2_patch1, _ = self._parse_mbox(mbox2) + mbox2.close() + + series1 = series1_patch1.series + series2 = series2_patch1.series + + self.assertIn(series2, series1.dependents.all()) + self.assertIn(series1, series2.dependencies.all()) + + def test_dependency_by_patch_msgid_on_cover(self): + mbox1 = self._load_mbox('dependency-base-patch.mbox') + _, series1_patch1, _ = self._parse_mbox(mbox1) + mbox1.close() + + series1 = series1_patch1.series + + mbox2 = self._load_mbox_template( + 'dependency-one-cover.mbox.template', + depends_token=series1_patch1.msgid, + ) + _, series2_patch1, _ = self._parse_mbox(mbox2) + mbox2.close() + + series2 = series2_patch1.series + + self.assertIn(series2, series1.dependents.all()) + self.assertIn(series1, series2.dependencies.all()) + + def test_dependency_by_patch2_msgid(self): + mbox1 = self._load_mbox('dependency-base-patch.mbox') + _, _, series1_patch2 = self._parse_mbox(mbox1) + mbox1.close() + + mbox2 = self._load_mbox_template( + 'dependency-one-cover.mbox.template', + depends_token=series1_patch2.msgid, + ) + _, series2_patch1, _ = self._parse_mbox(mbox2) + mbox2.close() + + series1 = series1_patch2.series + series2 = series2_patch1.series + + self.assertIn(series2, series1.dependents.all()) + self.assertIn(series1, series2.dependencies.all()) + + def test_dependency_no_circular_relation(self): + mbox = self._load_mbox_template( + 'dependency-one-first-patch.mbox.template', + # Message ID from the cover letter in this patch, + # which should be parsed ahead of the 1st patch. + depends_token='<20240611160854.192806-1-ahassick@iol.unh.edu>', + ) + _, patch, _ = self._parse_mbox(mbox) + mbox.close() + + self.assertNotIn(patch.series, patch.series.dependencies.all()) + + def test_dependency_no_cross_project_relation(self): + project2 = utils.create_project(name='testproject2') + mbox1 = self._load_mbox('dependency-base-patch.mbox') + _, series1_patch1, _ = self._parse_mbox(mbox1) + mbox1.close() + + series1 = series1_patch1.series + + mbox2 = self._load_mbox_template( + 'dependency-one-first-patch.mbox.template', + depends_token=series1_patch1.msgid, + ) + _, series2_patch1, _ = self._parse_mbox( + mbox2, project_override=project2 + ) + mbox2.close() + + series2 = series2_patch1.series + + self.assertNotIn(series1, series2.dependencies.all()) + + def test_dependency_multi_1(self): + mbox1 = self._load_mbox('dependency-base-patch.mbox') + _, series1_patch1, _ = self._parse_mbox(mbox1) + mbox1.close() + + series1 = series1_patch1.series + + mbox2 = self._load_mbox_template( + 'dependency-one-cover.mbox.template', + depends_token=series1_patch1.msgid, + ) + _, series2_patch1, _ = self._parse_mbox(mbox2) + mbox2.close() + + series2 = series2_patch1.series + + mbox3 = self._load_mbox_template( + 'dependency-multi.mbox.template', + depends_token_1=series1_patch1.msgid, + depends_token_2=series2_patch1.msgid, + ) + _, series3_patch1, _ = self._parse_mbox(mbox3) + mbox3.close() + + series3 = series3_patch1.series + + self.assertIn(series2, series1.dependents.all()) + self.assertIn(series2, series3.dependencies.all()) + self.assertIn(series1, series2.dependencies.all()) + self.assertIn(series3, series2.dependents.all()) + self.assertEqual(series1.dependencies.count(), 0) + self.assertEqual(series1.dependents.count(), 2) + self.assertEqual(series2.dependents.count(), 1) + self.assertEqual(series2.dependencies.count(), 1) + self.assertEqual(series3.dependencies.count(), 2) + self.assertEqual(series3.dependents.count(), 0) + + # Test that the ordering is correct. + d1, d2 = [dep for dep in series3.dependencies.all()] + + # First item in the query set should be the first dependency. + self.assertEqual(d1, series1) + self.assertEqual(d2, series2) + + def test_dependency_multi_2(self): + mbox1 = self._load_mbox('dependency-base-patch.mbox') + _, series1_patch1, _ = self._parse_mbox(mbox1) + mbox1.close() + + series1 = series1_patch1.series + + mbox2 = self._load_mbox_template( + 'dependency-one-cover.mbox.template', + depends_token=series1_patch1.msgid, + ) + _, series2_patch1, _ = self._parse_mbox(mbox2) + mbox2.close() + + series2 = series2_patch1.series + + mbox3 = self._load_mbox_template( + 'dependency-multi-2.mbox.template', + depends_token_1=series1_patch1.msgid, + depends_token_2=series2_patch1.msgid, + ) + _, series3_patch1, _ = self._parse_mbox(mbox3) + mbox3.close() + + series3 = series3_patch1.series + + self.assertIn(series2, series1.dependents.all()) + self.assertIn(series2, series3.dependencies.all()) + self.assertIn(series1, series2.dependencies.all()) + self.assertIn(series3, series2.dependents.all()) + self.assertEqual(series1.dependencies.count(), 0) + self.assertEqual(series1.dependents.count(), 2) + self.assertEqual(series2.dependents.count(), 1) + self.assertEqual(series2.dependencies.count(), 1) + self.assertEqual(series3.dependencies.count(), 2) + self.assertEqual(series3.dependents.count(), 0)