Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

Commit

Permalink
[LTP] Remove the reference to LibOS/shim/test/Makefile.Test
Browse files Browse the repository at this point in the history
  • Loading branch information
yamahata authored and dimakuv committed Feb 6, 2020
1 parent 37e15af commit bf68bf9
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ltp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exec_target =

clean-extra = clean-build

include ../../Makefile.Test
include Makefile.Test

$(SRCDIR)/Makefile:
$(error "$(SRCDIR) is empty. Please run `git submodule update --init $(SRCDIR)` or download the LTP source code (https://github.com/linux-test-project/ltp) into $(SRCDIR).")
Expand Down
130 changes: 130 additions & 0 deletions ltp/Makefile.Test
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
LTP_DIR := $(dir $(lastword $(MAKEFILE_LIST)))

SYS ?= $(shell gcc -dumpmachine)
export SYS

PALDIR = $(LTP_DIR)/../../../../../Pal/src
SHIMDIR = $(LTP_DIR)/../../../src
RUNTIME = $(LTP_DIR)/../../../../../Runtime

ifeq ($(SGX),1)
PAL_LOADER = pal_loader SGX
else
PAL_LOADER = pal_loader
endif

CC = gcc
CXX = g++
CFLAGS =
CXXFLAGS =
LDFLAGS =

.PHONY: default
default: all

expand_target_to_token = $(foreach t,$(filter-out manifest,$(1)),$(patsubst %.manifest,%,$(t)).token)
ifeq ($(SGX),1)
expand_target = $(1) $(foreach t,$(filter-out manifest,$(1)), \
$(patsubst %.manifest,%,$(t)).manifest.sgx)
else
expand_target = $(1)
endif

.PHONY: all
all: pal_loader $(target) | $(call expand_target,$(exec_target))

.PHONY: sgx-tokens
sgx-tokens: $(call expand_target_to_token,$(exec_target))

ifeq ($(DEBUG),1)
CC += -g
CXX += -g
endif
export DEBUG

ifeq ($(WERROR),1)
CFLAGS += -Werror
endif

ifeq ($(ABSPATH_IN_MANIFEST),yes)
manifest_rules = \
-e 's:\$$(PAL):$(abspath $(RUNTIME))/$(PAL_LOADER):g' \
-e 's:\$$(PWD):$(PWD):g' \
-e 's:\$$(BIN):$(subst .manifest,,$(notdir $@)):g' \
-e 's:\$$(SHIMPATH):$(abspath $(RUNTIME))/libsysdb.so:g' \
-e 's:\$$(LIBCDIR):$(abspath $(RUNTIME)):g' \
$(extra_rules)
else
manifest_rules= \
-e 's:\$$(PAL):$(abspath $(RUNTIME))/$(PAL_LOADER):g' \
-e 's:\$$(PWD):$(PWD):g' \
-e 's:\$$(BIN):$(subst .manifest,,$(notdir $@)):g' \
-e 's:\$$(SHIMPATH):'$$RELDIR'$(RUNTIME)/libsysdb.so:g' \
-e 's:\$$(LIBCDIR):'$$RELDIR'$(RUNTIME):g' \
$(extra_rules)
endif

pal_loader:
ln -sf $(RUNTIME)/pal_loader

relative-to = $(shell python -c "import os.path; print os.path.relpath(\"$(abspath $2)\",\"$(abspath $1)\")")

%.manifest: %.manifest.template
@echo [ $@ ]
RELDIR=$(filter-out ./,$(call relative-to,$(dir $@),$(shell pwd))/) && \
sed $(manifest_rules) $< > $@
(grep -q '^#!' $@ && chmod +x $@) || true

manifest: manifest.template
@echo [ $@ ]
sed $(manifest_rules) $< > $@

ifeq ($(SGX),1)
SGX_DIR = $(PALDIR)/host/Linux-SGX
RUNTIME_DIR = $(RUNTIME)

LIBPAL = $(RUNTIME_DIR)/libpal-Linux-SGX.so
SGX_SIGNER_KEY ?= $(SGX_DIR)/signer/enclave-key.pem
SGX_SIGN = $(SGX_DIR)/signer/pal-sgx-sign -libpal $(LIBPAL) -key $(SGX_SIGNER_KEY)
SGX_GET_TOKEN = $(SGX_DIR)/signer/pal-sgx-get-token

# sgx manifest.sgx/sig/token
drop_manifest_suffix = $(filter-out manifest,$(sort $(patsubst %.manifest,%,$(1))))
expand_target_to_token = $(addsuffix .token,$(call drop_manifest_suffix, $(1)))
expand_target_to_sig = $(addsuffix .sig,$(call drop_manifest_suffix,$(1)))
expand_target_to_sgx = $(addsuffix .manifest.sgx,$(call drop_manifest_suffix,$(1)))

%.token: %.sig
@echo [ $@ ]
@$(SGX_GET_TOKEN) -output $@ -sig $^ > .output.sgx_get_token.$(basename $*)

%.sig %.manifest.sgx: %.manifest % $(LIBPAL) $(SGX_SIGNER_KEY) %.manifest.sgx.d
@echo [ $@ ]
@$(SGX_SIGN) -output $*.manifest.sgx -exec $* -manifest $< > .output.sgx_sign.$*

%.sig %.manifest.sgx: manifest % $(LIBPAL) $(SGX_SIGNER_KEY) %.manifest.sgx.d
@echo [ $@ ]
@$(SGX_SIGN) -output $*.manifest.sgx -exec $* -manifest $< > .output.sgx_sign.$*

%.sig %.manifest.sgx: %.manifest $(LIBPAL) $(SGX_SIGNER_KEY) %.manifest.sgx.d
@echo [ $@ ]
@$(SGX_SIGN) -output $*.manifest.sgx -manifest $< > .output.sgx_sign.$*

.PRECIOUS: %.manifest.sgx.d

%.manifest.sgx.d: %.manifest
@echo [ $@ ]
@$(SGX_SIGN) -depend -output $@ -exec $* -manifest $<

%.manifest.sgx.d: manifest
@echo [ $@ ]
@$(SGX_SIGN) -depend -output $@ -manifest $<

ifeq ($(filter clean,$(MAKECMDGOALS)),)
include $(addsuffix .manifest.sgx.d,$(call drop_manifest_suffix,$(exec_target)))
endif
endif

.PHONY: clean
clean: $(clean-extra)
rm -rf pal_loader $(exec_target) *.token *.sig *.manifest.sgx $(target) $(wildcard *.d) .output.*
2 changes: 1 addition & 1 deletion ltp/Makefile.testcases
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ testcases = $(shell cd $(ROOTDIR); \
exec_target = $(testcases)
target = $(manifests) $(testcases) etc/nsswitch.conf etc/passwd

include $(ROOTDIR)/../../Makefile.Test
include $(ROOTDIR)/Makefile.Test

$(addsuffix .template,$(manifests)): %: ../../../../%
ln -sf $< $@
Expand Down

0 comments on commit bf68bf9

Please sign in to comment.