From 4e8fc7499210287e6b4bf842d3de62f287bba801 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 1 Apr 2015 10:07:00 -0700 Subject: [PATCH] tools: Change into to current directory before running test --- tools/test-runner.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/test-runner.c b/tools/test-runner.c index 25ff52147..8caf35125 100644 --- a/tools/test-runner.c +++ b/tools/test-runner.c @@ -219,11 +219,7 @@ static void start_qemu(void) else snprintf(initcmd, sizeof(initcmd), "%s/%s", cwd, own_binary); - if (test_argv[0][0] == '/') - pos = snprintf(testargs, sizeof(testargs), "%s", test_argv[0]); - else - pos = snprintf(testargs, sizeof(testargs), "%s/%s", - cwd, test_argv[0]); + pos = snprintf(testargs, sizeof(testargs), "%s", test_argv[0]); for (i = 1; i < test_argc; i++) { int len = sizeof(testargs) - pos; @@ -293,6 +289,12 @@ static void run_command(char *cmdname, char *home) } if (pid == 0) { + if (home) { + printf("Changing into directory %s\n", home + 5); + if (chdir(home + 5) < 0) + perror("Failed to change directory"); + } + execve(argv[0], argv, envp); exit(EXIT_SUCCESS); } -- 2.47.3