Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | import os |
| 2 | |
| 3 | from oeqa.selftest.case import OESelftestTestCase |
| 4 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var |
| 5 | import oeqa.utils.ftools as ftools |
| 6 | from oeqa.core.decorator.oeid import OETestID |
| 7 | |
| 8 | class LayerAppendTests(OESelftestTestCase): |
| 9 | layerconf = """ |
| 10 | # We have a conf and classes directory, append to BBPATH |
| 11 | BBPATH .= ":${LAYERDIR}" |
| 12 | |
| 13 | # We have a recipes directory, add to BBFILES |
| 14 | BBFILES += "${LAYERDIR}/recipes*/*.bb ${LAYERDIR}/recipes*/*.bbappend" |
| 15 | |
| 16 | BBFILE_COLLECTIONS += "meta-layerINT" |
| 17 | BBFILE_PATTERN_meta-layerINT := "^${LAYERDIR}/" |
| 18 | BBFILE_PRIORITY_meta-layerINT = "6" |
| 19 | """ |
| 20 | recipe = """ |
| 21 | LICENSE="CLOSED" |
| 22 | INHIBIT_DEFAULT_DEPS = "1" |
| 23 | |
| 24 | python do_build() { |
| 25 | bb.plain('Building ...') |
| 26 | } |
| 27 | addtask build |
| 28 | """ |
| 29 | append = """ |
| 30 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" |
| 31 | |
| 32 | SRC_URI_append = " file://appendtest.txt" |
| 33 | |
| 34 | sysroot_stage_all_append() { |
| 35 | install -m 644 ${WORKDIR}/appendtest.txt ${SYSROOT_DESTDIR}/ |
| 36 | } |
| 37 | |
| 38 | """ |
| 39 | |
| 40 | append2 = """ |
| 41 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" |
| 42 | |
| 43 | SRC_URI_append = " file://appendtest.txt" |
| 44 | """ |
| 45 | layerappend = '' |
| 46 | |
| 47 | def tearDownLocal(self): |
| 48 | if self.layerappend: |
| 49 | ftools.remove_from_file(self.builddir + "/conf/bblayers.conf", self.layerappend) |
| 50 | super(LayerAppendTests, self).tearDownLocal() |
| 51 | |
| 52 | @OETestID(1196) |
| 53 | def test_layer_appends(self): |
| 54 | corebase = get_bb_var("COREBASE") |
| 55 | |
| 56 | for l in ["0", "1", "2"]: |
| 57 | layer = os.path.join(corebase, "meta-layertest" + l) |
| 58 | self.assertFalse(os.path.exists(layer)) |
| 59 | os.mkdir(layer) |
| 60 | os.mkdir(layer + "/conf") |
| 61 | with open(layer + "/conf/layer.conf", "w") as f: |
| 62 | f.write(self.layerconf.replace("INT", l)) |
| 63 | os.mkdir(layer + "/recipes-test") |
| 64 | if l == "0": |
| 65 | with open(layer + "/recipes-test/layerappendtest.bb", "w") as f: |
| 66 | f.write(self.recipe) |
| 67 | elif l == "1": |
| 68 | with open(layer + "/recipes-test/layerappendtest.bbappend", "w") as f: |
| 69 | f.write(self.append) |
| 70 | os.mkdir(layer + "/recipes-test/layerappendtest") |
| 71 | with open(layer + "/recipes-test/layerappendtest/appendtest.txt", "w") as f: |
| 72 | f.write("Layer 1 test") |
| 73 | elif l == "2": |
| 74 | with open(layer + "/recipes-test/layerappendtest.bbappend", "w") as f: |
| 75 | f.write(self.append2) |
| 76 | os.mkdir(layer + "/recipes-test/layerappendtest") |
| 77 | with open(layer + "/recipes-test/layerappendtest/appendtest.txt", "w") as f: |
| 78 | f.write("Layer 2 test") |
| 79 | self.track_for_cleanup(layer) |
| 80 | |
| 81 | self.layerappend = "BBLAYERS += \"{0}/meta-layertest0 {0}/meta-layertest1 {0}/meta-layertest2\"".format(corebase) |
| 82 | ftools.append_file(self.builddir + "/conf/bblayers.conf", self.layerappend) |
| 83 | stagingdir = get_bb_var("SYSROOT_DESTDIR", "layerappendtest") |
| 84 | bitbake("layerappendtest") |
| 85 | data = ftools.read_file(stagingdir + "/appendtest.txt") |
| 86 | self.assertEqual(data, "Layer 2 test") |
| 87 | os.remove(corebase + "/meta-layertest2/recipes-test/layerappendtest/appendtest.txt") |
| 88 | bitbake("layerappendtest") |
| 89 | data = ftools.read_file(stagingdir + "/appendtest.txt") |
| 90 | self.assertEqual(data, "Layer 1 test") |
| 91 | with open(corebase + "/meta-layertest2/recipes-test/layerappendtest/appendtest.txt", "w") as f: |
| 92 | f.write("Layer 2 test") |
| 93 | bitbake("layerappendtest") |
| 94 | data = ftools.read_file(stagingdir + "/appendtest.txt") |
| 95 | self.assertEqual(data, "Layer 2 test") |