Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | # ex:ts=4:sw=4:sts=4:et |
| 4 | # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- |
| 5 | # |
| 6 | # Copyright (C) 2015 Alexandru Damian for Intel Corp. |
| 7 | # |
| 8 | # This program is free software; you can redistribute it and/or modify |
| 9 | # it under the terms of the GNU General Public License version 2 as |
| 10 | # published by the Free Software Foundation. |
| 11 | # |
| 12 | # This program is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU General Public License for more details. |
| 16 | # |
| 17 | # You should have received a copy of the GNU General Public License along |
| 18 | # with this program; if not, write to the Free Software Foundation, Inc., |
| 19 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | |
| 21 | # This is the configuration/single module for tts |
| 22 | # everything that would be a global variable goes here |
| 23 | |
| 24 | import os, sys, logging |
| 25 | import socket |
| 26 | |
| 27 | LOGDIR = "log" |
| 28 | SETTINGS_FILE = os.path.join(os.path.dirname(__file__), "settings.json") |
| 29 | TEST_DIR_NAME = "tts_testdir" |
| 30 | |
| 31 | DEBUG = True |
| 32 | |
| 33 | OWN_PID = os.getpid() |
| 34 | |
| 35 | W3C_VALIDATOR = "http://icarus.local/w3c-validator/check?doctype=HTML5&uri=" |
| 36 | |
| 37 | TOASTER_PORT = 56789 |
| 38 | |
| 39 | TESTDIR = None |
| 40 | |
| 41 | #we parse the w3c URL to know where to connect |
| 42 | |
| 43 | import urlparse |
| 44 | |
| 45 | def get_public_ip(): |
| 46 | temp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) |
| 47 | parsed_url = urlparse.urlparse("http://icarus.local/w3c-validator/check?doctype=HTML5&uri=") |
| 48 | temp_socket.connect((parsed_url.netloc, 80 if parsed_url.port is None else parsed_url.port)) |
| 49 | public_ip = temp_socket.getsockname()[0] |
| 50 | temp_socket.close() |
| 51 | return public_ip |
| 52 | |
| 53 | TOASTER_BASEURL = "http://%s:%d/" % (get_public_ip(), TOASTER_PORT) |
| 54 | |
| 55 | |
| 56 | OWN_EMAIL_ADDRESS = "Toaster Testing Framework <alexandru.damian@intel.com>" |
| 57 | REPORT_EMAIL_ADDRESS = "alexandru.damian@intel.com" |
| 58 | |
| 59 | # make sure we have the basic logging infrastructure |
| 60 | |
| 61 | #pylint: disable=invalid-name |
| 62 | # we disable the invalid name because the module-level "logger" is used througout bitbake |
| 63 | logger = logging.getLogger("toastertest") |
| 64 | __console__ = logging.StreamHandler(sys.stdout) |
| 65 | __console__.setFormatter(logging.Formatter("%(asctime)s %(levelname)s: %(message)s")) |
| 66 | logger.addHandler(__console__) |
| 67 | logger.setLevel(logging.DEBUG) |
| 68 | |
| 69 | |
| 70 | # singleton file names |
| 71 | LOCKFILE = "/tmp/ttf.lock" |
| 72 | BACKLOGFILE = os.path.join(os.path.dirname(__file__), "backlog.txt") |
| 73 | |
| 74 | # task states |
| 75 | def enum(*sequential, **named): |
| 76 | enums = dict(zip(sequential, range(len(sequential))), **named) |
| 77 | reverse = dict((value, key) for key, value in enums.iteritems()) |
| 78 | enums['reverse_mapping'] = reverse |
| 79 | return type('Enum', (), enums) |
| 80 | |
| 81 | |
| 82 | class TASKS(object): |
| 83 | #pylint: disable=too-few-public-methods |
| 84 | PENDING = "PENDING" |
| 85 | INPROGRESS = "INPROGRESS" |
| 86 | DONE = "DONE" |
| 87 | |
| 88 | @staticmethod |
| 89 | def next_task(task): |
| 90 | if task == TASKS.PENDING: |
| 91 | return TASKS.INPROGRESS |
| 92 | if task == TASKS.INPROGRESS: |
| 93 | return TASKS.DONE |
| 94 | raise Exception("Invalid next task state for %s" % task) |
| 95 | |
| 96 | # TTS specific |
| 97 | CONTRIB_REPO = "git@git.yoctoproject.org:poky-contrib" |
| 98 | |