| 1 |
#!/bin/bash |
| 2 |
# SPDX-License-Identifier: MPL-2.0 |
| 3 |
# |
| 4 |
# libpathrs: safe path resolution on Linux |
| 5 |
# Copyright (C) 2019-2025 SUSE LLC |
| 6 |
# Copyright (C) 2026 Aleksa Sarai <[email protected]> |
| 7 |
# |
| 8 |
# This Source Code Form is subject to the terms of the Mozilla Public |
| 9 |
# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 10 |
# file, You can obtain one at https://mozilla.org/MPL/2.0/. |
| 11 |
|
| 12 |
ifneq ($(RUN_AS),) |
| 13 |
SUDO := sudo -u $(RUN_AS) |
| 14 |
endif |
| 15 |
|
| 16 |
BATS ?= bats |
| 17 |
|
| 18 |
ALL_TESTS := $(patsubst cmd/%/Makefile,test-%,$(wildcard cmd/*/Makefile)) |
| 19 |
|
| 20 |
.DEFAULT: test-all |
| 21 |
.PHONY: test-all |
| 22 |
test-all: $(ALL_TESTS) |
| 23 |
|
| 24 |
test-%: cmd/%/pathrs-cmd FORCE |
| 25 |
$(SUDO) PATHRS_CMD=$< $(BATS) -t tests/ |
| 26 |
|
| 27 |
cmd/%/pathrs-cmd: FORCE |
| 28 |
make -C $(@D) $(@F) |
| 29 |
|
| 30 |
# .PHONY doesn't work with patterns so we need to create a dummy rule. |
| 31 |
# See <https://www.gnu.org/software/make/manual/html_node/Force-Targets.html> |
| 32 |
# and <https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html>. |
| 33 |
FORCE: |