Software APIs
coverage_test.c
1 // Copyright lowRISC contributors (OpenTitan project).
2 // Licensed under the Apache License, Version 2.0, see LICENSE for details.
3 // SPDX-License-Identifier: Apache-2.0
4 
5 #include "sw/device/lib/testing/test_framework/coverage.h"
6 
7 #include <stdbool.h>
8 #include <stdint.h>
9 
15 
16 static void spin_45(uint8_t state) {
17  static const char kSpinnerChars[] = "|/-\\";
18  base_printf("%c\r", kSpinnerChars[state]);
19 }
20 
21 static void spin_180(void) {
22  for (uint8_t state = 0; state < 4; ++state) {
23  spin_45(state);
24  busy_spin_micros(100 * 1000); // 0.1s
25  }
26 }
27 
28 OTTF_DEFINE_TEST_CONFIG();
29 
30 /**
31  * A simple program for testing the coverage functionality.
32  *
33  * Prints a message and displays a spinning bar.
34  */
35 bool test_main(void) {
36  // Print an assuring message.
37  LOG_INFO("Collecting coverage data.");
38  // Display a spinning bar.
39  for (uint8_t i = 0; i < 4; ++i) {
40  spin_180();
41  }
42  return true;
43 }