mirror of
git://git.gnupg.org/gnupg.git
synced 2024-11-10 21:38:50 +01:00
gpgscm: Improve test of low-level functions.
* tests/gpgscm/t-child.c: Print large amounts of data. * tests/gpgscm/t-child.scm: Test that this works. Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
dff2660598
commit
11eac7eb2f
@ -30,6 +30,8 @@
|
|||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
char buffer[4096];
|
||||||
|
memset (buffer, 'A', sizeof buffer);
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
if (! setmode (stdin, O_BINARY))
|
if (! setmode (stdin, O_BINARY))
|
||||||
return 23;
|
return 23;
|
||||||
@ -49,10 +51,16 @@ main (int argc, char **argv)
|
|||||||
fprintf (stdout, "hello");
|
fprintf (stdout, "hello");
|
||||||
else if (strcmp (argv[1], "hello_stderr") == 0)
|
else if (strcmp (argv[1], "hello_stderr") == 0)
|
||||||
fprintf (stderr, "hello");
|
fprintf (stderr, "hello");
|
||||||
|
else if (strcmp (argv[1], "stdout4096") == 0)
|
||||||
|
fwrite (buffer, 1, sizeof buffer, stdout);
|
||||||
|
else if (strcmp (argv[1], "stdout8192") == 0)
|
||||||
|
{
|
||||||
|
fwrite (buffer, 1, sizeof buffer, stdout);
|
||||||
|
fwrite (buffer, 1, sizeof buffer, stdout);
|
||||||
|
}
|
||||||
else if (strcmp (argv[1], "cat") == 0)
|
else if (strcmp (argv[1], "cat") == 0)
|
||||||
while (! feof (stdin))
|
while (! feof (stdin))
|
||||||
{
|
{
|
||||||
char buffer[4096];
|
|
||||||
size_t bytes_read;
|
size_t bytes_read;
|
||||||
bytes_read = fread (buffer, 1, sizeof buffer, stdin);
|
bytes_read = fread (buffer, 1, sizeof buffer, stdin);
|
||||||
fwrite (buffer, 1, bytes_read, stdout);
|
fwrite (buffer, 1, bytes_read, stdout);
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
(define (qualify executable)
|
(define (qualify executable)
|
||||||
(string-append executable (getenv "EXEEXT")))
|
(string-append executable (getenv "EXEEXT")))
|
||||||
|
|
||||||
|
(define child (qualify "t-child"))
|
||||||
|
|
||||||
(assert (= 0 (call `(,(qualify "t-child") "return0"))))
|
(assert (= 0 (call `(,(qualify "t-child") "return0"))))
|
||||||
(assert (= 1 (call `(,(qualify "t-child") "return1"))))
|
(assert (= 1 (call `(,(qualify "t-child") "return1"))))
|
||||||
(assert (= 77 (call `(,(qualify "t-child") "return77"))))
|
(assert (= 77 (call `(,(qualify "t-child") "return77"))))
|
||||||
@ -51,6 +53,16 @@
|
|||||||
(assert (string=? "" (:stdout r)))
|
(assert (string=? "" (:stdout r)))
|
||||||
(assert (string=? "hello" (:stderr r))))
|
(assert (string=? "hello" (:stderr r))))
|
||||||
|
|
||||||
|
(let ((r (call-with-io `(,(qualify "t-child") "stdout4096") "")))
|
||||||
|
(assert (= 0 (:retcode r)))
|
||||||
|
(assert (= 4096 (string-length (:stdout r))))
|
||||||
|
(assert (string=? "" (:stderr r))))
|
||||||
|
|
||||||
|
(let ((r (call-with-io `(,(qualify "t-child") "stdout8192") "")))
|
||||||
|
(assert (= 0 (:retcode r)))
|
||||||
|
(assert (= 8192 (string-length (:stdout r))))
|
||||||
|
(assert (string=? "" (:stderr r))))
|
||||||
|
|
||||||
(let ((r (call-with-io `(,(qualify "t-child") "cat") "hellohello")))
|
(let ((r (call-with-io `(,(qualify "t-child") "cat") "hellohello")))
|
||||||
(assert (= 0 (:retcode r)))
|
(assert (= 0 (:retcode r)))
|
||||||
(assert (string=? "hellohello" (:stdout r)))
|
(assert (string=? "hellohello" (:stdout r)))
|
||||||
@ -90,4 +102,17 @@
|
|||||||
(wait-processes '("child0" "child1") (list pid0 pid1) #t))))
|
(wait-processes '("child0" "child1") (list pid0 pid1) #t))))
|
||||||
(echo " world.")
|
(echo " world.")
|
||||||
|
|
||||||
|
(tr:do
|
||||||
|
(tr:pipe-do
|
||||||
|
(pipe:spawn `(,child stdout4096))
|
||||||
|
(pipe:spawn `(,child cat)))
|
||||||
|
(tr:call-with-content (lambda (c)
|
||||||
|
(assert (= 4096 (length c))))))
|
||||||
|
(tr:do
|
||||||
|
(tr:pipe-do
|
||||||
|
(pipe:spawn `(,child stdout8192))
|
||||||
|
(pipe:spawn `(,child cat)))
|
||||||
|
(tr:call-with-content (lambda (c)
|
||||||
|
(assert (= 8192 (length c))))))
|
||||||
|
|
||||||
(echo "All good.")
|
(echo "All good.")
|
||||||
|
Loading…
Reference in New Issue
Block a user