aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tools/singlejar/test_util.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/tools/singlejar/test_util.h b/src/tools/singlejar/test_util.h
index 4f92376ee4..853455e66d 100644
--- a/src/tools/singlejar/test_util.h
+++ b/src/tools/singlejar/test_util.h
@@ -16,6 +16,7 @@
#include <sys/types.h>
#include <fcntl.h>
+#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
@@ -44,6 +45,24 @@ class TestUtil {
}
}
+ // Combine the passed arguments to a shell command and run it.
+ // E.g. calling RunCommand("cmd", "arg1", "arg2", nullptr) results in
+ // running 'cmd arg1 arg2'.
+ // Returns command's return code.
+ static int RunCommand(const char *cmd, ...) {
+ std::string args_string(cmd);
+ va_list ap;
+ va_start(ap, cmd);
+ for (const char *arg = va_arg(ap, const char *); arg;
+ arg = va_arg(ap, const char *)) {
+ args_string += ' ';
+ args_string += arg;
+ }
+ va_end(ap);
+ fprintf(stderr, "Arguments: %s\n", args_string.c_str());
+ return system(args_string.c_str());
+ }
+
// List zip file contents.
static void LsZip(const char *zip_name) {
#if !defined(__APPLE__)