2022-01-10 20:22:17 +01:00
|
|
|
.POSIX:
|
2022-07-04 21:39:45 +02:00
|
|
|
.PHONY: test e2etest unittest crontest daemontest pre-clean clean restore-keyhome
|
2021-11-09 21:25:41 +01:00
|
|
|
|
2022-01-10 20:22:17 +01:00
|
|
|
#
|
|
|
|
# On systems where Python 3.x binary has a different name, just
|
|
|
|
# overwrite the name/path on the command line, like:
|
|
|
|
#
|
|
|
|
# make test PYTHON=/usr/local/bin/python3.8
|
|
|
|
#
|
2023-11-25 15:05:27 +01:00
|
|
|
# This macro is passed via environment to test/e2e_test.py, where it's
|
2022-01-10 20:22:17 +01:00
|
|
|
# used to compute further commands.
|
|
|
|
#
|
2023-09-30 22:33:49 +02:00
|
|
|
PYTHON = python
|
2022-01-10 20:22:17 +01:00
|
|
|
|
2023-11-25 15:05:27 +01:00
|
|
|
#
|
|
|
|
# SQLite database used during tests
|
|
|
|
#
|
|
|
|
# This database stores key queue and identity repository for e2etest,
|
|
|
|
# daemontest, and crontest.
|
|
|
|
#
|
2022-04-23 13:08:40 +02:00
|
|
|
TEST_DB = test/lacre.db
|
|
|
|
|
|
|
|
#
|
2023-11-25 15:05:27 +01:00
|
|
|
# Main goal to run all tests.
|
2022-04-23 13:08:40 +02:00
|
|
|
#
|
2023-11-25 15:05:27 +01:00
|
|
|
test: e2etest daemontest unittest crontest
|
2022-04-23 13:08:40 +02:00
|
|
|
|
2022-01-09 21:00:51 +01:00
|
|
|
#
|
|
|
|
# Run a set of end-to-end tests.
|
|
|
|
#
|
2024-01-06 14:45:09 +01:00
|
|
|
# Test scenarios are described and configured by the test/e2e.ini file.
|
|
|
|
# Basically this is just a script that feeds Lacre with known input and checks
|
|
|
|
# whether output meets expectations.
|
2022-01-09 21:00:51 +01:00
|
|
|
#
|
2022-06-27 08:53:24 +02:00
|
|
|
e2etest: test/tmp test/logs pre-clean restore-keyhome
|
2021-11-09 21:25:41 +01:00
|
|
|
$(PYTHON) test/e2e_test.py
|
2021-11-11 10:57:00 +01:00
|
|
|
|
2022-04-23 13:08:40 +02:00
|
|
|
#
|
|
|
|
# Run a basic cron-job test.
|
|
|
|
#
|
|
|
|
# We use PYTHONPATH to make sure that cron.py can import GnuPG
|
2024-01-06 14:45:09 +01:00
|
|
|
# package. We also set LACRE_CONFIG env. variable to make sure
|
2022-04-23 13:08:40 +02:00
|
|
|
# it slurps the right config.
|
|
|
|
#
|
|
|
|
crontest: clean-db $(TEST_DB)
|
2024-01-07 21:52:52 +01:00
|
|
|
LACRE_CONFIG=test/lacre-daemon.conf PYTHONPATH=`pwd` \
|
2023-11-25 15:05:27 +01:00
|
|
|
$(PYTHON) webgate-cron.py
|
2022-04-23 13:08:40 +02:00
|
|
|
|
|
|
|
$(TEST_DB):
|
2022-07-05 22:32:13 +02:00
|
|
|
$(PYTHON) test/utils/schema.py $(TEST_DB)
|
2022-04-23 13:08:40 +02:00
|
|
|
|
2022-07-04 21:39:45 +02:00
|
|
|
#
|
|
|
|
# Run an e2e test of Advanced Content Filter.
|
|
|
|
#
|
2023-11-25 15:05:27 +01:00
|
|
|
daemontest: restore-keyhome
|
2022-07-11 20:27:27 +02:00
|
|
|
$(PYTHON) test/daemon_test.py
|
2022-07-04 21:39:45 +02:00
|
|
|
|
2022-04-23 13:08:40 +02:00
|
|
|
# Before running the crontest goal we need to make sure that the
|
|
|
|
# database gets regenerated.
|
|
|
|
clean-db:
|
|
|
|
rm -f $(TEST_DB)
|
|
|
|
|
2022-01-09 21:00:51 +01:00
|
|
|
#
|
|
|
|
# Run unit tests
|
|
|
|
#
|
|
|
|
unittest:
|
2024-01-06 15:06:36 +01:00
|
|
|
LACRE_CONFIG=test/lacre.conf $(PYTHON) -m unittest discover -s test/modules
|
2022-01-09 21:00:51 +01:00
|
|
|
|
2021-11-11 10:57:00 +01:00
|
|
|
pre-clean:
|
2024-01-06 14:45:09 +01:00
|
|
|
rm -fv test/lacre.conf
|
2022-01-06 16:23:10 +01:00
|
|
|
rm -f test/logs/*.log
|
2021-11-11 10:57:00 +01:00
|
|
|
|
2022-06-27 08:53:24 +02:00
|
|
|
restore-keyhome:
|
|
|
|
git restore test/keyhome
|
2023-11-25 15:05:27 +01:00
|
|
|
git restore test/keyhome.other
|
2022-06-27 08:53:24 +02:00
|
|
|
|
2021-11-11 10:57:00 +01:00
|
|
|
test/tmp:
|
|
|
|
mkdir test/tmp
|
|
|
|
|
|
|
|
test/logs:
|
|
|
|
mkdir test/logs
|
|
|
|
|
2023-11-25 15:05:27 +01:00
|
|
|
clean: pre-clean clean-db
|
2021-11-11 10:57:00 +01:00
|
|
|
rm -rfv test/tmp test/logs
|