summaryrefslogtreecommitdiff
path: root/cts
diff options
context:
space:
mode:
authorChris Chen <twothreecc@google.com>2016-07-11 14:52:05 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-07-15 21:39:16 -0700
commit846741eddbb28e6770532ab09fb64dc619c2f6e6 (patch)
tree2e8e9815341d82ff83214ba5b4d94ef6869bd748 /cts
parentdb1b3b34c21530672118754e84ddbe879925542e (diff)
downloadchrome-ec-846741eddbb28e6770532ab09fb64dc619c2f6e6.tar.gz
cts: Added GPIO test suite
Contains code for all the gpio tests so far. Code in cts_task for th and dut is for testing purposes and test result reporting will be updated in the next patch. BRANCH=None BUG=None TEST=Manual - Connect handshake and gpio test lines between th and dut - Build tests - run 'cat /dev/ttyACM0' in one terminal - run 'cat /def/ttyACM1' in another - Flash boards - All test results should print either passed or unknown Change-Id: I7142fb87a6ce0a20c571cde608fbbe60e35898ea Reviewed-on: https://chromium-review.googlesource.com/359935 Commit-Ready: Daisuke Nojiri <dnojiri@chromium.org> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'cts')
-rw-r--r--cts/common/dut_common.c1
-rw-r--r--cts/common/th_common.c1
-rwxr-xr-xcts/cts.py10
-rw-r--r--cts/gpio/dut.c99
-rw-r--r--cts/gpio/gpio_common.h21
-rw-r--r--cts/gpio/th.c97
6 files changed, 221 insertions, 8 deletions
diff --git a/cts/common/dut_common.c b/cts/common/dut_common.c
index f8c18fd81c..9b0561eaa9 100644
--- a/cts/common/dut_common.c
+++ b/cts/common/dut_common.c
@@ -7,6 +7,7 @@
#include "timer.h"
#include "watchdog.h"
#include "cts_common.h"
+#include "dut_common.h"
/* Returns unknown because TH could potentially still get stuck
* even if the DUT completes the sync
diff --git a/cts/common/th_common.c b/cts/common/th_common.c
index 1c75ef9dee..8e9bd47fa3 100644
--- a/cts/common/th_common.c
+++ b/cts/common/th_common.c
@@ -7,6 +7,7 @@
#include "timer.h"
#include "watchdog.h"
#include "cts_common.h"
+#include "th_common.h"
/* Return SUCCESS if and only if we reach end of function
* Returning success here means sync was successful
diff --git a/cts/cts.py b/cts/cts.py
index 9c4940b6ff..79550a9aff 100755
--- a/cts/cts.py
+++ b/cts/cts.py
@@ -106,19 +106,17 @@ def flash_boards(dut_board, th_serial_loc):
'flash write_image erase build/' + th_board + '/ec.bin 0x08000000',
'reset halt']
- dut_flash_cmds = ['reset_config connect_assert_srst',
+ dut_flash_cmds = ['hla_serial ' + dut_hla,
+ 'reset_config connect_assert_srst',
'init',
'reset init',
'flash write_image erase build/' + dut_board + '/ec.bin 0x08000000',
'reset halt']
- if dut_hla != None:
- dut_flash_cmds.insert(0, 'hla_serial ' + dut_hla)
-
openocd_cmd(th_flash_cmds, th_cfg)
openocd_cmd(dut_flash_cmds, dut_cfg)
- openocd_cmd(['init', 'reset init', 'resume'], th_cfg)
- openocd_cmd(['init', 'reset init', 'resume'], dut_cfg)
+ openocd_cmd(['hla_serial ' + th_hla, 'init', 'reset init', 'resume'], th_cfg)
+ openocd_cmd(['hla_serial ' + dut_hla, 'init', 'reset init', 'resume'], dut_cfg)
def main():
global ocd_script_dir
diff --git a/cts/gpio/dut.c b/cts/gpio/dut.c
index 7120a4da3e..c1b32ef0de 100644
--- a/cts/gpio/dut.c
+++ b/cts/gpio/dut.c
@@ -10,12 +10,109 @@
#include "watchdog.h"
#include "dut_common.h"
#include "cts_common.h"
+#include "gpio_common.h"
+
+enum cts_error_code sync_test(void)
+{
+ return SUCCESS;
+}
+
+enum cts_error_code set_high_test(void)
+{
+ gpio_set_flags(GPIO_OUTPUT_TEST, GPIO_ODR_LOW);
+ gpio_set_level(GPIO_OUTPUT_TEST, 1);
+ msleep(READ_WAIT_TIME_MS*2);
+ return UNKNOWN;
+}
+
+enum cts_error_code set_low_test(void)
+{
+ gpio_set_flags(GPIO_OUTPUT_TEST, GPIO_ODR_LOW);
+ gpio_set_level(GPIO_OUTPUT_TEST, 0);
+ msleep(READ_WAIT_TIME_MS*2);
+ return UNKNOWN;
+}
+
+enum cts_error_code read_high_test(void)
+{
+ int level;
+
+ gpio_set_flags(GPIO_INPUT_TEST, GPIO_INPUT | GPIO_PULL_UP);
+ msleep(READ_WAIT_TIME_MS);
+ level = gpio_get_level(GPIO_INPUT_TEST);
+ if (level)
+ return SUCCESS;
+ else
+ return FAILURE;
+}
+
+enum cts_error_code read_low_test(void)
+{
+ int level;
+
+ gpio_set_flags(GPIO_INPUT_TEST, GPIO_INPUT | GPIO_PULL_UP);
+ msleep(READ_WAIT_TIME_MS);
+ level = gpio_get_level(GPIO_INPUT_TEST);
+ if (!level)
+ return SUCCESS;
+ else
+ return FAILURE;
+}
+
+enum cts_error_code od_read_high_test(void)
+{
+ int level;
+
+ gpio_set_flags(GPIO_OUTPUT_TEST, GPIO_ODR_HIGH | GPIO_PULL_UP);
+ msleep(READ_WAIT_TIME_MS);
+ level = gpio_get_level(GPIO_OUTPUT_TEST);
+ if (!level)
+ return SUCCESS;
+ else
+ return FAILURE;
+}
void cts_task(void)
{
+ enum cts_error_code results[GPIO_CTS_TEST_COUNT];
+ int i;
+
+ sync();
+ results[0] = sync_test();
sync();
- CPRINTS("Successful Sync!");
+ results[1] = set_low_test();
+ sync();
+ results[2] = set_high_test();
+ sync();
+ results[3] = read_high_test();
+ sync();
+ results[4] = read_low_test();
+ sync();
+ results[5] = od_read_high_test();
+
+ CPRINTS("GPIO test suite finished");
uart_flush_output();
+ CPRINTS("Results:");
+ for (i = 0; i < GPIO_CTS_TEST_COUNT; i++) {
+ switch (results[i]) {
+ case SUCCESS:
+ CPRINTS("%d) Passed", i);
+ break;
+ case FAILURE:
+ CPRINTS("%d) Failed", i);
+ break;
+ case BAD_SYNC:
+ CPRINTS("%d) Bad sync", i);
+ break;
+ case UNKNOWN:
+ CPRINTS("%d) Test result unknown", i);
+ break;
+ default:
+ CPRINTS("%d) ErrorCode not recognized", i);
+ break;
+ }
+ }
+
while (1) {
watchdog_reload();
sleep(1);
diff --git a/cts/gpio/gpio_common.h b/cts/gpio/gpio_common.h
new file mode 100644
index 0000000000..b19d23165a
--- /dev/null
+++ b/cts/gpio/gpio_common.h
@@ -0,0 +1,21 @@
+/* Copyright 2016 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.
+ */
+
+#ifndef __GPIO_COMMON_H
+#define __GPIO_COMMON_H
+
+/* sync_test tests whether sync completes successfully
+ * set_low_test checks if the dut can set a line low
+ * set_high test checks if the dut can set a line high
+ * read_low_test checks if the dut can read a line that is low
+ * read_high_test checks if the dut can read a line that is high
+ * od_read_high_test checks if the dut reads its true pin level (success)
+ * or its register level when configured as a low open drain output pin
+ */
+
+#define READ_WAIT_TIME_MS 100
+#define GPIO_CTS_TEST_COUNT 6
+
+#endif
diff --git a/cts/gpio/th.c b/cts/gpio/th.c
index 7120a4da3e..ddc46f6602 100644
--- a/cts/gpio/th.c
+++ b/cts/gpio/th.c
@@ -10,12 +10,107 @@
#include "watchdog.h"
#include "dut_common.h"
#include "cts_common.h"
+#include "gpio_common.h"
+
+enum cts_error_code sync_test(void)
+{
+ return SUCCESS;
+}
+
+enum cts_error_code set_high_test(void)
+{
+ int level;
+
+ gpio_set_flags(GPIO_INPUT_TEST, GPIO_INPUT | GPIO_PULL_UP);
+ msleep(READ_WAIT_TIME_MS);
+ level = gpio_get_level(GPIO_INPUT_TEST);
+ if (level)
+ return SUCCESS;
+ else
+ return FAILURE;
+}
+
+enum cts_error_code set_low_test(void)
+{
+ int level;
+
+ gpio_set_flags(GPIO_INPUT_TEST, GPIO_INPUT | GPIO_PULL_UP);
+ msleep(READ_WAIT_TIME_MS);
+ level = gpio_get_level(GPIO_INPUT_TEST);
+ if (!level)
+ return SUCCESS;
+ else
+ return FAILURE;
+}
+
+enum cts_error_code read_high_test(void)
+{
+ gpio_set_flags(GPIO_OUTPUT_TEST, GPIO_ODR_LOW);
+ gpio_set_level(GPIO_OUTPUT_TEST, 1);
+ msleep(READ_WAIT_TIME_MS*2);
+ return UNKNOWN;
+}
+
+enum cts_error_code read_low_test(void)
+{
+ gpio_set_flags(GPIO_OUTPUT_TEST, GPIO_ODR_LOW);
+ gpio_set_level(GPIO_OUTPUT_TEST, 0);
+ msleep(READ_WAIT_TIME_MS*2);
+ return UNKNOWN;
+}
+
+enum cts_error_code od_read_high_test(void)
+{
+ gpio_set_flags(GPIO_INPUT_TEST, GPIO_OUTPUT | GPIO_ODR_LOW);
+ msleep(READ_WAIT_TIME_MS*2);
+ return UNKNOWN;
+}
void cts_task(void)
{
+ enum cts_error_code results[GPIO_CTS_TEST_COUNT];
+ int i;
+
+ /* Don't bother checking sync's return value now because
+ * host will deal with hanging syncs/tests as well as
+ * interpreting test results later
+ */
+ sync();
+ results[0] = sync_test();
sync();
- CPRINTS("Successful Sync!");
+ results[1] = set_low_test();
+ sync();
+ results[2] = set_high_test();
+ sync();
+ results[3] = read_high_test();
+ sync();
+ results[4] = read_low_test();
+ sync();
+ results[5] = od_read_high_test();
+
+ CPRINTS("GPIO test suite finished");
uart_flush_output();
+ CPRINTS("Results:");
+ for (i = 0; i < GPIO_CTS_TEST_COUNT; i++) {
+ switch (results[i]) {
+ case SUCCESS:
+ CPRINTS("%d) Passed", i);
+ break;
+ case FAILURE:
+ CPRINTS("%d) Failed", i);
+ break;
+ case BAD_SYNC:
+ CPRINTS("%d) Bad sync", i);
+ break;
+ case UNKNOWN:
+ CPRINTS("%d) Test result unknown", i);
+ break;
+ default:
+ CPRINTS("%d) ErrorCode not recognized", i);
+ break;
+ }
+ }
+
while (1) {
watchdog_reload();
sleep(1);