bootperf: fix running with non-default output directory

This fixes a bug in the bootperf script that uses $PWD as the output
directory even if the user specifies the output directory with the -o
option.

BUG=b:186298152
TEST=bootperf -o ~/bootperf-out $IP_ADDR && bootperf -o ~/bootperf-out
$IP_ADDR && showbootdata ~/bootperf-out

Change-Id: I4ba64d7c1ea2f71611c270286fa45b4366fb47b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crostestutils/+/2852639
Reviewed-by: Grant Grundler <grundler@chromium.org>
Tested-by: Chinglin Yu <chinglinyu@chromium.org>
Tested-by: Grant Grundler <grundler@chromium.org>
Commit-Queue: Grant Grundler <grundler@chromium.org>
diff --git a/performance/bootperf-bin/bootperf b/performance/bootperf-bin/bootperf
index c87bdd9..db962ff 100755
--- a/performance/bootperf-bin/bootperf
+++ b/performance/bootperf-bin/bootperf
@@ -253,9 +253,12 @@
   def _run_boot_test_once(self):
     """Run the platform.BootPerf tast test once."""
     remote = self.args.ip_address
-
-    iter_rundir = f'{_RUNDIR}.{self._current_iter_str()}'
-    logfile = os.path.join(os.getcwd(), iter_rundir, _RUNDIR_LOG)
+    # |iter_rundir| is the absolute path of the run.??? directory for the
+    # current iteration.
+    iter_rundir = os.path.join(
+        self.output_dir,
+        f'{_RUNDIR}.{self._current_iter_str()}')
+    logfile = os.path.join(iter_rundir, _RUNDIR_LOG)
     summary_dir = os.path.join(iter_rundir, _RUNDIR_SUMMARY)
     all_results_dir = os.path.join(iter_rundir, _RUNDIR_ALL_RESULTS)