initial commit

This commit is contained in:
2022-10-23 23:45:43 -07:00
commit e190fa5193
6450 changed files with 8626944 additions and 0 deletions
@@ -0,0 +1,21 @@
#include "test_bss.h"
#define BYTES_TO_FILL 64
char bss_1[BYTES_TO_FILL];
char bss_2[BYTES_TO_FILL] = {0};
//
// test_bss
void test_bss( test_info_t** info ){
static test_info_t test_bss_info;
static char* test_bss_name = "BSS Zereo Fill";
test_bss_info.name = test_bss_name;
test_bss_info.passed = true;
*(info) = &test_bss_info;
for(size_t ix = 0; ix < BYTES_TO_FILL; ix++){
if(bss_1[ix] != 0){ test_bss_info.passed = false; }
if(bss_2[ix] != 0){ test_bss_info.passed = false; }
}
}
@@ -0,0 +1,8 @@
#ifndef _TEST_BSS_H_
#define _TEST_BSS_H_
#include "tests.h"
void test_bss( test_info_t** info );
#endif // _TEST_BSS_H_
@@ -0,0 +1,41 @@
#include "test_constructors.h"
#define STATE1 0x00
#define STATE2 0x01
#define STATE3 0xDD
#define STATE4 0xCC
/* A very simple class to test constructor execution */
class LEDSTATE {
private:
protected:
public:
uint8_t state; // Trivial initialization is 0
LEDSTATE(uint8_t init);
};
LEDSTATE::LEDSTATE(uint8_t init){
state=init;
}
// This object should be initialized with a non-zero state
LEDSTATE state1(STATE1);
LEDSTATE state2(STATE2);
LEDSTATE state3(STATE3);
//
// test_constructors
void test_constructors( test_info_t** info ){
static LEDSTATE state4(STATE4);
static test_info_t test_constructors_info;
static char* test_constructors_name = "Global / Static Constructors";
test_constructors_info.name = test_constructors_name;
test_constructors_info.passed = true;
*(info) = &test_constructors_info;
if(state1.state != STATE1){ test_constructors_info.passed = false; }
if(state2.state != STATE2){ test_constructors_info.passed = false; }
if(state3.state != STATE3){ test_constructors_info.passed = false; }
if(state4.state != STATE4){ test_constructors_info.passed = false; }
}
@@ -0,0 +1,8 @@
#ifndef _TEST_CONSTRUCTORS_H_
#define _TEST_CONSTRUCTORS_H_
#include "tests.h"
void test_constructors( test_info_t** info );
#endif // _TEST_CONSTRUCTORS_H_
@@ -0,0 +1,99 @@
#include "test_data.h"
#define BYTES_TO_COPY 8
// Automatially add some variables that won't be optimized
// away to fill up the number of requested bytes
#ifdef BYTES_TO_COPY
#if BYTES_TO_COPY > 0
#define VAR11 0xDE
#endif
#if BYTES_TO_COPY > 1
#define VAR12 0xAD
#endif
#if BYTES_TO_COPY > 2
#define VAR13 0xBE
#endif
#if BYTES_TO_COPY > 3
#define VAR14 0xEF
#endif
#if BYTES_TO_COPY > 4
#define VAR21 0xC0
#endif
#if BYTES_TO_COPY > 5
#define VAR22 0xFE
#endif
#if BYTES_TO_COPY > 6
#define VAR23 0xE6
#endif
#if BYTES_TO_COPY > 7
#define VAR24 0x0D
#endif
#endif // BYTES_TO_COPY
#ifdef BYTES_TO_COPY
static volatile char data[] = {
#if BYTES_TO_COPY > 0
VAR11,
#endif
#if BYTES_TO_COPY > 1
VAR12,
#endif
#if BYTES_TO_COPY > 2
VAR13,
#endif
#if BYTES_TO_COPY > 3
VAR14,
#endif
#if BYTES_TO_COPY > 4
VAR21,
#endif
#if BYTES_TO_COPY > 5
VAR22,
#endif
#if BYTES_TO_COPY > 6
VAR23,
#endif
#if BYTES_TO_COPY > 7
VAR24,
#endif
};
#endif // BYTES_TO_COPY
//
// test_data
void test_data( test_info_t** info ){
static test_info_t test_data_info;
static char* test_data_name = "Data Segment Copy";
test_data_info.name = test_data_name;
test_data_info.passed = true;
*(info) = &test_data_info;
// Verify that all bytes were copied into RAM correctly
#ifdef BYTES_TO_COPY
#if BYTES_TO_COPY > 0
if( data[0] != VAR11 ){ test_data_info.passed = false; }
#endif
#if BYTES_TO_COPY > 1
if( data[1] != VAR12 ){ test_data_info.passed = false; }
#endif
#if BYTES_TO_COPY > 2
if( data[2] != VAR13 ){ test_data_info.passed = false; }
#endif
#if BYTES_TO_COPY > 3
if( data[3] != VAR14 ){ test_data_info.passed = false; }
#endif
#if BYTES_TO_COPY > 4
if( data[4] != VAR21 ){ test_data_info.passed = false; }
#endif
#if BYTES_TO_COPY > 5
if( data[5] != VAR22 ){ test_data_info.passed = false; }
#endif
#if BYTES_TO_COPY > 6
if( data[6] != VAR23 ){ test_data_info.passed = false; }
#endif
#if BYTES_TO_COPY > 7
if( data[7] != VAR24 ){ test_data_info.passed = false; }
#endif
#endif // BYTES_TO_COPY
}
@@ -0,0 +1,8 @@
#ifndef _TEST_DATA_H_
#define _TEST_DATA_H_
#include "tests.h"
void test_data( test_info_t** info );
#endif // _TEST_DATA_H_
@@ -0,0 +1,21 @@
#include "test_fn_init.h"
#define VAL 0xFA
char init_fn( void ){
return VAL;
}
char var = init_fn();
//
// test_fn_init
void test_fn_init( test_info_t** info ){
static test_info_t test_fn_init_info;
static char* test_fn_init_name = "Initialization of Global by Function";
test_fn_init_info.name = test_fn_init_name;
test_fn_init_info.passed = true;
*(info) = &test_fn_init_info;
if( var != VAL ){ test_fn_init_info.passed = false; }
}
@@ -0,0 +1,8 @@
#ifndef _TEST_FN_INIT_H_
#define _TEST_FN_INIT_H_
#include "tests.h"
void test_fn_init( test_info_t** info );
#endif // _TEST_FN_INIT_H_
@@ -0,0 +1,30 @@
#include "tests.h"
test_fn tests[] = {
test_data,
test_bss,
test_constructors,
test_fn_init,
// test_fail,
// test_pass,
NULL, // NULL terminates the list
};
// test definitions
void test_fail( test_info_t** info ){
static test_info_t test_fail_info;
static char* test_fail_name = "Fail Test";
test_fail_info.name = test_fail_name;
test_fail_info.passed = false;
*(info) = &test_fail_info;
}
void test_pass( test_info_t** info ){
static test_info_t test_pass_info;
static char* test_pass_name = "Pass Test";
test_pass_info.name = test_pass_name;
test_pass_info.passed = true;
*(info) = &test_pass_info;
}
@@ -0,0 +1,20 @@
// test definitions
#ifndef _TESTS_H_
#define _TESTS_H_
#include "test_framework.h"
// included tests
#include "test_data.h"
#include "test_bss.h"
#include "test_constructors.h"
#include "test_fn_init.h"
// simple tests
void test_fail( test_info_t** info );
void test_pass( test_info_t** info );
// list of tests to run
extern test_fn tests[];
#endif // _TESTS_H_