1
0
mirror of https://github.com/facebook/zstd.git synced 2025-07-30 22:23:13 +03:00

[cli-tests] Fix zstd symlinks

The zstd symlinks, notably `zstdcat`, weren't working as expected
because only the `tests/cli-tests/bin/zstd` wrapper was symlinked. We
still invoked `zstd` with the name `zstd`. The fix is to create a
directory of zstd symlinks in `tests/cli-tests/bin/symlinks` for each
name that zstd recognizes. And when `tets/cli-tests/bin/zstd` is
invoked, it selects the correct symlink to call.

See the test `zstd-cli/zstdcat.sh` for an example of how it would work.
This commit is contained in:
Nick Terrell
2022-02-07 15:20:42 -08:00
parent b848c167ab
commit 169f8c11ff
6 changed files with 67 additions and 6 deletions

View File

@ -21,6 +21,24 @@ import tempfile
import typing
ZSTD_SYMLINKS = [
"zstd",
"zstdmt",
"unzstd",
"zstdcat",
"zcat",
"gzip",
"gunzip",
"gzcat",
"lzma",
"unlzma",
"xz",
"unxz",
"lz4",
"unlz4",
]
EXCLUDED_DIRS = {
"bin",
"common",
@ -592,6 +610,16 @@ def run_tests(test_suites: TestSuites, options: Options) -> bool:
return False
def setup_zstd_symlink_dir(zstd_symlink_dir: str, zstd: str) -> None:
assert os.path.join("bin", "symlinks") in zstd_symlink_dir
if not os.path.exists(zstd_symlink_dir):
os.makedirs(zstd_symlink_dir)
for symlink in ZSTD_SYMLINKS:
path = os.path.join(zstd_symlink_dir, symlink)
if os.path.exists(path):
os.remove(path)
os.symlink(zstd, path)
if __name__ == "__main__":
CLI_TEST_DIR = os.path.dirname(sys.argv[0])
REPO_DIR = os.path.join(CLI_TEST_DIR, "..", "..")
@ -655,17 +683,20 @@ if __name__ == "__main__":
args.timeout = None
args.test_dir = os.path.normpath(os.path.abspath(args.test_dir))
bin_dir = os.path.join(args.test_dir, "bin")
bin_dir = os.path.abspath(os.path.join(args.test_dir, "bin"))
zstd_symlink_dir = os.path.join(bin_dir, "symlinks")
scratch_dir = os.path.join(args.test_dir, "scratch")
setup_zstd_symlink_dir(zstd_symlink_dir, os.path.abspath(args.zstd))
env = {}
if args.exec_prefix is not None:
env["EXEC_PREFIX"] = args.exec_prefix
env["ZSTD_BIN"] = os.path.abspath(args.zstd)
env["ZSTD_SYMLINK_DIR"] = zstd_symlink_dir
env["DATAGEN_BIN"] = os.path.abspath(args.datagen)
env["ZSTDGREP_BIN"] = os.path.abspath(args.zstdgrep)
env["COMMON"] = os.path.abspath(os.path.join(args.test_dir, "common"))
env["PATH"] = os.path.abspath(bin_dir) + ":" + os.getenv("PATH", "")
env["PATH"] = bin_dir + ":" + os.getenv("PATH", "")
opts = Options(
env=env,