Index: src/tests/pybin/settings.py
===================================================================
--- src/tests/pybin/settings.py	(revision 099a40d75e43725c90b9886739e2ec41f30092e7)
+++ src/tests/pybin/settings.py	(revision f3b9efcc8e56c4be21e2e133209b16b5760e0cdb)
@@ -1,14 +1,54 @@
+import sys
 
 class Architecture:
-	def __init__(self, cmd):
-		if cmd:
+	KnownArchitectures = {
+		'x64'			: 'x64',
+		'x86-64'		: 'x64',
+		'x86'			: 'x86',
+		'i386'		: 'x86',
+		'i486'		: 'x86',
+		'i686'		: 'x86',
+		'Intel 80386'	: 'x86',
+		'arm'			: 'arm',
+		'ARM'			: 'arm',
+	}
+
+	def __init__(self, arch):
+		if arch:
 			self.cross_compile = True
-			self.target = cmd
+			try:
+				self.target = Architecture.makeCanonical( arch )
+			except KeyError:
+				print("Unkown architecture %s" % arch)
+				sys.exit(1)
 		else:
 			self.cross_compile = False
-			self.target = 'x64'
+			try:
+				arch = machine_default()
+				self.target = Architecture.makeCanonical( arch )
+			except KeyError:
+				print("Running on unkown architecture %s" % arch)
+				sys.exit(1)
 
-	def toString(self):
-		return self.target
+		self.string = self.target
+
+	def update(self):
+		if not self.cross_compile:
+			self.target = machine_default()
+			self.string = self.target
+			print("updated to %s" % self.target)
+
+	def match(self, arch):
+		return True if not arch else self.target == arch
+
+	@classmethod
+	def makeCanonical(_, arch):
+		return Architecture.KnownArchitectures[arch]
+
+
+class Debug:
+	def __init__(self, value):
+		self.string = "debug" if value else "no debug"
+		self.flags  = """DEBUG_FLAGS="%s" """ % ("-debug" if value else "-nodebug")
 
 def init( options ):
@@ -20,13 +60,18 @@
 	global debugFlag
 
-	arch       = Architecture(options.arch)
 	dry_run    = options.dry_run
 	generating = options.regenerate_expected
-	make       = './make_command_not_initialized'
-	debug	     = "debug" if options.debug else "no debug"
-	debugFlag  = """DEBUG_FLAGS="%s" """ % ("-debug" if debug else "-nodebug")
+	make       = 'make'
+	debug	     = Debug(options.debug)
+	arch       = Architecture(options.arch)
 
 def updateMakeCmd(force, jobs):
 	global make
 
-	make = "make" if force else ("make -j%i" % jobs)
+	make = "make" if not force else ("make -j%i" % jobs)
+
+
+def set_machine_default( func ):
+	global machine_default
+
+	machine_default = func
Index: src/tests/pybin/test_run.py
===================================================================
--- src/tests/pybin/test_run.py	(revision 099a40d75e43725c90b9886739e2ec41f30092e7)
+++ src/tests/pybin/test_run.py	(revision f3b9efcc8e56c4be21e2e133209b16b5760e0cdb)
@@ -21,5 +21,5 @@
 
 	def expect(self):
-		return ("%s/.expect/%s.txt" % (self.path, self.name))
+		return ("%s/.expect/%s%s.txt" % (self.path, self.name, '' if not self.arch else ".%s" % self.arch))
 
 	def error_log(self):
@@ -39,9 +39,9 @@
 
 	@classmethod
-	def valid_name(cls, name):
+	def valid_name(_, name):
 		return not name.endswith( ('.c', '.cc', '.cpp', '.cfa') )
 
 	@classmethod
-	def from_target(cls, target):
+	def from_target(_, target):
 		test = Test()
 		test.name = os.path.basename(target)
Index: src/tests/pybin/tools.py
===================================================================
--- src/tests/pybin/tools.py	(revision 099a40d75e43725c90b9886739e2ec41f30092e7)
+++ src/tests/pybin/tools.py	(revision f3b9efcc8e56c4be21e2e133209b16b5760e0cdb)
@@ -76,5 +76,5 @@
 		'-s' if silent else '',
 		test_param,
-		settings.debugFlag,
+		settings.debug.flags,
 		flags,
 		target,
@@ -147,5 +147,4 @@
 # parses the Makefile to find the machine type (32-bit / 64-bit)
 def getMachineType():
-	return 'x64'
 	sh('echo "void ?{}(int&a,int b){}int main(){return 0;}" > .dummy.c')
 	ret, out = make('.dummy', silent = True)
@@ -161,6 +160,8 @@
 	rm( (".dummy.c",".dummy") )
 
-	return out
-	return re.search("ELF\s([0-9]+)-bit", out).group(1)
+	if settings.dry_run :
+		return 'x64'
+
+	return re.search(r"[^,]+,([^,]+),", out).group(1).strip()
 
 # count number of jobs to create
@@ -213,2 +214,5 @@
 	raise argparse.ArgumentTypeError(msg)
 	return False
+
+
+settings.set_machine_default( getMachineType )
Index: src/tests/test.py
===================================================================
--- src/tests/test.py	(revision 099a40d75e43725c90b9886739e2ec41f30092e7)
+++ src/tests/test.py	(revision f3b9efcc8e56c4be21e2e133209b16b5760e0cdb)
@@ -17,5 +17,5 @@
 	expected = []
 
-	def findTest(path):
+	def matchTest(path):
 		match = re.search("(\.[\w\/\-_]*)\/.expect\/([\w\-_]+)(\.[\w\-_]+)?\.txt", path)
 		if match :
@@ -24,7 +24,8 @@
 			test.path = match.group(1)
 			test.arch = match.group(3)[1:] if match.group(3) else None
-			expected.append(test)
-
-	pathWalk( findTest )
+			if settings.arch.match(test.arch):
+				expected.append(test)
+
+	pathWalk( matchTest )
 
 	return expected
@@ -77,5 +78,5 @@
 
 	# make sure we have at least some test to run
-	if tests :
+	if not tests :
 		print('ERROR: No valid test to run', file=sys.stderr)
 		sys.exit(1)
@@ -139,7 +140,4 @@
 	)
 
-	retcode = 0
-	error = None
-
 	# if the make command succeds continue otherwise skip to diff
 	if make_ret == 0 or settings.dry_run:
@@ -149,7 +147,7 @@
 		else :
 			# simply cat the result into the output
-			sh("cat %s > %s" % (test.target(), out_file))
+			retcode, _ = sh("cat %s > %s" % (test.target(), out_file))
 	else:
-		sh("mv %s %s" % (err_file, out_file))
+		retcode, _ = sh("mv %s %s" % (err_file, out_file))
 
 
@@ -161,4 +159,6 @@
 				error = "\t\tNo make target for test %s!" % test.target()
 				sh("rm %s" % out_file, False)
+			else:
+				error = None
 		else :
 			# fetch return code and error from the diff command
@@ -250,18 +250,18 @@
 		tests = allTests
 
+	#otherwise we need to validate that the test list that was entered is valid
 	else :
-		#otherwise we need to validate that the test list that was entered is valid
 		tests = validTests( options )
 
 	# sort the test alphabetically for convenience
-	tests.sort(key=lambda t: t.target())
+	tests.sort(key=lambda t: (t.arch if t.arch else '') + t.target())
 
 	# users may want to simply list the tests
 	if options.list_comp :
-		print("-h --help --debug --dry-run --list --all --regenerate-expected -j --jobs ", end='')
+		print("-h --help --debug --dry-run --list --arch --all --regenerate-expected -j --jobs ", end='')
 		print(" ".join(map(lambda t: "%s" % (t.target()), tests)))
 
 	elif options.list :
-		print("Listing for %s:%s"% (settings.arch.toString(), settings.debug))
+		print("Listing for %s:%s"% (settings.arch.string, settings.debug.string))
 		print("\n".join(map(lambda t: "%s" % (t.toString()), tests)))
 
@@ -272,6 +272,6 @@
 		print('%s (%s:%s) on %i cores' % (
 			'Regenerate tests' if settings.generating else 'Running',
-			settings.arch.toString(),
-			settings.debug,
+			settings.arch.string,
+			settings.debug.string,
 			options.jobs
 		))
