@@ -13,6 +13,7 @@ import (
1313 "github.com/google/syzkaller/dashboard/dashapi"
1414 "github.com/google/syzkaller/pkg/email"
1515 "github.com/stretchr/testify/assert"
16+ "github.com/stretchr/testify/require"
1617)
1718
1819func TestThreadsCollection (t * testing.T ) {
@@ -381,6 +382,17 @@ func TestDiscussionType(t *testing.T) {
381382 }
382383}
383384
385+ const dummyPatch = `diff --git a/kernel/kcov.c b/kernel/kcov.c
386+ index 85e5546cd791..949ea4574412 100644
387+ --- a/kernel/kcov.c
388+ +++ b/kernel/kcov.c
389+ @@ -127,7 +127,6 @@ void kcov_task_exit(struct task_struct *t)
390+ if (kcov == NULL)
391+ return;
392+ - spin_lock(&kcov->lock);
393+ if (WARN_ON(kcov->t != t)) {
394+ `
395+
384396func TestParseSeries (t * testing.T ) {
385397 messages := []string {
386398 // A simple patch series.
@@ -390,8 +402,7 @@ Message-ID: <First>
390402From: UserA <a@user.com>
391403Content-Type: text/plain
392404
393-
394- Some text` ,
405+ ` + dummyPatch ,
395406 // A series with a cover.
396407 `Date: Sun, 7 May 2017 19:55:00 -0700
397408Subject: [PATCH net v2 00/02] A longer series
@@ -409,8 +420,7 @@ To: UserA <a@user.com>, UserB <b@user.com>
409420Content-Type: text/plain
410421In-Reply-To: <Second>
411422
412-
413- Patch 1/2` ,
423+ ` + dummyPatch ,
414424 `Date: Sun, 7 May 2017 19:56:00 -0700
415425Subject: [PATCH net v2 02/02] Second patch
416426Message-ID: <Second-2>
@@ -419,16 +429,24 @@ To: UserA <a@user.com>, UserB <b@user.com>
419429Content-Type: text/plain
420430In-Reply-To: <Second>
421431
422-
423- Patch 2/2` ,
424- // Missing patches.
432+ ` + dummyPatch ,
433+ // Some missing patches.
425434 `Date: Sun, 7 May 2017 19:57:00 -0700
426435Subject: [PATCH 01/03] Series
427436Message-ID: <Third>
428437From: Someone <a@b.com>
429438Content-Type: text/plain
430439
431- Bug report` ,
440+ ` + dummyPatch ,
441+ // Reply with a patch subject.
442+ `Date: Sun, 7 May 2017 19:57:00 -0700
443+ Subject: [PATCH] Series
444+ Message-ID: <Fourth>
445+ From: Someone <a@b.com>
446+ Content-Type: text/plain
447+ In-Reply-To: <Something>
448+
449+ No patch, just text` ,
432450 }
433451
434452 var emails []* Email
@@ -441,7 +459,7 @@ Bug report`,
441459 }
442460
443461 series := PatchSeries (emails )
444- assert .Len (t , series , 3 )
462+ assert .Len (t , series , 4 )
445463
446464 expectPerID := map [string ]* Series {
447465 "<First>" : {
@@ -480,6 +498,12 @@ Bug report`,
480498 },
481499 },
482500 },
501+ "<Fourth>" : {
502+ Subject : "Series" ,
503+ Version : 1 ,
504+ Corrupted : "the subject mentions 1 patches, 0 are found" ,
505+ Patches : nil ,
506+ },
483507 }
484508 for _ , s := range series {
485509 expect := expectPerID [s .MessageID ]
@@ -491,7 +515,7 @@ Bug report`,
491515 assert .Equal (t , expect .Corrupted , s .Corrupted , "corrupted differs" )
492516 assert .Equal (t , expect .Subject , s .Subject , "subject differs" )
493517 assert .Equal (t , expect .Version , s .Version , "version differs" )
494- assert .Len (t , s .Patches , len (expect .Patches ), "patch count differs" )
518+ require .Len (t , s .Patches , len (expect .Patches ), "patch count differs" )
495519 for i , expectPatch := range expect .Patches {
496520 got := s .Patches [i ]
497521 assert .Equal (t , expectPatch .Seq , got .Seq , "seq differs" )
0 commit comments