summaryrefslogtreecommitdiff
path: root/tests/commandtest.c
diff options
context:
space:
mode:
authorMichal Privoznik <mprivozn@redhat.com>2019-10-22 15:26:14 +0200
committerMichal Privoznik <mprivozn@redhat.com>2019-11-12 16:15:59 +0100
commit4fa804c0c72c4786715a22f491c55a18780ca863 (patch)
tree4eb5670b1ae0973431411183642dc59b81de41b3 /tests/commandtest.c
parent06030f05bbdc1eb8d836829e256a3657f9aee1ee (diff)
downloadlibvirt-4fa804c0c72c4786715a22f491c55a18780ca863.tar.gz
tests: Use g_strdup_printf() instead of virAsprintf()
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Diffstat (limited to 'tests/commandtest.c')
-rw-r--r--tests/commandtest.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/tests/commandtest.c b/tests/commandtest.c
index 6ff2039ab1..a8686f777f 100644
--- a/tests/commandtest.c
+++ b/tests/commandtest.c
@@ -67,11 +67,8 @@ static int checkoutput(const char *testname,
char *actualname = NULL;
char *actuallog = NULL;
- if (virAsprintf(&expectname, "%s/commanddata/%s.log", abs_srcdir,
- testname) < 0)
- goto cleanup;
- if (virAsprintf(&actualname, "%s/commandhelper.log", abs_builddir) < 0)
- goto cleanup;
+ expectname = g_strdup_printf("%s/commanddata/%s.log", abs_srcdir, testname);
+ actualname = g_strdup_printf("%s/commandhelper.log", abs_builddir);
if (virFileReadAll(expectname, 1024*64, &expectlog) < 0) {
fprintf(stderr, "cannot read %s\n", expectname);
@@ -86,8 +83,7 @@ static int checkoutput(const char *testname,
if (prefix) {
char *tmp = NULL;
- if (virAsprintf(&tmp, "%s%s", prefix, expectlog) < 0)
- goto cleanup;
+ tmp = g_strdup_printf("%s%s", prefix, expectlog);
VIR_FREE(expectlog);
expectlog = tmp;
@@ -595,8 +591,7 @@ static int test15(const void *unused G_GNUC_UNUSED)
char *cwd = NULL;
int ret = -1;
- if (virAsprintf(&cwd, "%s/commanddata", abs_srcdir) < 0)
- goto cleanup;
+ cwd = g_strdup_printf("%s/commanddata", abs_srcdir);
virCommandSetWorkingDirectory(cmd, cwd);
virCommandSetUmask(cmd, 002);
@@ -815,8 +810,7 @@ static int test20(const void *unused G_GNUC_UNUSED)
sigaction(SIGPIPE, &sig_action, NULL);
- if (virAsprintf(&buf, "1\n%100000d\n", 2) < 0)
- goto cleanup;
+ buf = g_strdup_printf("1\n%100000d\n", 2);
virCommandSetInputBuffer(cmd, buf);
if (virCommandRun(cmd, NULL) < 0) {
@@ -1174,13 +1168,10 @@ static int test27(const void *unused G_GNUC_UNUSED)
buffer2[buflen - 2] = '\n';
buffer2[buflen - 1] = 0;
- if (virAsprintf(&outexpect, TEST27_OUTEXPECT_TEMP,
- buffer0, buffer1, buffer2) < 0 ||
- virAsprintf(&errexpect, TEST27_ERREXPECT_TEMP,
- buffer0, buffer1, buffer2) < 0) {
- printf("Could not virAsprintf expected output\n");
- goto cleanup;
- }
+ outexpect = g_strdup_printf(TEST27_OUTEXPECT_TEMP,
+ buffer0, buffer1, buffer2);
+ errexpect = g_strdup_printf(TEST27_ERREXPECT_TEMP,
+ buffer0, buffer1, buffer2);
if (pipe(pipe1) < 0 || pipe(pipe2) < 0) {
printf("Could not create pipe: %s\n", g_strerror(errno));