summaryrefslogtreecommitdiff
path: root/t/helper/test-pkt-line.c
diff options
context:
space:
mode:
Diffstat (limited to 't/helper/test-pkt-line.c')
-rw-r--r--t/helper/test-pkt-line.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/t/helper/test-pkt-line.c b/t/helper/test-pkt-line.c
index 282d536..5e638f0 100644
--- a/t/helper/test-pkt-line.c
+++ b/t/helper/test-pkt-line.c
@@ -46,6 +46,9 @@ static void unpack(void)
case PACKET_READ_DELIM:
printf("0001\n");
break;
+ case PACKET_READ_RESPONSE_END:
+ printf("0002\n");
+ break;
}
}
}
@@ -67,7 +70,7 @@ static void unpack_sideband(void)
case PACKET_READ_NORMAL:
band = reader.line[0] & 0xff;
if (band < 1 || band > 2)
- die("unexpected side band %d", band);
+ continue; /* skip non-sideband packets */
fd = band;
write_or_die(fd, reader.line + 1, reader.pktlen - 1);
@@ -75,11 +78,31 @@ static void unpack_sideband(void)
case PACKET_READ_FLUSH:
return;
case PACKET_READ_DELIM:
+ case PACKET_READ_RESPONSE_END:
break;
}
}
}
+static int send_split_sideband(void)
+{
+ const char *part1 = "Hello,";
+ const char *primary = "\001primary: regular output\n";
+ const char *part2 = " world!\n";
+
+ send_sideband(1, 2, part1, strlen(part1), LARGE_PACKET_MAX);
+ packet_write(1, primary, strlen(primary));
+ send_sideband(1, 2, part2, strlen(part2), LARGE_PACKET_MAX);
+ packet_response_end(1);
+
+ return 0;
+}
+
+static int receive_sideband(void)
+{
+ return recv_sideband("sideband", 0, 1);
+}
+
int cmd__pkt_line(int argc, const char **argv)
{
if (argc < 2)
@@ -91,6 +114,10 @@ int cmd__pkt_line(int argc, const char **argv)
unpack();
else if (!strcmp(argv[1], "unpack-sideband"))
unpack_sideband();
+ else if (!strcmp(argv[1], "send-split-sideband"))
+ send_split_sideband();
+ else if (!strcmp(argv[1], "receive-sideband"))
+ receive_sideband();
else
die("invalid argument '%s'", argv[1]);