1 /*
2 * Copyright (c) 2021 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include <zephyr.h>
8 #include <device.h>
9 #include <ztest.h>
10
11 #include <drivers/edac.h>
12
13 /**
14 * EDAC dummy is used for coverage tests for -ENOSYS returns
15 */
16
edac_dummy_init(const struct device * dev)17 int edac_dummy_init(const struct device *dev)
18 {
19 return 0;
20 }
21
22 static const struct edac_driver_api edac_dummy_api = { 0 };
23
24 DEVICE_DEFINE(dummy_edac, "dummy_edac", edac_dummy_init, NULL,
25 NULL, NULL,
26 POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
27 &edac_dummy_api);
28
test_edac_dummy_api(void)29 void test_edac_dummy_api(void)
30 {
31 const struct device *dev = device_get_binding("dummy_edac");
32 uint64_t value;
33 int ret;
34
35 zassert_not_null(dev, "Device not found");
36
37 /* Error log API */
38
39 ret = edac_ecc_error_log_get(dev, &value);
40 zassert_equal(ret, -ENOSYS, "dummy api failed");
41
42 ret = edac_ecc_error_log_clear(dev);
43 zassert_equal(ret, -ENOSYS, "dummy api failed");
44
45 ret = edac_parity_error_log_get(dev, &value);
46 zassert_equal(ret, -ENOSYS, "dummy api failed");
47
48 ret = edac_parity_error_log_clear(dev);
49 zassert_equal(ret, -ENOSYS, "dummy api failed");
50
51 /* Error stat API */
52
53 ret = edac_errors_cor_get(dev);
54 zassert_equal(ret, -ENOSYS, "dummy api failed");
55
56 ret = edac_errors_uc_get(dev);
57 zassert_equal(ret, -ENOSYS, "dummy api failed");
58
59 /* Notification API */
60
61 /* It is OK to use NULL as a callback pointer */
62 ret = edac_notify_callback_set(dev, NULL);
63 zassert_equal(ret, -ENOSYS, "dummy api failed");
64
65 /* Injection API */
66
67 ret = edac_inject_set_param1(dev, 0x0);
68 zassert_equal(ret, -ENOSYS, "dummy api failed");
69
70 ret = edac_inject_get_param1(dev, &value);
71 zassert_equal(ret, -ENOSYS, "dummy api failed");
72
73 ret = edac_inject_set_param2(dev, 0x0);
74 zassert_equal(ret, -ENOSYS, "dummy api failed");
75
76 ret = edac_inject_get_param2(dev, &value);
77 zassert_equal(ret, -ENOSYS, "dummy api failed");
78
79 ret = edac_inject_set_error_type(dev, 0x0);
80 zassert_equal(ret, -ENOSYS, "dummy api failed");
81
82 ret = edac_inject_get_error_type(dev, (uint32_t *)&value);
83 zassert_equal(ret, -ENOSYS, "dummy api failed");
84
85 ret = edac_inject_error_trigger(dev);
86 zassert_equal(ret, -ENOSYS, "dummy api failed");
87 }
88