summaryrefslogtreecommitdiff
path: root/test/TEST-55-OOMD/test.sh
blob: afc6706e32f748b6770f926c57f975d305818fbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
set -e

TEST_DESCRIPTION="systemd-oomd Memory Pressure Test"

# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"

check_result_nspawn() {
    local workspace="${1:?}"
    local ret=1
    local journald_report=""
    local pids=""

    [[ -e "$workspace/testok" ]] && ret=0
    if [[ -e "$workspace/skipped" ]]; then
        echo "TEST-56-OOMD was skipped:"
        cat "$workspace/skipped"
        ret=0
    fi

    [[ -f "$workspace/failed" ]] && cp -a "$workspace/failed" "${TESTDIR:?}"
    save_journal "$workspace/var/log/journal"
    [[ -f "$TESTDIR/failed" ]] && cat "$TESTDIR/failed"
    echo "${JOURNAL_LIST:-No journals were saved}"

    test -s "$TESTDIR/failed" && ret=$((ret + 1))
    [ -n "${TIMED_OUT:=}" ] && ret=$((ret + 1))
    check_asan_reports "$workspace" || ret=$((ret + 1))
    _umount_dir "${initdir:?}"
    return $ret
}

check_result_qemu() {
    local ret=1

    mount_initdir
    [[ -e "${initdir:?}/testok" ]] && ret=0
    if [[ -e "$initdir/skipped" ]]; then
        echo "TEST-56-OOMD was skipped:"
        cat "$initdir/skipped"
        ret=0
    fi

    [[ -f "$initdir/failed" ]] && cp -a "$initdir/failed" "${TESTDIR:?}"
    save_journal "$initdir/var/log/journal"
    check_asan_reports "$initdir" || ret=$((ret + 1))
    _umount_dir "$initdir"
    [[ -f "$TESTDIR/failed" ]] && cat "$TESTDIR/failed"
    echo "${JOURNAL_LIST:-No journals were saved}"

    test -s "$TESTDIR/failed" && ret=$((ret + 1))
    [ -n "${TIMED_OUT:=}" ] && ret=$((ret + 1))
    return $ret
}

do_test "$@" 55