summaryrefslogtreecommitdiff
path: root/zephyr/test/drivers/default/src/console_cmd/version.c
blob: e3606b5d0e1677e12c6f4f37f7348fcfa63d4f0a (plain)
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
/* 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 "console.h"
#include "system.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"

#include <zephyr/drivers/emul.h>
#include <zephyr/shell/shell_dummy.h>
#include <zephyr/ztest.h>

ZTEST_USER(console_cmd_version, test_no_args)
{
	const struct shell *shell_zephyr = get_ec_shell();
	const char *outbuffer;
	size_t buffer_size;

	shell_backend_dummy_clear_output(shell_zephyr);

	zassert_ok(shell_execute_cmd(shell_zephyr, "version"), NULL);
	outbuffer = shell_backend_dummy_get_output(shell_zephyr, &buffer_size);

	zassert_true(buffer_size > 0, NULL);

	/* Weakly verify some contents */
	zassert_not_null(strstr(outbuffer, "Chip:"), NULL);
	zassert_not_null(strstr(outbuffer, "Board:"), NULL);
	zassert_not_null(strstr(outbuffer, "RO:"), NULL);
	zassert_not_null(strstr(outbuffer, "RW:"), NULL);
	zassert_not_null(strstr(outbuffer, "Build:"), NULL);
}

ZTEST_SUITE(console_cmd_version, drivers_predicate_post_main, NULL, NULL, NULL,
	    NULL);