From patchwork Thu Aug 8 09:40:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Terceiro X-Patchwork-Id: 18847 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CA68D246A4 for ; Thu, 8 Aug 2013 09:40:43 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id z20sf3407232yhz.7 for ; Thu, 08 Aug 2013 02:40:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:delivered-to:mime-version:to:from:subject :message-id:date:reply-to:sender:errors-to:precedence :x-original-sender:x-original-authentication-results:mailing-list :list-id:list-post:list-help:list-archive:list-unsubscribe :content-type; bh=fGz1iIUOegVuprvXaIobyyIyOAB7jX332y1a8XbWTcM=; b=ErJNiW7BKUcAy0pzV47pEZ51BrZCWklc1TZ13EuskKbfzSVJ+9CHXy5QIdiFPmdpCR aSFPlMRGBCFrfLF9Yq+mtkzLMZa42AzqBC3qNSSYEOJfi/8w2vbdVCHM7cyeeleKfk2z yR+IiuLfBzrDw/qBUeoGTRyui+P6348p1jk6jxhLnboMAzMaUAfG6p6zDYDs4Ln5B1Hs Lr5CJ26VUw1ei6/laryFltfO4ZLlXX7cltf4q+S+jb57dtmbkme3/eaWAF377FGOptH0 QR9KEbbdoJ4+tD01rj7uxKC1HGT7J9TYhXQX6umanPEKR25zRzFrI9aqIv3YKOe133R6 eqCQ== X-Received: by 10.224.137.137 with SMTP id w9mr5375117qat.6.1375954842885; Thu, 08 Aug 2013 02:40:42 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.29.167 with SMTP id l7ls1001468qeh.47.gmail; Thu, 08 Aug 2013 02:40:42 -0700 (PDT) X-Received: by 10.58.134.84 with SMTP id pi20mr888172veb.55.1375954842729; Thu, 08 Aug 2013 02:40:42 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id mu5si2842702vec.103.2013.08.08.02.40.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 08 Aug 2013 02:40:42 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id cy12so2869009veb.32 for ; Thu, 08 Aug 2013 02:40:42 -0700 (PDT) X-Gm-Message-State: ALoCoQm87wUCsdDxMRZD4AD0OZM7duUNqBz+VPbZaTTC7AChTqV5b+pHgMCxf5m93TpLUctC27lr X-Received: by 10.221.47.193 with SMTP id ut1mr3456921vcb.8.1375954842607; Thu, 08 Aug 2013 02:40:42 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp5692vcz; Thu, 8 Aug 2013 02:40:41 -0700 (PDT) X-Received: by 10.14.119.73 with SMTP id m49mr7157234eeh.146.1375954841210; Thu, 08 Aug 2013 02:40:41 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id o41si9924029eew.239.2013.08.08.02.40.40 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 08 Aug 2013 02:40:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1V7Mi0-0005kd-C0 for ; Thu, 08 Aug 2013 09:40:40 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 4E986E07E4 for ; Thu, 8 Aug 2013 09:40:40 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-dispatcher X-Launchpad-Branch: ~linaro-validation/lava-dispatcher/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 644 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 644: Bring unit tests to a reasonable state Message-Id: <20130808094040.28624.32434.launchpad@ackee.canonical.com> Date: Thu, 08 Aug 2013 09:40:40 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: list X-Generated-By: Launchpad (canonical.com); Revision="16723"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 31650aef4bb7a8083996a3cdba2a147b87752b3b X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: noreply@launchpad.net X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Merge authors: Antonio Terceiro (terceiro) Related merge proposals: https://code.launchpad.net/~terceiro/lava-dispatcher/fix-unit-tests/+merge/178186 proposed by: Antonio Terceiro (terceiro) review: Approve - Milo Casagrande (milo) ------------------------------------------------------------ revno: 644 [merge] committer: Antonio Terceiro branch nick: trunk timestamp: Thu 2013-08-08 11:37:05 +0200 message: Bring unit tests to a reasonable state We had 6 unit tests who were broken. 3 of those were mostly obsolete and/or utterly broken. So now we "only" have 3 unit test, but they pass. This should be considered the first step towards improving automated testing in the dispatcher codebase. removed: lava_dispatcher/tests/test-config/devices/ lava_dispatcher/tests/test-config/devices/beaglexm01.conf lava_dispatcher/tests/test-config/lava-dispatcher.conf added: lava_dispatcher/tests/test-config/bin/ lava_dispatcher/tests/test-config/bin/fake-qemu modified: lava_dispatcher/tests/helper.py lava_dispatcher/tests/test_config.py lava_dispatcher/tests/test_device_version.py --- lp:lava-dispatcher https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk You are subscribed to branch lp:lava-dispatcher. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription === modified file 'lava_dispatcher/tests/helper.py' --- lava_dispatcher/tests/helper.py 2013-07-16 16:09:42 +0000 +++ lava_dispatcher/tests/helper.py 2013-08-07 16:05:41 +0000 @@ -19,13 +19,14 @@ import os from lava_dispatcher.config import get_device_config +import lava_dispatcher.config -__tmp_dir = os.getenv("TMPDIR") or '/tmp' -__tmp_config_dir = os.path.join(__tmp_dir, 'lava-dispatcher-config') +tmp_dir = os.getenv("TMPDIR") or '/tmp' +tmp_config_dir = os.path.join(tmp_dir, 'lava-dispatcher-config') def create_config(name, data): - filename = os.path.join(__tmp_config_dir, name) + filename = os.path.join(tmp_config_dir, name) if not os.path.exists(os.path.dirname(filename)): os.mkdir(os.path.dirname(filename)) with open(filename, 'w') as f: @@ -35,23 +36,27 @@ def create_device_config(name, data): create_config("devices/%s.conf" % name, data) - return get_device_config(name, __tmp_config_dir) + lava_dispatcher.utils.custom_config_path = tmp_config_dir + config = get_device_config(name) + lava_dispatcher.utils.custom_config_path = None + return config def setup_config_dir(): - os.mkdir(__tmp_config_dir) + os.mkdir(tmp_config_dir) def cleanup_config_dir(): - os.system('rm -rf %s' % __tmp_config_dir) + os.system('rm -rf %s' % tmp_config_dir) from unittest import TestCase - class LavaDispatcherTestCase(TestCase): def setUp(self): setup_config_dir() + lava_dispatcher.config.custom_config_path = tmp_config_dir def tearDown(self): + lava_dispatcher.config.custom_config_path = None cleanup_config_dir() === added directory 'lava_dispatcher/tests/test-config/bin' === added file 'lava_dispatcher/tests/test-config/bin/fake-qemu' --- lava_dispatcher/tests/test-config/bin/fake-qemu 1970-01-01 00:00:00 +0000 +++ lava_dispatcher/tests/test-config/bin/fake-qemu 2013-08-08 09:18:23 +0000 @@ -0,0 +1,3 @@ +#!/bin/sh + +echo 'QEMU emulator version 1.5.0 (Debian 1.5.0+dfsg-4), Copyright (c) 2003-2008 Fabrice Bellard' === removed directory 'lava_dispatcher/tests/test-config/devices' === removed file 'lava_dispatcher/tests/test-config/devices/beaglexm01.conf' --- lava_dispatcher/tests/test-config/devices/beaglexm01.conf 2011-11-28 20:27:03 +0000 +++ lava_dispatcher/tests/test-config/devices/beaglexm01.conf 1970-01-01 00:00:00 +0000 @@ -1,1 +0,0 @@ -device_type = beagle-xm \ No newline at end of file === removed file 'lava_dispatcher/tests/test-config/lava-dispatcher.conf' --- lava_dispatcher/tests/test-config/lava-dispatcher.conf 2011-11-28 20:27:03 +0000 +++ lava_dispatcher/tests/test-config/lava-dispatcher.conf 1970-01-01 00:00:00 +0000 @@ -1,1 +0,0 @@ -LAVA_SERVER_IP = 192.168.200.200 \ No newline at end of file === modified file 'lava_dispatcher/tests/test_config.py' --- lava_dispatcher/tests/test_config.py 2013-07-16 16:09:24 +0000 +++ lava_dispatcher/tests/test_config.py 2013-08-07 16:05:41 +0000 @@ -19,39 +19,17 @@ from unittest import TestCase +import lava_dispatcher.config from lava_dispatcher.config import get_config, get_device_config from lava_dispatcher.utils import string_to_list from lava_dispatcher.tests.helper import * -test_config_dir = os.path.join(os.path.dirname(__file__), 'test-config') - - -class TestConfigData(TestCase): - - def setUp(self): - setup_config_dir() - - def tearDown(self): - cleanup_config_dir() - - def test_beagle01_uboot_cmds(self): - beagle01_config = get_device_config("beaglexm01", test_config_dir) - expected = [ - "mmc init", - "mmc part 0", - "setenv bootcmd 'fatload mmc 0:3 0x80000000 uImage; fatload mmc " - "0:3 0x81600000 uInitrd; bootm 0x80000000 0x81600000'", - "setenv bootargs ' console=tty0 console=ttyO2,115200n8 " - "root=LABEL=testrootfs rootwait ro earlyprintk fixrtc " - "nocompcache vram=12M omapfb.debug=y " - "omapfb.mode=dvi:1280x720MR-16@60'", - "boot"] - uboot_cmds = beagle01_config.boot_cmds - self.assertEquals(expected, string_to_list(uboot_cmds)) +class TestConfigData(LavaDispatcherTestCase): def test_server_ip(self): - server_config = get_config(test_config_dir) - expected = "192.168.200.200" + create_config('lava-dispatcher.conf', { 'LAVA_SERVER_IP': '99.99.99.99' }) + server_config = get_config() + expected = "99.99.99.99" lava_server_ip = server_config.lava_server_ip self.assertEqual(expected, lava_server_ip) === modified file 'lava_dispatcher/tests/test_device_version.py' --- lava_dispatcher/tests/test_device_version.py 2013-07-16 16:09:15 +0000 +++ lava_dispatcher/tests/test_device_version.py 2013-08-08 09:18:23 +0000 @@ -18,7 +18,9 @@ # along with this program; if not, see . import re -from lava_dispatcher.tests.helper import LavaDispatcherTestCase, create_device_config, create_config, __tmp_config_dir +import lava_dispatcher.config +from lava_dispatcher.tests.helper import LavaDispatcherTestCase, create_device_config, create_config +import os from lava_dispatcher.device.target import Target from lava_dispatcher.device.qemu import QEMUTarget @@ -34,10 +36,14 @@ return target -def _create_qemu_target(): - create_config('lava-dispatcher.conf', {'default_qemu_binary': 'qemu-system-arm'}) - device_config = create_device_config('qemu01', {'device_type': 'qemu'}) - dispatcher_config = get_config(__tmp_config_dir) +def _create_qemu_target(extra_device_config={}): + create_config('lava-dispatcher.conf', {}) + + device_config_data = {'device_type': 'qemu'} + device_config_data.update(extra_device_config) + device_config = create_device_config('qemu01', device_config_data) + + dispatcher_config = get_config() context = LavaContext('qemu01', dispatcher_config, None, None, None) return QEMUTarget(context, device_config) @@ -50,22 +56,7 @@ self.assertIsInstance(target.get_device_version(), str) def test_qemu(self): - target = _create_qemu_target() + fake_qemu = os.path.join(os.path.dirname(__file__), 'test-config', 'bin', 'fake-qemu') + target = _create_qemu_target({ 'qemu_binary': fake_qemu }) device_version = target.get_device_version() assert(re.search('^[0-9.]+', device_version)) - - def test_fastmodel(self): - banner = "\n".join([ - "Fast Models [7.1.36 (May 17 2012)]", - "Copyright 2000-2012 ARM Limited.", - "All Rights Reserved.", - "Top component name: RTSM_VE_Cortex_A15x1_A7x1" - ]) - target = _create_fastmodel_target() - version = target._parse_fastmodel_version(banner) - self.assertEqual('7.1.36', version) - - def test_fastmodel_wrong_format(self): - client = _create_fastmodel_target() - version = client._parse_fastmodel_version('random string') - self.assertEqual('unknown', version)