runtime_probe: add the invoker to find and run the executable

The `runtime_probe` binary for the factory toolkit is not always
at the same location in different scenario.  For example, if RACC
hasn't enabled on the board, `/usr/bin/runtime_probe` won't exist
and the binary will be bundled into the factory toolkit instead.

To spare the callers the invocation details, this CL introduces an
executable script `${FACTORY_DIR}/bin/runtime_probe_invoker` to
locate and run the binary.

BUG=b:183384263
TEST=manual test

Cq-Depend: chromium:2777918
Change-Id: I148aa1b17a6aa40dba9a7f1fab2325295990e95a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/factory/+/2810665
Tested-by: Yong Hong <yhong@chromium.org>
Commit-Queue: Yong Hong <yhong@chromium.org>
Reviewed-by: Clark Chung <ckclark@chromium.org>
diff --git a/bin/runtime_probe_invoker b/bin/runtime_probe_invoker
new file mode 100755
index 0000000..6ff52ed
--- /dev/null
+++ b/bin/runtime_probe_invoker
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+# Copyright 2021 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+main() {
+  local script_path="$(realpath "${BASH_SOURCE[0]}")"
+  local factory_bin="$(dirname "${script_path}")"
+  local runtime_probe_candidates=(
+    "${factory_bin}/custom_runtime_probe"
+    "${factory_bin}/factory_runtime_probe/factory_runtime_probe"
+    "/usr/bin/runtime_probe"
+  )
+  local runtime_probe_path
+  for runtime_probe_path in "${runtime_probe_candidates[@]}"; do
+    if [[ -x "${runtime_probe_path}" ]]; then
+      exec "${runtime_probe_path}" "$@"
+    fi
+  done
+  echo "No runtime_probe executable available." >&2
+  return 1
+}
+
+main "$@"