[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: -work on FIXMEs
From: |
gnunet |
Subject: |
[gnunet] branch master updated: -work on FIXMEs |
Date: |
Sun, 19 May 2024 18:26:37 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new a2f814b86 -work on FIXMEs
a2f814b86 is described below
commit a2f814b863afe94721d7039be461e63aa2756863
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun May 19 18:26:24 2024 +0200
-work on FIXMEs
---
src/include/gnunet_testing_lib.h | 13 +++++++
src/lib/testing/testing_api_cmd_exec.c | 62 ++++++++++++++++++++++++++++++----
2 files changed, 69 insertions(+), 6 deletions(-)
diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h
index 8bab109c5..7cc03dfbe 100644
--- a/src/include/gnunet_testing_lib.h
+++ b/src/include/gnunet_testing_lib.h
@@ -678,6 +678,19 @@ GNUNET_TESTING_cmd_exec (
char *const script_argv[]);
+/**
+ * Command to execute a command.
+ *
+ * @param label Label of the command.
+*/
+const struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_exec_va (
+ const char *label,
+ enum GNUNET_OS_ProcessStatusType expected_type,
+ unsigned long int expected_exit_code,
+ ...);
+
+
/**
* Make the instruction pointer point to @a target_label
* only if @a counter is greater than zero.
diff --git a/src/lib/testing/testing_api_cmd_exec.c
b/src/lib/testing/testing_api_cmd_exec.c
index e452ce4b3..9e03e7c17 100644
--- a/src/lib/testing/testing_api_cmd_exec.c
+++ b/src/lib/testing/testing_api_cmd_exec.c
@@ -53,9 +53,9 @@ struct BashScriptState
struct GNUNET_OS_Process *start_proc;
/**
- * Arguments for the script
+ * NULL-terminated array of command-line arguments.
*/
- char *const*script_argv;
+ char **args;
/**
*
@@ -97,6 +97,9 @@ exec_bash_script_cleanup (void *cls)
GNUNET_OS_process_destroy (bss->start_proc);
bss->start_proc = NULL;
}
+ for (unsigned int i = 0; NULL != bss->args[i]; i++)
+ GNUNET_free (bss->args[i]);
+ GNUNET_free (bss->args);
GNUNET_free (bss);
}
@@ -147,8 +150,8 @@ exec_bash_script_run (void *cls,
NULL,
NULL,
NULL,
- bss->script_argv[0],
- bss->script_argv);
+ bss->args[0],
+ bss->args);
bss->cwh = GNUNET_wait_child (bss->start_proc,
&child_completed_callback,
bss);
@@ -156,7 +159,6 @@ exec_bash_script_run (void *cls,
}
-// FIXME: support variadic style...
const struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_exec (
const char *label,
@@ -165,9 +167,57 @@ GNUNET_TESTING_cmd_exec (
char *const script_argv[])
{
struct BashScriptState *bss;
+ unsigned int cnt;
+ cnt = 0;
+ while (NULL != script_argv[cnt])
+ cnt++;
bss = GNUNET_new (struct BashScriptState);
- bss->script_argv = script_argv; // FIXME: make copy?
+ bss->args = GNUNET_new_array (cnt + 1,
+ char *);
+ for (unsigned int i = 0; i<cnt; i++)
+ bss->args[i] = GNUNET_strdup (script_argv[i]);
+ bss->expected_type = expected_type;
+ bss->expected_exit_code = expected_exit_code;
+ return GNUNET_TESTING_command_new_ac (
+ bss,
+ label,
+ &exec_bash_script_run,
+ &exec_bash_script_cleanup,
+ NULL,
+ &bss->ac);
+}
+
+
+const struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_exec_va (
+ const char *label,
+ enum GNUNET_OS_ProcessStatusType expected_type,
+ unsigned long int expected_exit_code,
+ ...)
+{
+ struct BashScriptState *bss;
+ va_list ap;
+ const char *arg;
+ unsigned int cnt;
+
+ bss = GNUNET_new (struct BashScriptState);
+ va_start (ap,
+ expected_exit_code);
+ cnt = 1;
+ while (NULL != (arg = va_arg (ap,
+ const char *)))
+ cnt++;
+ va_end (ap);
+ bss->args = GNUNET_new_array (cnt,
+ char *);
+ cnt = 0;
+ va_start (ap,
+ expected_exit_code);
+ while (NULL != (arg = va_arg (ap,
+ const char *)))
+ bss->args[cnt++] = GNUNET_strdup (arg);
+ va_end (ap);
bss->expected_type = expected_type;
bss->expected_exit_code = expected_exit_code;
return GNUNET_TESTING_command_new_ac (
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: -work on FIXMEs,
gnunet <=