hadoop-functions_test_helper.bash 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env bash
  2. # Licensed to the Apache Software Foundation (ASF) under one or more
  3. # contributor license agreements. See the NOTICE file distributed with
  4. # this work for additional information regarding copyright ownership.
  5. # The ASF licenses this file to You under the Apache License, Version 2.0
  6. # (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. setup() {
  17. export LD_LIBRARY_PATH=""
  18. RELTMP="${BATS_TEST_DIRNAME}/../../../target/test-dir/bats.$$.${RANDOM}"
  19. mkdir -p ${RELTMP}
  20. TMP=$(cd -P -- "${RELTMP}" >/dev/null && pwd -P)
  21. export TMP
  22. TESTBINDIR=$(cd -P -- "$(pwd)" >/dev/null && pwd -P)
  23. HADOOP_LIBEXEC_DIR=${TESTBINDIR}/../../main/bin
  24. HADOOP_LIBEXEC_DIR=$(cd -P -- "${HADOOP_LIBEXEC_DIR}" >/dev/null && pwd -P)
  25. # shellcheck disable=SC2034
  26. HADOOP_SHELL_SCRIPT_DEBUG=true
  27. unset HADOOP_CONF_DIR
  28. # we unset both of these for bw compat
  29. unset HADOOP_HOME
  30. unset HADOOP_PREFIX
  31. echo "bindir: ${TESTBINDIR}" 2>&1
  32. mkdir -p "${TMP}"
  33. # shellcheck disable=SC2034
  34. QATESTMODE=true
  35. . "${BATS_TEST_DIRNAME}/../../main/bin/hadoop-functions.sh"
  36. pushd "${TMP}" >/dev/null
  37. }
  38. teardown() {
  39. popd >/dev/null
  40. rm -rf "${TMP}"
  41. }
  42. strstr() {
  43. if [ "${1#*$2}" != "${1}" ]; then
  44. echo true
  45. else
  46. echo false
  47. fi
  48. }