
On 12/18/23 12:02, Peter Krempa wrote:
We don't want to ever run an actuall command in qemuxml2argvtest poison the helper functions we have for running commands.
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- src/util/vircommand.h | 4 ++-- tests/qemuxml2argvmock.c | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/src/util/vircommand.h b/src/util/vircommand.h index 9bcdce35b9..566ac15947 100644 --- a/src/util/vircommand.h +++ b/src/util/vircommand.h @@ -39,7 +39,7 @@ typedef struct _virCommand virCommand; * call any function that is not async-signal-safe. */ typedef int (*virExecHook)(void *data);
-pid_t virFork(void) G_GNUC_WARN_UNUSED_RESULT; +pid_t virFork(void) G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE;
virCommand *virCommandNew(const char *binary) ATTRIBUTE_NONNULL(1);
@@ -184,7 +184,7 @@ int virCommandGetArgList(virCommand *cmd, char ***args); int virCommandExec(virCommand *cmd, gid_t *groups, int ngroups) G_GNUC_WARN_UNUSED_RESULT;
int virCommandRun(virCommand *cmd, - int *exitstatus) G_GNUC_WARN_UNUSED_RESULT; + int *exitstatus) G_GNUC_WARN_UNUSED_RESULT G_NO_INLINE;
int virCommandRunAsync(virCommand *cmd, pid_t *pid) G_GNUC_WARN_UNUSED_RESULT; diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 2deccd79c4..0ee8fbba79 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -276,3 +276,22 @@ qemuExtVhostUserGPUPrepareDomain(virQEMUDriver *driver G_GNUC_UNUSED, { return 0; } + + +int +virCommandRun(virCommand *cmd, + int *exitstatus G_GNUC_UNUSED) +{ + const char *path = virCommandGetBinaryPath(cmd); + + fprintf(stderr, "\nattempted virCommandRun() (path=%s) from test context\n", NULLSTR(path)); + return -1; +} + + +pid_t +virFork(void) +{ + fprintf(stderr, "\nattempted virFork() in test context\n"); + return -1; +}
Any reason to mock both? Or is it just to provide nicer error message? Michal