Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

Commit

Permalink
scripts/suite: support python 2 and 3
Browse files Browse the repository at this point in the history
With a few changes and imports it seems to be working fine.

Requested by Lei A Yang <[email protected]>

Signed-off-by: Bruno Dilly <[email protected]>
  • Loading branch information
bdilly committed Mar 3, 2016
1 parent 79e3293 commit 0902e5f
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions data/scripts/suite.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python

# This file is part of the Soletta Project
#
Expand Down Expand Up @@ -31,8 +31,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import argparse
import os
import queue
import multiprocessing
import subprocess
import sys
import threading
Expand All @@ -48,11 +47,11 @@ def __init__(self, name, cmd):
self.success = False
self.output = ""

def run_test_program(task_queue):
def run_test_program(task_queue, task_empty_exception):
while not task_queue.empty():
try:
task = task_queue.get_nowait()
except queue.Empty:
except task_empty_exception:
break

try:
Expand Down Expand Up @@ -116,7 +115,15 @@ def print_log(log_file, tasks):
def run_tests(args):
log_file = "test-suite.log"
tasks = []
task_queue = queue.Queue()

try:
import queue
task_queue = queue.Queue()
task_empty_exception = queue.Empty
except ImportError:
import Queue
task_queue = Queue.Queue()
task_empty_exception = Queue.Empty

prefix = ""
if args.valgrind:
Expand All @@ -131,8 +138,9 @@ def run_tests(args):
tasks.append(task)
task_queue.put(task)

for i in range(os.cpu_count()):
threading.Thread(target=run_test_program, args=(task_queue,)).start()
for i in range(multiprocessing.cpu_count()):
threading.Thread(target=run_test_program,
args=(task_queue, task_empty_exception)).start()

task_queue.join()
print_log(log_file, tasks)
Expand Down

0 comments on commit 0902e5f

Please sign in to comment.