summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/tests/eventreplay
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2016-10-31 16:40:38 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-11-04 12:50:56 +0000
commit3503c5426e0339c2c718dbb7f1bac50480bcbe9e (patch)
treef524260144dda35916c73b6a2d4486f1e165f1c8 /bitbake/lib/toaster/tests/eventreplay
parent98ac0b0a5b04cea8971a07f5ff9a2d711c95d6df (diff)
downloadpoky-3503c5426e0339c2c718dbb7f1bac50480bcbe9e.tar.gz
poky-3503c5426e0339c2c718dbb7f1bac50480bcbe9e.tar.bz2
poky-3503c5426e0339c2c718dbb7f1bac50480bcbe9e.zip
bitbake: toaster: add eventreplay test case for core-image-minimal
Run toaster-eventreplay with core-image-minimal.events and test if all required packages present in Target_Installed_Package table. (Bitbake rev: 73410e6dc965b2885c68e87ed6fa8d8b57e9c49d) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/tests/eventreplay')
-rw-r--r--bitbake/lib/toaster/tests/eventreplay/__init__.py87
1 files changed, 87 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/tests/eventreplay/__init__.py b/bitbake/lib/toaster/tests/eventreplay/__init__.py
new file mode 100644
index 0000000000..792f07d5ea
--- /dev/null
+++ b/bitbake/lib/toaster/tests/eventreplay/__init__.py
@@ -0,0 +1,87 @@
+#! /usr/bin/env python
+# ex:ts=4:sw=4:sts=4:et
+# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
+#
+# BitBake Toaster Implementation
+#
+# Copyright (C) 2016 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.
+
+# Tests were part of openembedded-core oe selftest Authored by: Lucian Musat
+# Ionut Chisanovici, Paul Eggleton and Cristian Iorga
+
+"""
+Test toaster backend by playing build event log files
+using toaster-eventreplay script
+"""
+
+import os
+
+from subprocess import getstatusoutput
+from pathlib import Path
+
+from django.test import TestCase
+
+from orm.models import Target_Installed_Package
+
+class EventReplay(TestCase):
+ """Base class for eventreplay test cases"""
+
+ def setUp(self):
+ """
+ Setup build environment:
+ - set self.script to toaster-eventreplay path
+ - set self.eventplay_dir to the value of EVENTPLAY_DIR env variable
+ """
+ bitbake_dir = Path(__file__.split('lib/toaster')[0])
+ self.script = bitbake_dir / 'bin' / 'toaster-eventreplay'
+ self.assertTrue(self.script.exists(), "%s doesn't exist")
+ self.eventplay_dir = os.getenv("EVENTREPLAY_DIR")
+ self.assertTrue(self.eventplay_dir,
+ "Environment variable EVENTREPLAY_DIR is not set")
+
+ def _replay(self, eventfile):
+ """Run toaster-eventplay <eventfile>"""
+ eventpath = Path(self.eventplay_dir) / eventfile
+ status, output = getstatusoutput('%s %s' % (self.script, eventpath))
+ if status:
+ print(output)
+
+ self.assertEqual(status, 0)
+
+class CoreImageMinimalEventReplay(EventReplay):
+ """Replay core-image-minimal events"""
+
+ def test_installed_packages(self):
+ """Test if all required packages have been installed"""
+
+ self._replay('core-image-minimal.events')
+
+ # test installed packages
+ packages = sorted(Target_Installed_Package.objects.\
+ values_list('package__name', flat=True))
+ self.assertEqual(packages, ['base-files', 'base-passwd', 'busybox',
+ 'busybox-hwclock', 'busybox-syslog',
+ 'busybox-udhcpc', 'eudev', 'glibc',
+ 'init-ifupdown', 'initscripts',
+ 'initscripts-functions', 'kernel-base',
+ 'kernel-module-uvesafb', 'libkmod',
+ 'modutils-initscripts', 'netbase',
+ 'packagegroup-core-boot', 'run-postinsts',
+ 'sysvinit', 'sysvinit-inittab',
+ 'sysvinit-pidof', 'udev-cache',
+ 'update-alternatives-opkg',
+ 'update-rc.d', 'util-linux-libblkid',
+ 'util-linux-libuuid', 'v86d', 'zlib'])