Commit Graph

23 Commits

Author SHA1 Message Date
Daisuke Nojiri
099eeb9b97 test: Make TEST_* report test location
This patch converts TEST_* functions to macros, which print file name
and line # of the check. This will allow us to locate a failed test
quickly.

New TEST_* macros also automatically generate a test name if
testname == NULL. This will save us time to think of a name for
every single check we write in a test.

BUG=none
BRANCH=tot
TEST=make runtests

Change-Id: Ibdeb99681985c3f348836d256fa3484f2f0c315f
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/343233
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-05-10 19:41:47 -07:00
Daisuke Nojiri
111c59b567 test: Add TEST_STR_NEQ
TEST_STR_NES can be used to check the returned string is not what it
shouldn't be.

BUG=none
BRANCH=tot
TEST=make runtests

Change-Id: I09d5a63334e9b8365a44bb96ed31db8155d95e21
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/343120
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2016-05-08 00:31:18 -07:00
Mike Frysinger
cdf7dc9498 vb21 tests: use the build dir for temp files
Rather than write to temp files in the cwd, use the existing build dir
as our scratch space.  This lets us build out of tree properly even if
the source repo is read only.

BUG=chromium:466499
TEST=precq still passes
TEST=out-of-tree ebuild passes
BRANCH=None

Change-Id: I5dd69dcb8289cc557143e115e409b9c0924263b3
Reviewed-on: https://chromium-review.googlesource.com/259530
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
2015-03-13 05:12:51 +00:00
Bill Richardson
89901f00ef futility: add tests for futil_file_type(), correctly this time
This adds a test to be sure we can identify the types of input
files that futility can handle.

This fixes commit d7e1e4f0be, which
was reverted in commit 1ab2c10e8c
because the Makefile dependencies were wrong.

BUG=chromium:466433
BRANCH=none
TEST=make runtests

Also try this:

  \rm -rf build
  make $(pwd)/build/tests/futility/test_file_types -j16

Before, that failed every time. Now it works.

Change-Id: I7702e1b99f4f593ef0121686a8616a2cb132e64a
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/259651
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2015-03-12 19:27:28 +00:00
Prathmesh Prabhu
1ab2c10e8c Revert "futility: add tests for futil_file_type()"
This reverts commit 271c071344.

BUG=chromium:466433
TEST=None.

Change-Id: Ic84d069d672a76b46201a0e3700801a1e6d47438
Reviewed-on: https://chromium-review.googlesource.com/259364
Reviewed-by: David James <davidjames@chromium.org>
Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
2015-03-12 03:15:51 +00:00
Bill Richardson
271c071344 futility: add tests for futil_file_type()
This adds a test to be sure we can identify the types of input
files that futility can handle.

BUG=none
BRANCH=none
TEST=make runtests

Change-Id: Iff1dcc05530af2969a82d7c32599850bba59597a
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/258501
2015-03-11 07:50:34 +00:00
Randall Spangler
b9be53640e vboot2: Use more specific error codes
Error codes reported by the crypto and storage APIs are now very
specific, and tests verify the proper errors are reported.

More specific error codes coming to other files next, but I don't want
this CL to get too long.

This also changes test_common.c so TEST_EQ() reports mismatched values
in both decimal and hex, and adds TEST_SUCC() to test for a successful
return value.

BUG=chromium:370082
BRANCH=none
TEST=make clean && VBOOT2=1 COV=1 make

Change-Id: I255c8e5769284fbc286b9d94631b19677a71cdd0
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202778
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2014-06-07 01:37:21 +00:00
Simon Glass
2500185a83 Add memory leak checking
Add checks that the vboot library does not leak memory. This works by
tracking VbExMalloc() calls and making sure that they have an associated
VbExFree().

Adjust host_signature to use VbExFree() instead of free(), so that this
scheme works correctly for existing code.

BUG=chrome-os-partner:21115
BRANCH=pit
TEST=FEATURES=test emerge-peach_pit vboot_reference

Change-Id: I6ccccfbcc162fc43fb75862cd0eddad78ce8b18a
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/66175
2013-09-17 23:17:17 +00:00
Bill Richardson
94d7034590 Enable (and test) custom dev-mode sounds
BUG=none
TEST=manual

  cd src/platform/vboot_reference
  make && make runtests

Change-Id: I7f7d50d7c9c5541e0b99031245f882996a6b88ec
Reviewed-on: http://gerrit.chromium.org/gerrit/8731
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2011-10-05 11:09:23 -07:00
Randall Spangler
6c6babc51b Add tests for vboot_firmware.c
Yaay, LoadFirmware() finally has unit tests!

Fix minor memory leak in LoadFirmware().

BUG=chromium-os:17564
TEST=make && make runtests

Change-Id: I7eabc14484271f488b77f286e846781ccc22b8f2
(cherry picked from commit 2b7c5635d7069c55a1d96d11b99d02291b7e308b)
Reviewed-on: http://gerrit.chromium.org/gerrit/7052
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
2011-09-01 09:05:04 -07:00
Randall Spangler
9c9606b7a6 Add tests for rsa_utility.c
BUG=chromium-os:17564
TEST=make && make runtests

Change-Id: Ia86241f5407ba53d93d3862b29c61b510e560e92
Reviewed-on: http://gerrit.chromium.org/gerrit/6959
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
2011-09-01 09:04:46 -07:00
Randall Spangler
cb3313e8cb Partial unit tests for rollback_index
BUG=chromium-os:17564
TEST=make && make runtests

Change-Id: I8ea6bcc15f277e10c5b8539f2ea19ad90be34889
Reviewed-on: http://gerrit.chromium.org/gerrit/6770
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
2011-08-26 14:15:26 -07:00
Randall Spangler
1f5d53f7bd Add tests for vboot_reference stateful_util.c
BUG=chromium-os:17564
TEST=make && make runtests

Change-Id: I5d55be2dfead0c5d7af72841cbd6c65485685cd6
Reviewed-on: http://gerrit.chromium.org/gerrit/6596
Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
Tested-by: Randall Spangler <rspangler@chromium.org>
2011-08-24 13:50:51 -07:00
vbendeb
3ecaf776d8 Make vboot_reference build in MSVC command line environment.
This is a mostly NOOP change which modifies the source code
to compile cleanly in the MSVC command line build
environment.

A new makefile is introduced (msc/nmakefile) along with a
README.txt in the same directory explaining how to build
the code in the DOS window. As of this submission the build
is running in a 32 bit environment, the intention is to use
the same makefile for 64 bit builds in the future.

Enabling high compilation warnings level allowed to
identify a couple of bugs in the code which are being fixed.

Not all sources are being compiled in the MSVC environment,
only those in firmware/ and most of those in test/
subdirectories. The benchmark calculations require porting
of the timer facilities and are being postponed.

TEST

Built in DOS and linux environments. Ran unit tests in
linux environment.

Review URL: http://codereview.chromium.org/2809037
2010-06-24 16:19:53 -07:00
Randall Spangler
620c38cf34 Remove unused files, and tidy the directory structure of the remaining ones.
Review URL: http://codereview.chromium.org/2815011
2010-06-17 14:45:22 -07:00
Randall Spangler
d471f2a839 Remove old firmware verification code, now that firmware build has switched to the new algorithms.
Review URL: http://codereview.chromium.org/2835006
2010-06-16 12:05:10 -07:00
Gaurav Shah
bcd8f4a07c Make kernel signature a part of the kernel preamble.
With this change, the kernel signature is a part of the preamble block (and therefore, used during preamble signature verification).

BUG=670
TEST=image verification tests still pass. corrected splicing test expectations (and it passes).

Review URL: http://codereview.chromium.org/2292001
2010-05-26 13:19:00 -07:00
Gaurav Shah
0265882a34 Change VerifyFirmware() to take separate pointers to firmware verification header and firmware data.
The firmware verification code no longer assumes that verification data and firmware data are contiguous and follow each other. Needed for EFI where the actual firmware must be stored in its own firmware volume.

BUG=1704
TEST=modified existing tests for the new API, and they still pass

Review URL: http://codereview.chromium.org/1578035
2010-04-18 16:35:07 -07:00
Gaurav Shah
e450be4ce4 Propagate use of uint64_t to more functions that may need to deal with arbitrary length data.
This CL fixes some functions to use uint64_t that I missed the first time around. It ended up requiring some minor changes to how some of the helper functions work (StatefulMemcpy*()).

Also adds new tests to make sure that reference code can verify/process big firmware and kernel images.

BUG=670
TEST=Adds some new, old ones still pass.

Review URL: http://codereview.chromium.org/1519008
2010-03-29 21:27:08 -07:00
Gaurav Shah
463be3f135 VBoot Reference: Fix splicing bugs in Firmware and Kernel verification.
BUG=670
TESTS=Adds new tests which verify this doesn't occur anymore. Existing tests still pass.

The existing code computes and verifies signatures on firmware/kernel data and firmware/kernel versions separately. This causes a image splicing bug where it is possible to combine together a version signature from a valid new firmware with firmware data and signature from an older version. The same problem exists with kernel verification.

This CL fixes this by changing the firmware/kernel signatures to also include the version information.

For the Firmware, there's a separate signature on the preamble (which contains the version) but the firmware signature now also includes this preamble in addition to the firmware data.

For the Kernel, there's a separate signature on the kernel config/options (wich also contains the version), but the kernel signature now also includes these config/options in addition to the kernel data.

Review URL: http://codereview.chromium.org/1430001
2010-03-29 16:13:45 -07:00
Gaurav Shah
a82bf268b2 VBoot Reference: Add kernel rollback prevention and choosing logic.
Also adds tests for kernel rollback prevention.

Review URL: http://codereview.chromium.org/1320010
2010-03-26 10:38:08 -07:00
Gaurav Shah
3199eed3d3 Move test utility functions to a common place.
Also removes the dev_mode flag from Firmware Image verification as key signature for the firmware should be checked whether or not dev mode is enabled.

BUG=670
TEST=All tests still pass.

Merge remote branch 'refs/remotes/origin/master' into fixtests

Fix tests, remove dev mode. Move common code.

Review URL: http://codereview.chromium.org/1280002
2010-03-25 13:04:45 -07:00
Gaurav Shah
ce0cc30e55 VBoot Reference: Add version checking to for preventing rollbacks.
This CL adds a new function VerifyFirmwareDriver_f() means to be a part of the RO firmware which determine which copy of the firmware to boot from. It is meant to ensure that a particular firmware is only booted if 1) it verifies successfully, 2) its version is newer or equal to current stored version. In addition, the driver function also updates the stored version if needed.

Currently I am using the TLCL API with stub calls, (in fact, most of the TPM interaction is done in rollback_index.c which implements the actual version query/update API) used by the firmware.

Review URL: http://codereview.chromium.org/1241002
2010-03-24 13:48:55 -07:00