Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion bazel/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ if [ -e openroad.repo_mapping ]; then
chmod u+w openroad.repo_mapping
rm -rf openroad.repo_mapping
fi
rm -rf openroad.runfiles/_main

echo "OpenROAD binary installed to $(realpath "$DEST_DIR")"
1 change: 1 addition & 0 deletions packaging/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ pkg_tar(
srcs = ["//:openroad"],
include_runfiles = True,
package_file_name = "openroad.tar",
visibility = ["//test:__subpackages__"],
)
12 changes: 12 additions & 0 deletions test/install/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2026, The OpenROAD Authors

load("@rules_shell//shell:sh_test.bzl", "sh_test")

sh_test(
name = "install_test",
srcs = ["install_test.sh"],
args = ["$(rootpath //packaging:tarfile)"],
data = ["//packaging:tarfile"],
tags = ["local"],
)
Comment on lines +6 to +12

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The local tag disables sandboxing and remote execution for this test, which can negatively impact build performance and reproducibility. Unless this test specifically requires access to host resources that cannot be provided in a sandbox (e.g., specific hardware or global paths), it is recommended to remove this tag to allow for better caching and parallel execution.

sh_test(
    name = "install_test",
    srcs = ["install_test.sh"],
    args = ["$(rootpath //packaging:tarfile)"],
    data = ["//packaging:tarfile"],
)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the test needs to be verified, i.e. that it is no more complicated than it needs to be to test this. Testing install like this is tricky because we're testing that an install used outside of bazel and not relying on pwd works. So an "hors format" bazel test.

26 changes: 26 additions & 0 deletions test/install/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Install smoke test

Verifies that the binary produced by `//packaging:tarfile` starts correctly
after extraction (Tcl initialisation, runfiles resolution, etc.).

## Running

```sh
bazelisk test //test/install/...
```

## What it checks

1. Extracts the packaging tarball into a temporary directory (same layout
that `bazelisk run //packaging:install` produces).
2. Launches the binary with a trivial Tcl script (`puts "install_test_ok"`).
3. Asserts the expected output appears, proving Tcl initialised and the
interpreter is functional.

## Background

The installed binary relies on Bazel runfiles for Tcl library files
(`init.tcl`, tclreadline, etc.). These live under
`openroad.runfiles/_main/bazel/tcl_resources_dir/`. If the runfiles
tree is damaged during packaging or installation the binary fails with
`application-specific initialization failed:` (GitHub issue #10115).
37 changes: 37 additions & 0 deletions test/install/install_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (c) 2026, The OpenROAD Authors
#
# Smoke test: extract the packaging tarball and verify the installed
# binary can start (Tcl initialisation succeeds).
set -euo pipefail

TARFILE="$1"

DEST_DIR=$(mktemp -d)
trap 'rm -rf "$DEST_DIR"' EXIT

cp "$TARFILE" "$DEST_DIR"
cd "$DEST_DIR"
tar -xf openroad.tar
rm -f openroad.tar

# Remove repo_mapping (same as install.sh)
if [ -e openroad.repo_mapping ]; then
chmod u+w openroad.repo_mapping
rm -rf openroad.repo_mapping
fi

# Clear Bazel runfiles env vars so the installed binary resolves its own
# runfiles tree (not the test runner's).
unset RUNFILES_DIR RUNFILES_MANIFEST_FILE TEST_SRCDIR

# Verify the binary starts and can evaluate a trivial Tcl expression.
echo 'puts "install_test_ok"' > test_script.tcl
if OUTPUT=$(./openroad -no_init -no_splash -exit test_script.tcl 2>&1) && echo "$OUTPUT" | grep -q "install_test_ok"; then
echo "PASS: installed binary started successfully"
else
echo "FAIL: installed binary failed to start or produced unexpected output"
echo "Output was: $OUTPUT"
exit 1
fi
Loading