Regres: Limit the Gerrit comment message length

This prevents '400 Bad Request' responses. The limit of 16000 was
determined through experimentation.

Bug: b/150284316
Change-Id: I5507efdcfbaac2c09c2dffde9bf173f4f9219a72
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/44989
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
diff --git a/tests/regres/cmd/regres/main.go b/tests/regres/cmd/regres/main.go
index 383892c..b4a1675 100644
--- a/tests/regres/cmd/regres/main.go
+++ b/tests/regres/cmd/regres/main.go
@@ -371,6 +371,13 @@
 		// already got a test result.
 		msg = reportHeader + "\n\n" + msg
 
+		// Limit the message length to prevent '400 Bad Request' response.
+		maxMsgLength := 16000
+		if len(msg) > maxMsgLength {
+			trunc := " [truncated]\n"
+			msg = msg[0:maxMsgLength-len(trunc)] + trunc
+		}
+
 		if r.dryRun {
 			log.Printf("DRY RUN: add review to change '%v':\n%v\n", change.id, msg)
 		} else {