summaryrefslogtreecommitdiffstats
path: root/tools/testing/vsock/control.c
diff options
context:
space:
mode:
authorArseniy Krasnov <AVKrasnov@sberdevices.ru>2023-01-10 11:15:15 +0100
committerPaolo Abeni <pabeni@redhat.com>2023-01-12 12:53:54 +0100
commit5c338112e48ab1937f99e4a8990a82c999fda126 (patch)
tree4a9e9bd4ce34b36fc1e8e5313787c20003630a8b /tools/testing/vsock/control.c
parentvsock: return errors other than -ENOMEM to socket (diff)
downloadlinux-5c338112e48ab1937f99e4a8990a82c999fda126.tar.xz
linux-5c338112e48ab1937f99e4a8990a82c999fda126.zip
test/vsock: rework message bounds test
This updates message bound test making it more complex. Instead of sending 1 bytes messages with one MSG_EOR bit, it sends messages of random length(one half of messages are smaller than page size, second half are bigger) with random number of MSG_EOR bits set. Receiver also don't know total number of messages. Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'tools/testing/vsock/control.c')
-rw-r--r--tools/testing/vsock/control.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/testing/vsock/control.c b/tools/testing/vsock/control.c
index 4874872fc5a3..d2deb4b15b94 100644
--- a/tools/testing/vsock/control.c
+++ b/tools/testing/vsock/control.c
@@ -141,6 +141,34 @@ void control_writeln(const char *str)
timeout_end();
}
+void control_writeulong(unsigned long value)
+{
+ char str[32];
+
+ if (snprintf(str, sizeof(str), "%lu", value) >= sizeof(str)) {
+ perror("snprintf");
+ exit(EXIT_FAILURE);
+ }
+
+ control_writeln(str);
+}
+
+unsigned long control_readulong(void)
+{
+ unsigned long value;
+ char *str;
+
+ str = control_readln();
+
+ if (!str)
+ exit(EXIT_FAILURE);
+
+ value = strtoul(str, NULL, 10);
+ free(str);
+
+ return value;
+}
+
/* Return the next line from the control socket (without the trailing newline).
*
* The program terminates if a timeout occurs.