]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-program-client: test-program-client-local - Use dd instead of head
authorAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 21 Feb 2019 16:50:10 +0000 (18:50 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 6 Oct 2021 19:57:32 +0000 (19:57 +0000)
`head -c n` is only guaranteed to print n bytes, but it may consume more.
FreeBSD's implementation of head(1) uses buffered stdio, which did just that.

`dd` consumes exactly the specified number of bytes.

src/lib-program-client/test-program-client-local.c

index 03e24015cd1d3e61259d28dddf2e9a445f27b4be..2040b1558103cb1db4861c6a85cd7127643c514c 100644 (file)
@@ -178,12 +178,12 @@ static void test_program_io_big(void)
           and then finally reads the rest in one go. */
        const char *const args[] = {
                "-c",
-               "(head -c 10240; sleep 0.1; "
-                "head -c 10240; sleep 0.1; "
-                "head -c 10240; sleep 0.1; "
-                "head -c 10240; sleep 0.1; "
-                "head -c 10240; sleep 0.1; "
-                "head -c 10240; sleep 0.1; cat)",
+               "(dd bs=10240 count=1; sleep 0.1; "
+                "dd bs=10240 count=1; sleep 0.1; "
+                "dd bs=10240 count=1; sleep 0.1; "
+                "dd bs=10240 count=1; sleep 0.1; "
+                "dd bs=10240 count=1; sleep 0.1; "
+                "dd bs=10240 count=1; sleep 0.1; cat) 2>/dev/null",
                NULL
        };