1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/* Copyright 2022 The ChromiumOS Authors.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include <zephyr/shell/shell.h>
#include <zephyr/ztest.h>
#include "console.h"
#include "ec_commands.h"
#include "include/lpc.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
struct console_cmd_hostevent_fixture {
struct host_events_ctx ctx;
};
static void *console_cmd_hostevent_setup(void)
{
static struct console_cmd_hostevent_fixture fixture = { 0 };
return &fixture;
}
static void console_cmd_hostevent_before(void *fixture)
{
struct console_cmd_hostevent_fixture *f = fixture;
host_events_save(&f->ctx);
}
static void console_cmd_hostevent_after(void *fixture)
{
struct console_cmd_hostevent_fixture *f = fixture;
host_events_restore(&f->ctx);
}
/* hostevent with no arguments */
ZTEST_USER(console_cmd_hostevent, test_hostevent)
{
zassert_ok(shell_execute_cmd(get_ec_shell(), "hostevent"),
"Failed default print");
}
/* hostevent with invalid arguments */
ZTEST_USER(console_cmd_hostevent, test_hostevent_invalid)
{
int rv;
/* Test invalid sub-command */
rv = shell_execute_cmd(get_ec_shell(), "hostevent invalid 0xFFFF");
zassert_equal(rv, EC_ERROR_PARAM1, "Expected %d, but got %d",
EC_ERROR_PARAM1, rv);
/* Test invalid mask */
rv = shell_execute_cmd(get_ec_shell(), "hostevent set invalid-mask");
zassert_equal(rv, EC_ERROR_PARAM2, "Expected %d, but got %d",
EC_ERROR_PARAM2, rv);
}
ZTEST_SUITE(console_cmd_hostevent, drivers_predicate_post_main,
console_cmd_hostevent_setup, console_cmd_hostevent_before,
console_cmd_hostevent_after, NULL);
|