Index: src/tests/.expect/abs.txt
===================================================================
--- src/tests/.expect/abs.txt	(revision efc1591827fc083d82be64f59cd21ba24b32492d)
+++ src/tests/.expect/abs.txt	(revision efc1591827fc083d82be64f59cd21ba24b32492d)
@@ -0,0 +1,12 @@
+/usr/local/bin/cfa -g -Wall -Wno-unused-function     abs.c   -o abs
+CFA Version 1.0.0 (debug)
+char			¿	abs A
+signed int		-65	abs 65
+signed long int		-65	abs 65
+signed long long int	-65	abs 65
+float			-65	abs 65
+double			-65	abs 65
+long double		-65	abs 65
+float _Complex		-65-2i	abs 65.0308
+double _Complex		-65-2i	abs 65.0307619515564
+long double _Complex	-65-2i	abs 65.0307619515564342
Index: src/tests/.gitignore
===================================================================
--- src/tests/.gitignore	(revision efc1591827fc083d82be64f59cd21ba24b32492d)
+++ src/tests/.gitignore	(revision efc1591827fc083d82be64f59cd21ba24b32492d)
@@ -0,0 +1,1 @@
+.out/
Index: src/tests/.in/vector_test.txt
===================================================================
--- src/tests/.in/vector_test.txt	(revision efc1591827fc083d82be64f59cd21ba24b32492d)
+++ src/tests/.in/vector_test.txt	(revision efc1591827fc083d82be64f59cd21ba24b32492d)
@@ -0,0 +1,1 @@
+1 2 3 4 5
Index: src/tests/test.py
===================================================================
--- src/tests/test.py	(revision efc1591827fc083d82be64f59cd21ba24b32492d)
+++ src/tests/test.py	(revision efc1591827fc083d82be64f59cd21ba24b32492d)
@@ -0,0 +1,149 @@
+#!python
+from __future__ import print_function
+
+from os import listdir
+from os.path import isfile, join
+from subprocess import Popen, PIPE, STDOUT
+
+import argparse
+import sys
+
+################################################################################
+#               help functions
+################################################################################
+def listTests():
+	list = [f.rstrip('.c') for f in listdir('.')
+		if not f.startswith('.') and (
+			not isfile(f) or f.endswith('.c')
+		)]
+
+	return list
+
+def sh(cmd, dry_run):
+	if dry_run :
+		print("cmd: %s" % cmd)
+		return 0
+	else :
+		proc = Popen(cmd, stderr=STDOUT, shell=True)
+		proc.communicate()
+		return proc.returncode
+
+################################################################################
+#               running test functions
+################################################################################
+def run_test_instance(test, dry_run):
+	sh("rm -f .out/%s.log" % test, dry_run)
+	sh("rm -f %s" % test, dry_run)
+
+	# build, skipping to next test on error
+	sh("make -j 8 %s >> .out/%s.log 2>&1" % (test, test), dry_run)
+
+	# fetch optional input
+	stdinput = "< .in/%s.txt" % test if isfile(".in/%s.txt" % test) else ""
+
+	# run test
+	sh("./%s %s >> .out/%s.log 2>&1" % (test, stdinput, test), dry_run)
+
+	# touch expected files so empty output are supported by default
+	sh("touch .expect/%s.txt" % test, dry_run)
+
+	# diff the output of the files
+	retcode = sh("diff .expect/%s.txt .out/%s.log" % (test, test), dry_run)
+
+	# clean the executable
+	sh("rm -f %s" % test, dry_run)
+
+	return retcode
+
+def run_tests(tests, dry_run) :
+	sh('make clean > /dev/null 2>&1', dry_run)
+
+	failed = False;
+	for t in tests:
+		print("%10s  " % t, end="")
+		sys.stdout.flush()
+		test_failed = run_test_instance(t, dry_run)
+		failed = test_failed or failed
+		print("FAILED" if test_failed else "PASSED")
+
+	sh('make clean > /dev/null 2>&1', dry_run)
+
+	return 0 if failed else 1
+
+################################################################################
+#               generate expectation functions
+################################################################################
+def generate_test_expect(test):
+	sh("rm -f .out/%s.log" % test, False)
+	sh("rm -f %s" % test, False)
+
+	# build, skipping to next test on error
+	sh("make -j 8 %s > .expect/%s.txt 2>&1" % (test, test), False)
+
+	# fetch optional input
+	stdinput = "< .in/%s.txt" % test if isfile(".in/%s.txt" % test) else ""
+
+	# run test
+	sh("./%s %s >> .expect/%s.txt 2>&1" % (test, stdinput, test), False)
+
+	# clean the executable
+	sh("rm -f %s" % test, False)
+
+def generate_expect(tests) :
+	sh('make clean > /dev/null 2>&1', False)
+
+	print( "Regenerate tests for" )
+
+	print( ", ".join( tests ) )
+
+	for t in tests:
+		generate_test_expect( t )
+
+	print( "Done" )
+
+	sh('make clean > /dev/null 2>&1', False)
+
+################################################################################
+#               main loop
+################################################################################
+parser = argparse.ArgumentParser(description='Script which runs cforall tests')
+parser.add_argument('--dry-run', help='Don\'t run the tests, only output the commands', action='store_true')
+parser.add_argument('--all', help='Run all test available', action='store_true')
+parser.add_argument('--generate-expected', help='Regenerate the .expect by running the specified tets, can be used with --all option', action='store_true')
+parser.add_argument('tests', metavar='test', type=str, nargs='*', help='a list of tests to run')
+
+options = parser.parse_args()
+
+tests = listTests()
+
+if options.all :
+	if len(options.tests) > 0 :
+		print('ERROR: cannot specify tests with \'--all\' option', file=sys.stderr)
+		sys.exit(1)
+
+	if options.generate_expected :
+		generate_expect( tests )
+	else :
+		sys.exit( run_tests(tests, options.dry_run) )
+
+else :
+	if len(options.tests) == 0 :
+		print('ERROR: must have option \'--all\' or non-empty test list', file=sys.stderr)
+		parser.print_help()
+		sys.exit(1)
+
+	unkownTests = False
+	for test in options.tests :
+		if not (test in tests) :
+			print("ERROR: unkown test %s" % test)
+			unkownTests = true
+
+	if unkownTests :
+		sys.exit(1)
+
+	if options.generate_expected :
+		generate_expect( options.tests )
+	else :
+		sys.exit( run_tests(options.tests, options.dry_run) )
+
+sys.exit(0)
