From 70534141e7df610335798fec54895a74664fc822 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Mon, 31 Aug 2015 00:14:24 +0300 Subject: [PATCH] oe-selftest: test generation of .env Added test case to check if .env file is generated and contains bitbake variables used in wic code. (From OE-Core rev: eaa5ecd2e7ff30192e51793d1419c0198638936d) Signed-off-by: Ed Bartosh Signed-off-by: Richard Purdie --- meta/lib/oeqa/selftest/wic.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py index 117bd9dd8e..fe8a2d06f4 100644 --- a/meta/lib/oeqa/selftest/wic.py +++ b/meta/lib/oeqa/selftest/wic.py @@ -23,6 +23,7 @@ """Test cases for wic.""" +import os import sys from glob import glob @@ -168,3 +169,22 @@ class Wic(oeSelfTest): self.assertEqual(1, len(glob(self.resultdir + "HYBRID_ISO_IMG-*.direct"))) self.assertEqual(1, len(glob(self.resultdir + "HYBRID_ISO_IMG-*.iso"))) + def test19_image_env(self): + """Test generation of .env files.""" + image = 'core-image-minimal' + stdir = get_bb_var('STAGING_DIR_TARGET', image) + imgdatadir = os.path.join(stdir, 'imgdata') + + basename = get_bb_var('IMAGE_BASENAME', image) + self.assertEqual(basename, image) + path = os.path.join(imgdatadir, basename) + '.env' + self.assertTrue(os.path.isfile(path)) + + wicvars = get_bb_var('WICVARS', image).split() + wicvars.remove('IMAGE_BOOT_FILES') # this variable is optional + with open(path) as envfile: + content = dict(line.split("=", 1) for line in envfile) + # test if variables used by wic present in the .env file + for var in wicvars: + self.assertTrue(var in content, "%s is not in .env file" % var) + self.assertTrue(content[var])