blob: bb5b91c3a2448cc9c64998850d43c4e3045002bf [file] [log] [blame]
Randall Spanglere8cfa312013-01-02 16:49:38 -08001# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
Gaurav Shah322536d2010-01-28 15:01:23 -08002# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
Simon Glass6d696e52011-11-14 13:46:33 -08005# This Makefile normally builds in a 'build' subdir, but use
6#
7# make BUILD=<dir>
8#
Bill Richardsoneecc18f2013-01-17 15:28:17 -08009# to put the output somewhere else.
10
11##############################################################################
12# Make variables come in two flavors, immediate or deferred.
13#
14# Variable definitions are parsed like this:
15#
16# IMMEDIATE = DEFERRED
17# or
18# IMMEDIATE := IMMEDIATE
19#
20# Rules are parsed this way:
21#
22# IMMEDIATE : IMMEDIATE
23# DEFERRED
24#
25# So you can assign variables in any order if they're only to be used in
26# actions, but if you use a variable in either the target or prerequisite of a
27# rule, the rule will be constructed using only the top-down, immediate value.
28#
29# So we'll try to define all the variables first. Then the rules.
30#
31
32##############################################################################
33# Configuration variables come first.
34#
35# Our convention is that we only use := for variables that will never be
36# changed or appended. They must be defined before being used anywhere.
37
38# we should only run pwd once, not every time we refer to ${BUILD}.
Randall Spanglere061a252013-01-22 15:34:07 -080039SRCDIR := $(shell pwd)
40BUILD ?= $(SRCDIR)/build
Randall Spangler844bce52013-01-15 16:16:43 -080041export BUILD
Simon Glass6d696e52011-11-14 13:46:33 -080042
Randall Spangler5d9bbf22013-01-08 10:44:23 -080043# Target for 'make install'
44DESTDIR ?= /usr/bin
Bill Richardson826db092013-01-14 12:37:15 -080045INSTALL ?= install
Randall Spangler5d9bbf22013-01-08 10:44:23 -080046
Bill Richardsoneecc18f2013-01-17 15:28:17 -080047# Where to install the (exportable) executables for testing?
48TEST_INSTALL_DIR = ${BUILD}/install_for_test
49
50# Verbose? Use V=1
51ifeq (${V},)
52Q := @
53endif
54
Simon Glassb265c342011-11-16 15:09:51 -080055# Provide default CC and CFLAGS for firmware builds; if you have any -D flags,
56# please add them after this point (e.g., -DVBOOT_DEBUG).
Che-Liang Chiou74359b72011-06-21 15:25:51 -070057#
Che-Liang Chiou6b0003c2011-10-14 11:11:28 +080058# TODO(crosbug.com/16808) We hard-code u-boot's compiler flags here just
59# temporarily. As we are still investigating which flags are necessary for
60# maintaining a compatible ABI, etc. between u-boot and vboot_reference.
Che-Liang Chiou74359b72011-06-21 15:25:51 -070061#
Simon Glassb265c342011-11-16 15:09:51 -080062# As a first step, this makes the setting of CC and CFLAGS here optional, to
63# permit a calling script or Makefile to set these.
Che-Liang Chiou74359b72011-06-21 15:25:51 -070064#
Simon Glassb265c342011-11-16 15:09:51 -080065# Flag ordering: arch, then -f, then -m, then -W
66DEBUG_FLAGS := $(if ${DEBUG},-g -O0,-Os)
67COMMON_FLAGS := -nostdinc -pipe \
68 -ffreestanding -fno-builtin -fno-stack-protector \
Bill Richardsoneecc18f2013-01-17 15:28:17 -080069 -Werror -Wall -Wstrict-prototypes ${DEBUG_FLAGS}
Simon Glassb265c342011-11-16 15:09:51 -080070
Bill Richardsoneecc18f2013-01-17 15:28:17 -080071# Note: FIRMWARE_ARCH is defined by the Chromium OS ebuild.
72ifeq (${FIRMWARE_ARCH}, arm)
Simon Glassb265c342011-11-16 15:09:51 -080073CC ?= armv7a-cros-linux-gnueabi-gcc
74CFLAGS ?= -march=armv5 \
75 -fno-common -ffixed-r8 \
Doug Andersond50b27d2012-05-11 12:08:02 -070076 -mfloat-abi=hard -marm -mabi=aapcs-linux -mno-thumb-interwork \
Bill Richardsoneecc18f2013-01-17 15:28:17 -080077 ${COMMON_FLAGS}
78else ifeq (${FIRMWARE_ARCH}, i386)
Simon Glassb265c342011-11-16 15:09:51 -080079CC ?= i686-pc-linux-gnu-gcc
80# Drop -march=i386 to permit use of SSE instructions
81CFLAGS ?= \
82 -ffunction-sections -fvisibility=hidden -fno-strict-aliasing \
83 -fomit-frame-pointer -fno-toplevel-reorder -fno-dwarf2-cfi-asm \
84 -mpreferred-stack-boundary=2 -mregparm=3 \
Bill Richardsoneecc18f2013-01-17 15:28:17 -080085 ${COMMON_FLAGS}
86else ifeq (${FIRMWARE_ARCH}, x86_64)
87CFLAGS ?= ${COMMON_FLAGS} \
Simon Glass8e85e982011-11-22 13:54:50 -080088 -fvisibility=hidden -fno-strict-aliasing -fomit-frame-pointer
Randall Spangler844bce52013-01-15 16:16:43 -080089else
Bill Richardsoneecc18f2013-01-17 15:28:17 -080090# FIRMWARE_ARCH not defined; assuming local compile.
Randall Spangler5d9bbf22013-01-08 10:44:23 -080091CC ?= gcc
Bill Richardsoneecc18f2013-01-17 15:28:17 -080092CFLAGS += -DCHROMEOS_ENVIRONMENT -Wall -Werror # HEY: always want last two?
Che-Liang Chiou34be8272011-01-27 16:44:36 +080093endif
94
95ifneq (${DEBUG},)
96CFLAGS += -DVBOOT_DEBUG
vbendebb2b0fcc2010-07-15 15:09:47 -070097endif
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +080098
vbendebb2b0fcc2010-07-15 15:09:47 -070099ifeq (${DISABLE_NDEBUG},)
100CFLAGS += -DNDEBUG
101endif
102
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800103# Create / use dependency files
104CFLAGS += -MMD -MF $@.d
Simon Glassb265c342011-11-16 15:09:51 -0800105
Randall Spangler59d75082013-01-23 09:29:54 -0800106# Code coverage
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800107ifneq (${COV},)
Randall Spangler59d75082013-01-23 09:29:54 -0800108 COV_FLAGS = -O0 --coverage
109 CFLAGS += ${COV_FLAGS}
110 LDFLAGS += ${COV_FLAGS}
111 COV_INFO = ${BUILD}/coverage.info
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800112endif
Gaurav Shah322536d2010-01-28 15:01:23 -0800113
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800114# And a few more default utilities
115LD = ${CC}
116CXX ?= g++ # HEY: really?
117PKG_CONFIG ?= pkg-config
118
119# Architecture detection. If we're cross-compiling, we may need to run unit
120# tests inside QEMU.
121_machname := $(shell uname -m)
122HOST_ARCH ?= ${_machname}
123
124# Note: ARCH is defined by the Chromium OS ebuild. Pick a sane target
125# architecture if none is defined.
126ifeq (${ARCH},)
127 ARCH := ${HOST_ARCH}
128 ifeq (${ARCH}, x86_64)
129 ARCH := amd64
130 endif
131endif
132
133# Determine QEMU architecture needed, if any
134ifeq (${ARCH},${HOST_ARCH})
135 # Same architecture; no need for QEMU
136 QEMU_ARCH :=
137else ifeq (${HOST_ARCH}-${ARCH},x86_64-i386)
138 # 64-bit host can run 32-bit targets directly
139 QEMU_ARCH :=
140else ifeq (${HOST_ARCH}-${ARCH},x86_64-amd64)
141 # 64-bit host can run 64-bit directly
142 QEMU_ARCH :=
143else ifeq (${ARCH},amd64)
144 QEMU_ARCH := x86_64
145else
146 QEMU_ARCH := ${ARCH}
147endif
148
149# The top of the chroot for qemu must be passed in via the SYSROOT environment
150# variable. In the Chromium OS chroot, this is done automatically by the
151# ebuild.
152
153ifeq (${QEMU_ARCH},)
154 # Path to build output for running tests is same as for building
155 BUILD_RUN = ${BUILD}
Randall Spanglere061a252013-01-22 15:34:07 -0800156 SRC_RUN = ${SRCDIR}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800157else
158 $(info Using qemu for testing.)
159 # Path to build output for running tests is different in the chroot
160 BUILD_RUN = $(subst ${SYSROOT},,${BUILD})
Randall Spanglere061a252013-01-22 15:34:07 -0800161 SRC_RUN = $(subst ${SYSROOT},,${SRCDIR})
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800162
163 QEMU_BIN = qemu-${QEMU_ARCH}
Randall Spanglere061a252013-01-22 15:34:07 -0800164 QEMU_RUN = ${BUILD_RUN}/${QEMU_BIN}
165 export QEMU_RUN
166
167 RUNTEST = tests/test_using_qemu.sh
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800168endif
169
Randall Spanglere061a252013-01-22 15:34:07 -0800170export BUILD_RUN
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800171
172# Some things only compile inside the Chromium OS chroot.
173# TODO: Those things should be in their own repo, not part of vboot_reference
174# TODO: Is there a better way to detect this?
175ifneq (${CROS_WORKON_SRCROOT},)
176IN_CHROOT := yes
177endif
178
179# TODO: Move to separate repo.
180ifneq (${IN_CHROOT},)
181PC_BASE_VER ?= 125070
182PC_DEPS := libchrome-${PC_BASE_VER}
183PC_CFLAGS := $(shell ${PKG_CONFIG} --cflags ${PC_DEPS})
184PC_LDLIBS := $(shell ${PKG_CONFIG} --libs ${PC_DEPS})
185endif
186
187
188##############################################################################
189# Now we need to describe everything we might want or need to build
190
191# TODO: This should go in its own repo.
192AU_CGPTLIB = ${BUILD}/cgpt/libcgpt-cc.a
193# This is just ... Gah. There's no good place for it.
194DUMPKERNELCONFIGLIB = ${BUILD}/libdump_kernel_config.a
195
196# Everything wants these headers.
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800197INCLUDES += \
198 -Ifirmware/include \
199 -Ifirmware/lib/include \
200 -Ifirmware/lib/cgptlib/include \
201 -Ifirmware/lib/cryptolib/include \
202 -Ifirmware/lib/tpm_lite/include
Bill Richardson0b8f35c2010-05-26 09:18:38 -0700203
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800204# If we're not building for a specific target, just stub out things like the
205# TPM commands and various external functions that are provided by the BIOS.
206ifeq (${FIRMWARE_ARCH},)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800207INCLUDES += -Ifirmware/stub/include
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800208else
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800209INCLUDES += -Ifirmware/arch/${FIRMWARE_ARCH}/include
Che-Liang Chiou0a0e8d02010-11-30 09:30:45 +0800210endif
Gaurav Shah322536d2010-01-28 15:01:23 -0800211
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800212# Firmware library. TODO: Do we still need to export this?
213FWLIB = ${BUILD}/vboot_fw.a
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800214
215# find lib -iname '*.c' | sort
216FWLIB_SRCS = \
217 firmware/lib/cgptlib/cgptlib.c \
218 firmware/lib/cgptlib/cgptlib_internal.c \
219 firmware/lib/cgptlib/crc32.c \
220 firmware/lib/crc8.c \
221 firmware/lib/cryptolib/padding.c \
222 firmware/lib/cryptolib/rsa.c \
223 firmware/lib/cryptolib/rsa_utility.c \
224 firmware/lib/cryptolib/sha1.c \
225 firmware/lib/cryptolib/sha256.c \
226 firmware/lib/cryptolib/sha512.c \
227 firmware/lib/cryptolib/sha_utility.c \
228 firmware/lib/stateful_util.c \
229 firmware/lib/utility.c \
230 firmware/lib/utility_string.c \
231 firmware/lib/vboot_api_init.c \
232 firmware/lib/vboot_api_firmware.c \
233 firmware/lib/vboot_api_kernel.c \
234 firmware/lib/vboot_audio.c \
235 firmware/lib/vboot_common.c \
236 firmware/lib/vboot_display.c \
237 firmware/lib/vboot_firmware.c \
238 firmware/lib/vboot_kernel.c \
239 firmware/lib/vboot_nvstorage.c
240
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800241# Support real TPM unless BIOS sets MOCK_TPM
242ifeq (${MOCK_TPM},)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800243FWLIB_SRCS += \
244 firmware/lib/rollback_index.c \
245 firmware/lib/tpm_bootmode.c \
246 firmware/lib/tpm_lite/tlcl.c
247else
248FWLIB_SRCS += \
249 firmware/lib/mocked_rollback_index.c \
250 firmware/lib/mocked_tpm_bootmode.c \
251 firmware/lib/tpm_lite/mocked_tlcl.c
252endif
253
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800254ifeq (${FIRMWARE_ARCH},)
255# Include BIOS stubs in the firmware library when compiling for host
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800256FWLIB_SRCS += \
257 firmware/stub/tpm_lite_stub.c \
258 firmware/stub/utility_stub.c \
259 firmware/stub/vboot_api_stub.c \
260 firmware/stub/vboot_api_stub_disk.c
261endif
262
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800263FWLIB_OBJS = ${FWLIB_SRCS:%.c=${BUILD}/%.o}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800264ALL_OBJS += ${FWLIB_OBJS}
265
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800266
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800267# Library to build the utilities. "HOST" mostly means "userspace".
268HOSTLIB = ${BUILD}/vboot_host.a
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800269
270HOSTLIB_SRCS = \
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800271 host/arch/${ARCH}/lib/crossystem_arch.c \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800272 host/lib/crossystem.c \
273 host/lib/file_keys.c \
274 host/lib/fmap.c \
275 host/lib/host_common.c \
276 host/lib/host_key.c \
277 host/lib/host_keyblock.c \
278 host/lib/host_misc.c \
279 host/lib/host_signature.c \
280 host/lib/signature_digest.c
281
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800282HOSTLIB_OBJS = ${HOSTLIB_SRCS:%.c=${BUILD}/%.o}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800283ALL_OBJS += ${HOSTLIB_OBJS}
284
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800285
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800286# Link with hostlib by default
287LIBS = $(HOSTLIB)
288
289# Might need this too.
290CRYPTO_LIBS := $(shell ${PKG_CONFIG} --libs libcrypto)
291
292
293# ----------------------------------------------------------------------------
294# Now for the userspace binaries
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800295
296CGPT = ${BUILD}/cgpt/cgpt
297
298CGPT_SRCS = \
299 cgpt/cgpt.c \
300 cgpt/cgpt_add.c \
301 cgpt/cgpt_boot.c \
302 cgpt/cgpt_common.c \
303 cgpt/cgpt_create.c \
304 cgpt/cgpt_find.c \
305 cgpt/cgpt_legacy.c \
306 cgpt/cgpt_prioritize.c \
307 cgpt/cgpt_repair.c \
308 cgpt/cgpt_show.c \
309 cgpt/cmd_add.c \
310 cgpt/cmd_boot.c \
311 cgpt/cmd_create.c \
312 cgpt/cmd_find.c \
313 cgpt/cmd_legacy.c \
314 cgpt/cmd_prioritize.c \
315 cgpt/cmd_repair.c \
316 cgpt/cmd_show.c
317
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800318CGPT_OBJS = ${CGPT_SRCS:%.c=${BUILD}/%.o}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800319ALL_OBJS += ${CGPT_OBJS}
320
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800321C_DESTDIR = ${DESTDIR}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800322
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800323
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800324# Scripts to install directly (not compiled)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800325UTIL_SCRIPTS = \
326 utility/dev_debug_vboot \
327 utility/dev_make_keypair \
328 utility/enable_dev_usb_boot \
329 utility/vbutil_what_keys
330
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800331# These utilities should be linked statically.
332UTIL_NAMES_STATIC = \
333 crossystem \
334 dump_fmap \
335 gbb_utility
336
337UTIL_NAMES = ${UTIL_NAMES_STATIC} \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800338 dev_sign_file \
339 dump_kernel_config \
340 dumpRSAPublicKey \
341 load_kernel_test \
342 pad_digest_utility \
343 signature_digest_utility \
344 tpm_init_temp_fix \
345 tpmc \
346 vbutil_ec \
347 vbutil_firmware \
348 vbutil_kernel \
349 vbutil_key \
350 vbutil_keyblock \
351 verify_data
352
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800353ifneq (${IN_CHROOT},)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800354UTIL_NAMES += mount-encrypted
355endif
356
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800357ifeq (${MINIMAL},)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800358UTIL_NAMES += \
359 bmpblk_font \
360 bmpblk_utility \
361 eficompress \
362 efidecompress
363endif
364
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800365UTIL_BINS_STATIC := $(addprefix ${BUILD}/utility/,${UTIL_NAMES_STATIC})
366UTIL_BINS = $(addprefix ${BUILD}/utility/,${UTIL_NAMES})
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800367ALL_DEPS += $(addsuffix .d,${UTIL_BINS})
368
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800369U_DESTDIR = ${DESTDIR}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800370
Bill Richardson826db092013-01-14 12:37:15 -0800371
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800372# The unified firmware utility will eventually replace all the others
373FUTIL_BIN = ${BUILD}/futility/futility
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800374
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800375FUTIL_SRCS = \
376 futility/IGNOREME.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800377
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800378FUTIL_LDS = futility/futility.lds
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800379
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800380FUTIL_OBJS = ${FUTIL_SRCS:%.c=${BUILD}/%.o}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800381
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800382ALL_DEPS += $(addsuffix .d,${FUTIL_BIN})
383ALL_OBJS += ${FUTIL_OBJS}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800384
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800385F_DESTDIR = ${DESTDIR}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800386
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800387
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800388# Library of handy test functions.
389TESTLIB = ${BUILD}/tests/test.a
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800390
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800391TESTLIB_SRCS = \
392 tests/test_common.c \
393 tests/timer_utils.c \
394 tests/crc32_test.c
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800395
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800396TESTLIB_OBJS = ${TESTLIB_SRCS:%.c=${BUILD}/%.o}
397ALL_OBJS += ${TESTLIB_OBJS}
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800398
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800399
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800400# And some compiled tests.
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800401TEST_NAMES = \
402 cgptlib_test \
403 rollback_index2_tests \
404 rsa_padding_test \
405 rsa_utility_tests \
406 rsa_verify_benchmark \
407 sha_benchmark \
408 sha_tests \
409 stateful_util_tests \
410 tpm_bootmode_tests \
411 utility_string_tests \
412 utility_tests \
413 vboot_nvstorage_test \
414 vboot_api_init_tests \
415 vboot_api_devmode_tests \
416 vboot_api_firmware_tests \
417 vboot_api_kernel_tests \
418 vboot_audio_tests \
419 vboot_common_tests \
420 vboot_common2_tests \
421 vboot_common3_tests \
422 vboot_ec_tests \
423 vboot_firmware_tests
424
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800425# Grrr
426ifneq (${IN_CHROOT},)
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800427TEST_NAMES += CgptManagerTests
428endif
429
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800430# TODO: port these tests to new API, if not already eqivalent
431# functionality in other tests. These don't even compile at present.
432#
433# big_firmware_tests
434# big_kernel_tests
435# firmware_image_tests
436# firmware_rollback_tests
437# firmware_splicing_tests
438# firmware_verify_benchmark
439# kernel_image_tests
440# kernel_rollback_tests
441# kernel_splicing_tests
442# kernel_verify_benchmark
443# rollback_index_test
444# verify_firmware_fuzz_driver
445# verify_kernel_fuzz_driver
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800446# utility/load_firmware_test
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800447
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800448# And a few more...
449TLCL_TESTS = \
450 tpmtest_earlyextend \
451 tpmtest_earlynvram \
452 tpmtest_earlynvram2 \
453 tpmtest_enable \
454 tpmtest_fastenable \
455 tpmtest_globallock \
456 tpmtest_redefine_unowned \
457 tpmtest_spaceperm \
458 tpmtest_testsetup \
459 tpmtest_timing \
460 tpmtest_writelimit
461TLCL_TEST_NAMES = $(addprefix tpm_lite/,${TLCL_TESTS})
462TLCL_TEST_BINS = $(addprefix ${BUILD}/tests/,${TLCL_TEST_NAMES})
463
464TEST_NAMES += ${TLCL_TEST_NAMES}
465
466TEST_BINS = $(addprefix ${BUILD}/tests/,${TEST_NAMES})
467ALL_DEPS += $(addsuffix .d,${TEST_BINS})
468
Randall Spanglere061a252013-01-22 15:34:07 -0800469# Directory containing test keys
470TEST_KEYS = ${SRC_RUN}/tests/testkeys
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800471
472# ----------------------------------------------------------------------------
473# TODO: why not make this include *all* the cgpt files, and simply have
474# cgpt link against it?
475# TODO: CgptManager.cc should move to the installer project. Shouldn't be
476# in libcgpt-cc.a.
477AU_CGPTLIB_SRCS = \
478 cgpt/CgptManager.cc \
479 cgpt/cgpt_create.c \
480 cgpt/cgpt_add.c \
481 cgpt/cgpt_boot.c \
482 cgpt/cgpt_show.c \
483 cgpt/cgpt_repair.c \
484 cgpt/cgpt_prioritize.c \
485 cgpt/cgpt_common.c \
486 firmware/lib/cgptlib/crc32.c \
487 firmware/lib/cgptlib/cgptlib_internal.c \
488 firmware/stub/utility_stub.c
489
490AU_CGPTLIB_OBJS = $(filter %.o, \
491 ${AU_CGPTLIB_SRCS:%.c=${BUILD}/%.o} \
492 ${AU_CGPTLIB_SRCS:%.cc=${BUILD}/%.o})
493ALL_OBJS += ${AU_CGPTLIB_OBJS}
494
495
496##############################################################################
497# Finally, some targets. High-level ones first.
498
499# Create output directories if necessary. Do this via explicit shell commands
500# so it happens before trying to generate/include dependencies.
501SUBDIRS := firmware host cgpt utility futility tests tests/tpm_lite
502_dir_create := $(foreach d, \
503 $(shell find ${SUBDIRS} -name '*.c' -exec dirname {} \; | sort -u), \
504 $(shell [ -d ${BUILD}/${d} ] || mkdir -p ${BUILD}/${d}))
505
506
507# Default target.
508.PHONY: all
Randall Spangler59d75082013-01-23 09:29:54 -0800509all: fwlib $(if ${FIRMWARE_ARCH},,host_stuff) $(if ${COV},coverage)
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800510
511# Host targets
512.PHONY: host_stuff
513host_stuff: hostlib cgpt utils futil tests
514
515# AU targets
516.PHONY: au_stuff
517au_stuff: libcgpt_cc libdump_kernel_config cgptmanager_tests
518
519.PHONY: clean
520clean:
521 ${Q}/bin/rm -rf ${BUILD}
522
523.PHONY: install
524install: cgpt_install utils_install futil_install
525
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800526# Don't delete intermediate object files
527.SECONDARY:
528
529# TODO: I suspect this is missing some object files. Make a temp
530# target which cleans all known obj/exe's and see what's left; those
531# are the files which need deps.
532ALL_DEPS += ${ALL_OBJS:%.o=%.o.d}
533-include ${ALL_DEPS}
534
535# ----------------------------------------------------------------------------
536# Firmware library
537
538# TPM-specific flags. These depend on the particular TPM we're targeting for.
539# They are needed here only for compiling parts of the firmware code into
540# user-level tests.
541
542# TPM_BLOCKING_CONTINUESELFTEST is defined if TPM_ContinueSelfTest blocks until
543# the self test has completed.
544
545${FWLIB}: CFLAGS += -DTPM_BLOCKING_CONTINUESELFTEST
546
547# TPM_MANUAL_SELFTEST is defined if the self test must be started manually
548# (with a call to TPM_ContinueSelfTest) instead of starting automatically at
549# power on.
550#
551# We sincerely hope that TPM_BLOCKING_CONTINUESELFTEST and TPM_MANUAL_SELFTEST
552# are not both defined at the same time. (See comment in code.)
553
554# CFLAGS += -DTPM_MANUAL_SELFTEST
555
556ifeq (${FIRMWARE_ARCH},i386)
557# Unrolling loops in cryptolib makes it faster
558${FWLIB}: CFLAGS += -DUNROLL_LOOPS
559
560# Workaround for coreboot on x86, which will power off asynchronously
561# without giving us a chance to react. This is not an example of the Right
562# Way to do things. See chrome-os-partner:7689, and the commit message
563# that made this change.
564${FWLIB}: CFLAGS += -DSAVE_LOCALE_IMMEDIATELY
565
566# On x86 we don't actually read the GBB data into RAM until it is needed.
567# Therefore it makes sense to cache it rather than reading it each time.
568# Enable this feature.
569${FWLIB}: CFLAGS += -DCOPY_BMP_DATA
570endif
571
572ifeq (${FIRMWARE_ARCH},)
573# Disable rollback TPM when compiling locally, since otherwise
574# load_kernel_test attempts to talk to the TPM.
575${FWLIB}: CFLAGS += -DDISABLE_ROLLBACK_TPM
576endif
577
578.PHONY: fwlib
579fwlib: ${FWLIB} $(if ${FIRMWARE_ARCH},,${BUILD}/firmware/linktest/main)
580
581${FWLIB}: ${FWLIB_OBJS}
582 @printf " RM $(subst ${BUILD}/,,$@)\n"
583 ${Q}rm -f $@
584 @printf " AR $(subst ${BUILD}/,,$@)\n"
585 ${Q}ar qc $@ $^
586
587# ----------------------------------------------------------------------------
588# Host library
589
590.PHONY: hostlib
591hostlib: ${HOSTLIB} ${BUILD}/host/linktest/main
592
593${BUILD}/host/% ${HOSTLIB}: INCLUDES += \
594 -Ihost/include\
595 -Ihost/arch/${ARCH}/include
596
597# TODO: better way to make .a than duplicating this recipe each time?
598${HOSTLIB}: ${HOSTLIB_OBJS} ${FWLIB_OBJS}
599 @printf " RM $(subst ${BUILD}/,,$@)\n"
600 ${Q}rm -f $@
601 @printf " AR $(subst ${BUILD}/,,$@)\n"
602 ${Q}ar qc $@ $^
603
604# ----------------------------------------------------------------------------
605# CGPT library and utility
606
607.PHONY: cgpt
608cgpt: ${CGPT}
609
610${CGPT}: LDFLAGS += -static
611${CGPT}: LDLIBS += -luuid
612
613${CGPT}: ${CGPT_OBJS} ${LIBS}
614 @printf " LDcgpt $(subst ${BUILD}/,,$@)\n"
615 ${Q}${LD} -o ${CGPT} ${CFLAGS} $^ ${LDFLAGS} ${LDLIBS}
616
617.PHONY: cgpt_install
618cgpt_install: ${CGPT}
619 @printf " INSTALL CGPT\n"
620 ${Q}mkdir -p ${C_DESTDIR}
621 ${Q}${INSTALL} -t ${C_DESTDIR} $^
622
623# ----------------------------------------------------------------------------
624# Utilities
625
626# These have their own headers too.
627${BUILD}/utility/%: INCLUDES += -Ihost/include -Iutility/include
628
629# Utilities for auto-update toolkits must be statically linked.
630${UTIL_BINS_STATIC}: LDFLAGS += -static
631
632.PHONY: utils
633utils: ${UTIL_BINS} ${UTIL_SCRIPTS}
634# TODO: change ebuild to pull scripts directly out of utility dir
635 ${Q}cp -f ${UTIL_SCRIPTS} ${BUILD}/utility
636 ${Q}chmod a+rx $(patsubst %,${BUILD}/%,${UTIL_SCRIPTS})
637
638.PHONY: utils_install
639utils_install: ${UTIL_BINS} ${UTIL_SCRIPTS}
640 @printf " INSTALL UTILS\n"
641 ${Q}mkdir -p ${U_DESTDIR}
642 ${Q}${INSTALL} -t ${U_DESTDIR} $^
643
644# ----------------------------------------------------------------------------
645# new Firmware Utility
646
647.PHONY: futil
648futil: ${FUTIL_BIN}
649
650${FUTIL_BIN}: ${FUTIL_LDS} ${FUTIL_OBJS}
651 @printf " LD $(subst ${BUILD}/,,$@)\n"
652 ${Q}${LD} -o $@ ${CFLAGS} $^ ${LDFLAGS} ${LDLIBS}
653
654.PHONY: futil_install
655futil_install: ${FUTIL_BIN}
656 @printf " INSTALL futility\n"
657 ${Q}mkdir -p ${F_DESTDIR}
658 ${Q}${INSTALL} -t ${F_DESTDIR} $^
659
660
661# ----------------------------------------------------------------------------
662# Mount-encrypted utility for cryptohome
663
664# TODO: mount-encrypted should move to cryptohome and just link against
665# vboot-host.a for tlcl and crossystem.
666
667# The embedded libcrypto conflicts with the shipped openssl,
668# so mount-* builds without the common CFLAGS (and those includes).
669
670${BUILD}/utility/mount-helpers.o: \
671 utility/mount-helpers.c \
672 utility/mount-helpers.h \
673 utility/mount-encrypted.h
674 @printf " CCm-e $(subst ${BUILD}/,,$@)\n"
675 ${Q}${CC} -Wall -Werror -O2 -D_FORTIFY_SOURCE=2 -fstack-protector \
676 ${COV_FLAGS} \
677 $(shell ${PKG_CONFIG} --cflags glib-2.0 openssl) \
678 -c $< -o $@
679
680${BUILD}/utility/mount-encrypted: \
681 utility/mount-encrypted.c \
682 utility/mount-encrypted.h \
683 ${BUILD}/utility/mount-helpers.o ${LIBS}
684 @printf " CCm-exe $(subst ${BUILD}/,,$@)\n"
685 ${Q}${CC} -Wall -Werror -O2 -D_FORTIFY_SOURCE=2 -fstack-protector \
686 $(shell ${PKG_CONFIG} --cflags glib-2.0 openssl) \
687 -Ifirmware/include \
688 -Ihost/include \
689 ${COV_FLAGS} \
690 ${LDFLAGS} \
691 $< -o $@ \
692 ${BUILD}/utility/mount-helpers.o ${LIBS} \
693 $(shell ${PKG_CONFIG} --libs glib-2.0 openssl) \
694 -lm
695ifneq (${COV},)
696 ${Q}mv -f mount-encrypted.gcno ${BUILD}/utility
697endif
698
699# ----------------------------------------------------------------------------
700# Utility to generate TLCL structure definition header file.
701
702${BUILD}/utility/tlcl_generator: CFLAGS += -fpack-struct
703
704STRUCTURES_TMP=${BUILD}/tlcl_structures.tmp
705STRUCTURES_SRC=firmware/lib/tpm_lite/include/tlcl_structures.h
706
707.PHONY: update_tlcl_structures
708update_tlcl_structures: ${BUILD}/utility/tlcl_generator
709 @printf " Rebuilding TLCL structures\n"
710 ${Q}${BUILD}/utility/tlcl_generator > ${STRUCTURES_TMP}
711 ${Q}cmp -s ${STRUCTURES_TMP} ${STRUCTURES_SRC} || \
712 ( echo "%% Updating structures.h %%" && \
713 cp ${STRUCTURES_TMP} ${STRUCTURES_SRC} )
714
715# ----------------------------------------------------------------------------
716# Library to dump kernel config
717# Used by platform/installer, as well as standalone utility.
718
719.PHONY: libdump_kernel_config
720libdump_kernel_config: ${DUMPKERNELCONFIGLIB}
721
722${DUMPKERNELCONFIGLIB}: ${BUILD}/utility/dump_kernel_config_lib.o
723 @printf " RM $(subst ${BUILD}/,,$@)\n"
724 ${Q}rm -f $@
725 @printf " AR $(subst ${BUILD}/,,$@)\n"
726 ${Q}ar qc $@ $^
727
728# ----------------------------------------------------------------------------
729# And this thing.
730
731.PHONY: libcgpt_cc
732libcgpt_cc: ${AU_CGPTLIB}
733
734${AU_CGPTLIB}: INCLUDES += -Ifirmware/lib/cgptlib/include
735${AU_CGPTLIB}: ${AU_CGPTLIB_OBJS}
736 @printf " RM $(subst ${BUILD}/,,$@)\n"
737 ${Q}rm -f $@
738 @printf " AR $(subst ${BUILD}/,,$@)\n"
739 ${Q}ar qc $@ $^
740
741# ----------------------------------------------------------------------------
742# Tests
743
744.PHONY: tests
745tests: ${TEST_BINS}
746
747${TEST_BINS}: ${TESTLIB}
748
749${TESTLIB}: ${TESTLIB_OBJS}
750 @printf " RM $(subst ${BUILD}/,,$@)\n"
751 ${Q}rm -f $@
752 @printf " AR $(subst ${BUILD}/,,$@)\n"
753 ${Q}ar qc $@ $^
754
755
756# ----------------------------------------------------------------------------
757# Generic build rules. LIBS and OBJS can be overridden to tweak the generic
758# rules for specific targets.
759
760${BUILD}/%: ${BUILD}/%.o ${OBJS} ${LIBS}
761 @printf " LD $(subst ${BUILD}/,,$@)\n"
762 ${Q}${LD} -o $@ ${CFLAGS} $< ${OBJS} ${LIBS} ${LDFLAGS} ${LDLIBS}
763
764${BUILD}/%.o: %.c
765 @printf " CC $(subst ${BUILD}/,,$@)\n"
766 ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
767
768# Rules to recompile a single source file for library and test
769# TODO: is there a tidier way to do this?
770${BUILD}/%_for_lib.o: CFLAGS += -DFOR_LIBRARY
771${BUILD}/%_for_lib.o: %.c
772 @printf " CC-for-lib $(subst ${BUILD}/,,$@)\n"
773 ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
774
775${BUILD}/%_for_test.o: CFLAGS += -DFOR_TEST
776${BUILD}/%_for_test.o: %.c
777 @printf " CC-for-test $(subst ${BUILD}/,,$@)\n"
778 ${Q}${CC} ${CFLAGS} ${INCLUDES} -c -o $@ $<
779
780# TODO: C++ files don't belong in vboot reference at all. Convert to C.
781${BUILD}/%.o: %.cc
782 @printf " CXX $(subst ${BUILD}/,,$@)\n"
783 ${Q}${CXX} ${CFLAGS} ${INCLUDES} -c -o $@ $<
784
785# ----------------------------------------------------------------------------
786# Here are the special tweaks to the generic rules.
787
788# Linktest ensures firmware lib doesn't rely on outside libraries
789${BUILD}/firmware/linktest/main: LIBS = ${FWLIB}
790
791# Specific dependency here.
792${BUILD}/utility/dump_kernel_config: LIBS += ${DUMPKERNELCONFIGLIB}
793${BUILD}/utility/dump_kernel_config: ${DUMPKERNELCONFIGLIB}
794
795# GBB utility needs C++ linker. TODO: It shouldn't.
796${BUILD}/utility/gbb_utility: LD = ${CXX}
797
798# Some utilities need external crypto functions
799${BUILD}/utility/dumpRSAPublicKey: LDLIBS += ${CRYPTO_LIBS}
800${BUILD}/utility/pad_digest_utility: LDLIBS += ${CRYPTO_LIBS}
801${BUILD}/utility/signature_digest_utility: LDLIBS += ${CRYPTO_LIBS}
802${BUILD}/utility/dev_sign_file: LDLIBS += ${CRYPTO_LIBS}
803${BUILD}/utility/vbutil_ec: LDLIBS += ${CRYPTO_LIBS}
804${BUILD}/utility/vbutil_firmware: LDLIBS += ${CRYPTO_LIBS}
805${BUILD}/utility/vbutil_kernel: LDLIBS += ${CRYPTO_LIBS}
806${BUILD}/utility/vbutil_key: LDLIBS += ${CRYPTO_LIBS}
807${BUILD}/utility/vbutil_keyblock: LDLIBS += ${CRYPTO_LIBS}
808
809${BUILD}/host/linktest/main: LDLIBS += ${CRYPTO_LIBS}
810${BUILD}/tests/vboot_common2_tests: LDLIBS += ${CRYPTO_LIBS}
811${BUILD}/tests/vboot_common3_tests: LDLIBS += ${CRYPTO_LIBS}
812${BUILD}/tests/vboot_ec_tests: LDLIBS += ${CRYPTO_LIBS}
813
814
815${BUILD}/utility/bmpblk_utility: LD = ${CXX}
816${BUILD}/utility/bmpblk_utility: LDLIBS = -llzma -lyaml
817
818BMPBLK_UTILITY_DEPS = \
819 ${BUILD}/utility/bmpblk_util.o \
820 ${BUILD}/utility/image_types.o \
821 ${BUILD}/utility/eficompress_for_lib.o \
822 ${BUILD}/utility/efidecompress_for_lib.o
823${BUILD}/utility/bmpblk_utility: OBJS = ${BMPBLK_UTILITY_DEPS}
824${BUILD}/utility/bmpblk_utility: ${BMPBLK_UTILITY_DEPS}
825
826${BUILD}/utility/bmpblk_font: OBJS += ${BUILD}/utility/image_types.o
827${BUILD}/utility/bmpblk_font: ${BUILD}/utility/image_types.o
828
829# Allow multiple definitions, so tests can mock functions from other libraries
830${BUILD}/tests/%: CFLAGS += -Xlinker --allow-multiple-definition
831${BUILD}/tests/%: INCLUDES += -Ihost/include
832${BUILD}/tests/%: LDLIBS += -lrt -luuid
833${BUILD}/tests/%: LIBS += ${TESTLIB}
834
835${BUILD}/tests/rollback_index2_tests: OBJS += \
836 ${BUILD}/firmware/lib/rollback_index_for_test.o
837${BUILD}/tests/rollback_index2_tests: \
838 ${BUILD}/firmware/lib/rollback_index_for_test.o
839
840${BUILD}/tests/vboot_audio_tests: OBJS += \
841 ${BUILD}/firmware/lib/vboot_audio_for_test.o
842${BUILD}/tests/vboot_audio_tests: \
843 ${BUILD}/firmware/lib/vboot_audio_for_test.o
844
845.PHONY: cgptmanager_tests
846cgptmanager_tests: ${BUILD}/tests/CgptManagerTests
847
848${BUILD}/tests/CgptManagerTests: CFLAGS += ${PC_CFLAGS}
849${BUILD}/tests/CgptManagerTests: LD = ${CXX}
850${BUILD}/tests/CgptManagerTests: LDLIBS += -lgtest -lgflags ${PC_LDLIBS}
851${BUILD}/tests/CgptManagerTests: LIBS = ${AU_CGPTLIB}
852${BUILD}/tests/CgptManagerTests: ${AU_CGPTLIB}
853
854${BUILD}/tests/rollback_index_test: INCLUDES += -I/usr/include
855${BUILD}/tests/rollback_index_test: LIBS += -ltlcl
856
857${TLCL_TEST_BINS}: OBJS += ${BUILD}/tests/tpm_lite/tlcl_tests.o
858${TLCL_TEST_BINS}: ${BUILD}/tests/tpm_lite/tlcl_tests.o
859
860##############################################################################
861# Targets that exist just to run tests
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800862
863# Frequently-run tests
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800864.PHONY: test_targets
865test_targets:: runcgpttests runmisctests
Randall Spangler844bce52013-01-15 16:16:43 -0800866
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800867ifeq (${MINIMAL},)
Randall Spangler844bce52013-01-15 16:16:43 -0800868# Bitmap utility isn't compiled for minimal variant
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800869test_targets:: runbmptests
Randall Spangler844bce52013-01-15 16:16:43 -0800870# Scripts don't work under qemu testing
871# TODO: convert scripts to makefile so they can be called directly
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800872test_targets:: runtestscripts
Randall Spangler844bce52013-01-15 16:16:43 -0800873endif
874
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800875.PHONY: test_setup
876test_setup:: cgpt utils futil tests
877
Randall Spangler844bce52013-01-15 16:16:43 -0800878# Qemu setup for cross-compiled tests. Need to copy qemu binary into the
879# sysroot.
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800880ifneq (${QEMU_ARCH},)
881test_setup:: qemu_install
Randall Spangler844bce52013-01-15 16:16:43 -0800882
883.PHONY: qemu_install
884qemu_install:
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800885ifeq (${SYSROOT},)
886 $(error SYSROOT must be set to the top of the target-specific root \
887when cross-compiling for qemu-based tests to run properly.)
888endif
Randall Spangler844bce52013-01-15 16:16:43 -0800889 @printf " Copying qemu binary.\n"
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800890 ${Q}cp -fu /usr/bin/${QEMU_BIN} ${BUILD}/${QEMU_BIN}
891 ${Q}chmod a+rx ${BUILD}/${QEMU_BIN}
Randall Spangler844bce52013-01-15 16:16:43 -0800892endif
893
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800894.PHONY: runtests
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800895runtests: test_targets
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800896
897# Generate test keys
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800898.PHONY: genkeys
Randall Spangler844bce52013-01-15 16:16:43 -0800899genkeys: utils
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800900 tests/gen_test_keys.sh
901
902# Generate test cases for fuzzing
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800903.PHONY: genfuzztestcases
Randall Spanglera808dc92013-01-14 12:59:05 -0800904genfuzztestcases: utils
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800905 tests/gen_fuzz_test_cases.sh
906
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800907.PHONY: runbmptests
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800908runbmptests: test_setup
909 cd tests/bitmaps && BMPBLK=${BUILD_RUN}/utility/bmpblk_utility \
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800910 ./TestBmpBlock.py -v
911
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800912.PHONY: runcgpttests
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800913runcgpttests: test_setup
914 ${RUNTEST} ${BUILD_RUN}/tests/cgptlib_test
915# HEY - elsewhere
916ifneq (${IN_CHROOT},)
917 ${RUNTEST} ${BUILD_RUN}/tests/CgptManagerTests --v=1
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800918endif
919
Randall Spangler844bce52013-01-15 16:16:43 -0800920.PHONY: runtestscripts
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800921runtestscripts: test_setup genfuzztestcases
922 tests/run_cgpt_tests.sh ${BUILD_RUN}/cgpt/cgpt
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800923 tests/run_preamble_tests.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800924 tests/run_rsa_tests.sh
Randall Spangler844bce52013-01-15 16:16:43 -0800925 tests/run_vbutil_kernel_arg_tests.sh
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800926 tests/run_vbutil_tests.sh
927
Randall Spangler844bce52013-01-15 16:16:43 -0800928.PHONY: runmisctests
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800929runmisctests: test_setup
930 ${RUNTEST} ${BUILD_RUN}/tests/rollback_index2_tests
931 ${RUNTEST} ${BUILD_RUN}/tests/rsa_utility_tests
932 ${RUNTEST} ${BUILD_RUN}/tests/sha_tests
933 ${RUNTEST} ${BUILD_RUN}/tests/stateful_util_tests
934 ${RUNTEST} ${BUILD_RUN}/tests/tpm_bootmode_tests
935 ${RUNTEST} ${BUILD_RUN}/tests/utility_string_tests
936 ${RUNTEST} ${BUILD_RUN}/tests/utility_tests
937 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_devmode_tests
938 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_init_tests
939 ${RUNTEST} ${BUILD_RUN}/tests/vboot_api_firmware_tests
940 ${RUNTEST} ${BUILD_RUN}/tests/vboot_audio_tests
Randall Spanglere061a252013-01-22 15:34:07 -0800941 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common_tests
942 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS}
943 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS}
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800944 ${RUNTEST} ${BUILD_RUN}/tests/vboot_firmware_tests
945
946.PHONY: runfutiltests
947runfutiltests: DESTDIR := ${TEST_INSTALL_DIR}
948runfutiltests: test_setup install
949 @echo "$@ passed"
Randall Spangler844bce52013-01-15 16:16:43 -0800950
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800951# Run long tests, including all permutations of encryption keys (instead of
952# just the ones we use) and tests of currently-unused code (e.g. vboot_ec).
953# Not run by automated build.
Bill Richardsonacb2ee92013-01-11 22:53:00 -0800954.PHONY: runlongtests
Bill Richardsoneecc18f2013-01-17 15:28:17 -0800955runlongtests: test_setup genkeys genfuzztestcases
Randall Spanglere061a252013-01-22 15:34:07 -0800956 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common2_tests ${TEST_KEYS} --all
957 ${RUNTEST} ${BUILD_RUN}/tests/vboot_common3_tests ${TEST_KEYS} --all
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800958 tests/run_preamble_tests.sh --all
Randall Spangler5d9bbf22013-01-08 10:44:23 -0800959 tests/run_vboot_ec_tests.sh
960 tests/run_vbutil_tests.sh --all
961
962# TODO: tests to run when ported to new API
963# ./run_image_verification_tests.sh
964# # Splicing tests
965# ${BUILD}/tests/firmware_splicing_tests
966# ${BUILD}/tests/kernel_splicing_tests
967# # Rollback Tests
968# ${BUILD}/tests/firmware_rollback_tests
969# ${BUILD}/tests/kernel_rollback_tests
970
Randall Spangler59d75082013-01-23 09:29:54 -0800971# Code coverage
972.PHONY: coverage_init
973coverage_init: test_setup
974 rm -f ${COV_INFO}*
975 lcov -c -i -d . -b . -o ${COV_INFO}.initial
976
977.PHONY: coverage_html
978coverage_html:
979 lcov -c -d . -b . -o ${COV_INFO}.tests
980 lcov -a ${COV_INFO}.initial -a ${COV_INFO}.tests -o ${COV_INFO}.total
981 lcov -r ${COV_INFO}.total '/usr/*' '*/linktest/*' -o ${COV_INFO}.local
982 genhtml ${COV_INFO}.local -o ${BUILD}/coverage
983
984# Generate addtional coverage stats just for firmware subdir, because the
985# per-directory stats for the whole project don't include their own subdirs.
986 lcov -e ${COV_INFO}.local '${SRCDIR}/firmware/*' \
987 -o ${COV_INFO}.firmware
988
989.PHONY: coverage
990ifeq (${COV},)
991coverage:
992 $(error Build coverage like this: make clean && COV=1 make)
993else
994coverage: coverage_init runtests coverage_html
995endif
996