summaryrefslogtreecommitdiffstats
path: root/scripts/oe-selftest
blob: f3ce89cedb50251d3d7373090cc368d1e4c27f22 (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
79
80
81
#!/bin/sh

# scripts/oe-selftest: calls oe-selftest-internal in a isolated environment
#
# Copyright (c) 2013-2017 Intel Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#

# Variable definitions
ORIGBUILDDIR="$BUILDDIR"
OESELFTESTSCRIPTDIR="$(which oe-selftest)"
SCRIPTSDIR="$(dirname $OESELFTESTSCRIPTDIR)"
OECOREDIR="$(dirname $SCRIPTSDIR)"

# oe-selftest-$$ related
OESELFTESTDIR="$ORIGBUILDDIR/oe-selftest-$$"
OESELFTESTOECOREDIR="$OESELFTESTDIR/openembedded-core"
OESELFTESTBUILDDIR="$OESELFTESTDIR/openembedded-core/build"
TEMPLATEPATH="$OESELFTESTDIR/template/conf"

# 0. Return immediately in case no test execution
ADDTESTS="$(echo "$@" | grep -i '\-a')"
SOMETESTS="$(echo "$@" | grep -i '\-r')"
if [ -z "$ADDTESTS" -a -z "$SOMETESTS" ]; then
    if [ -z "$@" ]; then
	oe-selftest-internal -h
    else
	oe-selftest-internal "$@"
    fi
    exit 0
fi

# 1. All work will be done under OESELFTESTDIR
mkdir $OESELFTESTDIR && cd $OESELFTESTDIR

# 2.1 Shallow clone OE-Core
git clone file://$OECOREDIR --depth 1 $OESELFTESTOECOREDIR

# 2.2 Shallow clone bitbake if necessary (if OE-Core is embedded on a combo repo, like Poky, there is no need)
if [ ! -d "$OESELFTESTOECOREDIR/bitbake" ]; then
    git clone file://$OECOREDIR/bitbake --depth 1 $OESELFTESTOECOREDIR/bitbake
fi

# 3. Template: create template directory based on BUILDIR/conf/local.conf
mkdir -p $TEMPLATEPATH
cp $ORIGBUILDDIR/conf/local.conf $TEMPLATEPATH/local.conf.sample

# 4. re-initialized environment with new metadata and templateconf environement
cd $OESELFTESTOECOREDIR
export TEMPLATEPATH && source ./oe-init-build-env $OESELFTESTBUILDDIR

# 5. Respect any site.conf and/or auto.conf and place it into conf directory
if [ -r "$ORIGBUILDDIR/conf/site.conf" ]; then
    cp -f $ORIGBUILDDIR/conf/site.conf $OESELFTESTBUILDDIR/conf
fi
if [ -r "$ORIGBUILDDIR/conf/auto.conf" ]; then
    cp -f $ORIGBUILDDIR/conf/auto.conf $OESELFTESTBUILDDIR/conf
fi

# 6. Execute the tests throught oe-selftest-internal
oe-selftest-internal "$@"

OESELFTESTRC="$?"

# 7. Echo working folder

echo -e "\nAll work done under $OESELFTESTDIR\n"

exit $OESELFTESTRC