Revert "autotest: Delete Check*Processes tests."
This reverts commit 9ccbe22723a5ecb1d31ea4b4957b7eb7e51f390a.
Reason for revert: bvt-cq is still trying to run these tests and
is failing with "test does not exist" errors.
Original change's description:
> autotest: Delete Check*Processes tests.
>
> Delete the following tests, which have been replaced by the
> platform.CheckProcesses Tast test:
>
> network_CheckCriticalProcesses
> platform_CheckCriticalProcesses
> platform_CheckDebugdProcesses
> platform_CheckMetricsProcesses
> platform_CheckPowerdProcesses
> platform_CheckTLSDateProcesses
>
> BUG=chromium:885910
> TEST=none
>
> Change-Id: I8b5c0a7fce1e5d28ffa5085feb77079688cc8e4d
> Reviewed-on: https://chromium-review.googlesource.com/1363823
> Commit-Ready: Dan Erat <derat@chromium.org>
> Tested-by: Dan Erat <derat@chromium.org>
> Reviewed-by: Shuhei Takahashi <nya@chromium.org>
> Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
Bug: chromium:885910,chromium:913120
Change-Id: I9c3ab460d5786c689a422c4beb8b65e0667245e3
Reviewed-on: https://chromium-review.googlesource.com/c/1369109
Reviewed-by: Dan Erat <derat@chromium.org>
Tested-by: Dan Erat <derat@chromium.org>
diff --git a/client/site_tests/network_CheckCriticalProcesses/control b/client/site_tests/network_CheckCriticalProcesses/control
new file mode 100644
index 0000000..1fc48f3
--- /dev/null
+++ b/client/site_tests/network_CheckCriticalProcesses/control
@@ -0,0 +1,32 @@
+# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+AUTHOR = 'pstew, quiche, wiley'
+NAME = 'network_CheckCriticalProcesses'
+ATTRIBUTES = "suite:bvt-cq, suite:network_nightly, subsystem:network"
+TIME = 'SHORT'
+TEST_TYPE = 'client'
+JOB_RETRIES = 2
+
+DOC = """
+This test has a static list of process names that should be running
+on a good Chrome OS Core image with client networking (shill) support.
+It fails if any of these are not running at the time of the test.
+"""
+
+NETWORK_CRITICAL_PROCESSES = [
+ 'dbus-daemon',
+ # dhcpcd expected for a test-lab DUT controlled via ethernet.
+ 'dhcpcd',
+ 'netfilter-queue|conntrackd',
+ # powerd expected as long as it controls set_wifi_transmit_power.
+ 'powerd',
+ 'shill',
+ 'udevd|systemd-udevd',
+ 'update_engine',
+ 'wpa_supplicant',
+ ]
+
+job.run_test('platform_CheckCriticalProcesses',
+ process_list=NETWORK_CRITICAL_PROCESSES)
diff --git a/client/site_tests/platform_CheckCriticalProcesses/platform_CheckCriticalProcesses.py b/client/site_tests/platform_CheckCriticalProcesses/platform_CheckCriticalProcesses.py
new file mode 100644
index 0000000..9dea77e
--- /dev/null
+++ b/client/site_tests/platform_CheckCriticalProcesses/platform_CheckCriticalProcesses.py
@@ -0,0 +1,65 @@
+# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import re
+
+from autotest_lib.client.bin import test
+from autotest_lib.client.common_lib import error
+
+class platform_CheckCriticalProcesses(test.test):
+ """
+ Builds a process list (without spawning 'ps'), and validates
+ that among these processes all the expected processes are running.
+ """
+ version = 1
+
+ def get_process_name(self, pid):
+ """Gathers info about one process, given its PID
+
+ @param pid string representing the process ID
+ @return string process name
+
+ """
+ with open(os.path.join('/proc', pid, 'status')) as pid_status_file:
+ for line in pid_status_file:
+ fields = re.split('\s+',line)
+ if fields[0] == 'Name:':
+ return fields[1]
+
+
+ def get_process_list(self):
+ """Returns the set the process names"""
+ process_names = set()
+ for pid in os.listdir('/proc'):
+ if not pid.isdigit():
+ continue
+
+ # There can be a race where after we listdir(), a process
+ # exits. In that case get_process_name will throw an IOError
+ # becase /proc/NNNN won't exist.
+ # In those cases, skip to the next go-round of our loop.
+ try:
+ process_names.add(self.get_process_name(pid))
+ except IOError:
+ continue
+
+ return process_names
+
+
+ def run_once(self, process_list):
+ """
+ Verify processes in |process_list| are running.
+
+ @param process_list: list of process names to check
+ """
+ processes = self.get_process_list()
+ missing_processes = []
+ for p in process_list:
+ processes_names = p.split('|')
+ if set(processes_names).isdisjoint(processes):
+ missing_processes.append(p)
+ if missing_processes:
+ raise error.TestFail('The following processes are not running: %r.'
+ % missing_processes)
diff --git a/client/site_tests/platform_CheckDebugdProcesses/control b/client/site_tests/platform_CheckDebugdProcesses/control
new file mode 100644
index 0000000..1c8f647
--- /dev/null
+++ b/client/site_tests/platform_CheckDebugdProcesses/control
@@ -0,0 +1,20 @@
+# Copyright 2014 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+AUTHOR = 'benchan, gauravsh'
+NAME = 'platform_CheckDebugdProcesses'
+ATTRIBUTES = "suite:bvt-cq"
+TIME = 'SHORT'
+TEST_TYPE = 'client'
+JOB_RETRIES = 2
+
+DOC = """
+This test has a static list of process names that should be running
+on a good Chrome OS Core image running with debugd support. It
+fails if any of these are not running at the time of the test.
+"""
+
+DEBUGD_PROCESSES = ['debugd']
+
+job.run_test('platform_CheckCriticalProcesses', process_list=DEBUGD_PROCESSES)
diff --git a/client/site_tests/platform_CheckMetricsProcesses/control b/client/site_tests/platform_CheckMetricsProcesses/control
new file mode 100644
index 0000000..f266e09
--- /dev/null
+++ b/client/site_tests/platform_CheckMetricsProcesses/control
@@ -0,0 +1,20 @@
+# Copyright 2014 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+AUTHOR = 'bsimonnet, gauravsh'
+NAME = 'platform_CheckMetricsProcesses'
+ATTRIBUTES = "suite:bvt-cq"
+TIME = 'SHORT'
+TEST_TYPE = 'client'
+JOB_RETRIES = 2
+
+DOC = """
+This test has a static list of process names that should be running
+on a good Chrome OS Core image with metrics reporter support. It
+fails if any of these are not running at the time of the test.
+"""
+
+METRICS_PROCESSES = ['metrics_daemon']
+
+job.run_test('platform_CheckCriticalProcesses', process_list=METRICS_PROCESSES)
diff --git a/client/site_tests/platform_CheckPowerdProcesses/control b/client/site_tests/platform_CheckPowerdProcesses/control
new file mode 100644
index 0000000..8b27538
--- /dev/null
+++ b/client/site_tests/platform_CheckPowerdProcesses/control
@@ -0,0 +1,20 @@
+# Copyright 2014 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+AUTHOR = 'derat, gauravsh'
+NAME = 'platform_CheckPowerdProcesses'
+ATTRIBUTES = "suite:bvt-cq"
+TIME = 'SHORT'
+TEST_TYPE = 'client'
+JOB_RETRIES = 2
+
+DOC = """
+This test has a static list of process names that should be running
+on a good Chrome OS Core image with power management support. It
+fails if any of these are not running at the time of the test.
+"""
+
+POWERD_PROCESSES = ['powerd']
+
+job.run_test('platform_CheckCriticalProcesses', process_list=POWERD_PROCESSES)
diff --git a/client/site_tests/platform_CheckTLSDateProcesses/control b/client/site_tests/platform_CheckTLSDateProcesses/control
new file mode 100644
index 0000000..f6ae405
--- /dev/null
+++ b/client/site_tests/platform_CheckTLSDateProcesses/control
@@ -0,0 +1,20 @@
+# Copyright 2014 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+AUTHOR = 'drewry, gauravsh'
+NAME = 'platform_CheckTLSDateProcesses'
+ATTRIBUTES = "suite:bvt-cq"
+TIME = 'SHORT'
+TEST_TYPE = 'client'
+JOB_RETRIES = 2
+
+DOC = """
+This test has a static list of process names that should be running
+on a good Chrome OS Core image running with network time support. It
+fails if any of these are not running at the time of the test.
+"""
+
+TLSDATE_PROCESSES = ['tlsdated']
+
+job.run_test('platform_CheckCriticalProcesses', process_list=TLSDATE_PROCESSES)