| #!/bin/bash |
| # |
| # Copyright 2021 Google Inc. All rights reserved. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| set -euo pipefail |
| |
| source "${RUNFILES_DIR}/bazel_tools/tools/bash/runfiles/runfiles.bash" |
| |
| # Smoke test to check that the stripped libc.so is smaller than the unstripped one. |
| function test_libc_stripping_basic() { |
| local stripped="$(rlocation __main__/bionic/libc/liblibc_bp2build_cc_library_shared.so)" |
| local unstripped="$(rlocation __main__/bionic/libc/liblibc_bp2build_cc_library_shared_unstripped.so)" |
| |
| stripped_size=$(stat -c %s "${stripped}") |
| unstripped_size=$(stat -c %s "${unstripped}") |
| |
| # Check that the unstripped size is not greater or equal to the stripped size. |
| if [ "${stripped_size}" -ge "${unstripped_size}" ]; then |
| echo "Expected the size of stripped libc.so to be strictly smaller than the unstripped one." |
| exit 1 |
| fi |
| } |
| |
| test_libc_stripping_basic |