exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit 3f99db063a3bd23296163ac4fff8d51459f92f78
parent f1488298bfeb1e1b109e73cfc8916f606c62b488
Author: Florian Dold <florian@dold.me>
Date:   Fri,  8 May 2026 00:23:24 +0200

return test root path from test setup helper

The setup helper may now only write structured commands to stdout, all
logging must go to stderr. In the past the output was mixed, leading to
confusion / missing logs.

Diffstat:
Msrc/testing/taler-unified-setup.sh | 31+++++++++++++++++--------------
Msrc/testing/testing_api_cmd_system_start.c | 65++++++++++++++++++++++++++++-------------------------------------
2 files changed, 45 insertions(+), 51 deletions(-)

diff --git a/src/testing/taler-unified-setup.sh b/src/testing/taler-unified-setup.sh @@ -19,11 +19,13 @@ # # Author: Christian Grothoff # -# This script configures and launches various GNU Taler services. -# Which ones depend on command-line options. Use "-h" to find out. -# Prints "<<READY>>" on a separate line once all requested services -# are running. Close STDIN (or input 'NEWLINE') to stop all started -# services again. +# This script configures and launches various GNU Taler services. Which ones +# depend on command-line options. Use "-h" to find out. Prints +# "READY:$TEST_ROOT" on a separate line once all requested services are +# running. Close STDIN (or input 'NEWLINE') to stop all started services again. +# +# This script must *only* write output to stderr, as stdout is used to for +# structured communication with the parent process. # # shellcheck disable=SC2317 @@ -215,6 +217,9 @@ done STAGE="init" + +TESTROOT=$(mktemp --tmpdir -d taler-testing-XXXXXX) + echo "Starting with configuration file at: $CONF_ORIG" >&2 CONF="$CONF_ORIG.edited" cp "${CONF_ORIG}" "${CONF}" @@ -223,38 +228,38 @@ STAGE="checks" echo -n "Testing for jq" >&2 jq -h > /dev/null || exit_skip " jq required" -echo " FOUND" +echo " FOUND" >&2 echo -n "Testing for wget" >&2 wget --help > /dev/null || exit_skip " wget required" >&2 -echo " FOUND" +echo " FOUND" >&2 if [ "1" = "$START_EXCHANGE" ] then echo -n "Testing for Taler exchange" >&2 taler-exchange-httpd -h > /dev/null || exit_skip " taler-exchange-httpd required" - echo " FOUND" + echo " FOUND" >&2 fi if [ "1" = "$START_DONAU" ] then echo -n "Testing for Donau" >&2 donau-httpd -h > /dev/null || exit_skip " donau-httpd required" - echo " FOUND" + echo " FOUND" >&2 fi if [ "1" = "$START_MERCHANT" ] then echo -n "Testing for Taler merchant" >&2 taler-merchant-httpd -h > /dev/null || exit_skip " taler-merchant-httpd required" - echo " FOUND" + echo " FOUND" >&2 fi if [ "1" = "$START_CHALLENGER" ] then echo -n "Testing for Taler challenger" >&2 challenger-httpd -h > /dev/null || exit_skip " challenger-httpd required" - echo " FOUND" + echo " FOUND" >&2 fi if [ "1" = "$START_BACKUP" ] @@ -1028,7 +1033,7 @@ fi STAGE="ready" # Signal caller that we are ready. -echo "<<READY>>" +echo "READY:$TESTROOT" if [ "1" = "$WAIT_FOR_SIGNAL" ] then @@ -1042,8 +1047,6 @@ else read fi - - STAGE="exiting" echo "Taler unified setup terminating!" >&2 diff --git a/src/testing/testing_api_cmd_system_start.c b/src/testing/testing_api_cmd_system_start.c @@ -72,10 +72,9 @@ struct SystemState char **args; /** - * Current input buffer, 0-terminated. Contains the last 15 bytes of input - * so we can search them again for the "<<READY>>" tag. + * Input buffer for the stdin of the test setup helper. */ - char ibuf[16]; + struct GNUNET_Buffer ibuf; /** * Did we find the ready tag? @@ -131,25 +130,24 @@ setup_terminated (void *cls, static void start_reader (struct SystemState *as); +#define READY_MARKER "READY:" static void read_stdout (void *cls) { struct SystemState *as = cls; const struct GNUNET_DISK_FileHandle *fh; - char buf[1024 * 10]; + char buf[1024]; ssize_t ret; size_t off = 0; + char *testroot = NULL; as->reader = NULL; - strcpy (buf, - as->ibuf); - off = strlen (buf); fh = GNUNET_DISK_pipe_handle (as->pipe_out, GNUNET_DISK_PIPE_END_READ); ret = GNUNET_DISK_file_read (fh, - &buf[off], - sizeof (buf) - off); + buf, + sizeof (buf) - 1); if (-1 == ret) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, @@ -163,43 +161,35 @@ read_stdout (void *cls) "Child closed stdout\n"); return; } - /* forward log, except single '.' outputs */ - if ( (1 != ret) || - ('.' != buf[off]) ) - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "TUS: %.*s\n", - (int) ret, - &buf[off]); - start_reader (as); - off += ret; - if (as->ready) - { - /* already done */ - return; - } - if (NULL != - memmem (buf, - off, - "\n<<READY>>\n", - strlen ("\n<<READY>>\n"))) + GNUNET_buffer_write (&as->ibuf, buf, ret); + if ( (0 == strncmp (as->ibuf.mem, + READY_MARKER, + strlen (READY_MARKER))) && + (NULL != (testroot = strchr (as->ibuf.mem, + '\n'))) ) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, + "Got test root %s\n", + testroot); + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Taler system UP\n"); as->ready = true; TALER_TESTING_interpreter_next (as->is); return; } - + if (NULL != strchr (as->ibuf.mem, + '\n') || + as->ibuf.position > 4096) { - size_t mcpy; - - mcpy = GNUNET_MIN (off, - sizeof (as->ibuf) - 1); - memcpy (as->ibuf, - &buf[off - mcpy], - mcpy); - as->ibuf[mcpy] = '\0'; + TALER_TESTING_interpreter_fail (as->is); + /* Only commands are allowed! */ + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Unexpected stdout of test setup helper: %.*s\n", + (int) ret, + &buf[off]); } + + start_reader (as); } @@ -289,6 +279,7 @@ system_cleanup (void *cls, GNUNET_SCHEDULER_cancel (as->reader); as->reader = NULL; } + GNUNET_buffer_clear (&as->ibuf); if (NULL != as->system_proc) { if (as->active)