Better way to detect the double new lines the API issues from time to time.
authorclaudio <claudio@openbsd.org>
Mon, 10 May 2021 10:26:23 +0000 (10:26 +0000)
committerclaudio <claudio@openbsd.org>
Mon, 10 May 2021 10:26:23 +0000 (10:26 +0000)
This way done lines now will have a newline.

regress/usr.sbin/bgpd/integrationtests/api-exabgp.c

index 5591977..d4f5426 100644 (file)
@@ -72,7 +72,9 @@ main(int argc, char **argv)
                        n = read(0, buf, sizeof(buf));
                        if (n == -1)
                                err(1, "read stdin");
-                       if (write(2, buf, n - 1) != n - 1)
+                       if (n > 2 && strncmp(buf + n - 2, "\n\n", 2) == 0)
+                               n--;
+                       if (write(2, buf, n) != n)
                                errx(1, "bad write to stderr");
                        if (n > 8 && strncmp(buf, "shutdown", 8) == 0)
                                errx(0, "exabgp shutdown");