blob: 40d45f3b7a920a2f21e77a9481942ee7a3e0d19e [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001#!/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
24import os, sys, logging
25import socket
26
27LOGDIR = "log"
28SETTINGS_FILE = os.path.join(os.path.dirname(__file__), "settings.json")
29TEST_DIR_NAME = "tts_testdir"
30
31DEBUG = True
32
33OWN_PID = os.getpid()
34
35W3C_VALIDATOR = "http://icarus.local/w3c-validator/check?doctype=HTML5&uri="
36
37TOASTER_PORT = 56789
38
39TESTDIR = None
40
41#we parse the w3c URL to know where to connect
42
43import urlparse
44
45def 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
53TOASTER_BASEURL = "http://%s:%d/" % (get_public_ip(), TOASTER_PORT)
54
55
56OWN_EMAIL_ADDRESS = "Toaster Testing Framework <alexandru.damian@intel.com>"
57REPORT_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
63logger = logging.getLogger("toastertest")
64__console__ = logging.StreamHandler(sys.stdout)
65__console__.setFormatter(logging.Formatter("%(asctime)s %(levelname)s: %(message)s"))
66logger.addHandler(__console__)
67logger.setLevel(logging.DEBUG)
68
69
70# singleton file names
71LOCKFILE = "/tmp/ttf.lock"
72BACKLOGFILE = os.path.join(os.path.dirname(__file__), "backlog.txt")
73
74# task states
75def 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
82class 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
97CONTRIB_REPO = "git@git.yoctoproject.org:poky-contrib"
98