Source release 17.1.0
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine Master
|
||||
// License Agreement.
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
|
||||
#include <assert.h>
|
||||
#include <gtest/gtest.h>
|
||||
@@ -10,11 +10,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if defined(__linux__)
|
||||
# include <sys/utsname.h>
|
||||
#endif
|
||||
|
||||
#include "cdm.h"
|
||||
#include "cdm_test_runner.h"
|
||||
#include "device_cert.h"
|
||||
#include "log.h"
|
||||
#include "test_base.h"
|
||||
@@ -23,72 +20,22 @@
|
||||
using namespace widevine;
|
||||
|
||||
TestHost* g_host = nullptr;
|
||||
std::string g_sandbox_id = "";
|
||||
|
||||
namespace {
|
||||
constexpr const char kSandboxIdParam[] = "--sandbox_id=";
|
||||
|
||||
// Following the pattern established by help text in test_base.cpp
|
||||
constexpr const char kExtraHelpText[] =
|
||||
" --sandbox_id=<sandbox_id>\n"
|
||||
" Specifies the Sandbox ID that should be sent to OEMCrypto via\n"
|
||||
" OEMCrypto_SetSandbox(). On most platforms, since Sandbox IDs are not\n"
|
||||
" in use, this parameter should be omitted.\n";
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
// Find and filter out the Sandbox ID, if any.
|
||||
std::vector<std::string> args(argv, argv + argc);
|
||||
auto sandbox_id_iter = std::find_if(std::begin(args) + 1, std::end(args),
|
||||
[](const std::string& elem) -> bool {
|
||||
return elem.find(kSandboxIdParam) == 0;
|
||||
});
|
||||
if (sandbox_id_iter != std::end(args)) {
|
||||
g_sandbox_id = sandbox_id_iter->substr(strlen(kSandboxIdParam));
|
||||
args.erase(sandbox_id_iter);
|
||||
}
|
||||
|
||||
// Set up a Host and initialize the library. This makes these services
|
||||
// available to the tests. We would do this in the test suite itself, but the
|
||||
// core & OEMCrypto tests don't know they depend on this for storage.
|
||||
g_host = new TestHost();
|
||||
Cdm::ClientInfo client_info;
|
||||
// Set client info that denotes this as the test suite:
|
||||
client_info.product_name = "CE cdm tests";
|
||||
client_info.company_name = "www";
|
||||
client_info.model_name = "www";
|
||||
#if defined(__linux__)
|
||||
client_info.device_name = "Linux";
|
||||
{
|
||||
struct utsname name;
|
||||
if (uname(&name) == 0) {
|
||||
client_info.arch_name = name.machine;
|
||||
}
|
||||
}
|
||||
#else
|
||||
client_info.device_name = "unknown";
|
||||
#endif
|
||||
client_info.build_info = __DATE__;
|
||||
|
||||
Cdm::Status status = Cdm::initialize(
|
||||
Cdm::kNoSecureOutput, client_info, g_host, g_host, g_host,
|
||||
static_cast<Cdm::LogLevel>(wvcdm::g_cutoff), g_sandbox_id);
|
||||
(void)status; // status is now used when assertions are turned off.
|
||||
assert(status == Cdm::kSuccess);
|
||||
// TODO(b/195338975): document that using a real IStorage means you should not
|
||||
// run the tests in $CDM_DIR/cdm/test/cdm_test.cpp
|
||||
|
||||
std::vector<const char*> new_argv(args.size());
|
||||
std::transform(
|
||||
std::begin(args), std::end(args), std::begin(new_argv),
|
||||
[](const std::string& arg) -> const char* { return arg.c_str(); });
|
||||
// This must take place after the call to Cdm::initialize() because it makes
|
||||
// calls that are only valid after the library is initialized.
|
||||
if (!wvcdm::WvCdmTestBase::Initialize(new_argv.size(), new_argv.data(),
|
||||
kExtraHelpText)) {
|
||||
return 0;
|
||||
}
|
||||
// Partners will want to replace this with a real IStorage.
|
||||
Cdm::IStorage* const storage = &g_host->global_storage();
|
||||
|
||||
// Init gtest after oemcrypto and cdm host have been initialized.
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
// Partners may also want to replace this with real implementations of IClock
|
||||
// and ITimer. If so, make not to set the command line argument
|
||||
// "--fake_sleep".
|
||||
Cdm::IClock* const clock = g_host;
|
||||
Cdm::ITimer* const timer = g_host;
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
const int test_results = Main(storage, clock, timer, argc, argv);
|
||||
return test_results;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user