hadoop-functions_test_helper.bash 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #!/bin/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. RELTMP="${BATS_TEST_DIRNAME}/../../../target/test-dir/bats.$$.${RANDOM}"
  18. mkdir -p ${RELTMP}
  19. TMP=$(cd -P -- "${RELTMP}" >/dev/null && pwd -P)
  20. export TMP
  21. TESTBINDIR=$(cd -P -- "$(pwd)" >/dev/null && pwd -P)
  22. HADOOP_LIBEXEC_DIR=${TESTBINDIR}/../../main/bin
  23. HADOOP_LIBEXEC_DIR=$(cd -P -- "${HADOOP_LIBEXEC_DIR}" >/dev/null && pwd -P)
  24. # shellcheck disable=SC2034
  25. HADOOP_SHELL_SCRIPT_DEBUG=true
  26. unset HADOOP_CONF_DIR
  27. # we unset both of these for bw compat
  28. unset HADOOP_HOME
  29. unset HADOOP_PREFIX
  30. echo "bindir: ${TESTBINDIR}" 2>&1
  31. mkdir -p "${TMP}"
  32. # shellcheck disable=SC2034
  33. QATESTMODE=true
  34. . "${BATS_TEST_DIRNAME}/../../main/bin/hadoop-functions.sh"
  35. pushd "${TMP}" >/dev/null
  36. }
  37. teardown() {
  38. popd >/dev/null
  39. rm -rf "${TMP}"
  40. }
  41. strstr() {
  42. if [ "${1#*$2}" != "${1}" ]; then
  43. echo true
  44. else
  45. echo false
  46. fi
  47. }