get_next_line_testing/Makefile
2025-10-31 20:14:58 +01:00

85 lines
2.6 KiB
Makefile

# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2025/10/22 20:41:03 by lalgarra #+# #+# #
# Updated: 2025/10/31 19:12:59 by lalgarra ### ########.fr #
# #
# **************************************************************************** #
NAME = report
# Relative location of sources to test
LIBDIR = ../repo_algarra
TIME = valgrind --leak-check=yes
GNL_SOURCES = get_next_line.c get_next_line_utils.c
SOURCES = $(foreach f, $(GNL_SOURCES), $(LIBDIR)/$f)
CFLAGS += -Wall -Wextra -Werror -g3 -iquote $(LIBDIR) -O0
test001: test001.c $(SOURCES)
$(CC) $(CFLAGS) $+ -o $@
run_test = printf "==\n test001_01: BUFFER_SIZE=$(1): input$(3) vs output$(3)\n" >> $(4) ;\
$(TIME) ./$(2) input$(3) > output$(3) ;\
diff -s input$(3) output$(3) >> $(4) ;
test_recipe = $(CC) $(CFLAGS) -D BUFFER_SIZE=$(BUFFER_SIZE) $+ -o $(PRG) ; \
$(foreach i, $(IDXS), $(call run_test, $(BUFFER_SIZE),$(PRG),$i,$@))
PRG = test_bs$(BUFFER_SIZE)
IDXS = 001 002 003 004 005 006
report_01: BUFFER_SIZE = 42
report_01: test001.c $(SOURCES)
$(call test_recipe)
report_02: BUFFER_SIZE = 80
report_02: test001.c $(SOURCES)
$(call test_recipe)
report_03: BUFFER_SIZE = 100000
report_03: test001.c $(SOURCES)
$(call test_recipe)
report_04: BUFFER_SIZE = 1
report_04: IDXS = 001 002 003 004 005
report_04: test001.c $(SOURCES)
$(call test_recipe)
BONUS_SRC_BN = get_next_line_bonus.c get_next_line_utils_bonus.c
BONUS_SRC = $(foreach f, $(BONUS_SRC_BN), $(LIBDIR)/$f)
bonus_01: BUFFER_SIZE = 42
bonus_01: test001.c $(BONUS_SRC)
$(call test_recipe)
bonus_02: BUFFER_SIZE = 80
bonus_02: test001.c $(BONUS_SRC)
$(call test_recipe)
bonus_03: BUFFER_SIZE = 100000
bonus_03: test001.c $(BONUS_SRC)
$(call test_recipe)
bonus_04: BUFFER_SIZE = 1
bonus_04: IDXS = 001 002 003 004 005
bonus_04: test001.c $(BONUS_SRC)
$(call test_recipe)
fclean:
rm -f test001 test001_01 output* report_* rpt_01 test_bs* bonus_*
all: report_01 report_02 report_03 report_04
bonus_all: bonus_01 bonus_02 bonus_03 bonus_04
re: fclean all