aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dediprog.c
diff options
context:
space:
mode:
authorAnastasia Klimchuk <aklm@chromium.org>2022-06-30 15:25:04 +1000
committerAnastasia Klimchuk <aklm@chromium.org>2022-07-10 22:28:45 +0000
commit94efa4454225ca09db5c12dfcd2b6057dd1682bf (patch)
treeee266104cbe106a473b340ac019026f15b73f39e /tests/dediprog.c
parent2aafc1fda5c917fc85e020414b0af2cc8c841417 (diff)
downloadflashrom-94efa4454225ca09db5c12dfcd2b6057dd1682bf.tar.gz
flashrom-94efa4454225ca09db5c12dfcd2b6057dd1682bf.tar.bz2
flashrom-94efa4454225ca09db5c12dfcd2b6057dd1682bf.zip
tests: Split lifecycle test file into per-programmer files
This patch creates individual files for each programmer's lifecycle tests. Common functions that are reusable for all tests are gathered in lifecycle.c. Each individual file needs to include lifecycle.h BUG=b:237606255 TEST=ninja test Change-Id: If2307699dcbb3a085b91a2dcd41156e6fd07f812 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/65543 Reviewed-by: Peter Marheine <pmarheine@chromium.org> Reviewed-by: Felix Singer <felixsinger@posteo.net> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Thomas Heijligen <src@posteo.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'tests/dediprog.c')
-rw-r--r--tests/dediprog.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/dediprog.c b/tests/dediprog.c
new file mode 100644
index 00000000..26b1e751
--- /dev/null
+++ b/tests/dediprog.c
@@ -0,0 +1,58 @@
+/*
+ * This file is part of the flashrom project.
+ *
+ * Copyright 2021 Google LLC
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include "lifecycle.h"
+
+#if CONFIG_DEDIPROG == 1
+static int dediprog_libusb_init(void *state, libusb_context **ctx)
+{
+ *ctx = not_null();
+ return 0;
+}
+
+static int dediprog_libusb_control_transfer(void *state,
+ libusb_device_handle *devh,
+ uint8_t bmRequestType,
+ uint8_t bRequest,
+ uint16_t wValue,
+ uint16_t wIndex,
+ unsigned char *data,
+ uint16_t wLength,
+ unsigned int timeout)
+{
+ if (bRequest == 0x08 /* dediprog_cmds CMD_READ_PROG_INFO */) {
+ /* Provide dediprog Device String into data buffer */
+ memcpy(data, "SF600 V:7.2.2 ", wLength);
+ }
+ return wLength;
+}
+
+void dediprog_basic_lifecycle_test_success(void **state)
+{
+ struct io_mock_fallback_open_state dediprog_fallback_open_state = {
+ .noc = 0,
+ .paths = { NULL },
+ };
+ const struct io_mock dediprog_io = {
+ .libusb_init = dediprog_libusb_init,
+ .libusb_control_transfer = dediprog_libusb_control_transfer,
+ .fallback_open_state = &dediprog_fallback_open_state,
+ };
+
+ run_basic_lifecycle(state, &dediprog_io, &programmer_dediprog, "voltage=3.5V");
+}
+#else
+ SKIP_TEST(dediprog_basic_lifecycle_test_success)
+#endif /* CONFIG_DEDIPROG */