Commit Graph

33 Commits

Author SHA1 Message Date
Rahul Frias
ea2e110213 Log test name
[ Merge of http://go/wvgerrit/94083 ]

Logs the test case and test name when widevine android unit/integration
tests are run.

Bug: 149664134
Test: wv unit/integration tests
Change-Id: I446b88aa2954a386765e4559358d386b1a263913
2020-02-16 23:30:26 -08:00
Fred Gylys-Colwell
7665614b2e OEMCrypto v16.1
Merge of http://go/wvgerrit/93404

This CL updates the Widevine CDM to support OEMCrypto v16.1

Test: Tested in 16.2 CL
Bug: 141247171
Change-Id: I69bd993500f6fb63bf6010c8b0250dc7acc3d71b
2020-02-03 14:45:32 -08:00
John W. Bruce
1bc1bad1f0 Improvements to TestBase
This patch merges some features that were added to TestBase in
http://go/wvgerrit/92349 in the Widevine Repo. Certain parameters to
TestBase that could have been const but weren't now are. The caller to
Initialize() can now specify additional, platform-specific help text to
be displayed after the generic help text. And some missing headers were
added to test_base.h.

The Android code does not yet take advantage of any of this, but it
could in the future.

Bug: 145013234
Test: Android Unit Tests
Change-Id: I3c54532a39641622d454256b25979ad89727d43f
2020-01-30 16:15:46 -08:00
Rahul Frias
b8a6035298 Address compilation warnings
[ Merge of http://go/wvgerrit/90350 ]

Bug: 145244554
Test: wv android unit/integration tests
Change-Id: I5cd8a132836ce097a7b539fffdcef574f64cbdcf
2019-12-02 17:44:56 -08:00
Alex Dale
093fd4718c Removed a few more log prefixes in core/
[ Merge of http://go/wvgerrit/89705 ]

Test: Android and Linux unit tests
Bug: 134460638
Change-Id: Ieb84296eefd00478260ebc42d242f9bef2d8c8d1
2019-11-26 13:19:28 -08:00
Rahul Frias
2e22e2321e clang-format core/test files
[ Merge of http://go/wvgerrit/88006 ]

Certain test files have yet to be formatted since we introduced
clang-formatting.

Test: android unit/integration tests
Bug: 134365840
Change-Id: I2d30ad367d76a9dfbf389614e1b31ed39fa17c72
2019-10-22 17:30:23 -07:00
Alex Dale
8a82379e81 Unittests will retry provisioning if failed.
[ Merge of http://go/wvgerrit/84490 ]

The unit tests will now make at most 10 attempts to provision
themselves before declaring failure.

This change is made to help with flaky provisioning requests that
have been experienced on the Jenkins build server.

Bug: 139298083
Test: Linux unit test, Jenkins build and Android unit tests
Change-Id: I6415a5ef9fdf10ceb893867d5fc73131338e9f76
2019-09-11 13:04:58 -07:00
Alex Dale
ee995d5fae Replacing NULL with nullptr in core/
[ Merge of http://go/wvgerrit/84647 ]
[ Merge of http://go/wvgerrit/84648 ]

Replacing most instances of C's NULL with C++'s nullptr.  Also changed
how a NULL check is performed on smart pointers.  They provided an
implicit boolean operator for null checks, meaning the underlying
pointer does not need to be compared directly (as it was in some places
before).

Note that clang-format has performed additional changes to some of the
test files that have not yet been formatted.

Bug: 120602075
Test: Linux and Android unittests
Change-Id: I06ddebe34b0ea6dfecedb5527e7e808e32f5269a
2019-08-19 14:18:25 -07:00
Fred Gylys-Colwell
b60f75805d Unify log level for tests
Merge from Widevine repo of http://go/wvgerrit/79463 and
http://go/wvgerrit/82383

Several tests explicitly set the log level. This CL unifies that a
little bit. When running the unit tests by hand, on android or for ce
cdm, the log level is 0 (ERROR) and can be incremented on the command
line using the "--verbose" switch.

When running on the desktop, you can set the environment variable
VERBOSE_LOG to "yes", and the log level is set to VERBOSE.  This is
done by the buildbot so you can see full logs in the build archive.

When running with the test bed (i.e. Mod Mock) you can edit the
options.txt file and set log_level to 0=ERROR up to 4=VERBOSE. if you
are using the run_current_tests script, you can create a file in the
linux directory called override_options.txt and add the line
log_level 4

This CL only changes test code.

bug: 124390006
Test: unit tests
Change-Id: I1e042004692750e218b8c4220bce3ec1e387004e
2019-07-10 14:02:45 -07:00
Fred Gylys-Colwell
aa7f7d3ac4 Remove test keybox one more time
Merge from Widevine repo of http://go/wvgerrit/78883

Bug: 119316243
Test: unit tests
Change-Id: Ic6748a6e020c2a4058510fb5c6c5a821e57cc5fd
2019-05-22 00:25:56 +00:00
John W. Bruce
5ea429ee2b Don't Use StringStream When It's Overkill
(This is a merge of http://go/wvgerrit/76063)

Now that we have C++11, many places that do string formatting or parsing
can be replaced with std::to_string() or one of the std::sto*() family
of functions. This patch updates places that do simple stringifying or
parsing to use these functions. Some parts of the code are left
untouched because they were using StringStream to do more complex
actions, such as constructing more complex output or checking the status
of the parsing.

Bug: 120599938
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: I482dc234ecd7c6014fa9b6874387ff51e04b772f
2019-04-17 17:46:31 -07:00
Adam Stone
9f31068de6 Merge "Add a metric decorator around cdm engine" 2019-02-04 17:55:35 +00:00
Fred Gylys-Colwell
4287df7d3d Merge "Revert "Remove Test Keybox Again"" 2019-02-01 19:23:31 +00:00
Adam Stone
46eecb6b80 Add a metric decorator around cdm engine
[ Merge from http://go/wvgerrit/69105 ]

This adds a metric collecting decorator class around cdm engine. This
implementation uses a templated decorator. The decorator enables:

1) Wrapping the CDM Engine methods to capture timing and error
information.
2) Allows use of a mock CDM Engine for testing.

Test: Unit tests. GPlay manual testing and GTS tests.
BUG: http://b/64724336
Change-Id: I5e4a0f552974fab1939bc7ab02719a1f5849cf3f
2019-02-01 10:32:44 -08:00
Rahul Frias
272e60db27 Add recoverable errors
[ Merge of http://go/wvgerrit/71326 ]

Nonce flood, frame size, session and system invalidation errors
will now bubble up to the app. OEMCrypto v15 returns
OEMCrypto_ERROR_BUFFER_TOO_LARGE, OEMCrypto_ERROR_SESSION_LOST_STATE,
OEMCrypto_ERROR_SYSTEM_INVALIDATED and a variety of nonce errors.
These will be reported to HIDL as OUTPUT_TOO_LARGE_ERROR,
ERROR_DRM_SESSION_LOST_STATE, ERROR_DRM_INVALID_STATE and
ERROR_DRM_RESOURCE_CONTENTION.

Bug: 120572706
Test: Unit/Integration tests
Change-Id: Ida177300046327ce81592a273028ef6c3a0d9fd9
2019-01-31 00:44:02 -08:00
Fred Gylys-Colwell
fca89868f8 Revert "Remove Test Keybox Again"
This reverts commit 408509efdc.

Reason for revert: just kidding. We want to run the tests on 
old devices, too.

Change-Id: I920fa825380638122f638e057bcfbe98b5f7b301
2019-01-30 19:17:06 +00:00
John Bruce
d21695d395 Merge "Add a cross-platform argument parser." 2019-01-28 18:29:10 +00:00
Fred Gylys-Colwell
03c10789f9 Add mutex lock around InstallTestRootOfTrust
Merge from Widevine repo of http://go/wvgerrit/71323

When running multithreaded tests, we need to make sure there are no other
OEMCrypto calls between OEMCrypto_Initialize and the installation of the test
keybox.

bug: 123319961
test: ran juce's threading test
Change-Id: Ibd8951c764f6538da4afa9ad146a6a72064eb13a
2019-01-26 01:05:38 +00:00
Jacob Trimble
9a66a6f590 Add a cross-platform argument parser.
(This is a merge of http://go/wvgerrit/70343)

Instead of using the POSIX-specific getopt(), this uses a manual
string comparison so it works on Windows.

Test: Android Unit Tests
Bug: 122953649
Change-Id: If009f8b3bfc8581d252da0f5ed55293c46d70bc6
2019-01-25 15:44:28 -08:00
Fred Gylys-Colwell
408509efdc Remove Test Keybox Again
Merge from Widevine repo of http://go/wvgerrit/69563

This CL also disables unit tests that depend on the old test keybox when run
against OEMCrypto v13 or earlier.

Unit tests that require a particular API level have been
removed.  This requirement for Android is tested in GTS tests.

Bug: 119316243
Test: unit tests
Change-Id: I9a13dbaee1693ecea906fd0184a8e2590dc5beed
2019-01-24 11:59:02 -08:00
John Bruce
0c194ff115 Merge "Re-enable Binary Provisioning Test Again" 2019-01-17 00:30:42 +00:00
John W. Bruce
777abaef01 Add some platform abstractions.
(This is a merge of http://go/wvgerrit/70303)

This adds a platform.h file to abstract some of the differences
between Windows and POSIX platforms.  This includes ntohl, setenv,
and ssize_t.

Bug: 122953649
Test: Android Unit Tests
Change-Id: I3235f3f284b53d24d7365ff3f4a06dcd9b403697
2019-01-16 11:06:55 -08:00
John W. Bruce
e12a837e14 Re-enable Binary Provisioning Test Again
(This is a merge of http://go/wvgerrit/70384)

It turns out the reason the binary provisioning unit test was failing is
because the test base class was setting the property to turn on binary
provisioning before calling Init(), however all current Init()
implementations overwrite the value of that field. As such, the tests
weren't actually using binary provisioning. With that fixed, everything
passes; the binary provisioning flow doesn't appear to actually be
broken.

This is the exact same commit as was previously reverted,
cf5464d7a2fbecd1938ae0700199145b7b61c3c3. However, a pending patch fixes
the multiple runs of Properties::Init() that lead to the inconsistent
failures of the previous patch. (See http://go/wvgerrit/70383)

Bug: 112046733
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: I79fc2c8d4d24505b46cab0e21eef85a37d66748d
2019-01-15 16:28:01 -08:00
John Bruce
38c45a66a3 Revert "Re-enable Binary Provisioning Test"
(The matching reversion in the Widevine Repository is
http://go/wvgerrit/69923)

This reverts commit c207ef8ea6.

Reason for revert: Widevine Buildbot failures

Change-Id: Ied9e36f9eaa94bb7e9cd13b8dff7a2cbdca07a07
2019-01-09 18:55:06 +00:00
John W. Bruce
c207ef8ea6 Re-enable Binary Provisioning Test
(This is a merge of http://go/wvgerrit/69843)

It turns out the reason the binary provisioning unit test was failing is
because the test base class was setting the property to turn on binary
provisioning before calling Init(), however all current Init()
implementations overwrite the value of that field. As such, the tests
weren't actually using binary provisioning. With that fixed, everything
passes; the binary provisioning flow doesn't appear to actually be
broken.

Bug: 112046733
Test: CE CDM Unit Tests
Test: Android Unit Tests
Change-Id: I7413f7fb2227e596fb610d6ddc5b95cda2f406b8
2019-01-08 18:08:26 -08:00
Adam Stone
0a64d25067 Add a field indicating online vs offline licenses.
Import of http://go/wvgerrit/68188

This adds an attribute to metrics indicating if the license was online
or offline.

Also, added a unit test for CdmEngineMetricsImpl.

Test: Unit tests. GPlay manual. GTS tests.
Bug: 115523917

Change-Id: Id315c643048914a2c51904451f9665987bc87eb7
2018-12-21 13:09:29 -08:00
Srujan Gaddam
e6439255ba Update OEMCrypto calls to use substrings
Merge from master branch of Widevine repo of http://go/wvgerrit/66073
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/64083

As part of the update to v15, LoadKeys, RefreshKeys, and
LoadEntitledContentKeys should all use offsets and lengths into the
message rather than a pointer for its parameters. The CDM, tests,
adapters, and OEMCrypto implementations are changed to reflect this.

Test: tested as part of http://go/ag/5501993
Bug: 115874964

Change-Id: I981fa322dec7c565066fd163ca5775dbff71fccf
2018-11-16 17:14:00 -08:00
Fred Gylys-Colwell
05fc8b5e97 Temporarily use old test keybox
Merge from Widevine repo of http://go/wvgerrit/65922

This CL puts the old 4121 test keybox back into the unit and android
integration tests so that we can run tests on a device with OEMCrypto v13.

This change should not be released, and should not be included in CE CDM.  It
should be removed once we have more test devices with v14 or v15.

Bug: 119313532
Bug: 119316243
Test: unit tests
Test: tested as part of http://go/ag/5501993

Change-Id: If6a459e11176e07c66fbe6fc45c63d87595a20dc
2018-11-16 15:38:45 -08:00
John W. Bruce
3d603eb12d Reject Embedded Keys Under 16 Bytes
(This is a merge of http://go/wvgerrit/60620)

The license code handles keys larger than 16 bytes correctly, but it
does not properly reject keys smaller than 16 bytes.

This patch adds unit tests not only for the new error case but also
the existing success cases which were not previously being tested. As
part of this, license_unittest was changed to use a Test Peer instead
of making the test fixture a friend class.

Bug: 111069024
Test: CE CDM unit tests
Test: Android unit tests
Change-Id: Idb2deb6fbe0aeb19b530f9818bebff480541f5c8
2018-10-08 10:05:34 -07:00
Fred Gylys-Colwell
f4258cc628 Send test name to server
Merge from Widevine repo of http://go/wvgerrit/59700

This CL sets the environment variable MODEL_NAME to be the current
unit test.  When running on a test platform, this environment variable
is used in the license request as model_name.

test: unit tests.
bug: 38004627

Change-Id: I347c5cec35942d68285cc01615b976097f37d214
2018-09-18 16:33:11 -07:00
Fred Gylys-Colwell
790799ceaa Refactor provisioning tests
Merge from Widevine repo of http://go/wvgerrit/56522

This CL moves provisioning from core/test/cdm_engine_test.cpp to
test_base.cpp because other tests should also only be run when the
device has been provisioned.

It also adds a fake license server.  The license holder helps a test
create a license request and then generates a bare-bones license,
without actually sending anything to a real license server.

Test: more unit tests pass than before.
Bug: 72354901 Fix Generic Crypto tests.
Change-Id: Iec067a6a1fb91fa8fd7b904fdf36e90981e293a3
2018-09-18 16:33:11 -07:00
Fred Gylys-Colwell
e635d4d384 Common test main
Merge from Widevine repo of http://go/wvgerrit/56521

This CL adds a common main routine for integration tests.  It sets a
default test configuration for the provisioning and license server
urls and certificates, and allows the user to set them on the command
line.

Test: current unit tests still pass.
Bug: 72354901 Fix Generic Crypto tests.
Change-Id: I604a3d9e15d50da5041794624c4571c0dcb091f5
2018-09-18 16:33:11 -07:00
Fred Gylys-Colwell
4af5aaf18a Add test base that catches nonce flood
Merge from Widevine repo of http://go/wvgerrit/56520

This CL adds a test base that installs a test keybox and catches nonce
flood errors for all CDM tests.

In order to do this, a new class is added called a
CryptoSessionFactory.  The default factory just creates a new
CryptoSession.  All places in the code that create a new CryptoSession
now call the static method MakeCryptoSession, which uses the current
factory to create a CryptoSession.  If MakeCryptoSession is called and
there is no current factory, a default factory is created.

The CryptoSession constructor is now private, so that we do not
accidentally try to create one without using the factory.

For the new test base, we first create a special test
CryptoSessionFactory that creates a TestCryptoSession.  The test
factory catches the first call to MakeCryptoSession and injects an
installation of the test keybox after OEMCrypto_Initialize is called.

The TestCryptoSession injects a sleep statement and a retry whenever
it detects a nonce flood.

Test: current unit tests still pass.
bug: 72354901 Fix Generic Crypto tests.
bug: 111361440 Remove #ifdef from unit tests
Change-Id: I248e7f3c53721c04d2af412ef835e19bb4d15d9a
2018-09-18 16:33:11 -07:00