diff options
-rw-r--r-- | app/tests/__init__.py | 1 | ||||
-rw-r--r-- | app/utils/tests/samples/sample_boot_complex.log | 87 | ||||
-rw-r--r-- | app/utils/tests/samples/sample_boot_simple.log | 9 | ||||
-rw-r--r-- | app/utils/tests/test_bootimport.py | 85 |
4 files changed, 182 insertions, 0 deletions
diff --git a/app/tests/__init__.py b/app/tests/__init__.py index aacb341..cae4142 100644 --- a/app/tests/__init__.py +++ b/app/tests/__init__.py @@ -24,6 +24,7 @@ def test_modules(): 'handlers.tests.test_job_handler', 'handlers.tests.test_subscription_handler', 'models.tests.test_models', + 'utils.tests.test_bootimport', 'utils.tests.test_docimport', 'utils.tests.test_subscribe', 'utils.tests.test_validator' diff --git a/app/utils/tests/samples/sample_boot_complex.log b/app/utils/tests/samples/sample_boot_complex.log new file mode 100644 index 0000000..18d7943 --- /dev/null +++ b/app/utils/tests/samples/sample_boot_complex.log @@ -0,0 +1,87 @@ +Tree/Branch: next +Git describe: next-20140505 +Full Report +=========== + +arm-davinci_all_defconfig +------------------------- + legacy,dm365evm 0 min 17.7 sec: PASS + da850-evm 0 min 15.8 sec: PASS + +arm-tegra_defconfig +------------------- + tegra30-beaver 0 min 17.7 sec: PASS + +arm-omap2plus_defconfig +----------------------- + legacy,3730xm 0 min 52.0 sec: PASS + am335x-boneblack 0 min 43.9 sec: PASS + omap3-beagle-xm 0 min 59.6 sec: PASS + legacy,3530beagle 0 min 48.6 sec: PASS (Warnings: 1) + omap4-panda 1 min 11.8 sec: PASS + omap3-overo-tobi 0 min 23.3 sec: PASS (Warnings: 1) + am335x-bone 0 min 32.2 sec: PASS + omap3-overo-storm-tobi 0 min 21.9 sec: PASS + omap5-uevm 1 min 7.4 sec: PASS (Warnings: 1) + omap3-n900 0 min 16.3 sec: PASS (Warnings: 1) + legacy,n900 0 min 16.9 sec: PASS (Warnings: 1) + omap4-panda-es 1 min 5.8 sec: PASS + legacy,3730storm 0 min 20.1 sec: PASS + legacy,3530overo 0 min 21.3 sec: PASS (Warnings: 1) + +arm-imx_v6_v7_defconfig +----------------------- + imx6dl-wandboard,wand-dual 0 min 19.1 sec: PASS + imx6dl-wandboard,wand-solo 0 min 19.0 sec: PASS + imx6q-wandboard 0 min 17.2 sec: PASS + +arm-multi_v7_defconfig +---------------------- + qcom-apq8074-dragonboard 0 min 16.9 sec: PASS + ste-snowball 1 min 22.4 sec: PASS + tegra30-beaver 0 min 24.9 sec: PASS + am335x-boneblack 0 min 37.5 sec: PASS + omap3-beagle-xm 0 min 51.1 sec: PASS + sun7i-a20-cubieboard2 0 min 12.4 sec: PASS + armada-370-mirabox 0 min 22.5 sec: PASS + omap4-panda 0 min 58.8 sec: PASS + armada-xp-openblocks-ax3-4 0 min 25.4 sec: PASS + sun4i-a10-cubieboard 0 min 18.8 sec: PASS + bcm28155-ap 0 min 26.9 sec: PASS + omap3-overo-tobi 0 min 22.3 sec: PASS (Warnings: 1) + imx6dl-wandboard,wand-solo 0 min 17.9 sec: PASS + am335x-bone 0 min 26.8 sec: PASS + omap3-overo-storm-tobi 0 min 23.9 sec: PASS + omap5-uevm 1 min 41.7 sec: PASS (Warnings: 1) + omap3-n900 0 min 16.0 sec: PASS (Warnings: 1) + imx6q-wandboard 0 min 16.9 sec: PASS + omap4-panda-es 0 min 57.2 sec: PASS + imx6dl-wandboard,wand-dual 0 min 18.3 sec: PASS + +arm-sunxi_defconfig +------------------- + sun7i-a20-cubieboard2 0 min 22.8 sec: PASS + sun4i-a10-cubieboard 0 min 12.7 sec: PASS + +arm-bcm_defconfig +----------------- + bcm28155-ap 0 min 24.2 sec: PASS + +arm-exynos_defconfig +-------------------- + exynos5420-arndale-octa 0 min 32.2 sec: PASS + exynos5250-arndale 0 min 29.0 sec: PASS + +arm-u8500_defconfig +------------------- + ste-snowball 0 min 30.7 sec: PASS + +arm-mvebu_v7_defconfig +---------------------- + armada-xp-openblocks-ax3-4 0 min 22.7 sec: PASS + armada-370-mirabox 0 min 20.6 sec: PASS + +arm-sama5_defconfig +------------------- + sama5d35ek 0 min 18.9 sec: PASS + diff --git a/app/utils/tests/samples/sample_boot_simple.log b/app/utils/tests/samples/sample_boot_simple.log new file mode 100644 index 0000000..21cda1b --- /dev/null +++ b/app/utils/tests/samples/sample_boot_simple.log @@ -0,0 +1,9 @@ +Tree/Branch: next +Git describe: next-20140505 +Full Report +=========== + +arm-davinci_all_defconfig +------------------------- + legacy,dm365evm 0 min 17.7 sec: PASS (Warnings: 1) + da850-evm 0 min 15.8 sec: PASS diff --git a/app/utils/tests/test_bootimport.py b/app/utils/tests/test_bootimport.py new file mode 100644 index 0000000..3decc77 --- /dev/null +++ b/app/utils/tests/test_bootimport.py @@ -0,0 +1,85 @@ +# Copyright (C) 2014 Linaro Ltd. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +import logging +import mongomock +import os +import types +import unittest + +from datetime import ( + datetime, + timedelta, +) + +from models.boot import BootDocument +from utils.bootimport import ( + _parse_boot_log +) + + +class TestParseBoot(unittest.TestCase): + + def setUp(self): + logging.disable(logging.CRITICAL) + self.db = mongomock.Database(mongomock.Connection(), 'kernel-ci') + + self.sample_dir = os.path.abspath( + os.path.join(os.path.dirname(__file__), 'samples')) + self.simple_boot_log = os.path.join( + self.sample_dir, 'sample_boot_simple.log') + self.complex_boot_log = os.path.join( + self.sample_dir, 'sample_boot_complex.log') + + def tearDown(self): + logging.disable(logging.NOTSET) + + def test_import_parse_simple(self): + docs = _parse_boot_log(self.simple_boot_log) + + self.assertEqual(len(docs), 1) + self.assertIsInstance(docs[0], BootDocument) + + self.assertEqual( + docs[0].name, 'boot-next-next-20140505-arm-davinci_all_defconfig') + + self.assertIsInstance(docs[0].boards, types.ListType) + self.assertEqual(len(docs[0].boards), 2) + + self.assertEqual(docs[0].job, 'next') + self.assertEqual(docs[0].kernel, 'next-20140505') + self.assertEqual(docs[0].defconfig, 'arm-davinci_all_defconfig') + self.assertIsInstance(docs[0].created, datetime) + + self.assertIsInstance(docs[0].boards[0], types.DictionaryType) + self.assertEqual(docs[0].boards[0]['board'], 'legacy,dm365evm') + + self.assertIsInstance(docs[0].boards[0]['time'], datetime) + + time_d = timedelta(minutes=0, seconds=17.7) + time = datetime( + 1970, 1, 1, + minute=time_d.seconds / 60, + second=time_d.seconds % 60, + microsecond=time_d.microseconds + ) + + self.assertEqual(docs[0].boards[0]['time'], time) + self.assertEqual(docs[0].boards[0]['warnings'], '1') + + def test_import_parse_complex(self): + docs = _parse_boot_log(self.complex_boot_log) + + self.assertEqual(len(docs), 11) |