diff options
author | 2015-08-28 14:45:44 +0000 | |
---|---|---|
committer | 2015-08-28 15:00:52 +0000 | |
commit | 601be74a64585172bd487caa267623bf7b00253c (patch) | |
tree | e7692b65a8adaae26a7bd77b5f86da4a2e69b738 /src/test/shell | |
parent | 72545d5d5cf1d59254f64b13688175e0f301e324 (diff) |
Fixes #400: Linux sandboxing and relative symbolic links.
Symlink resolution did not work in all cases and broke ./compile.sh on certain Linux distros.
--
MOS_MIGRATED_REVID=101775459
Diffstat (limited to 'src/test/shell')
-rwxr-xr-x | src/test/shell/bazel/bazel_sandboxing_test.sh | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/test/shell/bazel/bazel_sandboxing_test.sh b/src/test/shell/bazel/bazel_sandboxing_test.sh index 24f6baa8f1..14f110a26e 100755 --- a/src/test/shell/bazel/bazel_sandboxing_test.sh +++ b/src/test/shell/bazel/bazel_sandboxing_test.sh @@ -73,6 +73,12 @@ EOF ln -sf cyclic2 examples/genrule/cyclic1 ln -sf cyclic1 examples/genrule/cyclic2 + # Create relative symlinks. + mkdir -p examples/genrule/symlinks/{a,ok/sub} + echo OK > examples/genrule/symlinks/ok/x.txt + ln -s $PWD/examples/genrule/symlinks/ok/sub examples/genrule/symlinks/a/b + ln -s ../x.txt examples/genrule/symlinks/a/b/x.txt + cat << 'EOF' > examples/genrule/BUILD genrule( name = "works", @@ -103,6 +109,13 @@ genrule( ) genrule( + name = "relative_symlinks", + srcs = [ "symlinks/a/b/x.txt" ], + outs = [ "relative_symlinks.txt" ], + cmd = "cat $(location :symlinks/a/b/x.txt) > $@", +) + +genrule( name = "breaks1", srcs = [ "a.txt" ], outs = [ "breaks1.txt" ], @@ -169,6 +182,23 @@ function test_sandboxed_genrule_with_tools() { || fail "Genrule didn't produce output: examples/genrule:tools_work" } +# Test for #400: Linux sandboxing and relative symbolic links. +# +# let A = examples/genrule/symlinks/a/b/x.txt -> ../x.txt +# where examples/genrule/symlinks/a/b -> examples/genrule/symlinks/ok/sub +# thus the realpath of A is example/genrule/symlinks/ok/x.txt +# but if the code doesn't correctly resolve intermediate symlinks and instead +# uses string operations to handle ".." parts, it will arrive at: +# examples/genrule/symlinks/a/x.txt, which is wrong. +# +function test_sandbox_relative_symlink_in_inputs() { + bazel build --genrule_strategy=sandboxed \ + examples/genrule:relative_symlinks \ + || fail "Hermetic genrule failed: examples/genrule:relative_symlinks" + [ -f "${BAZEL_GENFILES_DIR}/examples/genrule/relative_symlinks.txt" ] \ + || fail "Genrule didn't produce output: examples/genrule:relative_symlinks" +} + function test_sandbox_undeclared_deps() { bazel build --genrule_strategy=sandboxed \ examples/genrule:breaks1 \ |