# SPDX-License-Identifier: GPL-2.0-only
#
# tests can be built & run independently.
# To use this, you should implement run and clean argument.
# run_seq will run all tests sequencially in one thread.
#
# Copyright (C) 2024, guoct1@chinatelecom.cn.
#
subdirs = $(shell find . -maxdepth 1 -mindepth 1 -type d)
.phony: all build run run_seq
all: build

build: $(addsuffix .build, $(subdirs))
	echo "tests build finished"
%.build: %
	make -C $*

run: $(addsuffix .run, $(subdirs))
	echo "tests run finished"
%.run: %
	make -C $* run

clean: $(addsuffix .clean, $(subdirs))
	echo "tests clean finished"
%.clean: %
	make -C $* clean

run_seq:
	$(foreach dir, $(subdirs), make -C $(dir) run &&) \
	echo "All tests succeeded."
