2021-11-15 18:58:29 +00:00
|
|
|
ENV ?= env
|
2022-11-14 19:40:30 +00:00
|
|
|
M4 ?= m4 -E -E
|
2008-08-19 19:30:36 +00:00
|
|
|
MKDIR ?= mkdir
|
|
|
|
EXE ?= libsepol-tests
|
|
|
|
|
2022-11-14 19:40:30 +00:00
|
|
|
CFLAGS += -g3 -gdwarf-2 -O0 \
|
|
|
|
-Werror -Wall -Wextra \
|
|
|
|
-Wfloat-equal \
|
|
|
|
-Wformat=2 \
|
|
|
|
-Winit-self \
|
|
|
|
-Wmissing-format-attribute \
|
|
|
|
-Wmissing-noreturn \
|
|
|
|
-Wmissing-prototypes \
|
|
|
|
-Wnull-dereference \
|
|
|
|
-Wpointer-arith \
|
|
|
|
-Wshadow \
|
|
|
|
-Wstrict-prototypes \
|
|
|
|
-Wundef \
|
|
|
|
-Wunused \
|
|
|
|
-Wwrite-strings \
|
|
|
|
-fno-common
|
2008-08-19 19:30:36 +00:00
|
|
|
|
|
|
|
# Statically link libsepol on the assumption that we are going to
|
|
|
|
# be testing internal functions.
|
|
|
|
LIBSEPOL := ../src/libsepol.a
|
|
|
|
|
|
|
|
# In order to load source policies we need to link in the checkpolicy/checkmodule parser and util code.
|
|
|
|
# This is less than ideal, but it makes the tests easier to maintain by allowing source policies
|
|
|
|
# to be loaded directly.
|
|
|
|
CHECKPOLICY := ../../checkpolicy/
|
2017-06-28 21:42:20 +00:00
|
|
|
override CPPFLAGS += -I../include/ -I$(CHECKPOLICY)
|
2008-08-19 19:30:36 +00:00
|
|
|
|
|
|
|
# test program object files
|
2017-05-30 14:21:32 +00:00
|
|
|
objs := $(patsubst %.c,%.o,$(sort $(wildcard *.c)))
|
2008-08-19 19:30:36 +00:00
|
|
|
parserobjs := $(CHECKPOLICY)queue.o $(CHECKPOLICY)y.tab.o \
|
|
|
|
$(CHECKPOLICY)parse_util.o $(CHECKPOLICY)lex.yy.o \
|
|
|
|
$(CHECKPOLICY)policy_define.o $(CHECKPOLICY)module_compiler.o
|
|
|
|
|
|
|
|
# test policy pieces
|
|
|
|
m4support := $(wildcard policies/support/*.spt)
|
|
|
|
testsuites := $(wildcard policies/test-*)
|
|
|
|
policysrc := $(foreach path,$(testsuites),$(wildcard $(path)/*.conf))
|
|
|
|
stdpol := $(addsuffix .std,$(policysrc))
|
|
|
|
mlspol := $(addsuffix .mls,$(policysrc))
|
|
|
|
policies := $(stdpol) $(mlspol)
|
|
|
|
|
|
|
|
all: $(EXE) $(policies)
|
|
|
|
policies: $(policies)
|
|
|
|
|
|
|
|
$(EXE): $(objs) $(parserobjs) $(LIBSEPOL)
|
2020-05-01 09:23:30 +00:00
|
|
|
$(CC) $(LDFLAGS) $(objs) $(parserobjs) -lcunit $(LIBSEPOL) -o $@
|
2008-08-19 19:30:36 +00:00
|
|
|
|
|
|
|
%.conf.std: $(m4support) %.conf
|
|
|
|
$(M4) $(M4PARAMS) $^ > $@
|
|
|
|
|
|
|
|
%.conf.mls: $(m4support) %.conf
|
|
|
|
$(M4) $(M4PARAMS) -D enable_mls $^ > $@
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f $(objs) $(EXE)
|
|
|
|
rm -f $(policies)
|
|
|
|
rm -f policies/test-downgrade/policy.hi policies/test-downgrade/policy.lo
|
|
|
|
|
2021-11-15 18:58:29 +00:00
|
|
|
# mkdir is run in a clean environment created by env -i to avoid failing under ASan with:
|
|
|
|
#
|
|
|
|
# ASan runtime does not come first in initial library list;
|
|
|
|
# you should either link runtime to your application or manually preload it with LD_PRELOAD
|
|
|
|
#
|
|
|
|
# when the source code is built with ASan
|
2008-08-19 19:30:36 +00:00
|
|
|
test: $(EXE) $(policies)
|
2021-11-15 18:58:29 +00:00
|
|
|
$(ENV) -i $(MKDIR) -p policies/test-downgrade
|
2008-08-19 19:30:36 +00:00
|
|
|
../../checkpolicy/checkpolicy -M policies/test-cond/refpolicy-base.conf -o policies/test-downgrade/policy.hi
|
|
|
|
./$(EXE)
|
|
|
|
|
|
|
|
.PHONY: all policies clean test
|