diff options
author | Yongqin Liu <yongqin.liu@linaro.org> | 2018-05-17 19:31:52 +0800 |
---|---|---|
committer | Yongqin Liu <yongqin.liu@linaro.org> | 2018-05-17 19:31:52 +0800 |
commit | 50e0b935cd3c2f51e78d619549123e42fb52b8fc (patch) | |
tree | 7b6aa3d6db0b127d4a0aae516849d0a6526a3bd6 /automated/linux/memtester/memtester.sh | |
parent | efa089e9435eacf202eeffe76b008e8e687585da (diff) |
update with upstream
Change-Id: I62ba6c882a8eb5044c677daf54174f52057c46da
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
Diffstat (limited to 'automated/linux/memtester/memtester.sh')
-rwxr-xr-x | automated/linux/memtester/memtester.sh | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/automated/linux/memtester/memtester.sh b/automated/linux/memtester/memtester.sh new file mode 100755 index 0000000..54e80a1 --- /dev/null +++ b/automated/linux/memtester/memtester.sh @@ -0,0 +1,63 @@ +#!/bin/sh -e + +# shellcheck disable=SC1091 +. ../../lib/sh-test-lib +OUTPUT="$(pwd)/output" +RESULT_FILE="${OUTPUT}/result.txt" +export RESULT_FILE +MEMORY='1M' +ITERATIONS=1 + +usage() { + echo "Usage: $0 [-s <true|false>] [-m memory] [-i iterations]" 1>&2 + exit 1 +} + +while getopts "s:m:i:h" o; do + case "$o" in + s) SKIP_INSTALL="${OPTARG}" ;; + m) MEMORY="${OPTARG}" ;; + i) ITERATIONS="${OPTARG}" ;; + *) usage ;; + esac +done + +install() { + dist_name + # shellcheck disable=SC2154 + case "${dist}" in + debian|ubuntu) install_deps "memtester" "${SKIP_INSTALL}";; + unknown) warn_msg "Unsupported distro: package install skipped" ;; + esac +} + +parser() { + test_log="$1" + if [ "${ITERATIONS}" -gt 1 ]; then + suffix="-iter$2" + else + suffix="" + fi + + # The follow lines: + # Remove redundant spaces. + # Replace ok with pass. + # Replace spaces in test case name with minus. + # Save test results like 'Stuck-Address pass' to result file. + grep ': ok' "${test_log}" \ + | sed 's/^ *//g; s/ *: ok/:pass/g; s/ /-/g' \ + | awk -v suffix="${suffix}" -F':' '{printf("%s%s %s\n",$1,suffix,$2)}' \ + | tee -a "$RESULT_FILE" +} + +create_out_dir "${OUTPUT}" +install +for i in $(seq "${ITERATIONS}"); do + output="${OUTPUT}/memtester-iter$i.txt" + + memtester "${MEMORY}" 1 \ + | sed 's/:.*ok/: ok/g' \ + | tee "${output}" + + parser "${output}" "$i" +done |