blob: 55ec215c329e2fd405d818b531936cfde37a6449 [file] [log] [blame]
mbligh9bb92fe2007-09-12 15:54:23 +00001#!/usr/bin/python
2import os, re, db
3
mbligh8e1ab172007-09-13 17:29:56 +00004# Pulling hierarchy:
5#
6# test pulls in (kernel, job, attributes, iterations)
7# kernel pulls in (patches)
8#
9# Note that job does put pull test - test is the primary object.
mbligh9bb92fe2007-09-12 15:54:23 +000010
mbligh250300e2007-09-18 00:50:57 +000011html_root = 'http://test.kernel.org/google/'
12
mbligh9bb92fe2007-09-12 15:54:23 +000013class kernel:
mbligh8e1ab172007-09-13 17:29:56 +000014 @classmethod
15 def select(klass, db, where = {}):
16 fields = ['kernel_idx', 'kernel_hash', 'base', 'printable']
17 kernels = []
18 for row in db.select(','.join(fields), 'kernels', where):
19 kernels.append(klass(db, *row))
20 return kernels
mbligh9bb92fe2007-09-12 15:54:23 +000021
mbligh8e1ab172007-09-13 17:29:56 +000022
23 def __init__(self, db, idx, hash, base, printable):
mbligh9bb92fe2007-09-12 15:54:23 +000024 self.db = db
mbligh8e1ab172007-09-13 17:29:56 +000025 self.idx = idx
mbligh9bb92fe2007-09-12 15:54:23 +000026 self.hash = hash
mbligh8e1ab172007-09-13 17:29:56 +000027 self.base = base
28 self.printable = printable
29 self.patches = [] # THIS SHOULD PULL IN PATCHES!
mbligh9bb92fe2007-09-12 15:54:23 +000030
31
32class test:
mbligh8e1ab172007-09-13 17:29:56 +000033 @classmethod
34 def select(klass, db, where = {}):
35 fields = ['test_idx', 'job_idx', 'test', 'subdir',
36 'kernel_idx', 'status', 'reason', 'machine']
37 tests = []
38 for row in db.select(','.join(fields), 'tests', where):
39 tests.append(klass(db, *row))
40 return tests
41
42
43 def __init__(self, db, test_idx, job_idx, testname, subdir, kernel_idx, status_num, reason, machine):
44 self.idx = test_idx
mbligh250300e2007-09-18 00:50:57 +000045 self.job = job(db, job_idx)
mbligh8e1ab172007-09-13 17:29:56 +000046 # self.machine = self.job.machine
47 self.test = testname
48 self.subdir = subdir
mbligh16ae9262007-09-21 00:53:08 +000049 self.kernel = kernel.select(db, {'kernel_idx' : kernel_idx})[0]
mbligh8e1ab172007-09-13 17:29:56 +000050 self.status_num = status_num
51 self.status_word = db.status_word[status_num]
mbligh9bb92fe2007-09-12 15:54:23 +000052 self.reason = reason
mbligh250300e2007-09-18 00:50:57 +000053 self.url = html_root + self.job.tag + '/' + self.subdir
mbligh16ae9262007-09-21 00:53:08 +000054
55 self.iterations = {}
56 # Create a dictionary - dict{key} = [value1, value2, ....]
57 for i in iteration.select(db, {'test_idx' : test_idx}):
58 if self.iterations.has_key(i.key):
59 self.iterations[i.key].append(i.value)
60 else:
61 self.iterations[i.key] = [i.value]
62
mbligh250300e2007-09-18 00:50:57 +000063
64class job:
65 def __init__(self, db, job_idx):
66 where = {'job_idx' : job_idx}
67 rows = db.select('tag, machine', 'jobs', where)
68 if not rows:
69 return None
70 (self.tag, self.machine) = rows[0]
71
mbligh8e1ab172007-09-13 17:29:56 +000072
mbligh16ae9262007-09-21 00:53:08 +000073class iteration:
74 @classmethod
75 def select(klass, db, where):
76 fields = ['iteration', 'attribute', 'value']
77 iterations = []
78 rows = db.select(','.join(fields), 'iteration_result', where)
79 for row in rows:
80 iterations.append(klass(*row))
81 return iterations
82
83
84 def __init__(self, iteration, key, value):
85 self.iteration = iteration
86 self.key = key
87 self.value = value
88
mbligh8e1ab172007-09-13 17:29:56 +000089# class patch:
90# def __init__(self):
91# self.spec = None