test-runner: Fix -l/--emulator
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 9 Mar 2022 02:00:49 +0000 (18:00 -0800)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:53 +0000 (14:55 +0530)
This fixes -l/--emulator not able to start depending on what parameters
are given as it was not setting the directory properly.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
tools/test-runner.c

index 6b94e9c..5bc0d8d 100755 (executable)
@@ -608,13 +608,18 @@ static const char *btvirt_table[] = {
        NULL
 };
 
-static pid_t start_btvirt(void)
+static pid_t start_btvirt(const char *home)
 {
        const char *btvirt = NULL;
        char *argv[3], *envp[2];
        pid_t pid;
        int i;
 
+       if (chdir(home + 5) < 0) {
+               perror("Failed to change home directory for daemon");
+               return -1;
+       }
+
        for (i = 0; btvirt_table[i]; i++) {
                struct stat st;
 
@@ -693,7 +698,7 @@ static void run_command(char *cmdname, char *home)
                monitor_pid = -1;
 
        if (start_emulator)
-               emulator_pid = start_btvirt();
+               emulator_pid = start_btvirt(home);
        else
                emulator_pid = -1;