summaryrefslogtreecommitdiff
path: root/ci/_test-git-branch.sh
blob: b0b8dbbfaa78eb32a5eafe2aa7fdad64d1a95c97 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash

set -o nounset
set -o errexit
set -o errtrace

JOBSERVER_LINUX_REPO=ssh://$JOBSERVER/$JOBSERVER_HOME/linux

git_fetch()
{
    local repo=$1
    shift

    git fetch ssh://$JOBSERVER/$JOBSERVER_HOME/$repo $@
}

sync_git_repos()
{
    local repo

    for repo in ${JOBSERVER_GIT_REPOS[@]}; do
	(cd ~/$repo; git_fetch $repo; git checkout -f FETCH_HEAD) > /dev/null
    done
}

echo "Getting test job"

TEST_JOB=( $(ssh $JOBSERVER get-test-job.sh) )

BRANCH=${TEST_JOB[0]}
COMMIT=${TEST_JOB[1]}
TEST_PATH=${TEST_JOB[2]}
TEST_NAME=$(basename -s .ktest $TEST_PATH)

if [[ -z $BRANCH ]]; then
    echo "Error getting test job: need git branch"
    exit 1
fi

if [[ -z $COMMIT ]]; then
    echo "Error getting test job: need git commit"
    exit 1
fi

if [[ -z $TEST_PATH ]]; then
    echo "Error getting test job: need test to run"
    exit 1
fi

echo "Running test job ${TEST_JOB[@]}"

sync_git_repos
git_fetch linux $COMMIT
git checkout FETCH_HEAD

git_fetch linux ci-monkeypatch
git merge --no-edit FETCH_HEAD || git reset --hard

mkdir -p ktest-out
rm -rf ktest-out/out

build-test-kernel run $TEST_PATH ${TEST_JOB[@]:3} || true

if [[ -f ktest-out/out/$TEST_NAME ]]; then
    echo "Test $TEST_NAME completed"
else
    echo "Test $TEST_NAME failed to start"
    echo "TEST FAILED" > "ktest-out/out/$TEST_NAME"
fi

find ktest-out/out -type f -name \*.log -print0|xargs -0 brotli --rm -9

OUTPUT=$JOBSERVER_OUTPUT_DIR/c/$COMMIT
ssh $JOBSERVER mkdir -p $OUTPUT
scp -r ktest-out/out/* $JOBSERVER:$OUTPUT

echo "Running test-job-done.sh"
ssh $JOBSERVER test-job-done.sh $BRANCH $COMMIT