mirror of
https://github.com/troglobit/libite.git
synced 2026-10-31 12:50:41 +00:00
Add generic support for running tests as root.
By setting `ASROOT=1` in a unit test makefile a test will now run as root, using `sudo -n`. This patch allows us to simplify the pidfilefn() test. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
e8ff38ad6a
commit
44e787c966
3 files changed
+22
-7
No files matched your search
@@ -25,6 +25,13 @@ REDIRECT = >/dev/null
|
||||
MAKEFLAGS = --no-print-directory --silent
|
||||
endif
|
||||
|
||||
# Some tests may need to be run as root, e.g. pidfile()
|
||||
ifeq ($(ASROOT), 1)
|
||||
SUDO = sudo -n
|
||||
else
|
||||
SUDO =
|
||||
endif
|
||||
|
||||
# Default install paths
|
||||
prefix ?= /usr/local
|
||||
libdir ?= $(prefix)/lib
|
||||
@@ -40,10 +47,11 @@ incdir ?= $(prefix)/include
|
||||
$(PRINT) " LINK $(subst $(ROOTDIR)/,,$(shell pwd)/)$@\n"
|
||||
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-Map,$@.map -o $@ $^ $(LDLIBS$(LDLIBS-$(@)))
|
||||
|
||||
.PHONY: %.test
|
||||
%.test: %.c
|
||||
$(PRINT) " TEST $(subst $(ROOTDIR)/,,$(shell pwd)/)$(@:.test=)\n"
|
||||
$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -g -o $@ -DUNITTEST $< $(OBJS)
|
||||
$(Q)@./$@ $(REDIRECT)
|
||||
$(Q)$(SUDO) ./$@ $(REDIRECT)
|
||||
|
||||
|
||||
# Default build rules for both main and unit test makefiles
|
||||
|
||||
Reference in new issue
Block a user