summaryrefslogtreecommitdiff
path: root/tests/Makefile
diff options
context:
space:
mode:
authoradmin <admin@optics-design.com>2025-08-05 11:28:41 +0200
committeradmin <admin@optics-design.com>2025-08-05 11:28:41 +0200
commit04b3fcb479f5aaae06d18b315a8bdc8c298f4eae (patch)
tree92f60caef26f98a83681aa0e1f360df03203bbe4 /tests/Makefile
parent9496ae0a50e6848121c7e913ca2dc55c8e6c84c1 (diff)
removed clustering
Diffstat (limited to 'tests/Makefile')
-rw-r--r--tests/Makefile169
1 files changed, 169 insertions, 0 deletions
diff --git a/tests/Makefile b/tests/Makefile
new file mode 100644
index 0000000..84e64dc
--- /dev/null
+++ b/tests/Makefile
@@ -0,0 +1,169 @@
+# Test Makefile for GlaMaC
+# Builds and runs unit tests and integration tests
+
+# Include common build configuration
+include ../build/common.mk
+
+# Test-specific directories
+TESTDIR := .
+UNIT_TESTDIR := $(TESTDIR)/unit
+INTEGRATION_TESTDIR := $(TESTDIR)/integration
+TEST_BINDIR := $(TESTDIR)/bin
+
+# Test source files
+UNIT_TESTS := $(wildcard $(UNIT_TESTDIR)/*.c)
+INTEGRATION_TESTS := $(wildcard $(INTEGRATION_TESTDIR)/*.c)
+
+# Test binaries (specific ones we have rules for)
+UNIT_TEST_BINS := $(TEST_BINDIR)/test_glass_data $(TEST_BINDIR)/test_fgla $(TEST_BINDIR)/test_glamac_view
+INTEGRATION_TEST_BINS := $(TEST_BINDIR)/test_simple_pipeline
+
+# Glass data dependencies (needed for tests)
+GLASS_DATA_DEPS := ../src/glamac/glass_data.c ../src/glamac/glamac_errors.c
+
+# View system dependencies
+VIEW_DEPS := ../src/glamac/glamac_view.c ../src/glamac/glamac_errors.c
+
+# Test-specific compiler flags
+TEST_CFLAGS := $(CFLAGS_NATIVE) -I$(TESTDIR) -DTEST_BUILD
+
+# Default target
+all: unit-tests integration-tests
+
+# Create test bin directory
+$(TEST_BINDIR):
+ $(MKDIR) $(TEST_BINDIR)
+
+# Unit test rules
+unit-tests: $(UNIT_TEST_BINS)
+
+# Unit test for glass_data
+$(TEST_BINDIR)/test_glass_data: $(UNIT_TESTDIR)/test_glass_data.c $(GLASS_DATA_DEPS) | $(TEST_BINDIR)
+ $(CC) $^ $(TEST_CFLAGS) -o $@
+
+# Unit test for fgla (needs fgla.c for internal function testing)
+$(TEST_BINDIR)/test_fgla: $(UNIT_TESTDIR)/test_fgla.c ../src/glautils/fgla.c $(GLASS_DATA_DEPS) | $(TEST_BINDIR)
+ $(CC) $^ $(TEST_CFLAGS) -o $@
+
+# Unit test for glamac_view (simplified version)
+$(TEST_BINDIR)/test_glamac_view: $(UNIT_TESTDIR)/test_glamac_view_simple.c $(VIEW_DEPS) $(GLASS_DATA_DEPS) | $(TEST_BINDIR)
+ $(CC) $^ $(TEST_CFLAGS) -o $@
+
+# Integration tests
+integration-tests: $(INTEGRATION_TEST_BINS)
+
+# Integration test for simple pipeline
+$(TEST_BINDIR)/test_simple_pipeline: $(INTEGRATION_TESTDIR)/test_simple_pipeline.c ../src/glautils/fgla.c $(VIEW_DEPS) $(GLASS_DATA_DEPS) | $(TEST_BINDIR)
+ $(CC) $^ $(TEST_CFLAGS) -o $@
+
+# Run all tests
+test: unit-tests integration-tests
+ @echo ""
+ @echo "$(CYAN)Running Unit Tests$(RESET)"
+ @echo "=================="
+ @for test in $(UNIT_TEST_BINS); do \
+ if [ -f "$$test" ]; then \
+ echo "$(BLUE)Running $$test$(RESET)"; \
+ ./$$test; \
+ echo ""; \
+ fi; \
+ done
+ @echo ""
+ @echo "$(CYAN)Running Integration Tests$(RESET)"
+ @echo "========================="
+ @for test in $(INTEGRATION_TEST_BINS); do \
+ if [ -f "$$test" ]; then \
+ echo "$(BLUE)Running $$test$(RESET)"; \
+ ./$$test; \
+ echo ""; \
+ fi; \
+ done
+
+# Run only unit tests
+test-unit: unit-tests
+ @echo "$(CYAN)Running Unit Tests$(RESET)"
+ @echo "=================="
+ @for test in $(UNIT_TEST_BINS); do \
+ if [ -f "$$test" ]; then \
+ echo "$(BLUE)Running $$test$(RESET)"; \
+ ./$$test; \
+ echo ""; \
+ fi; \
+ done
+
+# Run only integration tests
+test-integration: integration-tests
+ @echo "$(CYAN)Running Integration Tests$(RESET)"
+ @echo "========================="
+ @for test in $(INTEGRATION_TEST_BINS); do \
+ if [ -f "$$test" ]; then \
+ echo "$(BLUE)Running $$test$(RESET)"; \
+ ./$$test; \
+ echo ""; \
+ fi; \
+ done
+
+# Run specific test
+test-%: $(TEST_BINDIR)/%
+ @echo "$(CYAN)Running specific test: $*$(RESET)"
+ @./$(TEST_BINDIR)/$*
+
+# Clean test binaries
+clean:
+ $(RMDIR) $(TEST_BINDIR) 2>/dev/null || true
+
+# Verbose test runs (for debugging)
+test-verbose: SHELL:=/bin/bash
+test-verbose: unit-tests integration-tests
+ @echo ""
+ @echo "$(CYAN)Running Unit Tests (Verbose)$(RESET)"
+ @echo "============================"
+ @for test in $(UNIT_TEST_BINS); do \
+ if [ -f "$$test" ]; then \
+ echo "$(BLUE)Running $$test$(RESET)"; \
+ ./$$test 2>&1 | tee "$$test.log"; \
+ echo ""; \
+ fi; \
+ done
+ @echo ""
+ @echo "$(CYAN)Running Integration Tests (Verbose)$(RESET)"
+ @echo "=================================="
+ @for test in $(INTEGRATION_TEST_BINS); do \
+ if [ -f "$$test" ]; then \
+ echo "$(BLUE)Running $$test$(RESET)"; \
+ ./$$test 2>&1 | tee "$$test.log"; \
+ echo ""; \
+ fi; \
+ done
+
+# Help
+help:
+ @echo "GlaMaC Test System"
+ @echo ""
+ @echo "Targets:"
+ @echo " all - Build all tests"
+ @echo " unit-tests - Build unit tests"
+ @echo " integration-tests- Build integration tests"
+ @echo " test - Build and run all tests"
+ @echo " test-unit - Build and run unit tests only"
+ @echo " test-integration - Build and run integration tests only"
+ @echo " test-<name> - Run specific test by name"
+ @echo " test-verbose - Run all tests with verbose output"
+ @echo " clean - Clean test binaries"
+ @echo " help - Show this help"
+ @echo ""
+ @echo "Examples:"
+ @echo " make test # Run all tests"
+ @echo " make test-unit # Run only unit tests"
+ @echo " make test-test_glass_data # Run specific test"
+
+# Color definitions for use in shell commands
+export RESET := \033[0m
+export RED := \033[31m
+export GREEN := \033[32m
+export YELLOW := \033[33m
+export BLUE := \033[34m
+export MAGENTA := \033[35m
+export CYAN := \033[36m
+
+.PHONY: all unit-tests integration-tests test test-unit test-integration clean help test-verbose \ No newline at end of file
Back to https://optics-design.com