commit f927f5feb79cc1317d0fcd97fde8ac45d92b68d5
parent dbb51710c8ba034539ce7e20bbbaa7f482663690
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Sat, 29 Mar 2025 19:18:02 +0100
combustion & planets: building the missing tests
These tests have certainly not been built since the switch to POSIX
make.
Add the test target to automatically launch the tests.
Diffstat:
5 files changed, 63 insertions(+), 3 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1,6 +1,7 @@
*~
*.[aod]
[Bb]uild*
+*.bin
.config*
.gitignore
htrdr
@@ -12,7 +13,10 @@ htrdr-combustion.1
htrdr-planets
htrdr-planets.1
htrdr_version.h
+*.obj
*.pc
*.so
*.sw[po]
tags
+test_*
+!test_*.[ch]
diff --git a/Makefile b/Makefile
@@ -32,6 +32,10 @@ default install uninstall lint clean:
@if [ "$(COMBUSTION)" == "ENABLE" ]; then $(MAKE) -fMakefile.combustion $@; fi
@if [ "$(PLANETS)" == ENABLE ]; then $(MAKE) -fMakefile.planets $@; fi
+test:
+ @if [ "$(COMBUSTION)" == "ENABLE" ]; then $(MAKE) -fMakefile.combustion $@; fi
+ @if [ "$(PLANETS)" == ENABLE ]; then $(MAKE) -fMakefile.planets $@; fi
+
default: htrdr
install: install_common
uninstall: uninstall_common
diff --git a/Makefile.combustion b/Makefile.combustion
@@ -28,7 +28,7 @@ include config.mk
LIBNAME = libhtrdr-combustion.a
-default: command
+default: command tests
################################################################################
# Build the library
@@ -105,6 +105,31 @@ $(CMD_OBJ):
$(CC) $(CFLAGS_CMD) -c $(@:.o=.c) -o $@
################################################################################
+# Build the test
+################################################################################
+TEST_SRC = src/combustion/test_htrdr_combustion_laser.c
+TEST_OBJ = $(TEST_SRC:.c=.o)
+TEST_DEP = $(TEST_SRC:.c=.d)
+
+CFLAGS_TEST = $(CFLAGS_EXE) $$($(PKG_CONFIG_LOCAL) --static --cflags htrdr-combustion rsys)
+LDFLAGS_TEST = $(LDFLAGS_EXE) $$($(PKG_CONFIG_LOCAL) --static --libs htrdr-combustion rsys)
+
+test: tests
+ ./test_htrdr_combustion_laser > /dev/null 2>&1
+
+tests: library $(TEST_DEP)
+ @$(MAKE) -fMakefile.combustion -f$(TEST_DEP) test_htrdr_combustion_laser
+
+test_htrdr_combustion_laser: $(TEST_OBJ)
+ $(CC) $(CFLAGS_TEST) -o $@ $(TEST_OBJ) src/combustion/htrdr_combustion_laser.o $(LDFLAGS_TEST)
+
+$(TEST_DEP):
+ @$(CC) $(CFLAGS_TEST) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
+
+$(TEST_OBJ):
+ $(CC) $(CFLAGS_TEST) -c $(@:.o=.c) -o $@
+
+################################################################################
# Generate files from template
################################################################################
src/combustion/htrdr_combustion_args.h: config.mk src/combustion/htrdr_combustion_args.h.in
@@ -167,6 +192,7 @@ clean:
rm -f htrdr-combustion $(CMD_OBJ) $(CMD_DEP)
rm -f .config_combustion libhtrdr-combustion.o htrdr-combustion.pc
rm -f doc/htrdr-combustion.1 src/combustion/htrdr_combustion_args.h
+ rm -f test_htrdr_combustion_laser
lint: doc/htrdr-combustion.1
mandoc -Tlint -Wall doc/htrdr-combustion.1 || [ $$? -le 1 ]
diff --git a/Makefile.planets b/Makefile.planets
@@ -28,7 +28,7 @@ include config.mk
LIBNAME = libhtrdr-planets.a
-default: command
+default: command tests
################################################################################
# Build the library
@@ -107,6 +107,31 @@ $(CMD_OBJ):
$(CC) $(CFLAGS_CMD) -c $(@:.o=.c) -o $@
################################################################################
+# Tests
+################################################################################
+TEST_SRC = src/planets/test_htrdr_planets_source.c
+TEST_OBJ = $(TEST_SRC:.c=.o)
+TEST_DEP = $(TEST_SRC:.c=.d)
+
+CFLAGS_TEST = $(CFLAGS_EXE) $$($(PKG_CONFIG_LOCAL) --static --cflags htrdr-planets rsys)
+LDFLAGS_TEST = $(LDFLAGS_EXE) $$($(PKG_CONFIG_LOCAL) --static --libs htrdr-planets rsys)
+
+test: tests
+ ./test_htrdr_planets_source > /dev/null 2>&1
+
+tests: library $(TEST_DEP)
+ @$(MAKE) -fMakefile.planets -f$(TEST_DEP) test_htrdr_planets_source
+
+test_htrdr_planets_source: $(TEST_OBJ)
+ $(CC) $(CFLAGS_TEST) -o $@ $(TEST_OBJ) src/planets/htrdr_planets_source.o $(LDFLAGS_TEST)
+
+$(TEST_DEP):
+ @$(CC) $(CFLAGS_TEST) -MM -MT "$(@:.d=.o) $@" $(@:.d=.c) -MF $@
+
+$(TEST_OBJ):
+ $(CC) $(CFLAGS_TEST) -c $(@:.o=.c) -o $@
+
+################################################################################
# Generate files from template
################################################################################
src/planets/htrdr_planets_args.h: config.mk src/planets/htrdr_planets_args.h.in
@@ -161,6 +186,7 @@ clean:
rm -f $(CMD_OBJ) $(CMD_DEP) htrdr-planets
rm -f .config_planets libhtrdr-planets.o htrdr-planets.pc
rm -f doc/htrdr-planets.1 src/planets/htrdr_planets_args.h
+ rm -f test_htrdr_planets_source
lint: doc/htrdr-planets.1
mandoc -Tlint -Wall doc/htrdr-planets.1 || [ $$? -le 1 ]
diff --git a/src/planets/test_htrdr_planets_source.c b/src/planets/test_htrdr_planets_source.c
@@ -237,7 +237,7 @@ test_spectrum_from_files(struct htrdr* htrdr, int argc, char** argv)
struct htrdr_planets_source_args source_args = HTRDR_PLANETS_SOURCE_ARGS_NULL;
struct htrdr_planets_source_spectrum spectrum = HTRDR_PLANETS_SOURCE_SPECTRUM_NULL;
struct htrdr_planets_source* source = NULL;
- size_t i;
+ int i;
source_args.longitude = 0;
source_args.latitude = 0;