1#!/usr/bin/python3 2import subprocess 3from scripts.config import (PREFIX, VALAC) 4from scripts.run import run 5from scripts.version import LIBXMLBIRD_SO_VERSION 6 7def read_elements(file): 8 tests = [] 9 f = open(file) 10 line = f.readline().strip () 11 while line: 12 if not line == "": 13 tests += [line] 14 line = f.readline().strip () 15 16 return tests 17 18def get_benchmarks(): 19 return read_elements("tests/benchmarks.txt") 20 21def get_tests(): 22 return read_elements("tests/tests.txt") 23 24def all_tests(): 25 tests = get_benchmarks() 26 tests += get_tests() 27 return tests 28 29def build_tests(): 30 tests = all_tests() + ["fuzz"] 31 run ("mkdir -p build/bin"); 32 run ("mkdir -p build/tests"); 33 34 for test in tests: 35 run (VALAC + " --ccode --pkg=posix --pkg=xmlbird --vapidir=./build " 36 + "--directory=./build tests/" + test + ".vala tests/Test.vala"); 37 38 run ("""gcc -fPIC -c \ 39 -I ./build/xmlbird \ 40 $(pkg-config --cflags glib-2.0) \ 41 $(pkg-config --cflags gobject-2.0) \ 42 -I ./build -L./build/bin -lxmlbird \ 43 build/tests/""" + test + """.c \ 44 build/tests/Test.c"""); 45 46 run ("mv *.o build/tests/"); 47 48 run ("""gcc build/tests/""" + test + """.o build/tests/Test.o \ 49 $(pkg-config --libs glib-2.0) \ 50 $(pkg-config --libs gobject-2.0) \ 51 -L./build/bin -lxmlbird \ 52 -o ./build/bin/""" + test); 53 54