| 41 | | for test in self.testsList : |
|---|
| 42 | | t = Timer(15.0, self.__timeout, [test]) |
|---|
| 43 | | t.start() |
|---|
| 44 | | self.__startTest(test) |
|---|
| 45 | | t.cancel() |
|---|
| | 45 | threads = [] |
|---|
| | 46 | start = 0 |
|---|
| | 47 | start_time = time.time() |
|---|
| | 48 | cpu_count = multiprocessing.cpu_count() |
|---|
| | 49 | while start < len(self.testsList) : |
|---|
| | 50 | inc = cpu_count |
|---|
| | 51 | if (start + inc) > len(self.testsList) : |
|---|
| | 52 | inc = len(self.testsList) - start |
|---|
| | 53 | for i in xrange(start, start + inc) : |
|---|
| | 54 | # we cannot have more than one thread for storage also we have lock error on base. |
|---|
| | 55 | if self.testsList[i].find("/storage") != -1 : |
|---|
| | 56 | if i == start : |
|---|
| | 57 | threads.append(self.__startTest(self.testsList[i])) |
|---|
| | 58 | inc = 1; |
|---|
| | 59 | break |
|---|
| | 60 | else : |
|---|
| | 61 | inc = i - start |
|---|
| | 62 | break |
|---|
| | 63 | else : |
|---|
| | 64 | threads.append(self.__startTest(self.testsList[i])) |
|---|
| | 65 | |
|---|
| | 66 | try: |
|---|
| | 67 | for thread in threads : |
|---|
| | 68 | if thread.isAlive(): |
|---|
| | 69 | thread.join() |
|---|
| | 70 | except KeyboardInterrupt: |
|---|
| | 71 | #for thread in threads: |
|---|
| | 72 | # thread.Cancel() |
|---|
| | 73 | raise |
|---|
| | 74 | |
|---|
| | 75 | for thread in threads: |
|---|
| | 76 | self.__updateProgressBar() |
|---|
| | 77 | if thread.isTimeouted() : |
|---|
| | 78 | if self.config['verbose'] : |
|---|
| | 79 | print "\n" + thread.getTest() + ": timeout" |
|---|
| | 80 | self.resultTimeout[thread.getTest()] = [thread.getTime(), "", ""] |
|---|
| | 81 | elif thread.isCrashed() : |
|---|
| | 82 | if self.config['verbose'] : |
|---|
| | 83 | print "\n" + thread.getTest() + ": crashed" |
|---|
| | 84 | self.resultCrashed[thread.getTest()] = [thread.getTime(), "", ""] |
|---|
| | 85 | elif thread.isFailed() : |
|---|
| | 86 | if self.config['verbose'] : |
|---|
| | 87 | print "\n" + thread.getTest() + ": failed" |
|---|
| | 88 | self.resultFailed[thread.getTest()] = [thread.getTime(), thread.getDiff(), thread.getFile()] |
|---|
| | 89 | elif thread.isPlatformFailed() : |
|---|
| | 90 | if self.config['verbose'] : |
|---|
| | 91 | print "\n" + thread.getTest() + ": platform failed" |
|---|
| | 92 | self.resultPlatformFailed[thread.getTest()] = [thread.getTime(), thread.getDiff(), thread.getFile()] |
|---|
| | 93 | elif thread.isNewTest() : |
|---|
| | 94 | if self.config['verbose'] : |
|---|
| | 95 | print "\n" + thread.getTest() + ": new test" |
|---|
| | 96 | self.resultNew[thread.getTest()] = [thread.getTime(), thread.getOutput(), thread.getFile()] |
|---|
| | 97 | else : |
|---|
| | 98 | self.resultSuccess[thread.getTest()] = [thread.getTime(), thread.getDiff(), thread.getFile()] |
|---|
| | 99 | if self.config['leak'] : |
|---|
| | 100 | for k in thread.getLeaks().keys() : |
|---|
| | 101 | self.leakList[k] += thread.getLeaks()[k] |
|---|
| | 102 | |
|---|
| | 103 | del threads[:] |
|---|
| | 104 | start += inc |
|---|
| 93 | | self.startTime = time.time() |
|---|
| 94 | | self.out = subprocess.Popen(self.config['drt'] + "/DumpRenderTree " + test, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True) |
|---|
| 95 | | (child_stdin, child_stdout, child_stderr) = (self.out.stdin, self.out.stdout, self.out.stderr) |
|---|
| 96 | | self.pid = self.out.pid |
|---|
| 97 | | self.out.wait() |
|---|
| 98 | | self.time += time.time() - self.startTime |
|---|
| 99 | | outprint = "" |
|---|
| 100 | | outTemp = "" |
|---|
| 101 | | signal.signal(signal.SIGALRM, handler) |
|---|
| 102 | | try: |
|---|
| 103 | | signal.alarm(2) |
|---|
| 104 | | outTemp = child_stdout.read() |
|---|
| 105 | | self.err = child_stderr.read() |
|---|
| 106 | | except Exception, e: |
|---|
| 107 | | if not str(e) == 'timeout': # something else went wrong .. |
|---|
| 108 | | self.pid = 0 |
|---|
| 109 | | |
|---|
| 110 | | # update progressbar |
|---|
| 111 | | self.__updateProgressBar() |
|---|
| 112 | | if self.config['verbose'] : |
|---|
| 113 | | print "\n" + test + ": timeout" |
|---|
| 114 | | signal.alarm(0) |
|---|
| 115 | | if not self.timeout : |
|---|
| 116 | | outprint = outTemp |
|---|
| 117 | | outprint = outprint[:outprint.find("#EOF")] |
|---|
| 118 | | else : |
|---|
| 119 | | if outTemp.find("#EOF") != -1 : |
|---|
| 120 | | outprint = outTemp |
|---|
| 121 | | outprint = outprint[:outprint.find("#EOF")] |
|---|
| 122 | | self.timeout = False |
|---|
| 123 | | if outprint == "" : |
|---|
| 124 | | if not self.timeout : |
|---|
| 125 | | if self.config['verbose'] : |
|---|
| 126 | | print "\n" + test + ": crashed" |
|---|
| 127 | | self.__updateProgressBar() |
|---|
| 128 | | self.resultCrashed[test] = [self.time, "", ""] |
|---|
| 129 | | return |
|---|
| 130 | | else : |
|---|
| 131 | | self.resultTimeout[test] = [self.time, "", ""] |
|---|
| 132 | | self.timeout = False |
|---|
| 133 | | return |
|---|
| 134 | | result, file = self.__getExpected(test) |
|---|
| 135 | | if result : |
|---|
| 136 | | #compare result |
|---|
| 137 | | cmp, diff = self.__compareResult(outprint, file) |
|---|
| 138 | | res = "" |
|---|
| 139 | | if cmp : |
|---|
| 140 | | #if self.config['verbose'] : |
|---|
| 141 | | # print test[test.rfind("/") + 1:] + ": success" |
|---|
| 142 | | #else : |
|---|
| 143 | | # sys.stderr.write(".") |
|---|
| 144 | | self.__updateProgressBar() |
|---|
| 145 | | self.resultSuccess[test] = [self.time, diff, file] |
|---|
| 146 | | else : |
|---|
| 147 | | if not self.timeout : |
|---|
| 148 | | if self.config['verbose'] : |
|---|
| 149 | | print "\n" + test + ": failed" |
|---|
| 150 | | self.__updateProgressBar() |
|---|
| 151 | | if (file.find("platform") == -1) : |
|---|
| 152 | | self.resultFailed[test] = [self.time, diff, file] |
|---|
| 153 | | else : |
|---|
| 154 | | self.resultPlatformFailed[test] = [self.time, diff, file] |
|---|
| 155 | | else : |
|---|
| 156 | | self.resultTimeout[test] = [self.time, "", ""] |
|---|
| 157 | | self.timeout = False |
|---|
| 158 | | else : |
|---|
| 159 | | #create expected |
|---|
| 160 | | try : |
|---|
| 161 | | os.makedirs(file[:file.rfind("/")], 0755) |
|---|
| 162 | | except OSError : |
|---|
| 163 | | logging.warning("dir exist : " + file[:file.rfind("/")]) |
|---|
| 164 | | f = open(file, "w") |
|---|
| 165 | | f.write(outprint) |
|---|
| 166 | | f.close() |
|---|
| 167 | | self.resultNew[test] = [self.time, outprint, file] |
|---|
| 168 | | self.__updateProgressBar() |
|---|
| 169 | | |
|---|
| 170 | | if self.config['leak'] : |
|---|
| 171 | | #get LEAK |
|---|
| 172 | | for leak in self.err.split('\n') : |
|---|
| 173 | | if leak.find("LEAK") != -1 : |
|---|
| 174 | | le = leak.split() |
|---|
| 175 | | try : |
|---|
| 176 | | count = int(self.leakList[le[2]]) |
|---|
| 177 | | except KeyError : |
|---|
| 178 | | count = 0 |
|---|
| 179 | | count += int(le[1]) |
|---|
| 180 | | self.leakList[le[2]] = count |
|---|
| 181 | | |
|---|
| 182 | | def __timeout(self, test) : |
|---|
| 183 | | self.time += time.time() - self.startTime |
|---|
| 184 | | self.timeout = True |
|---|
| 185 | | if self.pid != 0 : |
|---|
| 186 | | self.out.kill() |
|---|
| 187 | | #print test[test.rfind("/") + 1:] + ": timeout" |
|---|
| 188 | | |
|---|
| 189 | | def __getExpected(self, test) : |
|---|
| 190 | | #get extension |
|---|
| 191 | | ext = test[test.rfind("."):] |
|---|
| 192 | | expected = test.replace(ext, "-expected.txt") |
|---|
| 193 | | if test.find("http://") != -1 : |
|---|
| 194 | | if test.find("8000") != -1 : |
|---|
| 195 | | expected = expected.replace("http://127.0.0.1:8000", self.config['layout'] + "/http/tests") |
|---|
| 196 | | if test.find("8443") != -1 : |
|---|
| 197 | | expected = expected.replace("http://127.0.0.1:8443", self.config['layout'] + "/http/tests") |
|---|
| 198 | | if test.find("8880") != -1 : |
|---|
| 199 | | expected = expected.replace("http://127.0.0.1:8880", self.config['layout']) |
|---|
| 200 | | if not os.path.exists(expected) : |
|---|
| 201 | | dir = self.config['layout'] + "/platform/bal/" + self.config['platform'] + "/" |
|---|
| 202 | | file = dir + expected[len(self.config['layout']):] |
|---|
| 203 | | if not os.path.exists(file) : |
|---|
| 204 | | return False, file |
|---|
| 205 | | else : |
|---|
| 206 | | return True, file |
|---|
| 207 | | else : |
|---|
| 208 | | return True, expected |
|---|
| 209 | | |
|---|
| 210 | | def __compareResult(self, out, expectedFile) : |
|---|
| 211 | | f = open(expectedFile) |
|---|
| 212 | | expected = f.read() |
|---|
| 213 | | f.close() |
|---|
| 214 | | |
|---|
| 215 | | if out == expected : |
|---|
| 216 | | return True, "" |
|---|
| 217 | | else : |
|---|
| 218 | | diff = difflib.unified_diff(expected.split("\n"), out.split("\n")) |
|---|
| 219 | | outDiff = "" |
|---|
| 220 | | for line in diff : |
|---|
| 221 | | outDiff += line + "\n" |
|---|
| 222 | | return False, outDiff |
|---|
| | 155 | command = self.config['drt'] + "/DumpRenderTree " + test |
|---|
| | 156 | thread = runThreadTests.runTestThread(test, command, self.config); |
|---|
| | 157 | thread.start() |
|---|
| | 158 | return thread |
|---|