From 53c0afce1e3f635fd9e9db1c1498b722804eaf79 Mon Sep 17 00:00:00 2001 From: Luke Benstead Date: Mon, 26 Oct 2020 22:00:11 +0000 Subject: [PATCH] More work on the test suite --- .gitlab-ci.yml | 11 +++++++++++ tests/Makefile | 12 ++++++++---- tests/test_generator.py | 4 ++-- tests/test_nearz_clipping.h | 9 +++++++-- utils/test_parser.py | 18 ++++++++++++++++++ 5 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 utils/test_parser.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2c21ac7..0d18f22 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,6 @@ stages: - build + - test build:sh4-gcc: stage: build @@ -8,3 +9,13 @@ build:sh4-gcc: - source /etc/bash.bashrc - make clean - make samples + +test:sh4-gcc: + stage: test + image: kazade/dreamcast-sdk + script: + - source /etc/bash.bashrc + - make test + - lxdream -H -b -e tests/tests.elf | python3 utils/test_parser.py + + diff --git a/tests/Makefile b/tests/Makefile index 7ef501d..4e1e181 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,7 +1,6 @@ TARGET = tests.elf OBJS = test_runner.o - -TESTS = $(shell find . -name "*.cpp") +TESTS := $(shell find . -name \*.h) CXXFLAGS := $(CXXFLAGS) -std=c++11 @@ -10,12 +9,16 @@ all: rm-elf $(TARGET) include $(KOS_BASE)/Makefile.rules clean: - -rm -f $(TARGET) $(OBJS) romdisk.* + -rm -f $(TARGET) $(OBJS) romdisk.* test_runner.o test_runner.cpp rm-elf: -rm -f $(TARGET) romdisk.* -test_runner.cpp: $(shell python3 test_generator.py --output=test_runner.cpp $(TESTS)) +test_runner.cpp: + $(shell python3 test_generator.py --output=test_runner.cpp $(TESTS)) + @echo MY_VAR IS $(TESTS) + +test_runner.o: test_runner.cpp $(TARGET): $(OBJS) romdisk.o kos-c++ -o $(TARGET) $(OBJS) romdisk.o @@ -32,3 +35,4 @@ run: $(TARGET) dist: rm -f $(OBJS) romdisk.o romdisk.img $(KOS_STRIP) $(TARGET) + diff --git a/tests/test_generator.py b/tests/test_generator.py index 2817fdd..8bb54d9 100755 --- a/tests/test_generator.py +++ b/tests/test_generator.py @@ -86,7 +86,7 @@ int main(int argc, char* argv[]) { """ -VERBOSE = False +VERBOSE = True def log_verbose(message): if VERBOSE: @@ -165,7 +165,7 @@ def find_tests(files): # If this subclasses TestCase, or it subclasses any of the already found testcase subclasses # then add it to the list - if "TestCase" in subclass_names or "SimulantTestCase" in subclass_names or any(x[1] in subclasses[i][2] for x in test_case_subclasses): + if "TestCase" in subclass_names or "GLdcTestCase" in subclass_names or any(x[1] in subclasses[i][2] for x in test_case_subclasses): if subclasses[i] not in test_case_subclasses: test_case_subclasses.append(subclasses[i]) diff --git a/tests/test_nearz_clipping.h b/tests/test_nearz_clipping.h index 62296b1..b1e4f89 100644 --- a/tests/test_nearz_clipping.h +++ b/tests/test_nearz_clipping.h @@ -1,10 +1,15 @@ +#pragma once + #include "../utils/test.h" namespace { -class NearZClippingTests : gldc::test::GLdcTestCase { - +class NearZClippingTests : public gldc::test::GLdcTestCase { +public: + void test_failure() { + assert_false(true); + } }; } diff --git a/utils/test_parser.py b/utils/test_parser.py new file mode 100644 index 0000000..31d57c1 --- /dev/null +++ b/utils/test_parser.py @@ -0,0 +1,18 @@ +import re +import fileinput +import sys + +REGEX = "(\d+) tests ([failed|crashed])" + + +if __name__ == '__main__': + for line in sys.stdin: + print(line, end="") + + if re.search(REGEX, line): + print("DETECTED FAILURES") + sys.exit(1) + else: + print("TESTS PASSED!") + sys.exit(0) +