blob: c71e6cc12ee490c51545d9feb52b959639c7e512 [file] [log] [blame]
Will Arthurca8e7f32015-08-03 15:35:19 -04001#;**********************************************************************;
2#
3# Copyright (c) 2015, Intel Corporation
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions are met:
8#
9# 1. Redistributions of source code must retain the above copyright notice,
10# this list of conditions and the following disclaimer.
11#
12# 2. Redistributions in binary form must reproduce the above copyright notice,
13# this list of conditions and the following disclaimer in the documentation
14# and/or other materials provided with the distribution.
15#
16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26# THE POSSIBILITY OF SUCH DAMAGE.
27#;**********************************************************************;
28
Philip Triccae690e082015-09-07 18:17:35 -070029include src_vars.mk
30
Philip Triccaa509a682015-09-14 15:34:52 -070031ACLOCAL_AMFLAGS = -I m4
Philip Tricca391e8892017-02-08 13:15:27 -080032AM_CFLAGS = -I$(srcdir)/include -I$(srcdir)/sysapi/include -I$(srcdir)/log
Philip Triccaa509a682015-09-14 15:34:52 -070033
Philip Tricca2bd4adb2015-09-25 00:14:16 -070034# stuff to build, what that stuff is, and where/if to install said stuff
35sbin_PROGRAMS = $(resourcemgr)
36noinst_PROGRAMS = $(tpmclient) $(tpmtest)
Philip Tricca73609722017-02-10 10:50:06 -080037lib_LTLIBRARIES = $(libmarshal) $(libsapi) $(libtcti_device) $(libtcti_socket)
Philip Triccae72f2572016-12-02 11:26:59 -080038noinst_LTLIBRARIES = test/integration/libtest_utils.la
39check_PROGRAMS = $(TESTS_UNIT) $(TESTS_INTEGRATION)
Philip Tricca4334dee2016-08-09 19:56:28 -070040
Philip Triccab194be92016-03-15 13:27:09 -070041# unit tests
Philip Tricca4334dee2016-08-09 19:56:28 -070042if UNIT
Philip Triccae72f2572016-12-02 11:26:59 -080043TESTS_UNIT = \
Philip Triccae08bdb92016-12-01 15:37:50 -080044 test/unit/CommonPreparePrologue \
45 test/unit/CopyCommandHeader \
46 test/unit/getcommands-malloc-mock \
47 test/unit/GetNumHandles \
48 test/unit/marshal-TPM2B-simple \
Philip Triccae08bdb92016-12-01 15:37:50 -080049 test/unit/tcti-device \
Philip Tricca73609722017-02-10 10:50:06 -080050 test/unit/UINT8-marshal \
Philip Tricca689c0902017-02-03 21:10:53 -080051 test/unit/UINT16-marshal \
Philip Triccabff72122017-02-04 07:53:07 -080052 test/unit/UINT32-marshal \
Philip Tricca935972e2017-02-15 14:49:56 -080053 test/unit/UINT64-marshal
Philip Tricca4334dee2016-08-09 19:56:28 -070054endif #UNIT
55
hp43ac71d2016-12-02 11:16:45 -080056TESTS_INTEGRATION = \
hpab961cb2016-12-03 00:05:07 +080057 test/integration/get-random \
hpb4bebc72016-12-20 18:22:28 +080058 test/integration/self-test \
hp328ae1b2017-01-10 17:16:46 +080059 test/integration/pcr-extension \
60 test/integration/asymmetric-encrypt-decrypt
hp43ac71d2016-12-02 11:16:45 -080061
Philip Triccab194be92016-03-15 13:27:09 -070062TESTS = $(check_PROGRAMS)
Philip Tricca7ae01542016-05-05 18:45:03 -070063CLEANFILES = $(nodist_pkgconfig_DATA)
Philip Tricca7d3515f2015-09-07 10:06:56 -070064
Philip Triccae72f2572016-12-02 11:26:59 -080065AM_TESTS_ENVIRONMENT = \
66 export TPM20TEST_TCTI_NAME="socket"; \
67 export TPM20TEST_SOCKET_ADDRESS="127.0.0.1"; \
68 export TPM20TEST_SOCKET_PORT="2321";
69
Philip Tricca2bd4adb2015-09-25 00:14:16 -070070# headers and where to install them
Philip Triccad69337a2016-05-26 16:16:01 -070071libsapidir = $(includedir)/sapi
72libsapi_HEADERS = $(srcdir)/include/sapi/*.h
Philip Triccac3dedc22016-01-15 13:47:22 -080073libtctidir = $(includedir)/tcti
74libtcti_HEADERS = $(srcdir)/include/tcti/*.h
Philip Tricca73609722017-02-10 10:50:06 -080075
Philip Tricca7ae01542016-05-05 18:45:03 -070076# pkg-config files
77pkgconfigdir = $(libdir)/pkgconfig
Philip Tricca826f5902016-05-26 16:44:31 -070078nodist_pkgconfig_DATA = lib/sapi.pc lib/tcti-device.pc lib/tcti-socket.pc
Philip Tricca2bd4adb2015-09-25 00:14:16 -070079
Philip Tricca4334dee2016-08-09 19:56:28 -070080if UNIT
Philip Triccae08bdb92016-12-01 15:37:50 -080081test_unit_tcti_device_CFLAGS = $(CMOCKA_CFLAGS) -I$(srcdir)/include -I$(srcdir)/sysapi/include
82test_unit_tcti_device_LDADD = $(libsapi) $(libtcti_device) $(CMOCKA_LIBS)
83test_unit_tcti_device_SOURCES = test/unit/tcti-device.c
Philip Triccab194be92016-03-15 13:27:09 -070084
Philip Triccae08bdb92016-12-01 15:37:50 -080085test_unit_getcommands_malloc_mock_CFLAGS = $(CMOCKA_CFLAGS) -I$(srcdir)/include \
Philip Tricca4c1b4a02016-06-21 05:44:51 -070086 -I$(srcdir)/sysapi/include/
Philip Triccae08bdb92016-12-01 15:37:50 -080087test_unit_getcommands_malloc_mock_LDADD = $(CMOCKA_LIBS)
88test_unit_getcommands_malloc_mock_LDFLAGS = -Wl,--wrap=malloc \
Philip Tricca4c1b4a02016-06-21 05:44:51 -070089 -Wl,--wrap=Tss2_Sys_GetCapability
Philip Triccae08bdb92016-12-01 15:37:50 -080090test_unit_getcommands_malloc_mock_SOURCES = \
91 test/unit/getcommands-malloc-mock.c resourcemgr/getcommands.c
Philip Tricca4c1b4a02016-06-21 05:44:51 -070092
Philip Triccae08bdb92016-12-01 15:37:50 -080093test_unit_CommonPreparePrologue_CFLAGS = $(CMOCKA_CFLAGS) -I$(srcdir)/include \
Philip Tricca6f634c42016-07-23 12:32:15 -070094 -I$(srcdir)/include/sapi -I$(srcdir)/sysapi/include/
Philip Triccae08bdb92016-12-01 15:37:50 -080095test_unit_CommonPreparePrologue_LDFLAGS = -Wl,--unresolved-symbols=ignore-all
96test_unit_CommonPreparePrologue_LDADD = $(CMOCKA_LIBS)
97test_unit_CommonPreparePrologue_SOURCES = \
98 test/unit/CommonPreparePrologue.c sysapi/sysapi_util/CommandUtil.c \
Philip Tricca90363cd2016-07-23 15:22:37 -070099 sysapi/sysapi/ContextManagement.c
Philip Tricca6f634c42016-07-23 12:32:15 -0700100
Philip Triccae08bdb92016-12-01 15:37:50 -0800101test_unit_GetNumHandles_CFLAGS = $(CMOCKA_CFLAGS) \
Philip Tricca364c0ce2016-07-23 16:48:37 -0700102 -I$(srcdir)/include -I$(srcdir)/sysapi/include
Philip Triccae08bdb92016-12-01 15:37:50 -0800103test_unit_GetNumHandles_LDADD = $(CMOCKA_LIBS)
104test_unit_GetNumHandles_SOURCES = \
105 test/unit/GetNumHandles.c sysapi/sysapi_util/GetNumHandles.c
Philip Tricca1f3a1fd2016-08-14 11:48:45 -0700106
Philip Triccae08bdb92016-12-01 15:37:50 -0800107test_unit_CopyCommandHeader_CFLAGS = $(CMOCKA_CFLAGS) -I$(srcdir)/include \
Philip Tricca81223f42016-07-28 19:50:08 -0700108 -I$(srcdir)/include/sapi -I$(srcdir)/sysapi/include/
Philip Triccae08bdb92016-12-01 15:37:50 -0800109test_unit_CopyCommandHeader_LDFLAGS = -Wl,--unresolved-symbols=ignore-all
110test_unit_CopyCommandHeader_LDADD = $(CMOCKA_LIBS)
111test_unit_CopyCommandHeader_SOURCES = \
112 test/unit/CopyCommandHeader.c sysapi/sysapi_util/CommandUtil.c \
Philip Tricca81223f42016-07-28 19:50:08 -0700113 sysapi/sysapi/ContextManagement.c sysapi/sysapi_util/changeEndian.c
Philip Triccaf1811f02016-08-28 11:02:31 -0700114
Philip Triccae08bdb92016-12-01 15:37:50 -0800115test_unit_marshal_TPM2B_simple_CFLAGS = $(CMOCKA_CFLAGS) \
Philip Tricca430cda22016-09-01 15:41:53 -0700116 -I$(srcdir)/include -I$(srcdir)/include/sapi -I$(srcdir)/sysapi/include/
Philip Tricca6260ec02017-02-14 15:06:30 -0800117test_unit_marshal_TPM2B_simple_LDADD = $(CMOCKA_LIBS) $(libmarshal)
Philip Triccae08bdb92016-12-01 15:37:50 -0800118test_unit_marshal_TPM2B_simple_SOURCES = \
Philip Tricca430cda22016-09-01 15:41:53 -0700119 sysapi/sysapi_util/changeEndian.c \
Philip Tricca430cda22016-09-01 15:41:53 -0700120 sysapi/sysapi_util/CopySessionData.c \
121 sysapi/sysapi_util/marshal_simple_tpm2b.c \
122 sysapi/sysapi_util/unmarshal_simple_tpm2b.c \
123 sysapi/sysapi_util/unmarshal_simple_tpm2b_no_size_check.c \
Philip Triccae08bdb92016-12-01 15:37:50 -0800124 test/unit/marshal-TPM2B-simple.c
Philip Tricca430cda22016-09-01 15:41:53 -0700125
Philip Tricca73609722017-02-10 10:50:06 -0800126test_unit_UINT8_marshal_CFLAGS = $(CMOCKA_CFLAGS) -I$(srcdir)/include
127test_unit_UINT8_marshal_LDADD = $(CMOCKA_LIBS) $(libmarshal)
128test_unit_UINT8_marshal_SOURCES = test/unit/UINT8-marshal.c
Philip Tricca689c0902017-02-03 21:10:53 -0800129
130test_unit_UINT16_marshal_CFLAGS = $(CMOCKA_CFLAGS) -I$(srcdir)/include
131test_unit_UINT16_marshal_LDADD = $(CMOCKA_LIBS) $(libmarshal)
132test_unit_UINT16_marshal_SOURCES = test/unit/UINT16-marshal.c
Philip Triccabff72122017-02-04 07:53:07 -0800133
134test_unit_UINT32_marshal_CFLAGS = $(CMOCKA_CFLAGS) -I$(srcdir)/include
135test_unit_UINT32_marshal_LDADD = $(CMOCKA_LIBS) $(libmarshal)
136test_unit_UINT32_marshal_SOURCES = test/unit/UINT32-marshal.c
Philip Triccab33eb352017-02-04 09:41:35 -0800137
138test_unit_UINT64_marshal_CFLAGS = $(CMOCKA_CFLAGS) -I$(srcdir)/include
139test_unit_UINT64_marshal_LDADD = $(CMOCKA_LIBS) $(libmarshal)
140test_unit_UINT64_marshal_SOURCES = test/unit/UINT64-marshal.c
Philip Tricca4334dee2016-08-09 19:56:28 -0700141endif # UNIT
Philip Tricca364c0ce2016-07-23 16:48:37 -0700142
Philip Tricca2bd4adb2015-09-25 00:14:16 -0700143# how to build stuff
Philip Triccafe6b8ae2016-04-22 14:17:10 -0700144resourcemgr_resourcemgr_CFLAGS = $(RESOURCEMGR_INC) $(PTHREAD_CFLAGS) $(AM_CFLAGS)
Philip Tricca6260ec02017-02-14 15:06:30 -0800145resourcemgr_resourcemgr_LDADD = $(libsapi) $(libtcti_device) $(libtcti_socket) $(libmarshal)
Philip Tricca00692472015-09-16 13:09:54 -0700146resourcemgr_resourcemgr_LDFLAGS = $(PTHREAD_LDFLAGS)
Philip Tricca66f143a2016-04-17 00:09:06 -0700147resourcemgr_resourcemgr_SOURCES = $(RESOURCEMGR_C) $(COMMON_SRC)
Philip Tricca10d1aa22015-09-07 10:55:58 -0700148
Philip Tricca391e8892017-02-08 13:15:27 -0800149marshal_libmarshal_la_LDFLAGS = $(LIBRARY_LDFLAGS) -Wl,--version-script=$(srcdir)/lib/libmarshal.map
150marshal_libmarshal_la_SOURCES = marshal/base-types.c log/log.c
Philip Tricca73609722017-02-10 10:50:06 -0800151
Philip Triccad69337a2016-05-26 16:16:01 -0700152sysapi_libsapi_la_CFLAGS = -I$(srcdir)/sysapi/include $(AM_CFLAGS)
Philip Tricca391e8892017-02-08 13:15:27 -0800153sysapi_libsapi_la_LIBADD = $(libmarshal)
Philip Triccad69337a2016-05-26 16:16:01 -0700154sysapi_libsapi_la_LDFLAGS = $(LIBRARY_LDFLAGS)
155sysapi_libsapi_la_SOURCES = $(SYSAPI_C) $(SYSAPIUTIL_C)
Philip Tricca7d3515f2015-09-07 10:06:56 -0700156
Philip Tricca826f5902016-05-26 16:44:31 -0700157tcti_libtcti_device_la_CFLAGS = $(TCTIDEVICE_INC) $(AM_CFLAGS)
158tcti_libtcti_device_la_LDFLAGS = $(LIBRARY_LDFLAGS) \
Philip Tricca92fb8a72016-03-31 15:33:57 -0700159 -Wl,--version-script=$(srcdir)/tcti/tcti_device.map
Philip Tricca826f5902016-05-26 16:44:31 -0700160tcti_libtcti_device_la_SOURCES = $(TCTIDEVICE_C) \
Philip Tricca3d486352016-04-18 11:26:25 -0700161 sysapi/sysapi_util/changeEndian.c $(TCTICOMMON_C) common/debug.c
Philip Tricca97e869f2015-11-03 20:19:44 -0500162
Philip Triccab0927df2016-06-21 06:28:44 -0700163tcti_libtcti_socket_la_CFLAGS = $(TCTISOCKET_INC) $(AM_CFLAGS)
Philip Tricca826f5902016-05-26 16:44:31 -0700164tcti_libtcti_socket_la_LDFLAGS = $(LIBRARY_LDFLAGS) \
Philip Tricca92fb8a72016-03-31 15:33:57 -0700165 -Wl,--version-script=$(srcdir)/tcti/tcti_socket.map
Philip Tricca826f5902016-05-26 16:44:31 -0700166tcti_libtcti_socket_la_SOURCES = $(TCTISOCKET_C) \
Philip Tricca56fec892017-02-25 11:31:55 -0800167 sysapi/sysapi_util/changeEndian.c $(TCTICOMMON_C) \
168 common/sockets.c common/debug.c
Philip Triccaa51ca972015-11-04 00:13:42 -0500169
Philip Triccab0927df2016-06-21 06:28:44 -0700170test_tpmclient_tpmclient_CFLAGS = $(TPMCLIENT_INC) $(AM_CFLAGS)
Philip Tricca826f5902016-05-26 16:44:31 -0700171test_tpmclient_tpmclient_LDADD = $(libsapi) $(libtcti_socket) $(libtcti_device)
Philip Tricca56fec892017-02-25 11:31:55 -0800172test_tpmclient_tpmclient_SOURCES = test/tpmclient/tpmclient.c $(COMMON_C) $(SAMPLE_C)
Philip Tricca38de2022015-09-07 11:46:28 -0700173
Philip Triccab0927df2016-06-21 06:28:44 -0700174test_tpmtest_tpmtest_CFLAGS = $(TPMTEST_INC) $(AM_CFLAGS)
Philip Tricca826f5902016-05-26 16:44:31 -0700175test_tpmtest_tpmtest_LDADD = $(libsapi) $(libtcti_socket) $(libtcti_device)
Philip Tricca56fec892017-02-25 11:31:55 -0800176test_tpmtest_tpmtest_SOURCES = test/tpmtest/tpmtest.c $(COMMON_C) $(SAMPLE_C)
Gang Weie9600692015-09-10 14:07:14 +0800177
Philip Triccae72f2572016-12-02 11:26:59 -0800178test_integration_libtest_utils_la_SOURCES = test/integration/test-options.c \
179 test/integration/context-util.c
180
hp43ac71d2016-12-02 11:16:45 -0800181test_integration_get_random_LDADD = $(TESTS_LDADD)
182test_integration_get_random_SOURCES = test/integration/get-random.c \
183 test/integration/main.c
184
hpab961cb2016-12-03 00:05:07 +0800185test_integration_self_test_LDADD = $(TESTS_LDADD)
186test_integration_self_test_SOURCES = test/integration/self-test.c \
187 test/integration/main.c
188
hpb4bebc72016-12-20 18:22:28 +0800189test_integration_pcr_extension_LDADD = $(TESTS_LDADD)
190test_integration_pcr_extension_SOURCES = test/integration/pcr-extension.c \
191 test/integration/main.c
192
hp328ae1b2017-01-10 17:16:46 +0800193test_integration_asymmetric_encrypt_decrypt_LDADD = $(TESTS_LDADD)
194test_integration_asymmetric_encrypt_decrypt_SOURCES = test/integration/asymmetric-encrypt-decrypt.c \
195 test/integration/main.c
196
Philip Triccae72f2572016-12-02 11:26:59 -0800197TESTS_LDADD = $(noinst_LTLIBRARIES) $(lib_LTLIBRARIES)
198
Philip Tricca7ae01542016-05-05 18:45:03 -0700199%.pc : %.pc.in
Philip Triccafdce98d2016-05-23 15:47:16 -0700200 if [ ! -d $(dir $@) ]; then mkdir -p $(dir $@); fi
Philip Tricca7ae01542016-05-05 18:45:03 -0700201 sed -e "s,[@]VERSION[@],$(PACKAGE_VERSION),g; \
202 s,[@]includedir[@],$(includedir),g;" $^ > $@
203
Philip Triccab1a64062016-04-05 15:26:47 -0700204LIBRARY_LDFLAGS = -fPIC -Wl,--no-undefined
Philip Tricca125bb322016-03-31 16:11:51 -0700205
Philip Tricca475a02c2016-12-04 20:36:59 -0800206# simulator build / run scripts
207CLEANFILES += test/simulator-build.sh test/simulator-run.sh test/simulator.inc
208.PHONY = simulator-build simulator-start simulator-stop clean-local-ibmtpm
209clean-local : clean-local-ibmtpm
210clean-local-ibmtpm :
211 rm -rf test/ibmtpm*
212
213test/simulator.inc : $(srcdir)/script/simulator.inc
214 cp $< $@
215test/simulator-build.sh : $(srcdir)/script/simulator-build.sh
216 cp $< $@
217 chmod 755 $@
218simulator-build : test/simulator-build.sh test/simulator.inc
219 test/simulator-build.sh
220test/simulator-run.sh : $(srcdir)/script/simulator-run.sh
221 cp $< $@
222 chmod 755 $@
223simulator-start : test/simulator-run.sh test/simulator.inc
224 test/simulator-run.sh start
225simulator-stop : test/simulator-run.sh test/simulator.inc
226 test/simulator-run.sh stop
227
Philip Tricca2bd4adb2015-09-25 00:14:16 -0700228# simple variables
Philip Triccac3dedc22016-01-15 13:47:22 -0800229RESOURCEMGR_INC = -I$(srcdir)/include -I$(srcdir)/common \
Philip Tricca785e88d2016-02-13 12:02:44 -0800230 -I$(srcdir)/sysapi/include -I$(srcdir)/resourcemgr \
231 -I$(srcdir)/test/tpmclient
Philip Tricca4c1b4a02016-06-21 05:44:51 -0700232RESOURCEMGR_C = resourcemgr/resourcemgr.c resourcemgr/criticalsection_linux.c \
233 resourcemgr/getcommands.c
Philip Tricca10d1aa22015-09-07 10:55:58 -0700234
Philip Tricca785e88d2016-02-13 12:02:44 -0800235TCTICOMMON_INC = -I$(srcdir)/include -I$(srcdir)/common \
236 -I$(srcdir)/sysapi/include
237TCTICOMMON_C = tcti/commonchecks.c
Will-nuc8d4f9672015-11-25 16:48:20 -0500238
Philip Tricca785e88d2016-02-13 12:02:44 -0800239TCTIDEVICE_INC = $(TCTICOMMON_INC)
240TCTIDEVICE_C = tcti/tcti_device.c
Will-nucf2ea1f12015-11-25 16:29:57 -0500241
Philip Tricca785e88d2016-02-13 12:02:44 -0800242TCTISOCKET_INC = $(TCTICOMMON_INC)
Philip Tricca56fec892017-02-25 11:31:55 -0800243TCTISOCKET_C = tcti/platformcommand.c tcti/tcti_socket.c
Philip Tricca97e869f2015-11-03 20:19:44 -0500244
Gang Wei5f0d4e42016-08-17 12:11:22 +0800245TPMCLIENT_INC = -I$(srcdir)/include -I$(srcdir)/common \
246 -I$(srcdir)/test/tpmclient -I$(srcdir)/sysapi/include \
Philip Triccae2c16792016-01-05 12:07:22 -0800247 -I$(srcdir)/test/common/sample -I$(srcdir)/resourcemgr
Philip Triccae690e082015-09-07 18:17:35 -0700248
Gang Wei5f0d4e42016-08-17 12:11:22 +0800249TPMTEST_INC = -I$(srcdir)/include -I$(srcdir)/common \
250 -I$(srcdir)/test/tpmclient -I$(srcdir)/sysapi/include \
Gang Weie9600692015-09-10 14:07:14 +0800251 -I$(srcdir)/test/common/sample -I$(srcdir)/resourcemgr
Philip Tricca2bd4adb2015-09-25 00:14:16 -0700252
Philip Triccad69337a2016-05-26 16:16:01 -0700253libsapi = sysapi/libsapi.la
Philip Tricca826f5902016-05-26 16:44:31 -0700254libtcti_device = tcti/libtcti-device.la
255libtcti_socket = tcti/libtcti-socket.la
Philip Tricca73609722017-02-10 10:50:06 -0800256libmarshal = marshal/libmarshal.la
Philip Tricca2bd4adb2015-09-25 00:14:16 -0700257resourcemgr = resourcemgr/resourcemgr
258tpmclient = test/tpmclient/tpmclient
259tpmtest = test/tpmtest/tpmtest