source: rtems/testsuites/validation/tr-io-kernel.c @ f6a38fb

Last change on this file since f6a38fb was f6a38fb, checked in by Sebastian Huber <sebastian.huber@…>, on 08/05/22 at 13:35:33

validation: Use T_report_hash_sha256_update()

Add the direct BSP character ouput to the report hash.

Update #3716.

  • Property mode set to 100644
File size: 3.5 KB
RevLine 
[134b4cb7]1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup RTEMSTestCaseRtemsIoValKernel
7 */
8
9/*
10 * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de)
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 *    notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 *    notice, this list of conditions and the following disclaimer in the
19 *    documentation and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/*
35 * This file is part of the RTEMS quality process and was automatically
36 * generated.  If you find something that needs to be fixed or
37 * worded better please post a report or patch to an RTEMS mailing list
38 * or raise a bug report:
39 *
40 * https://www.rtems.org/bugs.html
41 *
42 * For information on updating and regenerating please refer to the How-To
43 * section in the Software Requirements Engineering chapter of the
44 * RTEMS Software Engineering manual.  The manual is provided as a part of
45 * a release.  For development sources please refer to the online
46 * documentation at:
47 *
48 * https://docs.rtems.org
49 */
50
51#ifdef HAVE_CONFIG_H
52#include "config.h"
53#endif
54
55#include <rtems/bspIo.h>
56
57#include "tr-io-kernel.h"
58
59#include <rtems/test.h>
60
61/**
62 * @defgroup RTEMSTestCaseRtemsIoValKernel spec:/rtems/io/val/kernel
63 *
64 * @ingroup RTEMSTestSuiteTestsuitesValidationIoKernel
65 *
66 * @brief Tests the functions referenced by BSP_output_char and BSP_poll_char.
67 *
68 * This test case performs the following actions:
69 *
70 * - Call the function referenced by BSP_output_char.
71 *
72 * - If BSP_poll_char references a function, then call it.
73 *
74 *   - Check that the returned value is minus one or an unsigned character
75 *     value.
76 *
77 * @{
78 */
79
80/**
81 * @brief Call the function referenced by BSP_output_char.
82 */
83static void RtemsIoValKernel_Action_0( void )
84{
[f6a38fb]85  T_report_hash_sha256_update( 'X' );
[134b4cb7]86  ( *BSP_output_char )( 'X' );
[f6a38fb]87  T_report_hash_sha256_update( '\n' );
[134b4cb7]88  ( *BSP_output_char )( '\n' );
89}
90
91/**
92 * @brief If BSP_poll_char references a function, then call it.
93 */
94static void RtemsIoValKernel_Action_1( void )
95{
96  BSP_polling_getchar_function_type poll_char;
97  int c;
98
99  poll_char = BSP_poll_char;
100
101  if ( poll_char != NULL ) {
102    c = ( *poll_char )();
103  } else {
104    c = -1;
105  }
106
107  /*
108   * Check that the returned value is minus one or an unsigned character value.
109   */
110  T_step_true( 0, c == -1 || ( c & ~0xff ) == 0 );
111}
112
113void RtemsIoValKernel_Run( void )
114{
115  T_case_begin( "RtemsIoValKernel", &T_empty_fixture );
116
117  T_plan( 1 );
118
119  RtemsIoValKernel_Action_0();
120  RtemsIoValKernel_Action_1();
121
122  T_case_end();
123}
124
125/** @} */
Note: See TracBrowser for help on using the repository browser.