settings.sh 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # SPDX-License-Identifier: GPL-2.0
  2. #
  3. # settings.sh
  4. # Author: Michael Petlan <mpetlan@redhat.com>
  5. #
  6. # Description:
  7. #
  8. # This file contains global settings for the whole testsuite.
  9. # Its purpose is to make it easier when it is necessary i.e. to
  10. # change the usual sample command which is used in all of the tests
  11. # in many files.
  12. #
  13. # This file is intended to be sourced in the tests.
  14. #
  15. #### which perf to use in the testing
  16. export CMD_PERF=${CMD_PERF:-`which perf`}
  17. #### basic programs examinated by perf
  18. export CMD_BASIC_SLEEP="sleep 0.1"
  19. export CMD_QUICK_SLEEP="sleep 0.01"
  20. export CMD_LONGER_SLEEP="sleep 2"
  21. export CMD_DOUBLE_LONGER_SLEEP="sleep 4"
  22. export CMD_VERY_LONG_SLEEP="sleep 30"
  23. export CMD_SIMPLE="true"
  24. #### testsuite run mode
  25. # define constants:
  26. export RUNMODE_BASIC=0
  27. export RUNMODE_STANDARD=1
  28. export RUNMODE_EXPERIMENTAL=2
  29. # default runmode is STANDARD
  30. export PERFTOOL_TESTSUITE_RUNMODE=${PERFTOOL_TESTSUITE_RUNMODE:-$RUNMODE_STANDARD}
  31. #### common settings
  32. export TESTLOG_VERBOSITY=${TESTLOG_VERBOSITY:-2}
  33. export TESTLOG_FORCE_COLOR=${TESTLOG_FORCE_COLOR:-n}
  34. export TESTLOG_ERR_MSG_MAX_LINES=${TESTLOG_ERR_MSG_MAX_LINES:-20}
  35. export TESTLOG_CLEAN=${TESTLOG_CLEAN:-y}
  36. #### other environment-related settings
  37. export TEST_IGNORE_MISSING_PMU=${TEST_IGNORE_MISSING_PMU:-n}
  38. #### clear locale
  39. export LC_ALL=C
  40. #### colors
  41. if [ -t 1 ] || [ "$TESTLOG_FORCE_COLOR" = "yes" ]; then
  42. export MPASS="\e[32m"
  43. export MALLPASS="\e[1;32m"
  44. export MFAIL="\e[31m"
  45. export MALLFAIL="\e[1;31m"
  46. export MWARN="\e[1;35m"
  47. export MSKIP="\e[33m"
  48. export MHIGH="\e[1;33m"
  49. export MEND="\e[m"
  50. else
  51. export MPASS=""
  52. export MALLPASS=""
  53. export MFAIL=""
  54. export MALLFAIL=""
  55. export MWARN=""
  56. export MSKIP=""
  57. export MHIGH=""
  58. export MEND=""
  59. fi
  60. ### general info
  61. DIR_PATH=`dirname "$(readlink -e "$0")"`
  62. TEST_NAME=`basename $DIR_PATH | sed 's/base/perf/'`; export TEST_NAME
  63. MY_ARCH=`arch`; export MY_ARCH
  64. # storing logs and temporary files variables
  65. if [ -n "$PERFSUITE_RUN_DIR" ]; then
  66. # when $PERFSUITE_RUN_DIR is set to something, all the logs and temp files will be placed there
  67. # --> the $PERFSUITE_RUN_DIR/perf_something/examples and $PERFSUITE_RUN_DIR/perf_something/logs
  68. # dirs will be used for that
  69. PERFSUITE_RUN_DIR=`readlink -f $PERFSUITE_RUN_DIR`; export PERFSUITE_RUN_DIR
  70. export CURRENT_TEST_DIR="$PERFSUITE_RUN_DIR/$TEST_NAME"
  71. export MAKE_TARGET_DIR="$CURRENT_TEST_DIR/examples"
  72. export LOGS_DIR="$CURRENT_TEST_DIR/logs"
  73. export HEADER_TAR_DIR="$CURRENT_TEST_DIR/header_tar"
  74. test -d "$CURRENT_TEST_DIR" || mkdir -p "$CURRENT_TEST_DIR"
  75. test -d "$LOGS_DIR" || mkdir -p "$LOGS_DIR"
  76. else
  77. # when $PERFSUITE_RUN_DIR is not set, logs will be placed here
  78. export CURRENT_TEST_DIR="."
  79. export LOGS_DIR="."
  80. export HEADER_TAR_DIR="./header_tar"
  81. fi
  82. #### test parametrization
  83. if [ ! -d ./common ]; then
  84. # set parameters based on runmode
  85. if [ -f ../common/parametrization.$PERFTOOL_TESTSUITE_RUNMODE.sh ]; then
  86. # shellcheck source=/dev/null
  87. . ../common/parametrization.$PERFTOOL_TESTSUITE_RUNMODE.sh
  88. fi
  89. # if some parameters haven't been set until now, set them to default
  90. if [ -f ../common/parametrization.sh ]; then
  91. . ../common/parametrization.sh
  92. fi
  93. fi