ml: add unit test for web platform hwr using  multiprocess.

The newly added unit test will test,
1. Whether the worker process is spawned, registered and alive.
2. Whether we can get expected predictions.
3. Whether disconnecting the mojo pipe in control process will cause
the worker process to exit.

There is also a 5min timeout to avoid worker process to hang.

Note that, currently we can not test whether the prediction result is
truly coming from the worker process with specific PID. This is
because currently the mojo interface does not send this. But this is
to some extent tested because we test that whether the worker process
exits when the mojo connection disconnects.

We also need to disable some sandboxing on the worker process to make
it work in unit test.

BUG=chromium:933017
TEST=FEATURES=test emerge-nocturne ml passed.
TEST=FEATURES=test emerge-pyro ml passed.
TEST=FEATURES=test emerge-strongbad ml passed.
TEST=on nocturne, pyro and strongbad, the hwr demo works.

Cq-Depend: 2879775
Change-Id: I3aaed90e2737139e016032fa950f54f59ab425c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2879261
Tested-by: Honglin Yu <honglinyu@chromium.org>
Commit-Queue: Honglin Yu <honglinyu@chromium.org>
Reviewed-by: Andrew Moylan <amoylan@chromium.org>
diff --git a/ml/machine_learning_service_impl.cc b/ml/machine_learning_service_impl.cc
index c0a2e03..7e1babd 100644
--- a/ml/machine_learning_service_impl.cc
+++ b/ml/machine_learning_service_impl.cc
@@ -520,7 +520,7 @@
 
   // If it is run in the control process, spawn a worker process and forward the
   // request to it.
-  if (Process::GetInstance()->GetType() == Process::Type::kControl) {
+  if (Process::GetInstance()->IsControlProcess()) {
     pid_t worker_pid;
     mojo::PlatformChannel channel;
     constexpr char kModelName[] = "WebPlatformHandwritingModel";
@@ -539,6 +539,7 @@
   }
 
   // From here below is in the worker process.
+  DCHECK(Process::GetInstance()->IsWorkerProcess());
 
   // If handwriting is installed on rootfs, load it from there.
   if (is_rootfs_enabled) {