<commit_before>/* Copyright 2022 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.
 */

#include <shell/shell.h>
#include <ztest.h>

#include "console.h"
#include "ec_commands.h"
#include "test/drivers/test_state.h"

static void console_cmd_accelinfo_after(void *fixture)
{
	ARG_UNUSED(fixture);
	shell_execute_cmd(get_ec_shell(), "accelinfo off");
}

ZTEST_SUITE(console_cmd_accelinfo, drivers_predicate_post_main, NULL, NULL,
	    console_cmd_accelinfo_after, NULL);

ZTEST_USER(console_cmd_accelinfo, test_too_many_args)
{
	int rv = shell_execute_cmd(get_ec_shell(), "accelinfo arg1 arg2");

	zassert_equal(rv, EC_ERROR_PARAM_COUNT, "Expected %d, but got %d",
		      EC_ERROR_PARAM_COUNT, rv);
}

ZTEST_USER(console_cmd_accelinfo, test_print_once)
{
	zassert_ok(shell_execute_cmd(get_ec_shell(), "accelinfo"), NULL);
}

ZTEST_USER(console_cmd_accelinfo, test_invalid_arg)
{
	int rv = shell_execute_cmd(get_ec_shell(), "accelinfo bar");

	zassert_equal(rv, EC_ERROR_PARAM1, "Expected %d, but got %d",
		      EC_ERROR_PARAM1, rv);
}

ZTEST_USER(console_cmd_accelinfo, test_enable_disable)
{
	/*
	 * There's no way to verify what is being printed to the console yet, so
	 * just assert that the command executed and returned 0.
	 */
	zassert_ok(shell_execute_cmd(get_ec_shell(), "accelinfo on"), NULL);
	zassert_ok(shell_execute_cmd(get_ec_shell(), "accelinfo off"), NULL);
}<commit_msg>test: cover logic to print accelinfo in motionsense loop<commit_after>/* Copyright 2022 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.
 */

#include <shell/shell.h>
#include <ztest.h>

#include "config.h"
#include "console.h"
#include "ec_commands.h"
#include "test/drivers/test_state.h"
#include "timer.h"

static void console_cmd_accelinfo_after(void *fixture)
{
	ARG_UNUSED(fixture);
	shell_execute_cmd(get_ec_shell(), "accelinfo off");
}

ZTEST_SUITE(console_cmd_accelinfo, drivers_predicate_post_main, NULL, NULL,
	    console_cmd_accelinfo_after, NULL);

ZTEST_USER(console_cmd_accelinfo, test_too_many_args)
{
	int rv = shell_execute_cmd(get_ec_shell(), "accelinfo arg1 arg2");

	zassert_equal(rv, EC_ERROR_PARAM_COUNT, "Expected %d, but got %d",
		      EC_ERROR_PARAM_COUNT, rv);
}

ZTEST_USER(console_cmd_accelinfo, test_print_once)
{
	zassert_ok(shell_execute_cmd(get_ec_shell(), "accelinfo"), NULL);
}

ZTEST_USER(console_cmd_accelinfo, test_invalid_arg)
{
	int rv = shell_execute_cmd(get_ec_shell(), "accelinfo bar");

	zassert_equal(rv, EC_ERROR_PARAM1, "Expected %d, but got %d",
		      EC_ERROR_PARAM1, rv);
}

ZTEST_USER(console_cmd_accelinfo, test_enable_disable)
{
	/*
	 * There's no way to verify what is being printed to the console yet, so
	 * just assert that the command executed and returned 0.
	 */
	zassert_ok(shell_execute_cmd(get_ec_shell(), "accelinfo on"), NULL);
	k_msleep(CONFIG_MOTION_MIN_SENSE_WAIT_TIME * MSEC * 2);

	zassert_ok(shell_execute_cmd(get_ec_shell(), "accelinfo off"), NULL);
}
{'fraction_non_alphanumeric': 0.10968569595894805, 'fraction_numerical': 0.006093649775497113, 'mean_word_length': 6.088636363636364, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1078002', 'n_tokens_mistral': 1175, 'n_tokens_neox': 1137, 'n_words': 263}