Fix checkpatch issue - ERROR:OPEN_BRACE

The open braces of the 'if','for', 'while' and 'do' statements should be at the end on the
same line of the statement to comply with the defined coding style. E.g.:

	if (x is true) {
		we do y
	}

Change accomplished with the following script:

	#!/bin/bash

	checkpatch_script="$VXMICRO_BASE/scripts/checkpatch.pl --mailback --no-tree -f --emacs --summary-file --show-types --ignore BRACES,PRINTK_WITHOUT_KERN_LEVEL,SPLIT_STRING --max-line-length=100 "

	for file in $(find ./ -name "*.[ch]" ! -path "./scripts/*" ! -path "./host/src/wrsconfig/*" ! -path "*/outdir/*");
	do
		if [ ! -h $file ];
		then
			# obtaining the line's number where the error is reported in a reversed order
			reversed_lines="";
			for line in $(eval $checkpatch_script $file | grep "ERROR:OPEN_BRACE" | cut -d":" -f2)
			do
				reversed_lines="$line $reversed_lines";
			done;

			# fixing the issues in reverse order due to lines can be deleted affecting futher lines
			for line_reported in $(echo $reversed_lines);
			do
				# search for the line where the open brace is
				char_found="";
				let line=$line_reported-1;
				while [ ${#char_found} -eq 0 ]
				do
					let line=$line+1;
					char_found="$(sed -n ''$line' { /{/ p }' $file)";
				done

				let statement_line=$line-1;
				let brace_line=$line;

				# condition to avoid modifying lines that ends with the character "\"
				char_found="$(sed -n ''$statement_line' { /\\$/ p }' $file)";
				if [ ${#char_found} -eq 0 ];
				then
					# fix the issue
					echo "$file : reported on $line_reported (found on $brace_line -> moved to $statement_line)";
					sed -i ''$statement_line' { s/[ \t]*$//; s/\([ \t]*\/\*.*\*\/\)$/ {\1/; /{/ b already_done s/$/ {/; :already_done }; '$brace_line' { s/{[ \t]*//; /^[ \t]*$/ d }; ' $file;
				fi
			done
		fi
	done;

Change-Id: I517c40bb33840ef531f2319354350f578b238abb
Signed-off-by: Yonattan Louise <yonattan.a.louise.mendoza@intel.com>
This commit is contained in:
Yonattan Louise 2015-05-11 10:10:41 -05:00 committed by Anas Nashif
commit 3f1439bf2d
71 changed files with 702 additions and 1390 deletions

View file

@ -46,8 +46,7 @@ int main (
char *argv[] char *argv[]
) )
{ {
if (argc != 2) if (argc != 2) {
{
usage (argv[0]); usage (argv[0]);
return -1; return -1;
} }

View file

@ -82,16 +82,14 @@ static void close_files(void);
static void genIdt(void); static void genIdt(void);
static void clean_exit(const int exit_code); static void clean_exit(const int exit_code);
typedef struct s_isrList typedef struct s_isrList {
{
void *fnc; void *fnc;
unsigned int dpl; unsigned int dpl;
} ISR_LIST; } ISR_LIST;
static ISR_LIST idt[256]; static ISR_LIST idt[256];
enum enum {
{
IFILE=0, /* input file */ IFILE=0, /* input file */
OFILE, /* output file */ OFILE, /* output file */
NUSERFILES, /* number of user-provided file names */ NUSERFILES, /* number of user-provided file names */
@ -120,10 +118,8 @@ static void get_options(int argc, char *argv[])
char *endptr; char *endptr;
int ii, opt; int ii, opt;
while ((opt = getopt(argc, argv, "hi:o:n:v")) != -1) while ((opt = getopt(argc, argv, "hi:o:n:v")) != -1) {
{ switch(opt) {
switch(opt)
{
case 'i': case 'i':
filenames[IFILE] = optarg; filenames[IFILE] = optarg;
break; break;
@ -151,16 +147,13 @@ static void get_options(int argc, char *argv[])
} }
} }
if ((unsigned int)-1 == numVecs) if ((unsigned int)-1 == numVecs) {
{
usage(SHORT_USAGE); usage(SHORT_USAGE);
exit(-1); exit(-1);
} }
for(ii = IFILE; ii < NUSERFILES; ii++) for(ii = IFILE; ii < NUSERFILES; ii++) {
{ if (!filenames[ii]) {
if (!filenames[ii])
{
usage(SHORT_USAGE); usage(SHORT_USAGE);
exit(-1); exit(-1);
} }
@ -171,8 +164,7 @@ static void get_exec_name(char *pathname)
{ {
int end = strlen(pathname)-1; int end = strlen(pathname)-1;
while(end != -1) while(end != -1) {
{
#if defined (WINDOWS) /* Might have both slashes in path */ #if defined (WINDOWS) /* Might have both slashes in path */
if (pathname[end] == '/' || pathname[end] == '\\') if (pathname[end] == '/' || pathname[end] == '\\')
#else #else
@ -196,15 +188,12 @@ static void open_files(void)
fds[IFILE] = open(filenames[IFILE], O_RDONLY|O_BINARY); fds[IFILE] = open(filenames[IFILE], O_RDONLY|O_BINARY);
fds[OFILE] = open(filenames[OFILE], O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, fds[OFILE] = open(filenames[OFILE], O_WRONLY|O_CREAT|O_TRUNC|O_BINARY,
S_IWUSR|S_IRUSR); S_IWUSR|S_IRUSR);
for(ii = 0; ii < NUSERFILES; ii++) for(ii = 0; ii < NUSERFILES; ii++) {
{
int invalid = fds[ii] == -1; int invalid = fds[ii] == -1;
if (invalid) if (invalid) {
{
char *invalid = filenames[ii]; char *invalid = filenames[ii];
fprintf(stderr, "invalid file %s\n", invalid); fprintf(stderr, "invalid file %s\n", invalid);
for(--ii; ii >= 0; ii--) for(--ii; ii >= 0; ii--) {
{
close(fds[ii]); close(fds[ii]);
} }
exit (-1); exit (-1);
@ -233,8 +222,7 @@ static void genIdt(void)
spurAddr, spurNoErrAddr); spurAddr, spurNoErrAddr);
/* Initially fill in the IDT array with the spurious handlers */ /* Initially fill in the IDT array with the spurious handlers */
for (i = 0; i < numVecs; i++) for (i = 0; i < numVecs; i++) {
{
if ((((1 << i) & _EXC_ERROR_CODE_FAULTS)) && (i < 32)) if ((((1 << i) & _EXC_ERROR_CODE_FAULTS)) && (i < 32))
idt[i].fnc = spurAddr; idt[i].fnc = spurAddr;
else else
@ -251,15 +239,13 @@ static void genIdt(void)
PRINTF ("There are %d ISR(s)\n", size); PRINTF ("There are %d ISR(s)\n", size);
if (size > numVecs) if (size > numVecs) {
{
fprintf (stderr, "Too many ISRs found. Got %u. Expected less than %u." fprintf (stderr, "Too many ISRs found. Got %u. Expected less than %u."
" Malformed input file?\n", size, numVecs); " Malformed input file?\n", size, numVecs);
clean_exit(-1); clean_exit(-1);
} }
while (size--) while (size--) {
{
void *addr; void *addr;
unsigned int vec; unsigned int vec;
unsigned int dpl; unsigned int dpl;
@ -284,8 +270,7 @@ static void genIdt(void)
* Now construct the actual idt. * Now construct the actual idt.
*/ */
for (i = 0; i < numVecs; i++) for (i = 0; i < numVecs; i++) {
{
unsigned long long idtEnt; unsigned long long idtEnt;
_IdtEntCreate (&idtEnt, idt[i].fnc, idt[i].dpl); _IdtEntCreate (&idtEnt, idt[i].fnc, idt[i].dpl);
@ -304,8 +289,7 @@ static void close_files(void)
{ {
int ii; int ii;
for(ii = 0; ii < NUSERFILES; ii++) for(ii = 0; ii < NUSERFILES; ii++) {
{
close(fds[ii]); close(fds[ii]);
} }
} }
@ -322,8 +306,7 @@ static void usage(const int len)
"\n%s -i <input file> -n <n>\n", "\n%s -i <input file> -n <n>\n",
filenames[EXECFILE]); filenames[EXECFILE]);
if (len == SHORT_USAGE) if (len == SHORT_USAGE) {
{
return; return;
} }

View file

@ -56,8 +56,7 @@ typedef unsigned int Elf32_Word;
#define EI_NIDENT 16 #define EI_NIDENT 16
typedef struct typedef struct {
{
unsigned char e_ident[EI_NIDENT]; unsigned char e_ident[EI_NIDENT];
Elf32_Half e_type; Elf32_Half e_type;
Elf32_Half e_machine; Elf32_Half e_machine;
@ -179,8 +178,7 @@ typedef struct
/* /*
* Section header * Section header
*/ */
typedef struct typedef struct {
{
Elf32_Word sh_name; Elf32_Word sh_name;
Elf32_Word sh_type; /* SHT_... */ Elf32_Word sh_type; /* SHT_... */
Elf32_Word sh_flags; /* SHF_... */ Elf32_Word sh_flags; /* SHF_... */
@ -240,8 +238,7 @@ typedef struct
/* /*
* Symbol table * Symbol table
*/ */
typedef struct typedef struct {
{
Elf32_Word st_name; Elf32_Word st_name;
Elf32_Addr st_value; Elf32_Addr st_value;
Elf32_Word st_size; Elf32_Word st_size;
@ -289,14 +286,12 @@ typedef struct
/* /*
* Relocation * Relocation
*/ */
typedef struct typedef struct {
{
Elf32_Addr r_offset; Elf32_Addr r_offset;
Elf32_Word r_info; Elf32_Word r_info;
} Elf32_Rel; } Elf32_Rel;
typedef struct typedef struct {
{
Elf32_Addr r_offset; Elf32_Addr r_offset;
Elf32_Word r_info; Elf32_Word r_info;
Elf32_Sword r_addend; Elf32_Sword r_addend;
@ -309,8 +304,7 @@ typedef struct
/* /*
* Program header * Program header
*/ */
typedef struct typedef struct {
{
Elf32_Word p_type; Elf32_Word p_type;
Elf32_Off p_offset; Elf32_Off p_offset;
Elf32_Addr p_vaddr; Elf32_Addr p_vaddr;
@ -344,11 +338,9 @@ typedef struct
#define PF_R 0x4 #define PF_R 0x4
#define PF_MASKPROC 0xf0000000 #define PF_MASKPROC 0xf0000000
typedef struct typedef struct {
{
Elf32_Sword d_tag; Elf32_Sword d_tag;
union union {
{
Elf32_Word d_val; Elf32_Word d_val;
Elf32_Addr d_ptr; Elf32_Addr d_ptr;
} d_un; } d_un;

View file

@ -197,8 +197,7 @@ static Elf32_Shdr *shdr; /* pointer to array ELF section headers */
static void swabElfHdr(Elf32_Ehdr *pHdrToSwab) static void swabElfHdr(Elf32_Ehdr *pHdrToSwab)
{ {
if (swabRequired == 0) if (swabRequired == 0) {
{
return; /* do nothing */ return; /* do nothing */
} }
@ -226,8 +225,7 @@ static void swabElfHdr(Elf32_Ehdr *pHdrToSwab)
static void swabElfSectionHdr(Elf32_Shdr *pHdrToSwab) static void swabElfSectionHdr(Elf32_Shdr *pHdrToSwab)
{ {
if (swabRequired == 0) if (swabRequired == 0) {
{
return; /* do nothing */ return; /* do nothing */
} }
@ -253,8 +251,7 @@ static void swabElfSectionHdr(Elf32_Shdr *pHdrToSwab)
static void swabElfSym(Elf32_Sym *pHdrToSwab) static void swabElfSym(Elf32_Sym *pHdrToSwab)
{ {
if (swabRequired == 0) if (swabRequired == 0) {
{
return; /* do nothing */ return; /* do nothing */
} }
@ -280,24 +277,21 @@ static int ehdrLoad(int fd /* file descriptor of file from which to read */
lseek (fd, 0, SEEK_SET); lseek (fd, 0, SEEK_SET);
nBytes = read (fd, &ehdr, sizeof (ehdr)); nBytes = read (fd, &ehdr, sizeof (ehdr));
if (nBytes != sizeof (ehdr)) if (nBytes != sizeof (ehdr)) {
{
fprintf (stderr, "Failed to read ELF header\n"); fprintf (stderr, "Failed to read ELF header\n");
return -1; return -1;
} }
/* perform some rudimentary ELF file validation */ /* perform some rudimentary ELF file validation */
if (strncmp ((char *)ehdr.e_ident, ELFMAG, 4) != 0) if (strncmp ((char *)ehdr.e_ident, ELFMAG, 4) != 0) {
{
fprintf (stderr, "Input object module not ELF format\n"); fprintf (stderr, "Input object module not ELF format\n");
return -1; return -1;
} }
/* 64-bit ELF module not supported (for now) */ /* 64-bit ELF module not supported (for now) */
if (ehdr.e_ident[EI_CLASS] != ELFCLASS32) if (ehdr.e_ident[EI_CLASS] != ELFCLASS32) {
{
fprintf (stderr, "ELF64 class not supported\n"); fprintf (stderr, "ELF64 class not supported\n");
return -1; return -1;
} }
@ -309,8 +303,7 @@ static int ehdrLoad(int fd /* file descriptor of file from which to read */
*/ */
if (((*(char *)&ix == 0x78) && (ehdr.e_ident[EI_DATA] == ELFDATA2MSB)) || if (((*(char *)&ix == 0x78) && (ehdr.e_ident[EI_DATA] == ELFDATA2MSB)) ||
((*(char *)&ix == 0x12) && (ehdr.e_ident[EI_DATA] == ELFDATA2LSB))) ((*(char *)&ix == 0x12) && (ehdr.e_ident[EI_DATA] == ELFDATA2LSB))) {
{
swabRequired = 1; swabRequired = 1;
DBG_PRINT ("Swab required\n"); DBG_PRINT ("Swab required\n");
} }
@ -341,8 +334,7 @@ int shdrsLoad(int fd /* file descriptor of file from which to read */
unsigned ix; /* loop index */ unsigned ix; /* loop index */
shdr = malloc (ehdr.e_shnum * sizeof (Elf32_Shdr)); shdr = malloc (ehdr.e_shnum * sizeof (Elf32_Shdr));
if (shdr == NULL) if (shdr == NULL) {
{
fprintf (stderr, "No memory for section headers!\n"); fprintf (stderr, "No memory for section headers!\n");
return -1; return -1;
} }
@ -350,11 +342,9 @@ int shdrsLoad(int fd /* file descriptor of file from which to read */
/* Seek to the start of the table of section headers */ /* Seek to the start of the table of section headers */
lseek (fd, ehdr.e_shoff, SEEK_SET); lseek (fd, ehdr.e_shoff, SEEK_SET);
for (ix = 0; ix < ehdr.e_shnum; ix++) for (ix = 0; ix < ehdr.e_shnum; ix++) {
{
nBytes = read (fd, &shdr[ix], sizeof (Elf32_Shdr)); nBytes = read (fd, &shdr[ix], sizeof (Elf32_Shdr));
if (nBytes != sizeof (Elf32_Shdr)) if (nBytes != sizeof (Elf32_Shdr)) {
{
fprintf (stderr, "Unable to read entire section header (#%d)\n", fprintf (stderr, "Unable to read entire section header (#%d)\n",
ix); ix);
return -1; return -1;
@ -382,10 +372,8 @@ int symTblFind(unsigned *pSymTblOffset, /* ptr to symbol table offset */
{ {
unsigned ix; /* loop index */ unsigned ix; /* loop index */
for (ix = 0; ix < ehdr.e_shnum; ++ix) for (ix = 0; ix < ehdr.e_shnum; ++ix) {
{ if (shdr[ix].sh_type == SHT_SYMTAB) {
if (shdr[ix].sh_type == SHT_SYMTAB)
{
*pSymTblOffset = shdr[ix].sh_offset; *pSymTblOffset = shdr[ix].sh_offset;
*pSymTblSize = shdr[ix].sh_size; *pSymTblSize = shdr[ix].sh_size;
@ -425,20 +413,16 @@ int strTblFind(unsigned *pStrTblIx /* ptr to string table's index */
unsigned strTblIx = 0xffffffff; unsigned strTblIx = 0xffffffff;
unsigned ix; unsigned ix;
for (ix = 0; ix < ehdr.e_shnum; ++ix) for (ix = 0; ix < ehdr.e_shnum; ++ix) {
{ if (shdr[ix].sh_type == SHT_STRTAB) {
if (shdr[ix].sh_type == SHT_STRTAB)
{
if ((strTblIx == 0xffffffff) || if ((strTblIx == 0xffffffff) ||
(ix != ehdr.e_shstrndx)) (ix != ehdr.e_shstrndx)) {
{
strTblIx = ix; strTblIx = ix;
} }
} }
} }
if (strTblIx == 0xffffffff) if (strTblIx == 0xffffffff) {
{
fprintf (stderr, "Object module missing string table!\n"); fprintf (stderr, "Object module missing string table!\n");
return -1; return -1;
} }
@ -467,8 +451,7 @@ int strTblLoad(int fd, /* file descriptor of file from which to read */
shdr[strTblIx].sh_size); shdr[strTblIx].sh_size);
pTable = malloc (shdr[strTblIx].sh_size); pTable = malloc (shdr[strTblIx].sh_size);
if (pTable == NULL) if (pTable == NULL) {
{
fprintf (stderr, "No memory for string table!"); fprintf (stderr, "No memory for string table!");
return -1; return -1;
} }
@ -476,8 +459,7 @@ int strTblLoad(int fd, /* file descriptor of file from which to read */
lseek (fd, shdr[strTblIx].sh_offset, SEEK_SET); lseek (fd, shdr[strTblIx].sh_offset, SEEK_SET);
nBytes = read (fd, pTable, shdr[strTblIx].sh_size); nBytes = read (fd, pTable, shdr[strTblIx].sh_size);
if (nBytes != shdr[strTblIx].sh_size) if (nBytes != shdr[strTblIx].sh_size) {
{
free (pTable); free (pTable);
fprintf (stderr, "Unable to read entire string table!\n"); fprintf (stderr, "Unable to read entire string table!\n");
return -1; return -1;
@ -514,8 +496,7 @@ void headerPreambleDump(FILE *fp, /* file pointer to which to write */
* of the hash should be unique enough for our purposes. * of the hash should be unique enough for our purposes.
*/ */
for (ix = 0; ix < sizeof(filename); ++ix) for (ix = 0; ix < sizeof(filename); ++ix) {
{
hash = (hash * 33) + (unsigned int) filename[ix]; hash = (hash * 33) + (unsigned int) filename[ix];
} }
@ -546,8 +527,7 @@ void headerAbsoluteSymbolsDump(int fd, /* file descriptor of file from which t
numSyms = symTblSize / sizeof(Elf32_Sym); numSyms = symTblSize / sizeof(Elf32_Sym);
lseek (fd, symTblOffset, SEEK_SET); lseek (fd, symTblOffset, SEEK_SET);
for (ix = 0; ix < numSyms; ++ix) for (ix = 0; ix < numSyms; ++ix) {
{
/* read in a single symbol structure */ /* read in a single symbol structure */
read (fd, &aSym, sizeof(Elf32_Sym)); read (fd, &aSym, sizeof(Elf32_Sym));
@ -560,13 +540,11 @@ void headerAbsoluteSymbolsDump(int fd, /* file descriptor of file from which t
*/ */
if ((aSym.st_shndx == SHN_ABS) && if ((aSym.st_shndx == SHN_ABS) &&
(ELF_ST_BIND(aSym.st_info) == STB_GLOBAL)) (ELF_ST_BIND(aSym.st_info) == STB_GLOBAL)) {
{
if ((strstr (&pStringTable[aSym.st_name], if ((strstr (&pStringTable[aSym.st_name],
STRUCT_OFF_SUFFIX) != NULL) || STRUCT_OFF_SUFFIX) != NULL) ||
(strstr (&pStringTable[aSym.st_name], (strstr (&pStringTable[aSym.st_name],
STRUCT_SIZ_SUFFIX) != NULL)) STRUCT_SIZ_SUFFIX) != NULL)) {
{
fprintf (fp, "#define\t%s\t0x%X\n", fprintf (fp, "#define\t%s\t0x%X\n",
&pStringTable[aSym.st_name], aSym.st_value); &pStringTable[aSym.st_name], aSym.st_value);
} }
@ -610,16 +588,13 @@ int main(int argc, char *argv[])
/* argument parsing */ /* argument parsing */
if (argc != 5) if (argc != 5) {
{
fprintf (stderr, usage, argv[0]); fprintf (stderr, usage, argv[0]);
goto errorReturn; goto errorReturn;
} }
while ((option = getopt (argc, argv, "i:o:")) != -1) while ((option = getopt (argc, argv, "i:o:")) != -1) {
{ switch (option) {
switch (option)
{
case 'i': case 'i':
inFileName = optarg; inFileName = optarg;
break; break;
@ -636,16 +611,14 @@ int main(int argc, char *argv[])
inFd = open (inFileName, OPEN_FLAGS); inFd = open (inFileName, OPEN_FLAGS);
if (inFd == -1) if (inFd == -1) {
{
fprintf (stderr, "Cannot open input object module"); fprintf (stderr, "Cannot open input object module");
goto errorReturn; goto errorReturn;
} }
outFile = fopen (outFileName, "w"); outFile = fopen (outFileName, "w");
if (outFile == NULL) if (outFile == NULL) {
{
fprintf (stderr, "Cannot open output header file"); fprintf (stderr, "Cannot open output header file");
goto errorReturn; goto errorReturn;
} }
@ -664,8 +637,7 @@ int main(int argc, char *argv[])
(shdrsLoad (inFd) != 0) || (shdrsLoad (inFd) != 0) ||
(symTblFind (&symTblOffset, &symTblSize) != 0) || (symTblFind (&symTblOffset, &symTblSize) != 0) ||
(strTblFind (&strTblIx) != 0) || (strTblFind (&strTblIx) != 0) ||
(strTblLoad (inFd, strTblIx, &pStringTable) != 0)) (strTblLoad (inFd, strTblIx, &pStringTable) != 0)) {
{
goto errorReturn; goto errorReturn;
} }
@ -692,23 +664,19 @@ int main(int argc, char *argv[])
return 0; return 0;
errorReturn: errorReturn:
if (inFd != -1) if (inFd != -1) {
{
close (inFd); close (inFd);
} }
if (outFile != NULL) if (outFile != NULL) {
{
fclose (outFile); fclose (outFile);
} }
if (shdr != NULL) if (shdr != NULL) {
{
free (shdr); free (shdr);
} }
if (pStringTable != NULL) if (pStringTable != NULL) {
{
free (pStringTable); free (pStringTable);
} }

View file

@ -57,8 +57,7 @@ int main (
{ {
int i, j; int i, j;
if (argc != 2) if (argc != 2) {
{
usage (argv[0]); usage (argv[0]);
return -1; return -1;
} }

View file

@ -75,8 +75,7 @@ typedef unsigned char __attribute__((aligned(_INT_STUB_ALIGN)))
NANO_INT_STUB[_INT_STUB_SIZE]; NANO_INT_STUB[_INT_STUB_SIZE];
typedef struct s_isrList typedef struct s_isrList {
{
void *fnc; /* Address of ISR/stub */ void *fnc; /* Address of ISR/stub */
unsigned int vec; /* Vector number associated with ISR/stub */ unsigned int vec; /* Vector number associated with ISR/stub */
unsigned int dpl; /* Privilege level associated with ISR/stub */ unsigned int dpl; /* Privilege level associated with ISR/stub */

View file

@ -87,8 +87,7 @@ static void workload_loop(void)
/* loop never terminates, except during calibration phase */ /* loop never terminates, except during calibration phase */
while (++_k_workload_i != _k_workload_n1) while (++_k_workload_i != _k_workload_n1) {
{
unsigned int s_iCountDummyProc = 0; unsigned int s_iCountDummyProc = 0;
while (64 != s_iCountDummyProc++) { /* 64 == 2^6 */ while (64 != s_iCountDummyProc++) { /* 64 == 2^6 */
x >>= y; x >>= y;

View file

@ -133,8 +133,7 @@ void _k_sem_group_wait_cancel(struct k_args *A)
struct k_args *Y = NULL; struct k_args *Y = NULL;
while (X && (X->Prio <= A->Prio)) { while (X && (X->Prio <= A->Prio)) {
if (X->Ctxt.args == A->Ctxt.args) if (X->Ctxt.args == A->Ctxt.args) {
{
if (Y) if (Y)
Y->Forw = X->Forw; Y->Forw = X->Forw;
else else
@ -197,8 +196,7 @@ void _k_sem_group_wait_accept(struct k_args *A)
struct k_args *Y = NULL; struct k_args *Y = NULL;
while (X && (X->Prio <= A->Prio)) { while (X && (X->Prio <= A->Prio)) {
if (X->Ctxt.args == A->Ctxt.args) if (X->Ctxt.args == A->Ctxt.args) {
{
if (Y) if (Y)
Y->Forw = X->Forw; Y->Forw = X->Forw;
else else
@ -311,8 +309,7 @@ void _k_sem_group_wait_request(struct k_args *A)
struct k_args *Y = NULL; struct k_args *Y = NULL;
while (X && (X->Prio <= A->Prio)) { while (X && (X->Prio <= A->Prio)) {
if (X->Ctxt.args == A->Ctxt.args) if (X->Ctxt.args == A->Ctxt.args) {
{
if (Y) if (Y)
Y->Forw = X->Forw; Y->Forw = X->Forw;
else else

View file

@ -87,8 +87,7 @@ void _k_task_monitor_args(struct k_args *A)
{ {
k_monitor_wptr->time = timer_read(); k_monitor_wptr->time = timer_read();
if ((uint32_t)A < _k_num_events) if ((uint32_t)A < _k_num_events) {
{
k_monitor_wptr->data2 = MO_EVENT | (uint32_t)A; k_monitor_wptr->data2 = MO_EVENT | (uint32_t)A;
} }
else { else {

View file

@ -77,16 +77,14 @@ typedef void (*vvpfn)(void *); /* void-void_pointer function pointer */
* filled in after calling irq_connect(). * filled in after calling irq_connect().
*/ */
static char sw_isr_trigger_0[] = static char sw_isr_trigger_0[] = {
{
0xcd, /* OPCODE: INT imm8 */ 0xcd, /* OPCODE: INT imm8 */
0x00, /* imm8 data (vector to trigger) filled in at runtime */ 0x00, /* imm8 data (vector to trigger) filled in at runtime */
0xc3 /* OPCODE: RET (near) */ 0xc3 /* OPCODE: RET (near) */
}; };
#if NUM_SW_IRQS >= 2 #if NUM_SW_IRQS >= 2
static char sw_isr_trigger_1[] = static char sw_isr_trigger_1[] = {
{
/* same as above */ /* same as above */
0xcd, 0xcd,
0x00, 0x00,
@ -111,8 +109,7 @@ static inline void sw_isr_trigger_1(void)
#endif /* CONFIG_CPU_CORTEXM */ #endif /* CONFIG_CPU_CORTEXM */
#endif #endif
struct isrInitInfo struct isrInitInfo {
{
vvpfn isr[2]; vvpfn isr[2];
void *arg[2]; void *arg[2];
}; };
@ -131,24 +128,20 @@ static int initIRQ
#if defined(VXMICRO_ARCH_x86) #if defined(VXMICRO_ARCH_x86)
int vector; /* vector to which interrupt is connected */ int vector; /* vector to which interrupt is connected */
if (i->isr[0]) if (i->isr[0]) {
{
vector = irq_connect (NANO_SOFT_IRQ, IRQ_PRIORITY, i->isr[0], vector = irq_connect (NANO_SOFT_IRQ, IRQ_PRIORITY, i->isr[0],
i->arg[0], nanoIntStub1); i->arg[0], nanoIntStub1);
if (-1 == vector) if (-1 == vector) {
{
return -1; return -1;
} }
sw_isr_trigger_0[1] = vector; sw_isr_trigger_0[1] = vector;
} }
#if NUM_SW_IRQS >= 2 #if NUM_SW_IRQS >= 2
if (i->isr[1]) if (i->isr[1]) {
{
vector = irq_connect (NANO_SOFT_IRQ, IRQ_PRIORITY, i->isr[1], vector = irq_connect (NANO_SOFT_IRQ, IRQ_PRIORITY, i->isr[1],
i->arg[1], nanoIntStub2); i->arg[1], nanoIntStub2);
if (-1 == vector) if (-1 == vector) {
{
return -1; return -1;
} }
sw_isr_trigger_1[1] = vector; sw_isr_trigger_1[1] = vector;
@ -156,13 +149,11 @@ static int initIRQ
#endif /* NUM_SW_IRQS >= 2 */ #endif /* NUM_SW_IRQS >= 2 */
#elif defined(VXMICRO_ARCH_arm) #elif defined(VXMICRO_ARCH_arm)
#if defined(CONFIG_CPU_CORTEXM) #if defined(CONFIG_CPU_CORTEXM)
if (i->isr[0]) if (i->isr[0]) {
{
(void) irq_connect (0, IRQ_PRIORITY, i->isr[0], i->arg[0]); (void) irq_connect (0, IRQ_PRIORITY, i->isr[0], i->arg[0]);
irq_enable (0); irq_enable (0);
} }
if (i->isr[1]) if (i->isr[1]) {
{
(void) irq_connect (1, IRQ_PRIORITY, i->isr[1], i->arg[1]); (void) irq_connect (1, IRQ_PRIORITY, i->isr[1], i->arg[1]);
irq_enable (1); irq_enable (1);
} }

View file

@ -62,8 +62,7 @@
*/ */
void helloLoop(const char *taskname, ksem_t mySem, ksem_t otherSem) void helloLoop(const char *taskname, ksem_t mySem, ksem_t otherSem)
{ {
while (1) while (1) {
{
task_sem_take_wait (mySem); task_sem_take_wait (mySem);
/* say "hello" */ /* say "hello" */
@ -121,8 +120,7 @@ void fiberEntry(void)
nano_sem_init (&nanoSemFiber); nano_sem_init (&nanoSemFiber);
nano_timer_init (&timer, data); nano_timer_init (&timer, data);
while (1) while (1) {
{
/* wait for task to let us have a turn */ /* wait for task to let us have a turn */
nano_fiber_sem_take_wait (&nanoSemFiber); nano_fiber_sem_take_wait (&nanoSemFiber);
@ -147,8 +145,7 @@ void main(void)
nano_sem_init (&nanoSemTask); nano_sem_init (&nanoSemTask);
nano_timer_init (&timer, data); nano_timer_init (&timer, data);
while (1) while (1) {
{
/* say "hello" */ /* say "hello" */
PRINT ("%s: Hello World!\n", __FUNCTION__); PRINT ("%s: Hello World!\n", __FUNCTION__);

View file

@ -132,19 +132,16 @@ void philEntry (void)
irq_unlock (pri); irq_unlock (pri);
/* always take the lowest fork first */ /* always take the lowest fork first */
if ((id+1) != N_PHILOSOPHERS) if ((id+1) != N_PHILOSOPHERS) {
{
f1 = FORK (id); f1 = FORK (id);
f2 = FORK (id + 1); f2 = FORK (id + 1);
} }
else else {
{
f1 = FORK (0); f1 = FORK (0);
f2 = FORK (id); f2 = FORK (id);
} }
while (1) while (1) {
{
TAKE (f1); TAKE (f1);
TAKE (f2); TAKE (f2);

View file

@ -79,8 +79,7 @@ int main (void)
PRINTF (DEMO_DESCRIPTION, "fibers", "nanokernel"); PRINTF (DEMO_DESCRIPTION, "fibers", "nanokernel");
for (i = 0; i < N_PHILOSOPHERS; i++) for (i = 0; i < N_PHILOSOPHERS; i++) {
{
nano_sem_init (&forks[i]); nano_sem_init (&forks[i]);
nano_task_sem_give (&forks[i]); nano_task_sem_give (&forks[i]);
} }
@ -91,8 +90,7 @@ int main (void)
(nano_fiber_entry_t) philEntry, 0, 0, 6, 0); (nano_fiber_entry_t) philEntry, 0, 0, 6, 0);
/* wait forever */ /* wait forever */
while (1) while (1) {
{
extern void nano_cpu_idle (void); extern void nano_cpu_idle (void);
nano_cpu_idle (); nano_cpu_idle ();
} }
@ -113,8 +111,7 @@ void philDemo (void)
task_group_start (PHI); task_group_start (PHI);
/* wait forever */ /* wait forever */
while (1) while (1) {
{
task_sleep (10000); task_sleep (10000);
} }
} }

View file

@ -73,12 +73,10 @@ void event_test (void)
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
et = BENCH_START (); et = BENCH_START ();
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) {
{
nReturn = task_event_send (TEST_EVENT); nReturn = task_event_send (TEST_EVENT);
#ifdef EVENT_CHECK #ifdef EVENT_CHECK
if (nReturn != RC_OK) if (nReturn != RC_OK) {
{
PRINT_STRING (EventSignalErr, output_file); PRINT_STRING (EventSignalErr, output_file);
return; /* error */ return; /* error */
} }
@ -91,12 +89,10 @@ void event_test (void)
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_EVENT_RUNS)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_EVENT_RUNS));
et = BENCH_START (); et = BENCH_START ();
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) {
{
nReturn = task_event_send (TEST_EVENT); nReturn = task_event_send (TEST_EVENT);
#ifdef EVENT_CHECK #ifdef EVENT_CHECK
if (nReturn != RC_OK) if (nReturn != RC_OK) {
{
PRINT_STRING (EventSignalErr, output_file); PRINT_STRING (EventSignalErr, output_file);
task_sleep (SLEEP_TIME); task_sleep (SLEEP_TIME);
return; /* error */ return; /* error */
@ -104,8 +100,7 @@ void event_test (void)
#endif /* EVENT_CHECK */ #endif /* EVENT_CHECK */
nReturn = task_event_recv (TEST_EVENT); nReturn = task_event_recv (TEST_EVENT);
#ifdef EVENT_CHECK #ifdef EVENT_CHECK
if (nReturn != RC_OK) if (nReturn != RC_OK) {
{
PRINT_STRING (EventTestErr, output_file); PRINT_STRING (EventTestErr, output_file);
task_sleep (SLEEP_TIME); task_sleep (SLEEP_TIME);
return; /* error */ return; /* error */
@ -119,20 +114,17 @@ void event_test (void)
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_EVENT_RUNS)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_EVENT_RUNS));
et = BENCH_START (); et = BENCH_START ();
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) {
{
nReturn = task_event_send (TEST_EVENT); nReturn = task_event_send (TEST_EVENT);
#ifdef EVENT_CHECK #ifdef EVENT_CHECK
if (nReturn != RC_OK) if (nReturn != RC_OK) {
{
PRINT_STRING (EventSignalErr, output_file); PRINT_STRING (EventSignalErr, output_file);
return; /* error */ return; /* error */
} }
#endif /* EVENT_CHECK */ #endif /* EVENT_CHECK */
nReturn = task_event_recv_wait (TEST_EVENT); nReturn = task_event_recv_wait (TEST_EVENT);
#ifdef EVENT_CHECK #ifdef EVENT_CHECK
if (nReturn != RC_OK) if (nReturn != RC_OK) {
{
PRINT_STRING (EventTestErr, output_file); PRINT_STRING (EventTestErr, output_file);
return; /* error */ return; /* error */
} }
@ -147,25 +139,21 @@ void event_test (void)
PRINT_STRING ("| Signal event with installed handler" PRINT_STRING ("| Signal event with installed handler"
" |\n", output_file); " |\n", output_file);
nReturn = task_event_set_handler (TEST_EVENT, example_handler); nReturn = task_event_set_handler (TEST_EVENT, example_handler);
if (nReturn != RC_OK) if (nReturn != RC_OK) {
{
PRINT_F (output_file, "-------- Error installing event handler.\n"); PRINT_F (output_file, "-------- Error installing event handler.\n");
task_sleep (SLEEP_TIME); task_sleep (SLEEP_TIME);
return; /* error */ return; /* error */
} }
for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) for (nCounter = 0; nCounter < NR_OF_EVENT_RUNS; nCounter++) {
{
nReturn = task_event_send (TEST_EVENT); nReturn = task_event_send (TEST_EVENT);
#ifdef EVENT_CHECK #ifdef EVENT_CHECK
if (nReturn != RC_OK) if (nReturn != RC_OK) {
{
PRINT_STRING (EventSignalErr, output_file); PRINT_STRING (EventSignalErr, output_file);
task_sleep (SLEEP_TIME); task_sleep (SLEEP_TIME);
return; /* error */ return; /* error */
} }
if (nEventValue != TEST_EVENT + 1) if (nEventValue != TEST_EVENT + 1) {
{
PRINT_STRING (EventHandlerErr, output_file); PRINT_STRING (EventHandlerErr, output_file);
task_sleep (SLEEP_TIME); task_sleep (SLEEP_TIME);
return; /* error */ return; /* error */
@ -175,8 +163,7 @@ void event_test (void)
} }
nReturn = task_event_set_handler (TEST_EVENT, NULL); nReturn = task_event_set_handler (TEST_EVENT, NULL);
if (nReturn != RC_OK) if (nReturn != RC_OK) {
{
PRINT_F (output_file, "Error removing event handler.\n"); PRINT_F (output_file, "Error removing event handler.\n");
task_sleep (SLEEP_TIME); task_sleep (SLEEP_TIME);
return; /* error */ return; /* error */

View file

@ -50,8 +50,7 @@ void queue_test (void)
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
{
task_fifo_put_wait (DEMOQX1, data_bench); task_fifo_put_wait (DEMOQX1, data_bench);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
@ -60,8 +59,7 @@ void queue_test (void)
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_FIFO_RUNS)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_FIFO_RUNS));
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
{
task_fifo_get_wait (DEMOQX1, data_bench); task_fifo_get_wait (DEMOQX1, data_bench);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
@ -71,8 +69,7 @@ void queue_test (void)
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_FIFO_RUNS)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_FIFO_RUNS));
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
{
task_fifo_put_wait (DEMOQX4, data_bench); task_fifo_put_wait (DEMOQX4, data_bench);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
@ -82,8 +79,7 @@ void queue_test (void)
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_FIFO_RUNS)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_FIFO_RUNS));
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
{
task_fifo_get_wait (DEMOQX4, data_bench); task_fifo_get_wait (DEMOQX4, data_bench);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
@ -95,8 +91,7 @@ void queue_test (void)
task_sem_give (STARTRCV); task_sem_give (STARTRCV);
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
{
task_fifo_put_wait (DEMOQX1, data_bench); task_fifo_put_wait (DEMOQX1, data_bench);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
@ -107,8 +102,7 @@ void queue_test (void)
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_FIFO_RUNS)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_FIFO_RUNS));
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_FIFO_RUNS; i++) for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
{
task_fifo_put_wait (DEMOQX4, data_bench); task_fifo_put_wait (DEMOQX4, data_bench);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);

View file

@ -49,13 +49,11 @@ void dequtask (void)
{ {
int x, i; int x, i;
for (i = 0; i < NR_OF_FIFO_RUNS; i++) for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
{
task_fifo_get_wait (DEMOQX1, &x); task_fifo_get_wait (DEMOQX1, &x);
} }
for (i = 0; i < NR_OF_FIFO_RUNS; i++) for (i = 0; i < NR_OF_FIFO_RUNS; i++) {
{
task_fifo_get_wait (DEMOQX4, &x); task_fifo_get_wait (DEMOQX4, &x);
} }
} }

View file

@ -130,8 +130,7 @@ void mailbox_test (void)
task_fifo_get_wait (MB_COMM, &getinfo); /* waiting for ack */ task_fifo_get_wait (MB_COMM, &getinfo); /* waiting for ack */
PRINT_ONE_RESULT (); PRINT_ONE_RESULT ();
EmptyMsgPutTime = puttime; EmptyMsgPutTime = puttime;
for (putsize = 8; putsize <= MESSAGE_SIZE; putsize <<= 1) for (putsize = 8; putsize <= MESSAGE_SIZE; putsize <<= 1) {
{
mailbox_put (putsize, putcount, &puttime); mailbox_put (putsize, putcount, &puttime);
task_fifo_get_wait (MB_COMM, &getinfo); /* waiting for ack */ task_fifo_get_wait (MB_COMM, &getinfo); /* waiting for ack */
PRINT_ONE_RESULT (); PRINT_ONE_RESULT ();
@ -167,8 +166,7 @@ void mailbox_put (
/* first sync with the receiver */ /* first sync with the receiver */
task_sem_give (SEM0); task_sem_give (SEM0);
t = BENCH_START (); t = BENCH_START ();
for (i = 0; i < count; i++) for (i = 0; i < count; i++) {
{
task_mbox_put_wait (MAILB1, 1, &Message); task_mbox_put_wait (MAILB1, 1, &Message);
} }
t = TIME_STAMP_DELTA_GET (t); t = TIME_STAMP_DELTA_GET (t);

View file

@ -71,8 +71,7 @@ void mailrecvtask (void)
getinfo.count = getcount; getinfo.count = getcount;
task_fifo_put_wait (MB_COMM, &getinfo); /* acknowledge to master */ task_fifo_put_wait (MB_COMM, &getinfo); /* acknowledge to master */
for (getsize = 8; getsize <= MESSAGE_SIZE; getsize <<= 1) for (getsize = 8; getsize <= MESSAGE_SIZE; getsize <<= 1) {
{
mailbox_get (MAILB1, getsize, getcount, &gettime); mailbox_get (MAILB1, getsize, getcount, &gettime);
getinfo.time = gettime; getinfo.time = gettime;
getinfo.size = getsize; getinfo.size = getsize;
@ -109,8 +108,7 @@ int mailbox_get (
/* sync with the sender */ /* sync with the sender */
task_sem_take_wait (SEM0); task_sem_take_wait (SEM0);
t = BENCH_START (); t = BENCH_START ();
for (i = 0; i < count; i++) for (i = 0; i < count; i++) {
{
task_mbox_get_wait (mailbox, &Message); task_mbox_get_wait (mailbox, &Message);
} }

View file

@ -45,8 +45,8 @@ char Msg[MAX_MSG];
char data_bench[OCTET_TO_SIZEOFUNIT (MESSAGE_SIZE)]; char data_bench[OCTET_TO_SIZEOFUNIT (MESSAGE_SIZE)];
#ifdef PIPE_BENCH #ifdef PIPE_BENCH
kpipe_t TestPipes[] = kpipe_t TestPipes[] = {
{PIPE_NOBUFF, PIPE_SMALLBUFF, PIPE_BIGBUFF}; PIPE_NOBUFF, PIPE_SMALLBUFF, PIPE_BIGBUFF};
#endif #endif
const char dashline[] = const char dashline[] =
"|--------------------------------------" "|--------------------------------------"
@ -135,8 +135,7 @@ void BenchTask (void)
bench_test_init (); bench_test_init ();
PRINT_STRING (newline, output_file); PRINT_STRING (newline, output_file);
do do {
{
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
PRINT_STRING ("| S I M P L E S E R V I C E " PRINT_STRING ("| S I M P L E S E R V I C E "
"M E A S U R E M E N T S | nsec |\n", "M E A S U R E M E N T S | nsec |\n",

View file

@ -53,8 +53,7 @@ void memorymap_test (void)
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_MAP_RUNS; i++) for (i = 0; i < NR_OF_MAP_RUNS; i++) {
{
task_mem_map_alloc_wait (MAP1, &p); task_mem_map_alloc_wait (MAP1, &p);
task_mem_map_free (MAP1, &p); task_mem_map_free (MAP1, &p);
} }

View file

@ -51,8 +51,7 @@ void mempool_test (void)
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_POOL_RUNS; i++) for (i = 0; i < NR_OF_POOL_RUNS; i++) {
{
task_mem_pool_alloc_wait (&block, DEMOPOOL, 16); task_mem_pool_alloc_wait (&block, DEMOPOOL, 16);
task_mem_pool_free (&block); task_mem_pool_free (&block);
} }

View file

@ -50,8 +50,7 @@ void mutex_test (void)
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_MUTEX_RUNS; i++) for (i = 0; i < NR_OF_MUTEX_RUNS; i++) {
{
task_mutex_lock_wait (DEMO_MUTEX); task_mutex_lock_wait (DEMO_MUTEX);
task_mutex_unlock (DEMO_MUTEX); task_mutex_unlock (DEMO_MUTEX);
} }

View file

@ -49,8 +49,7 @@ void call_test (void)
int i; int i;
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_NOP_RUNS; i++) for (i = 0; i < NR_OF_NOP_RUNS; i++) {
{
_task_nop(); _task_nop();
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);

View file

@ -165,18 +165,15 @@ void pipe_test (void)
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
/* Test with two different sender priorities */ /* Test with two different sender priorities */
for (prio = 0; prio < 2; prio++) for (prio = 0; prio < 2; prio++) {
{
/* non-buffered operation, non-matching (1_TO_N) */ /* non-buffered operation, non-matching (1_TO_N) */
if (prio == 0) if (prio == 0) {
{
PRINT_STRING ("| " PRINT_STRING ("| "
"non-matching sizes (1_TO_N) to higher priority" "non-matching sizes (1_TO_N) to higher priority"
" |\n", output_file); " |\n", output_file);
TaskPrio = task_priority_get (); TaskPrio = task_priority_get ();
} }
if (prio == 1) if (prio == 1) {
{
PRINT_STRING ("| " PRINT_STRING ("| "
"non-matching sizes (1_TO_N) to lower priority" "non-matching sizes (1_TO_N) to lower priority"
" |\n", output_file); " |\n", output_file);
@ -230,8 +227,7 @@ int pipeput (
/* first sync with the receiver */ /* first sync with the receiver */
task_sem_give (SEM0); task_sem_give (SEM0);
t = BENCH_START (); t = BENCH_START ();
for (i = 0; _1_TO_N == option || (i < count); i++) for (i = 0; _1_TO_N == option || (i < count); i++) {
{
int sizexferd = 0; int sizexferd = 0;
int size2xfer = min(size, size2xfer_total - sizexferd_total); int size2xfer = min(size, size2xfer_total - sizexferd_total);
int ret; int ret;
@ -253,15 +249,12 @@ int pipeput (
t = TIME_STAMP_DELTA_GET (t); t = TIME_STAMP_DELTA_GET (t);
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG (t, count); *time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG (t, count);
if (bench_test_end () < 0) if (bench_test_end () < 0) {
{ if (high_timer_overflow ()) {
if (high_timer_overflow ())
{
PRINT_STRING ("| Timer overflow. Results are invalid ", PRINT_STRING ("| Timer overflow. Results are invalid ",
output_file); output_file);
} }
else else {
{
PRINT_STRING ("| Tick occured. Results may be inaccurate ", PRINT_STRING ("| Tick occured. Results may be inaccurate ",
output_file); output_file);
} }

View file

@ -68,8 +68,7 @@ void piperecvtask (void)
/* matching (ALL_N) */ /* matching (ALL_N) */
for (getsize = 8; getsize <= MESSAGE_SIZE_PIPE; getsize <<= 1) { for (getsize = 8; getsize <= MESSAGE_SIZE_PIPE; getsize <<= 1) {
for (pipe = 0; pipe < 3; pipe++) for (pipe = 0; pipe < 3; pipe++) {
{
getcount = NR_OF_PIPE_RUNS; getcount = NR_OF_PIPE_RUNS;
pipeget (TestPipes[pipe], _ALL_N, getsize, pipeget (TestPipes[pipe], _ALL_N, getsize,
getcount, &gettime); getcount, &gettime);
@ -80,14 +79,11 @@ void piperecvtask (void)
} }
} }
for (prio = 0; prio < 2; prio++) for (prio = 0; prio < 2; prio++) {
{
/* non-matching (1_TO_N) */ /* non-matching (1_TO_N) */
for (getsize = (MESSAGE_SIZE_PIPE); getsize >= 8; getsize >>= 1) for (getsize = (MESSAGE_SIZE_PIPE); getsize >= 8; getsize >>= 1) {
{
getcount = MESSAGE_SIZE_PIPE / getsize; getcount = MESSAGE_SIZE_PIPE / getsize;
for (pipe = 0; pipe < 3; pipe++) for (pipe = 0; pipe < 3; pipe++) {
{
/* size*count == MESSAGE_SIZE_PIPE */ /* size*count == MESSAGE_SIZE_PIPE */
pipeget (TestPipes[pipe], _1_TO_N, pipeget (TestPipes[pipe], _1_TO_N,
getsize, getcount, &gettime); getsize, getcount, &gettime);
@ -127,8 +123,7 @@ int pipeget (
/* sync with the sender */ /* sync with the sender */
task_sem_take_wait (SEM0); task_sem_take_wait (SEM0);
t = BENCH_START (); t = BENCH_START ();
for (i = 0; _1_TO_N == option || (i < count); i++) for (i = 0; _1_TO_N == option || (i < count); i++) {
{
int sizexferd = 0; int sizexferd = 0;
int size2xfer = min(size, size2xfer_total - sizexferd_total); int size2xfer = min(size, size2xfer_total - sizexferd_total);
int ret; int ret;
@ -151,15 +146,12 @@ int pipeget (
t = TIME_STAMP_DELTA_GET (t); t = TIME_STAMP_DELTA_GET (t);
*time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG (t, count); *time = SYS_CLOCK_HW_CYCLES_TO_NS_AVG (t, count);
if (bench_test_end () < 0) if (bench_test_end () < 0) {
{ if (high_timer_overflow ()) {
if (high_timer_overflow ())
{
PRINT_STRING ("| Timer overflow. Results are invalid ", PRINT_STRING ("| Timer overflow. Results are invalid ",
output_file); output_file);
} }
else else {
{
PRINT_STRING ("| Tick occured. Results may be inaccurate ", PRINT_STRING ("| Tick occured. Results may be inaccurate ",
output_file); output_file);
} }

View file

@ -41,8 +41,7 @@
#include "receiver.h" #include "receiver.h"
char data_recv[OCTET_TO_SIZEOFUNIT (MESSAGE_SIZE)] = char data_recv[OCTET_TO_SIZEOFUNIT (MESSAGE_SIZE)] = {
{
0 0
}; };

View file

@ -38,8 +38,7 @@
#include "memcfg.h" #include "memcfg.h"
/* type defines. */ /* type defines. */
typedef struct typedef struct {
{
int count; int count;
unsigned int time; unsigned int time;
int size; int size;

View file

@ -51,8 +51,7 @@ void sema_test (void)
PRINT_STRING (dashline, output_file); PRINT_STRING (dashline, output_file);
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
{
task_sem_give (SEM0); task_sem_give (SEM0);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
@ -65,8 +64,7 @@ void sema_test (void)
task_sem_give (STARTRCV); task_sem_give (STARTRCV);
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
{
task_sem_give (SEM1); task_sem_give (SEM1);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
@ -76,8 +74,7 @@ void sema_test (void)
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS));
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
{
task_sem_give (SEM1); task_sem_give (SEM1);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
@ -88,8 +85,7 @@ void sema_test (void)
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS));
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
{
task_sem_give (SEM2); task_sem_give (SEM2);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
@ -99,8 +95,7 @@ void sema_test (void)
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS));
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
{
task_sem_give (SEM2); task_sem_give (SEM2);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
@ -110,8 +105,7 @@ void sema_test (void)
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS));
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
{
task_sem_give (SEM3); task_sem_give (SEM3);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
@ -121,8 +115,7 @@ void sema_test (void)
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS));
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
{
task_sem_give (SEM3); task_sem_give (SEM3);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
@ -132,8 +125,7 @@ void sema_test (void)
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS));
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
{
task_sem_give (SEM4); task_sem_give (SEM4);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);
@ -143,8 +135,7 @@ void sema_test (void)
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (et, NR_OF_SEMA_RUNS));
et = BENCH_START (); et = BENCH_START ();
for (i = 0; i < NR_OF_SEMA_RUNS; i++) for (i = 0; i < NR_OF_SEMA_RUNS; i++) {
{
task_sem_give (SEM4); task_sem_give (SEM4);
} }
et = TIME_STAMP_DELTA_GET (et); et = TIME_STAMP_DELTA_GET (et);

View file

@ -83,8 +83,7 @@ NANO_CPU_INT_REGISTER (isrDummyIntStub, TEST_SOFT_INT, 0);
#endif /* TEST_max */ #endif /* TEST_max */
/* pointer array ensures specified functions are linked into the image */ /* pointer array ensures specified functions are linked into the image */
static pfunc func_array[] = static pfunc func_array[] = {
{
/* event functions */ /* event functions */
(pfunc)task_event_send, (pfunc)task_event_send,
(pfunc)_task_event_recv, (pfunc)_task_event_recv,
@ -206,8 +205,7 @@ void fgTaskEntry (void)
printk ((char *)MESSAGE, func_array); printk ((char *)MESSAGE, func_array);
#endif /* TEST_max */ #endif /* TEST_max */
while (1) while (1) {
{
i++; i++;
} }
} }

View file

@ -82,8 +82,7 @@ static void makeInt (void)
initSwInterrupt (latencyTestIsr); initSwInterrupt (latencyTestIsr);
flagVar = 0; flagVar = 0;
raiseIntFunc (); raiseIntFunc ();
if (flagVar != 1) if (flagVar != 1) {
{
PRINT_FORMAT (" Flag variable has not changed. FAILED\n"); PRINT_FORMAT (" Flag variable has not changed. FAILED\n");
} }
else else
@ -105,8 +104,7 @@ int microIntToTask (void)
" interrupted task"); " interrupted task");
TICK_SYNCH (); TICK_SYNCH ();
makeInt (); makeInt ();
if (flagVar == 1) if (flagVar == 1) {
{
PRINT_FORMAT (" switching time is %lu tcs = %lu nsec", PRINT_FORMAT (" switching time is %lu tcs = %lu nsec",
timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp)); timestamp, SYS_CLOCK_HW_CYCLES_TO_NS(timestamp));
} }

View file

@ -73,38 +73,32 @@ int microSemaLockUnlock (void)
" that sema"); " that sema");
bench_test_start (); bench_test_start ();
timestamp = TIME_STAMP_DELTA_GET (0); timestamp = TIME_STAMP_DELTA_GET (0);
for (i = SEMASTART; i <= SEMAEND; i++) for (i = SEMASTART; i <= SEMAEND; i++) {
{
task_sem_give (i); task_sem_give (i);
} }
timestamp = TIME_STAMP_DELTA_GET (timestamp); timestamp = TIME_STAMP_DELTA_GET (timestamp);
if (bench_test_end () == 0) if (bench_test_end () == 0) {
{
PRINT_FORMAT (" Average semaphore signal time %lu tcs = %lu nsec", PRINT_FORMAT (" Average semaphore signal time %lu tcs = %lu nsec",
timestamp / N_TEST_SEMA, timestamp / N_TEST_SEMA,
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, N_TEST_SEMA)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, N_TEST_SEMA));
} }
else else {
{
errorCount++; errorCount++;
PRINT_OVERFLOW_ERROR (); PRINT_OVERFLOW_ERROR ();
} }
bench_test_start (); bench_test_start ();
timestamp = TIME_STAMP_DELTA_GET (0); timestamp = TIME_STAMP_DELTA_GET (0);
for (i = SEMASTART; i <= SEMAEND; i++) for (i = SEMASTART; i <= SEMAEND; i++) {
{
task_sem_take_wait (i); task_sem_take_wait (i);
} }
timestamp = TIME_STAMP_DELTA_GET (timestamp); timestamp = TIME_STAMP_DELTA_GET (timestamp);
if (bench_test_end () == 0) if (bench_test_end () == 0) {
{
PRINT_FORMAT (" Average semaphore test time %lu tcs = %lu nsec", PRINT_FORMAT (" Average semaphore test time %lu tcs = %lu nsec",
timestamp / N_TEST_SEMA, timestamp / N_TEST_SEMA,
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, N_TEST_SEMA)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, N_TEST_SEMA));
} }
else else {
{
errorCount++; errorCount++;
PRINT_OVERFLOW_ERROR (); PRINT_OVERFLOW_ERROR ();
} }
@ -130,8 +124,7 @@ int microMutexLockUnlock (void)
PRINT_FORMAT (" 4- Measure average time to lock a mutex then" PRINT_FORMAT (" 4- Measure average time to lock a mutex then"
" unlock that mutex"); " unlock that mutex");
timestamp = TIME_STAMP_DELTA_GET (0); timestamp = TIME_STAMP_DELTA_GET (0);
for (i = 0; i < N_TEST_MUTEX; i++) for (i = 0; i < N_TEST_MUTEX; i++) {
{
task_mutex_lock_wait (TEST_MUTEX); task_mutex_lock_wait (TEST_MUTEX);
} }
timestamp = TIME_STAMP_DELTA_GET (timestamp); timestamp = TIME_STAMP_DELTA_GET (timestamp);
@ -139,8 +132,7 @@ int microMutexLockUnlock (void)
timestamp / N_TEST_MUTEX, timestamp / N_TEST_MUTEX,
SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, N_TEST_MUTEX)); SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, N_TEST_MUTEX));
timestamp = TIME_STAMP_DELTA_GET (0); timestamp = TIME_STAMP_DELTA_GET (0);
for (i = 0; i <= N_TEST_MUTEX; i++) for (i = 0; i <= N_TEST_MUTEX; i++) {
{
task_mutex_unlock (TEST_MUTEX); task_mutex_unlock (TEST_MUTEX);
} }
timestamp = TIME_STAMP_DELTA_GET (timestamp); timestamp = TIME_STAMP_DELTA_GET (timestamp);

View file

@ -63,8 +63,7 @@ static uint32_t helper_task_iterations = 0;
void yieldingTask (void) void yieldingTask (void)
{ {
while (helper_task_iterations < NB_OF_YIELD) while (helper_task_iterations < NB_OF_YIELD) {
{
task_yield (); task_yield ();
helper_task_iterations++; helper_task_iterations++;
} }
@ -97,8 +96,7 @@ void microTaskSwitchYield (void)
timestamp = TIME_STAMP_DELTA_GET (0); timestamp = TIME_STAMP_DELTA_GET (0);
/* loop until either helper or this routine reaches number of yields */ /* loop until either helper or this routine reaches number of yields */
while (iterations < NB_OF_YIELD && helper_task_iterations < NB_OF_YIELD) while (iterations < NB_OF_YIELD && helper_task_iterations < NB_OF_YIELD) {
{
task_yield (); task_yield ();
iterations++; iterations++;
} }
@ -113,13 +111,11 @@ void microTaskSwitchYield (void)
* and forth. * and forth.
*/ */
delta = iterations - helper_task_iterations; delta = iterations - helper_task_iterations;
if (bench_test_end () < 0) if (bench_test_end () < 0) {
{
errorCount++; errorCount++;
PRINT_OVERFLOW_ERROR (); PRINT_OVERFLOW_ERROR ();
} }
else if (abs (delta) > 1) else if (abs (delta) > 1) {
{
/* expecting even alternating context switch, seems one routine /* expecting even alternating context switch, seems one routine
* called yield without the other having chance to execute * called yield without the other having chance to execute
*/ */
@ -127,8 +123,7 @@ void microTaskSwitchYield (void)
PRINT_FORMAT (" Error, iteration:%lu, helper iteration:%lu", PRINT_FORMAT (" Error, iteration:%lu, helper iteration:%lu",
iterations, helper_task_iterations); iterations, helper_task_iterations);
} }
else else {
{
/* task_yield is called (iterations + helper_task_iterations) /* task_yield is called (iterations + helper_task_iterations)
* times in total. * times in total.
*/ */

View file

@ -80,8 +80,7 @@ static void fiberOne (void)
{ {
nano_fiber_sem_take_wait (&syncSema); nano_fiber_sem_take_wait (&syncSema);
timestamp = TIME_STAMP_DELTA_GET (0); timestamp = TIME_STAMP_DELTA_GET (0);
while (ctxSwitchCounter < NCTXSWITCH) while (ctxSwitchCounter < NCTXSWITCH) {
{
fiber_yield (); fiber_yield ();
ctxSwitchCounter++; ctxSwitchCounter++;
ctxSwitchBalancer--; ctxSwitchBalancer--;
@ -104,8 +103,7 @@ static void fiberOne (void)
static void fiberTwo (void) static void fiberTwo (void)
{ {
nano_fiber_sem_give (&syncSema); nano_fiber_sem_give (&syncSema);
while (ctxSwitchCounter < NCTXSWITCH) while (ctxSwitchCounter < NCTXSWITCH) {
{
fiber_yield (); fiber_yield ();
ctxSwitchCounter++; ctxSwitchCounter++;
ctxSwitchBalancer++; ctxSwitchBalancer++;
@ -133,12 +131,10 @@ int nanoCtxSwitch (void)
(nano_fiber_entry_t) fiberOne, 0, 0, 6, 0); (nano_fiber_entry_t) fiberOne, 0, 0, 6, 0);
task_fiber_start (&fiberTwoStack[0], STACKSIZE, task_fiber_start (&fiberTwoStack[0], STACKSIZE,
(nano_fiber_entry_t) fiberTwo, 0, 0, 6, 0); (nano_fiber_entry_t) fiberTwo, 0, 0, 6, 0);
if (ctxSwitchBalancer > 3 || ctxSwitchBalancer < -3) if (ctxSwitchBalancer > 3 || ctxSwitchBalancer < -3) {
{
PRINT_FORMAT (" Balance is %d. FAILED", ctxSwitchBalancer); PRINT_FORMAT (" Balance is %d. FAILED", ctxSwitchBalancer);
} }
else if (bench_test_end () != 0) else if (bench_test_end () != 0) {
{
errorCount++; errorCount++;
PRINT_OVERFLOW_ERROR (); PRINT_OVERFLOW_ERROR ();
} }

View file

@ -68,20 +68,17 @@ int nanoIntLockUnlock (void)
" call"); " call");
bench_test_start (); bench_test_start ();
timestamp = TIME_STAMP_DELTA_GET (0); timestamp = TIME_STAMP_DELTA_GET (0);
for (i = 0; i < NTESTS; i++) for (i = 0; i < NTESTS; i++) {
{
mask = irq_lock (); mask = irq_lock ();
irq_unlock (mask); irq_unlock (mask);
} }
timestamp = TIME_STAMP_DELTA_GET (timestamp); timestamp = TIME_STAMP_DELTA_GET (timestamp);
if (bench_test_end () == 0) if (bench_test_end () == 0) {
{
PRINT_FORMAT (" Average time for lock then unlock " PRINT_FORMAT (" Average time for lock then unlock "
"is %lu tcs = %lu nsec", "is %lu tcs = %lu nsec",
timestamp / NTESTS, SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, NTESTS)); timestamp / NTESTS, SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, NTESTS));
} }
else else {
{
errorCount++; errorCount++;
PRINT_OVERFLOW_ERROR (); PRINT_OVERFLOW_ERROR ();
} }
@ -91,20 +88,17 @@ int nanoIntLockUnlock (void)
" function call"); " function call");
bench_test_start (); bench_test_start ();
timestamp = TIME_STAMP_DELTA_GET (0); timestamp = TIME_STAMP_DELTA_GET (0);
for (i = 0; i < NTESTS; i++) for (i = 0; i < NTESTS; i++) {
{
mask = irq_lock_inline (); mask = irq_lock_inline ();
irq_unlock_inline (mask); irq_unlock_inline (mask);
} }
timestamp = TIME_STAMP_DELTA_GET (timestamp); timestamp = TIME_STAMP_DELTA_GET (timestamp);
if (bench_test_end () == 0) if (bench_test_end () == 0) {
{
PRINT_FORMAT (" Average time for lock then unlock " PRINT_FORMAT (" Average time for lock then unlock "
"is %lu tcs = %lu nsec", "is %lu tcs = %lu nsec",
timestamp / NTESTS, SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, NTESTS)); timestamp / NTESTS, SYS_CLOCK_HW_CYCLES_TO_NS_AVG (timestamp, NTESTS));
} }
else else {
{
errorCount++; errorCount++;
PRINT_OVERFLOW_ERROR (); PRINT_OVERFLOW_ERROR ();
} }

View file

@ -86,8 +86,7 @@ static void fiberInt (void)
setSwInterrupt (latencyTestIsr); setSwInterrupt (latencyTestIsr);
flagVar = 0; flagVar = 0;
raiseIntFunc (); raiseIntFunc ();
if (flagVar != 1) if (flagVar != 1) {
{
PRINT_FORMAT (" Flag variable has not changed. FAILED"); PRINT_FORMAT (" Flag variable has not changed. FAILED");
} }
else else
@ -110,8 +109,7 @@ int nanoIntToFiber (void)
TICK_SYNCH (); TICK_SYNCH ();
task_fiber_start (&fiberStack[0], STACKSIZE, task_fiber_start (&fiberStack[0], STACKSIZE,
(nano_fiber_entry_t) fiberInt, 0, 0, 6, 0); (nano_fiber_entry_t) fiberInt, 0, 0, 6, 0);
if (flagVar == 1) if (flagVar == 1) {
{
PRINT_FORMAT (" switching time is %lu tcs = %lu nsec", PRINT_FORMAT (" switching time is %lu tcs = %lu nsec",
timestamp, SYS_CLOCK_HW_CYCLES_TO_NS (timestamp)); timestamp, SYS_CLOCK_HW_CYCLES_TO_NS (timestamp));
} }

View file

@ -84,8 +84,7 @@ uint32_t criticalLoop(uint32_t count)
int32_t ticks; int32_t ticks;
ticks = task_tick_get_32 (); ticks = task_tick_get_32 ();
while (task_tick_get_32 () < ticks + NUM_TICKS) while (task_tick_get_32 () < ticks + NUM_TICKS) {
{
task_offload_to_fiber (criticalRtn, &criticalVar); task_offload_to_fiber (criticalRtn, &criticalVar);
count++; count++;
} }
@ -141,14 +140,12 @@ void RegressionTask(void)
/* Wait for AlternateTask() to complete */ /* Wait for AlternateTask() to complete */
status = task_sem_take_wait_timeout (REGRESS_SEM, TEST_TIMEOUT); status = task_sem_take_wait_timeout (REGRESS_SEM, TEST_TIMEOUT);
if (status != RC_OK) if (status != RC_OK) {
{
TC_ERROR ("Timed out waiting for REGRESS_SEM\n"); TC_ERROR ("Timed out waiting for REGRESS_SEM\n");
goto errorReturn; goto errorReturn;
} }
if (criticalVar != nCalls + altTaskIterations) if (criticalVar != nCalls + altTaskIterations) {
{
TC_ERROR ("Unexpected value for <criticalVar>. Expected %d, got %d\n", TC_ERROR ("Unexpected value for <criticalVar>. Expected %d, got %d\n",
nCalls + altTaskIterations, criticalVar); nCalls + altTaskIterations, criticalVar);
goto errorReturn; goto errorReturn;
@ -165,14 +162,12 @@ void RegressionTask(void)
/* Wait for AlternateTask() to finish */ /* Wait for AlternateTask() to finish */
status = task_sem_take_wait_timeout (REGRESS_SEM, TEST_TIMEOUT); status = task_sem_take_wait_timeout (REGRESS_SEM, TEST_TIMEOUT);
if (status != RC_OK) if (status != RC_OK) {
{
TC_ERROR ("Timed out waiting for REGRESS_SEM\n"); TC_ERROR ("Timed out waiting for REGRESS_SEM\n");
goto errorReturn; goto errorReturn;
} }
if (criticalVar != nCalls + altTaskIterations) if (criticalVar != nCalls + altTaskIterations) {
{
TC_ERROR ("Unexpected value for <criticalVar>. Expected %d, got %d\n", TC_ERROR ("Unexpected value for <criticalVar>. Expected %d, got %d\n",
nCalls + altTaskIterations, criticalVar); nCalls + altTaskIterations, criticalVar);
goto errorReturn; goto errorReturn;

View file

@ -57,30 +57,26 @@
/* a single x87 FPU register in double extended format (80 bits) */ /* a single x87 FPU register in double extended format (80 bits) */
typedef struct fpReg typedef struct fpReg {
{
unsigned char reg[10]; unsigned char reg[10];
} FP_REG; } FP_REG;
/* a single XMM register (128 bits) */ /* a single XMM register (128 bits) */
typedef struct xmmReg typedef struct xmmReg {
{
unsigned char reg[16]; unsigned char reg[16];
} XMM_REG; } XMM_REG;
/* the set of volatile floating point registers */ /* the set of volatile floating point registers */
typedef struct fpVolatileRegSet typedef struct fpVolatileRegSet {
{
XMM_REG xmmRegs[8]; /* XMM[0] -> XMM[7] */ XMM_REG xmmRegs[8]; /* XMM[0] -> XMM[7] */
FP_REG fpRegs[8]; /* ST[0] -> ST[7] */ FP_REG fpRegs[8]; /* ST[0] -> ST[7] */
} FP_VOLATILE_REG_SET; } FP_VOLATILE_REG_SET;
/* the set of non-volatile floating point registers */ /* the set of non-volatile floating point registers */
typedef struct fpNonVolatileRegSet typedef struct fpNonVolatileRegSet {
{
/* this structure has been intentionally left blank */ /* this structure has been intentionally left blank */
} FP_NONVOLATILE_REG_SET; } FP_NONVOLATILE_REG_SET;
@ -95,8 +91,7 @@ typedef struct fpNonVolatileRegSet
/* the set of ALL floating point registers */ /* the set of ALL floating point registers */
typedef struct fpRegSet typedef struct fpRegSet {
{
FP_VOLATILE_REG_SET fpVolRegSet; FP_VOLATILE_REG_SET fpVolRegSet;
FP_NONVOLATILE_REG_SET fpNonVolRegSet; FP_NONVOLATILE_REG_SET fpNonVolRegSet;
} FP_REG_SET; } FP_REG_SET;

View file

@ -264,8 +264,7 @@ int RegressionTask (void)
TC_PRINT ("Validating access to supported libraries\n"); TC_PRINT ("Validating access to supported libraries\n");
if (ctypeTest () || inttypesTest () || iso646Test () || limitsTest () || if (ctypeTest () || inttypesTest () || iso646Test () || limitsTest () ||
stdboolTest () || stddefTest () || stdintTest () || stringTest ()) stdboolTest () || stddefTest () || stdintTest () || stringTest ()) {
{
TC_PRINT ("Library validation failed\n"); TC_PRINT ("Library validation failed\n");
return TC_FAIL; return TC_FAIL;
} }

View file

@ -109,13 +109,10 @@ void MonitorTaskEntry (void)
* then issue the appropriate test case summary message * then issue the appropriate test case summary message
*/ */
for (tasksDone = 0; tasksDone < NUM_TEST_TASKS; tasksDone++) for (tasksDone = 0; tasksDone < NUM_TEST_TASKS; tasksDone++) {
{
result = task_sem_group_take_wait_timeout (resultSems, TIMEOUT); result = task_sem_group_take_wait_timeout (resultSems, TIMEOUT);
if (result != resultSems[TC_PASS]) if (result != resultSems[TC_PASS]) {
{ if (result != resultSems[TC_FAIL]) {
if (result != resultSems[TC_FAIL])
{
TC_ERROR ("Monitor task timed out\n"); TC_ERROR ("Monitor task timed out\n");
} }
TC_END_REPORT (TC_FAIL); TC_END_REPORT (TC_FAIL);

View file

@ -135,13 +135,10 @@ void MonitorTaskEntry (void)
* then issue the appropriate test case summary message * then issue the appropriate test case summary message
*/ */
for (tasksDone = 0; tasksDone < NUM_TEST_TASKS; tasksDone++) for (tasksDone = 0; tasksDone < NUM_TEST_TASKS; tasksDone++) {
{
result = task_sem_group_take_wait_timeout (resultSems, TIMEOUT); result = task_sem_group_take_wait_timeout (resultSems, TIMEOUT);
if (result != resultSems[TC_PASS]) if (result != resultSems[TC_PASS]) {
{ if (result != resultSems[TC_FAIL]) {
if (result != resultSems[TC_FAIL])
{
TC_ERROR ("Monitor task timed out\n"); TC_ERROR ("Monitor task timed out\n");
} }
TC_END_RESULT (TC_FAIL); TC_END_RESULT (TC_FAIL);

View file

@ -96,8 +96,7 @@ void Task10 (void)
/* Wait and boost owner priority to 10 */ /* Wait and boost owner priority to 10 */
rv = task_mutex_lock_wait_timeout (Mutex4, ONE_SECOND); rv = task_mutex_lock_wait_timeout (Mutex4, ONE_SECOND);
if (rv != RC_TIME) if (rv != RC_TIME) {
{
tcRC = TC_FAIL; tcRC = TC_FAIL;
TC_ERROR ("Failed to timeout on mutex 0x%x\n", Mutex4); TC_ERROR ("Failed to timeout on mutex 0x%x\n", Mutex4);
return; return;
@ -128,8 +127,7 @@ void Task15 (void)
*/ */
rv = task_mutex_lock_wait_timeout (Mutex4, 2 * ONE_SECOND); rv = task_mutex_lock_wait_timeout (Mutex4, 2 * ONE_SECOND);
if (rv != RC_OK) if (rv != RC_OK) {
{
tcRC = TC_FAIL; tcRC = TC_FAIL;
TC_ERROR ("Failed to take mutex 0x%x\n", Mutex4); TC_ERROR ("Failed to take mutex 0x%x\n", Mutex4);
return; return;
@ -160,8 +158,7 @@ void Task20 (void)
*/ */
rv = task_mutex_lock_wait_timeout (Mutex3, 3 * ONE_SECOND); rv = task_mutex_lock_wait_timeout (Mutex3, 3 * ONE_SECOND);
if (rv != RC_TIME) if (rv != RC_TIME) {
{
tcRC = TC_FAIL; tcRC = TC_FAIL;
TC_ERROR ("Failed to timeout on mutex 0x%x\n", Mutex3); TC_ERROR ("Failed to timeout on mutex 0x%x\n", Mutex3);
return; return;
@ -183,8 +180,7 @@ void Task25 (void)
task_sleep (ONE_SECOND + HALF_SECOND); task_sleep (ONE_SECOND + HALF_SECOND);
rv = task_mutex_lock_wait (Mutex2); /* Wait and boost owner priority to 25 */ rv = task_mutex_lock_wait (Mutex2); /* Wait and boost owner priority to 25 */
if (rv != RC_OK) if (rv != RC_OK) {
{
tcRC = TC_FAIL; tcRC = TC_FAIL;
TC_ERROR ("Failed to take mutex 0x%x\n", Mutex2); TC_ERROR ("Failed to take mutex 0x%x\n", Mutex2);
return; return;
@ -207,16 +203,15 @@ void Task30 (void)
task_sleep (HALF_SECOND); /* Allow lower priority task to run */ task_sleep (HALF_SECOND); /* Allow lower priority task to run */
rv = task_mutex_lock (Mutex1); /* <Mutex1> is already locked. */ rv = task_mutex_lock (Mutex1); /* <Mutex1> is already locked. */
if (rv != RC_FAIL) /* This attempt to lock the mutex */ if (rv != RC_FAIL) { /* This attempt to lock the mutex */
{ /* should not succeed. */ /* should not succeed. */
tcRC = TC_FAIL; tcRC = TC_FAIL;
TC_ERROR ("Failed to NOT take locked mutex 0x%x\n", Mutex1); TC_ERROR ("Failed to NOT take locked mutex 0x%x\n", Mutex1);
return; return;
} }
rv = task_mutex_lock_wait (Mutex1); /* Wait and boost owner priority to 30 */ rv = task_mutex_lock_wait (Mutex1); /* Wait and boost owner priority to 30 */
if (rv != RC_OK) if (rv != RC_OK) {
{
tcRC = TC_FAIL; tcRC = TC_FAIL;
TC_ERROR ("Failed to take mutex 0x%x\n", Mutex1); TC_ERROR ("Failed to take mutex 0x%x\n", Mutex1);
return; return;
@ -238,8 +233,7 @@ void Task45 (void)
task_sleep (3 * ONE_SECOND + HALF_SECOND); task_sleep (3 * ONE_SECOND + HALF_SECOND);
rv = task_mutex_lock_wait (Mutex3); rv = task_mutex_lock_wait (Mutex3);
if (rv != RC_OK) if (rv != RC_OK) {
{
tcRC = TC_FAIL; tcRC = TC_FAIL;
TC_ERROR ("Failed to take mutex 0x%x\n", Mutex2); TC_ERROR ("Failed to take mutex 0x%x\n", Mutex2);
return; return;
@ -276,11 +270,9 @@ void RegressionTask (void)
* 4th iteration: Take Mutex4; Task10 waits on Mutex4 * 4th iteration: Take Mutex4; Task10 waits on Mutex4
*/ */
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++) {
{
rv = task_mutex_lock (mutexes[i]); rv = task_mutex_lock (mutexes[i]);
if (rv != RC_OK) if (rv != RC_OK) {
{
TC_ERROR ("Failed to lock mutex 0x%x\n", mutexes[i]); TC_ERROR ("Failed to lock mutex 0x%x\n", mutexes[i]);
tcRC = TC_FAIL; tcRC = TC_FAIL;
goto errorReturn; goto errorReturn;
@ -288,15 +280,13 @@ void RegressionTask (void)
task_sleep (ONE_SECOND); task_sleep (ONE_SECOND);
rv = task_priority_get (); rv = task_priority_get ();
if (rv != priority[i]) if (rv != priority[i]) {
{
TC_ERROR ("Expected priority %d, not %d\n", priority[i], rv); TC_ERROR ("Expected priority %d, not %d\n", priority[i], rv);
tcRC = TC_FAIL; tcRC = TC_FAIL;
goto errorReturn; goto errorReturn;
} }
if (tcRC != TC_PASS) /* Catch any errors from other tasks */ if (tcRC != TC_PASS) { /* Catch any errors from other tasks */
{
goto errorReturn; goto errorReturn;
} }
} }
@ -310,8 +300,7 @@ void RegressionTask (void)
/* ~ 5 seconds have passed */ /* ~ 5 seconds have passed */
rv = task_priority_get (); rv = task_priority_get ();
if (rv != 15) if (rv != 15) {
{
TC_ERROR ("%s timed out and out priority should drop.\n", "Task10"); TC_ERROR ("%s timed out and out priority should drop.\n", "Task10");
TC_ERROR ("Expected priority %d, not %d\n", 15, rv); TC_ERROR ("Expected priority %d, not %d\n", 15, rv);
tcRC = TC_FAIL; tcRC = TC_FAIL;
@ -320,8 +309,7 @@ void RegressionTask (void)
task_mutex_unlock (Mutex4); task_mutex_unlock (Mutex4);
rv = task_priority_get (); rv = task_priority_get ();
if (rv != 20) if (rv != 20) {
{
TC_ERROR ("Gave %s and priority should drop.\n", "Mutex4"); TC_ERROR ("Gave %s and priority should drop.\n", "Mutex4");
TC_ERROR ("Expected priority %d, not %d\n", 20, rv); TC_ERROR ("Expected priority %d, not %d\n", 20, rv);
tcRC = TC_FAIL; tcRC = TC_FAIL;
@ -332,26 +320,22 @@ void RegressionTask (void)
/* ~ 6 seconds have passed */ /* ~ 6 seconds have passed */
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++) {
{
rv = task_priority_get (); rv = task_priority_get ();
if (rv != dropPri[i]) if (rv != dropPri[i]) {
{
TC_ERROR ("Expected priority %d, not %d\n", dropPri[i], rv); TC_ERROR ("Expected priority %d, not %d\n", dropPri[i], rv);
tcRC = TC_FAIL; tcRC = TC_FAIL;
goto errorReturn; goto errorReturn;
} }
task_mutex_unlock (giveMutex[i]); task_mutex_unlock (giveMutex[i]);
if (tcRC != TC_PASS) if (tcRC != TC_PASS) {
{
goto errorReturn; goto errorReturn;
} }
} }
rv = task_priority_get (); rv = task_priority_get ();
if (rv != 40) if (rv != 40) {
{
TC_ERROR ("Expected priority %d, not %d\n", 40, rv); TC_ERROR ("Expected priority %d, not %d\n", 40, rv);
tcRC = TC_FAIL; tcRC = TC_FAIL;
goto errorReturn; goto errorReturn;
@ -359,8 +343,7 @@ void RegressionTask (void)
task_sleep (ONE_SECOND); /* Give Task45 time to run */ task_sleep (ONE_SECOND); /* Give Task45 time to run */
if (tcRC != TC_PASS) if (tcRC != TC_PASS) {
{
goto errorReturn; goto errorReturn;
} }

View file

@ -129,13 +129,10 @@ void MonitorTaskEntry (void)
* then issue the appropriate test case summary message * then issue the appropriate test case summary message
*/ */
for (tasksDone = 0; tasksDone < NUM_TEST_TASKS; tasksDone++) for (tasksDone = 0; tasksDone < NUM_TEST_TASKS; tasksDone++) {
{
result = task_sem_group_take_wait_timeout (resultSems, TIMEOUT); result = task_sem_group_take_wait_timeout (resultSems, TIMEOUT);
if (result != resultSems[TC_PASS]) if (result != resultSems[TC_PASS]) {
{ if (result != resultSems[TC_FAIL]) {
if (result != resultSems[TC_FAIL])
{
TC_ERROR ("Monitor task timed out\n"); TC_ERROR ("Monitor task timed out\n");
} }
TC_END_RESULT (TC_FAIL); TC_END_RESULT (TC_FAIL);

View file

@ -59,8 +59,7 @@ The following target pipe routine does not yet have a test case:
/* typedefs */ /* typedefs */
typedef struct typedef struct {
{
int size; /* number of bytes to send/receive */ int size; /* number of bytes to send/receive */
K_PIPE_OPTION options; /* options for task_pipe_XXX() APIs */ K_PIPE_OPTION options; /* options for task_pipe_XXX() APIs */
int sent; /* expected # of bytes sent */ int sent; /* expected # of bytes sent */
@ -73,8 +72,7 @@ typedef struct
static char txBuffer[PIPE_SIZE + 32]; static char txBuffer[PIPE_SIZE + 32];
static char rxBuffer[PIPE_SIZE + 32]; static char rxBuffer[PIPE_SIZE + 32];
static SIZE_EXPECT all_N[] = static SIZE_EXPECT all_N[] = {
{
{0, _ALL_N, 0, RC_FAIL}, {0, _ALL_N, 0, RC_FAIL},
{1, _ALL_N, 1, RC_OK}, {1, _ALL_N, 1, RC_OK},
{PIPE_SIZE - 1, _ALL_N, PIPE_SIZE - 1, RC_OK}, {PIPE_SIZE - 1, _ALL_N, PIPE_SIZE - 1, RC_OK},
@ -82,16 +80,14 @@ static SIZE_EXPECT all_N[] =
{PIPE_SIZE + 1, _ALL_N, 0, RC_FAIL} {PIPE_SIZE + 1, _ALL_N, 0, RC_FAIL}
}; };
static SIZE_EXPECT many_all_N[] = static SIZE_EXPECT many_all_N[] = {
{
{PIPE_SIZE / 3, _ALL_N, PIPE_SIZE / 3, RC_OK,}, {PIPE_SIZE / 3, _ALL_N, PIPE_SIZE / 3, RC_OK,},
{PIPE_SIZE / 3, _ALL_N, PIPE_SIZE / 3, RC_OK,}, {PIPE_SIZE / 3, _ALL_N, PIPE_SIZE / 3, RC_OK,},
{PIPE_SIZE / 3, _ALL_N, PIPE_SIZE / 3, RC_OK,}, {PIPE_SIZE / 3, _ALL_N, PIPE_SIZE / 3, RC_OK,},
{PIPE_SIZE / 3, _ALL_N, 0, RC_FAIL} {PIPE_SIZE / 3, _ALL_N, 0, RC_FAIL}
}; };
static SIZE_EXPECT one_to_N[] = static SIZE_EXPECT one_to_N[] = {
{
{0, _1_TO_N, 0, RC_FAIL}, {0, _1_TO_N, 0, RC_FAIL},
{1, _1_TO_N, 1, RC_OK}, {1, _1_TO_N, 1, RC_OK},
{PIPE_SIZE - 1, _1_TO_N, PIPE_SIZE - 1, RC_OK}, {PIPE_SIZE - 1, _1_TO_N, PIPE_SIZE - 1, RC_OK},
@ -99,8 +95,7 @@ static SIZE_EXPECT one_to_N[] =
{PIPE_SIZE + 1, _1_TO_N, PIPE_SIZE, RC_OK} {PIPE_SIZE + 1, _1_TO_N, PIPE_SIZE, RC_OK}
}; };
static SIZE_EXPECT many_one_to_N[] = static SIZE_EXPECT many_one_to_N[] = {
{
{PIPE_SIZE / 3, _1_TO_N, PIPE_SIZE / 3, RC_OK}, {PIPE_SIZE / 3, _1_TO_N, PIPE_SIZE / 3, RC_OK},
{PIPE_SIZE / 3, _1_TO_N, PIPE_SIZE / 3, RC_OK}, {PIPE_SIZE / 3, _1_TO_N, PIPE_SIZE / 3, RC_OK},
{PIPE_SIZE / 3, _1_TO_N, PIPE_SIZE / 3, RC_OK}, {PIPE_SIZE / 3, _1_TO_N, PIPE_SIZE / 3, RC_OK},
@ -108,8 +103,7 @@ static SIZE_EXPECT many_one_to_N[] =
{PIPE_SIZE / 3, _1_TO_N, 0, RC_FAIL} {PIPE_SIZE / 3, _1_TO_N, 0, RC_FAIL}
}; };
static SIZE_EXPECT zero_to_N[] = static SIZE_EXPECT zero_to_N[] = {
{
{0, _0_TO_N, 0, RC_FAIL}, {0, _0_TO_N, 0, RC_FAIL},
{1, _0_TO_N, 1, RC_OK}, {1, _0_TO_N, 1, RC_OK},
{PIPE_SIZE - 1, _0_TO_N, PIPE_SIZE - 1, RC_OK}, {PIPE_SIZE - 1, _0_TO_N, PIPE_SIZE - 1, RC_OK},
@ -117,8 +111,7 @@ static SIZE_EXPECT zero_to_N[] =
{PIPE_SIZE + 1, _0_TO_N, PIPE_SIZE, RC_OK} {PIPE_SIZE + 1, _0_TO_N, PIPE_SIZE, RC_OK}
}; };
static SIZE_EXPECT many_zero_to_N[] = static SIZE_EXPECT many_zero_to_N[] = {
{
{PIPE_SIZE / 3, _0_TO_N, PIPE_SIZE / 3, RC_OK}, {PIPE_SIZE / 3, _0_TO_N, PIPE_SIZE / 3, RC_OK},
{PIPE_SIZE / 3, _0_TO_N, PIPE_SIZE / 3, RC_OK}, {PIPE_SIZE / 3, _0_TO_N, PIPE_SIZE / 3, RC_OK},
{PIPE_SIZE / 3, _0_TO_N, PIPE_SIZE / 3, RC_OK}, {PIPE_SIZE / 3, _0_TO_N, PIPE_SIZE / 3, RC_OK},
@ -132,8 +125,7 @@ static SIZE_EXPECT many_zero_to_N[] =
* buffer would allow. * buffer would allow.
*/ */
static SIZE_EXPECT wait_all_N[] = static SIZE_EXPECT wait_all_N[] = {
{
{0, _ALL_N, 0, RC_FAIL}, {0, _ALL_N, 0, RC_FAIL},
{1, _ALL_N, 1, RC_OK}, {1, _ALL_N, 1, RC_OK},
{PIPE_SIZE - 1, _ALL_N, PIPE_SIZE - 1, RC_OK}, {PIPE_SIZE - 1, _ALL_N, PIPE_SIZE - 1, RC_OK},
@ -141,8 +133,7 @@ static SIZE_EXPECT wait_all_N[] =
{PIPE_SIZE + 1, _ALL_N, PIPE_SIZE + 1, RC_OK} {PIPE_SIZE + 1, _ALL_N, PIPE_SIZE + 1, RC_OK}
}; };
static SIZE_EXPECT wait_one_to_N[] = static SIZE_EXPECT wait_one_to_N[] = {
{
{0, _1_TO_N, 0, RC_FAIL}, {0, _1_TO_N, 0, RC_FAIL},
{1, _1_TO_N, 1, RC_OK}, {1, _1_TO_N, 1, RC_OK},
{PIPE_SIZE - 1, _1_TO_N, PIPE_SIZE - 1, RC_OK}, {PIPE_SIZE - 1, _1_TO_N, PIPE_SIZE - 1, RC_OK},
@ -150,8 +141,7 @@ static SIZE_EXPECT wait_one_to_N[] =
{PIPE_SIZE + 1, _1_TO_N, PIPE_SIZE + 1, RC_OK} {PIPE_SIZE + 1, _1_TO_N, PIPE_SIZE + 1, RC_OK}
}; };
static SIZE_EXPECT timeout_cases[] = static SIZE_EXPECT timeout_cases[] = {
{
{0, _ALL_N, 0, RC_FAIL}, {0, _ALL_N, 0, RC_FAIL},
{1, _ALL_N, 0, RC_TIME}, {1, _ALL_N, 0, RC_TIME},
{PIPE_SIZE - 1, _ALL_N, 0 , RC_TIME}, {PIPE_SIZE - 1, _ALL_N, 0 , RC_TIME},
@ -188,8 +178,7 @@ void microObjectsInit(void)
{ {
int i; /* loop counter */ int i; /* loop counter */
for (i = 0; i < sizeof (rxBuffer); i++) for (i = 0; i < sizeof (rxBuffer); i++) {
{
txBuffer[i] = (char) i; txBuffer[i] = (char) i;
} }
} }
@ -208,10 +197,8 @@ int receiveBufferCheck(char *buffer, int size)
{ {
int j; /* loop counter */ int j; /* loop counter */
for (j = 0; j < size; j++) for (j = 0; j < size; j++) {
{ if (buffer[j] != (char) j) {
if (buffer[j] != (char) j)
{
return j; return j;
} }
} }
@ -240,18 +227,15 @@ int pipePutHelperWork(SIZE_EXPECT *singleItems, int nSingles,
int index; /* index to corrupted byte in buffer */ int index; /* index to corrupted byte in buffer */
int bytesReceived; /* number of bytes received */ int bytesReceived; /* number of bytes received */
for (i = 0; i < nSingles; i++) for (i = 0; i < nSingles; i++) {
{
(void)task_sem_take_wait (altSem); (void)task_sem_take_wait (altSem);
for (j = 0; j < sizeof (rxBuffer); j++) for (j = 0; j < sizeof (rxBuffer); j++) {
{
rxBuffer[j] = 0; rxBuffer[j] = 0;
} }
rv = task_pipe_get (pipeId, rxBuffer, singleItems[i].size, rv = task_pipe_get (pipeId, rxBuffer, singleItems[i].size,
&bytesReceived, singleItems[i].options); &bytesReceived, singleItems[i].options);
if (rv != singleItems[i].rcode) if (rv != singleItems[i].rcode) {
{
TC_ERROR ("task_pipe_get(%d bytes) : Expected %d not %d.\n" TC_ERROR ("task_pipe_get(%d bytes) : Expected %d not %d.\n"
" bytesReceived = %d\n", " bytesReceived = %d\n",
singleItems[i].size, singleItems[i].rcode, singleItems[i].size, singleItems[i].rcode,
@ -259,8 +243,7 @@ int pipePutHelperWork(SIZE_EXPECT *singleItems, int nSingles,
return TC_FAIL; return TC_FAIL;
} }
if (bytesReceived != singleItems[i].sent) if (bytesReceived != singleItems[i].sent) {
{
TC_ERROR ("task_pipe_get(%d) : " TC_ERROR ("task_pipe_get(%d) : "
"Expected %d bytes to be received, not %d\n", "Expected %d bytes to be received, not %d\n",
singleItems[i].size, singleItems[i].sent, bytesReceived); singleItems[i].size, singleItems[i].sent, bytesReceived);
@ -268,8 +251,7 @@ int pipePutHelperWork(SIZE_EXPECT *singleItems, int nSingles,
} }
index = receiveBufferCheck (rxBuffer, bytesReceived); index = receiveBufferCheck (rxBuffer, bytesReceived);
if (index != bytesReceived) if (index != bytesReceived) {
{
TC_ERROR ("pipePutHelper: rxBuffer[%d] is %d, not %d\n", TC_ERROR ("pipePutHelper: rxBuffer[%d] is %d, not %d\n",
index, rxBuffer[index], index); index, rxBuffer[index], index);
return TC_FAIL; return TC_FAIL;
@ -286,18 +268,15 @@ int pipePutHelperWork(SIZE_EXPECT *singleItems, int nSingles,
(void)task_sem_take_wait (altSem); (void)task_sem_take_wait (altSem);
for (i = 0; i < nMany; i++) for (i = 0; i < nMany; i++) {
{ for (j = 0; j < sizeof (rxBuffer); j++) {
for (j = 0; j < sizeof (rxBuffer); j++)
{
rxBuffer[j] = 0; rxBuffer[j] = 0;
} }
rv = task_pipe_get (pipeId, rxBuffer, manyItems[i].size, rv = task_pipe_get (pipeId, rxBuffer, manyItems[i].size,
&bytesReceived, manyItems[i].options); &bytesReceived, manyItems[i].options);
if (rv != manyItems[i].rcode) if (rv != manyItems[i].rcode) {
{
TC_ERROR ("task_pipe_get(%d bytes) : Expected %d not %d.\n" TC_ERROR ("task_pipe_get(%d bytes) : Expected %d not %d.\n"
" bytesReceived = %d, iteration: %d\n", " bytesReceived = %d, iteration: %d\n",
manyItems[i].size, manyItems[i].rcode, manyItems[i].size, manyItems[i].rcode,
@ -305,8 +284,7 @@ int pipePutHelperWork(SIZE_EXPECT *singleItems, int nSingles,
return TC_FAIL; return TC_FAIL;
} }
if (bytesReceived != manyItems[i].sent) if (bytesReceived != manyItems[i].sent) {
{
TC_ERROR ("task_pipe_get(%d) : " TC_ERROR ("task_pipe_get(%d) : "
"Expected %d bytes to be received, not %d\n", "Expected %d bytes to be received, not %d\n",
manyItems[i].size, manyItems[i].sent, bytesReceived); manyItems[i].size, manyItems[i].sent, bytesReceived);
@ -314,8 +292,7 @@ int pipePutHelperWork(SIZE_EXPECT *singleItems, int nSingles,
} }
index = receiveBufferCheck (rxBuffer, bytesReceived); index = receiveBufferCheck (rxBuffer, bytesReceived);
if (index != bytesReceived) if (index != bytesReceived) {
{
TC_ERROR ("pipeGetHelper: rxBuffer[%d] is %d, not %d\n", TC_ERROR ("pipeGetHelper: rxBuffer[%d] is %d, not %d\n",
index, rxBuffer[index], index); index, rxBuffer[index], index);
return TC_FAIL; return TC_FAIL;
@ -342,24 +319,21 @@ int pipePutHelper(void)
rv = pipePutHelperWork (all_N, ARRAY_SIZE(all_N), rv = pipePutHelperWork (all_N, ARRAY_SIZE(all_N),
many_all_N, ARRAY_SIZE(many_all_N)); many_all_N, ARRAY_SIZE(many_all_N));
if (rv != TC_PASS) if (rv != TC_PASS) {
{
TC_ERROR ("Failed on all_N/many_all_N test\n"); TC_ERROR ("Failed on all_N/many_all_N test\n");
return TC_FAIL; return TC_FAIL;
} }
rv = pipePutHelperWork (one_to_N, ARRAY_SIZE(one_to_N), rv = pipePutHelperWork (one_to_N, ARRAY_SIZE(one_to_N),
many_one_to_N, ARRAY_SIZE(many_one_to_N)); many_one_to_N, ARRAY_SIZE(many_one_to_N));
if (rv != TC_PASS) if (rv != TC_PASS) {
{
TC_ERROR ("Failed on _1_TO_N/many_1_TO_N test\n"); TC_ERROR ("Failed on _1_TO_N/many_1_TO_N test\n");
return TC_FAIL; return TC_FAIL;
} }
rv = pipePutHelperWork (zero_to_N, ARRAY_SIZE(zero_to_N), rv = pipePutHelperWork (zero_to_N, ARRAY_SIZE(zero_to_N),
many_zero_to_N, ARRAY_SIZE(many_zero_to_N)); many_zero_to_N, ARRAY_SIZE(many_zero_to_N));
if (rv != TC_PASS) if (rv != TC_PASS) {
{
TC_ERROR ("Failed on _0_TO_N/many_0_TO_N test\n"); TC_ERROR ("Failed on _0_TO_N/many_0_TO_N test\n");
return TC_FAIL; return TC_FAIL;
} }
@ -391,12 +365,10 @@ int pipePutTestWork(SIZE_EXPECT *singleItems, int nSingles,
task_sem_reset (counterSem); task_sem_reset (counterSem);
for (i = 0; i < nSingles; i++) for (i = 0; i < nSingles; i++) {
{
rv = task_pipe_put (pipeId, txBuffer, singleItems[i].size, rv = task_pipe_put (pipeId, txBuffer, singleItems[i].size,
&bytesWritten, singleItems[i].options); &bytesWritten, singleItems[i].options);
if (rv != singleItems[i].rcode) if (rv != singleItems[i].rcode) {
{
TC_ERROR ("task_pipe_put(%d) : Expected %d not %d.\n" TC_ERROR ("task_pipe_put(%d) : Expected %d not %d.\n"
" bytesWritten = %d, Iteration: %d\n", " bytesWritten = %d, Iteration: %d\n",
singleItems[i].size, singleItems[i].rcode, singleItems[i].size, singleItems[i].rcode,
@ -404,8 +376,7 @@ int pipePutTestWork(SIZE_EXPECT *singleItems, int nSingles,
return TC_FAIL; return TC_FAIL;
} }
if (bytesWritten != singleItems[i].sent) if (bytesWritten != singleItems[i].sent) {
{
TC_ERROR ("task_pipe_put(%d) : " TC_ERROR ("task_pipe_put(%d) : "
"Expected %d bytes to be written, not %d\n", "Expected %d bytes to be written, not %d\n",
singleItems[i].size, singleItems[i].sent, bytesWritten); singleItems[i].size, singleItems[i].sent, bytesWritten);
@ -416,8 +387,7 @@ int pipePutTestWork(SIZE_EXPECT *singleItems, int nSingles,
(void)task_sem_take_wait (regSem); (void)task_sem_take_wait (regSem);
nitem = task_sem_count_get (counterSem) - 1; nitem = task_sem_count_get (counterSem) - 1;
if (nitem != i) if (nitem != i) {
{
TC_ERROR ("Expected item number is %d, not %d\n", TC_ERROR ("Expected item number is %d, not %d\n",
i, nitem); i, nitem);
return TC_FAIL; return TC_FAIL;
@ -428,12 +398,10 @@ int pipePutTestWork(SIZE_EXPECT *singleItems, int nSingles,
task_sem_reset (counterSem); task_sem_reset (counterSem);
for (i = 0; i < nMany; i++) for (i = 0; i < nMany; i++) {
{
rv = task_pipe_put (pipeId, txBuffer, manyItems[i].size, rv = task_pipe_put (pipeId, txBuffer, manyItems[i].size,
&bytesWritten, manyItems[i].options); &bytesWritten, manyItems[i].options);
if (rv != manyItems[i].rcode) if (rv != manyItems[i].rcode) {
{
TC_ERROR ("task_pipe_put(%d) : Expected %d not %d.\n" TC_ERROR ("task_pipe_put(%d) : Expected %d not %d.\n"
" bytesWritten = %d, iteration: %d\n", " bytesWritten = %d, iteration: %d\n",
manyItems[i].size, manyItems[i].rcode, manyItems[i].size, manyItems[i].rcode,
@ -441,8 +409,7 @@ int pipePutTestWork(SIZE_EXPECT *singleItems, int nSingles,
return TC_FAIL; return TC_FAIL;
} }
if (bytesWritten != manyItems[i].sent) if (bytesWritten != manyItems[i].sent) {
{
TC_ERROR ("task_pipe_put(%d) : " TC_ERROR ("task_pipe_put(%d) : "
"Expected %d bytes to be written, not %d\n", "Expected %d bytes to be written, not %d\n",
manyItems[i].size, manyItems[i].sent, bytesWritten); manyItems[i].size, manyItems[i].sent, bytesWritten);
@ -454,8 +421,7 @@ int pipePutTestWork(SIZE_EXPECT *singleItems, int nSingles,
/* wait for other task reading all the items from pipe */ /* wait for other task reading all the items from pipe */
(void)task_sem_take_wait (regSem); (void)task_sem_take_wait (regSem);
if (task_sem_count_get (counterSem) != nMany) if (task_sem_count_get (counterSem) != nMany) {
{
TC_ERROR ("Expected number of items %d, not %d\n", TC_ERROR ("Expected number of items %d, not %d\n",
nMany, task_sem_count_get (counterSem)); nMany, task_sem_count_get (counterSem));
return TC_FAIL; return TC_FAIL;
@ -479,24 +445,21 @@ int pipePutTest(void)
rv = pipePutTestWork (all_N, ARRAY_SIZE(all_N), rv = pipePutTestWork (all_N, ARRAY_SIZE(all_N),
many_all_N, ARRAY_SIZE(many_all_N)); many_all_N, ARRAY_SIZE(many_all_N));
if (rv != TC_PASS) if (rv != TC_PASS) {
{
TC_ERROR ("Failed on _ALL_N/many_ALL_N test\n"); TC_ERROR ("Failed on _ALL_N/many_ALL_N test\n");
return TC_FAIL; return TC_FAIL;
} }
rv = pipePutTestWork (one_to_N, ARRAY_SIZE(one_to_N), rv = pipePutTestWork (one_to_N, ARRAY_SIZE(one_to_N),
many_one_to_N, ARRAY_SIZE(many_one_to_N)); many_one_to_N, ARRAY_SIZE(many_one_to_N));
if (rv != TC_PASS) if (rv != TC_PASS) {
{
TC_ERROR ("Failed on _1_TO_N/many_1_TO_N test\n"); TC_ERROR ("Failed on _1_TO_N/many_1_TO_N test\n");
return TC_FAIL; return TC_FAIL;
} }
rv = pipePutTestWork (zero_to_N, ARRAY_SIZE(zero_to_N), rv = pipePutTestWork (zero_to_N, ARRAY_SIZE(zero_to_N),
many_zero_to_N, ARRAY_SIZE(many_zero_to_N)); many_zero_to_N, ARRAY_SIZE(many_zero_to_N));
if (rv != TC_PASS) if (rv != TC_PASS) {
{
TC_ERROR ("Failed on _0_TO_N/many_0_TO_N test\n"); TC_ERROR ("Failed on _0_TO_N/many_0_TO_N test\n");
return TC_FAIL; return TC_FAIL;
} }
@ -522,8 +485,7 @@ int pipePutWaitHelper(void)
/* 1. task_pipe_get_wait() will force a context switch to RegressionTask() */ /* 1. task_pipe_get_wait() will force a context switch to RegressionTask() */
rv = task_pipe_get_wait (pipeId, rxBuffer, PIPE_SIZE, rv = task_pipe_get_wait (pipeId, rxBuffer, PIPE_SIZE,
&bytesRead, _ALL_N); &bytesRead, _ALL_N);
if ((rv != RC_OK) || (bytesRead != PIPE_SIZE)) if ((rv != RC_OK) || (bytesRead != PIPE_SIZE)) {
{
TC_ERROR ("Expected return code %d, not %d\n" TC_ERROR ("Expected return code %d, not %d\n"
"Expected %d bytes to be read, not %d\n", "Expected %d bytes to be read, not %d\n",
RC_OK, rv, PIPE_SIZE, bytesRead); RC_OK, rv, PIPE_SIZE, bytesRead);
@ -533,8 +495,7 @@ int pipePutWaitHelper(void)
/* 2. task_pipe_get_wait() will force a context switch to RegressionTask(). */ /* 2. task_pipe_get_wait() will force a context switch to RegressionTask(). */
rv = task_pipe_get_wait (pipeId, rxBuffer, PIPE_SIZE, rv = task_pipe_get_wait (pipeId, rxBuffer, PIPE_SIZE,
&bytesRead, _1_TO_N); &bytesRead, _1_TO_N);
if ((rv != RC_OK) || (bytesRead != PIPE_SIZE)) if ((rv != RC_OK) || (bytesRead != PIPE_SIZE)) {
{
TC_ERROR ("Expected return code %d, not %d\n" TC_ERROR ("Expected return code %d, not %d\n"
"Expected %d bytes to be read, not %d\n", "Expected %d bytes to be read, not %d\n",
RC_OK, rv, PIPE_SIZE, bytesRead); RC_OK, rv, PIPE_SIZE, bytesRead);
@ -548,19 +509,16 @@ int pipePutWaitHelper(void)
rv = task_pipe_get_wait (pipeId, rxBuffer, PIPE_SIZE / 2, rv = task_pipe_get_wait (pipeId, rxBuffer, PIPE_SIZE / 2,
&bytesRead, _0_TO_N); &bytesRead, _0_TO_N);
if (rv != RC_FAIL) if (rv != RC_FAIL) {
{
TC_ERROR ("Expected return code %d, not %d\n", RC_FAIL, rv); TC_ERROR ("Expected return code %d, not %d\n", RC_FAIL, rv);
return TC_FAIL; return TC_FAIL;
} }
/* 3. Empty the pipe in two reads */ /* 3. Empty the pipe in two reads */
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++) {
{
rv = task_pipe_get (pipeId, rxBuffer, PIPE_SIZE / 2, rv = task_pipe_get (pipeId, rxBuffer, PIPE_SIZE / 2,
&bytesRead, _0_TO_N); &bytesRead, _0_TO_N);
if ((rv != RC_OK) || (bytesRead != PIPE_SIZE / 2)) if ((rv != RC_OK) || (bytesRead != PIPE_SIZE / 2)) {
{
TC_ERROR ("Expected return code %d, not %d\n" TC_ERROR ("Expected return code %d, not %d\n"
"Expected %d bytes to be read, not %d\n", "Expected %d bytes to be read, not %d\n",
RC_OK, rv, PIPE_SIZE / 2, bytesRead); RC_OK, rv, PIPE_SIZE / 2, bytesRead);
@ -588,8 +546,7 @@ int pipePutWaitTest(void)
/* 1. Fill the pipe */ /* 1. Fill the pipe */
rv = task_pipe_put_wait (pipeId, txBuffer, PIPE_SIZE, rv = task_pipe_put_wait (pipeId, txBuffer, PIPE_SIZE,
&bytesWritten, _ALL_N); &bytesWritten, _ALL_N);
if ((rv != RC_OK) || (bytesWritten != PIPE_SIZE)) if ((rv != RC_OK) || (bytesWritten != PIPE_SIZE)) {
{
TC_ERROR ("Return code: expected %d, got %d\n" TC_ERROR ("Return code: expected %d, got %d\n"
"Bytes written: expected %d, got %d\n", "Bytes written: expected %d, got %d\n",
RC_OK, rv, PIPE_SIZE, bytesWritten); RC_OK, rv, PIPE_SIZE, bytesWritten);
@ -601,8 +558,7 @@ int pipePutWaitTest(void)
/* 2. task_pipe_put_wait() will force a context switch to AlternateTask(). */ /* 2. task_pipe_put_wait() will force a context switch to AlternateTask(). */
rv = task_pipe_put_wait (pipeId, txBuffer, PIPE_SIZE, rv = task_pipe_put_wait (pipeId, txBuffer, PIPE_SIZE,
&bytesWritten, _ALL_N); &bytesWritten, _ALL_N);
if ((rv != RC_OK) || (bytesWritten != PIPE_SIZE)) if ((rv != RC_OK) || (bytesWritten != PIPE_SIZE)) {
{
TC_ERROR ("Return code: expected %d, got %d\n" TC_ERROR ("Return code: expected %d, got %d\n"
"Bytes written: expected %d, got %d\n", "Bytes written: expected %d, got %d\n",
RC_OK, rv, PIPE_SIZE, bytesWritten); RC_OK, rv, PIPE_SIZE, bytesWritten);
@ -612,8 +568,7 @@ int pipePutWaitTest(void)
/* 3. task_pipe_put_wait() will force a context switch to AlternateTask(). */ /* 3. task_pipe_put_wait() will force a context switch to AlternateTask(). */
rv = task_pipe_put_wait (pipeId, txBuffer, PIPE_SIZE, rv = task_pipe_put_wait (pipeId, txBuffer, PIPE_SIZE,
&bytesWritten, _1_TO_N); &bytesWritten, _1_TO_N);
if ((rv != RC_OK) || (bytesWritten != PIPE_SIZE)) if ((rv != RC_OK) || (bytesWritten != PIPE_SIZE)) {
{
TC_ERROR ("Return code: expected %d, got %d\n" TC_ERROR ("Return code: expected %d, got %d\n"
"Bytes written: expected %d, got %d\n", "Bytes written: expected %d, got %d\n",
RC_OK, rv, PIPE_SIZE, bytesWritten); RC_OK, rv, PIPE_SIZE, bytesWritten);
@ -623,8 +578,7 @@ int pipePutWaitTest(void)
/* This should return immediately as _0_TO_N with a wait is an error. */ /* This should return immediately as _0_TO_N with a wait is an error. */
rv = task_pipe_put_wait (pipeId, txBuffer, PIPE_SIZE, rv = task_pipe_put_wait (pipeId, txBuffer, PIPE_SIZE,
&bytesWritten, _0_TO_N); &bytesWritten, _0_TO_N);
if ((rv != RC_FAIL) || (bytesWritten != 0)) if ((rv != RC_FAIL) || (bytesWritten != 0)) {
{
TC_ERROR ("Return code: expected %d, got %d\n" TC_ERROR ("Return code: expected %d, got %d\n"
"Bytes written: expected %d, got %d\n", "Bytes written: expected %d, got %d\n",
RC_FAIL, rv, 0, bytesWritten); RC_FAIL, rv, 0, bytesWritten);
@ -655,8 +609,7 @@ int pipePutTimeoutHelper(void)
/* 1. task_pipe_get_wait_timeout() will force a context switch to RegressionTask() */ /* 1. task_pipe_get_wait_timeout() will force a context switch to RegressionTask() */
rv = task_pipe_get_wait_timeout (pipeId, rxBuffer, PIPE_SIZE, rv = task_pipe_get_wait_timeout (pipeId, rxBuffer, PIPE_SIZE,
&bytesRead, _ALL_N, ONE_SECOND); &bytesRead, _ALL_N, ONE_SECOND);
if ((rv != RC_OK) || (bytesRead != PIPE_SIZE)) if ((rv != RC_OK) || (bytesRead != PIPE_SIZE)) {
{
TC_ERROR ("Expected return code %d, not %d\n" TC_ERROR ("Expected return code %d, not %d\n"
"Expected %d bytes to be read, not %d\n", "Expected %d bytes to be read, not %d\n",
RC_OK, rv, PIPE_SIZE, bytesRead); RC_OK, rv, PIPE_SIZE, bytesRead);
@ -666,8 +619,7 @@ int pipePutTimeoutHelper(void)
/* 2. task_pipe_get_wait_timeout() will force a context switch to RegressionTask(). */ /* 2. task_pipe_get_wait_timeout() will force a context switch to RegressionTask(). */
rv = task_pipe_get_wait_timeout (pipeId, rxBuffer, PIPE_SIZE, rv = task_pipe_get_wait_timeout (pipeId, rxBuffer, PIPE_SIZE,
&bytesRead, _1_TO_N, ONE_SECOND); &bytesRead, _1_TO_N, ONE_SECOND);
if ((rv != RC_OK) || (bytesRead != PIPE_SIZE)) if ((rv != RC_OK) || (bytesRead != PIPE_SIZE)) {
{
TC_ERROR ("Expected return code %d, not %d\n" TC_ERROR ("Expected return code %d, not %d\n"
"Expected %d bytes to be read, not %d\n", "Expected %d bytes to be read, not %d\n",
RC_OK, rv, PIPE_SIZE, bytesRead); RC_OK, rv, PIPE_SIZE, bytesRead);
@ -681,19 +633,16 @@ int pipePutTimeoutHelper(void)
rv = task_pipe_get_wait_timeout (pipeId, rxBuffer, PIPE_SIZE / 2, rv = task_pipe_get_wait_timeout (pipeId, rxBuffer, PIPE_SIZE / 2,
&bytesRead, _0_TO_N, ONE_SECOND); &bytesRead, _0_TO_N, ONE_SECOND);
if (rv != RC_FAIL) if (rv != RC_FAIL) {
{
TC_ERROR ("Expected return code %d, not %d\n", RC_FAIL, rv); TC_ERROR ("Expected return code %d, not %d\n", RC_FAIL, rv);
return TC_FAIL; return TC_FAIL;
} }
/* 3. Empty the pipe in two reads */ /* 3. Empty the pipe in two reads */
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++) {
{
rv = task_pipe_get (pipeId, rxBuffer, PIPE_SIZE / 2, rv = task_pipe_get (pipeId, rxBuffer, PIPE_SIZE / 2,
&bytesRead, _0_TO_N); &bytesRead, _0_TO_N);
if ((rv != RC_OK) || (bytesRead != PIPE_SIZE / 2)) if ((rv != RC_OK) || (bytesRead != PIPE_SIZE / 2)) {
{
TC_ERROR ("Expected return code %d, not %d\n" TC_ERROR ("Expected return code %d, not %d\n"
"Expected %d bytes to be read, not %d\n", "Expected %d bytes to be read, not %d\n",
RC_OK, rv, PIPE_SIZE / 2, bytesRead); RC_OK, rv, PIPE_SIZE / 2, bytesRead);
@ -721,8 +670,7 @@ int pipePutTimeoutTest(void)
/* 1. Fill the pipe */ /* 1. Fill the pipe */
rv = task_pipe_put_wait_timeout (pipeId, txBuffer, PIPE_SIZE, rv = task_pipe_put_wait_timeout (pipeId, txBuffer, PIPE_SIZE,
&bytesWritten, _ALL_N, ONE_SECOND); &bytesWritten, _ALL_N, ONE_SECOND);
if ((rv != RC_OK) || (bytesWritten != PIPE_SIZE)) if ((rv != RC_OK) || (bytesWritten != PIPE_SIZE)) {
{
TC_ERROR ("Return code: expected %d, got %d\n" TC_ERROR ("Return code: expected %d, got %d\n"
"Bytes written: expected %d, got %d\n", "Bytes written: expected %d, got %d\n",
RC_OK, rv, PIPE_SIZE, bytesWritten); RC_OK, rv, PIPE_SIZE, bytesWritten);
@ -733,8 +681,7 @@ int pipePutTimeoutTest(void)
rv = task_pipe_put_wait_timeout (pipeId, txBuffer, PIPE_SIZE, rv = task_pipe_put_wait_timeout (pipeId, txBuffer, PIPE_SIZE,
&bytesWritten, _ALL_N, ONE_SECOND); &bytesWritten, _ALL_N, ONE_SECOND);
if ((rv != RC_TIME) || (bytesWritten != 0)) if ((rv != RC_TIME) || (bytesWritten != 0)) {
{
TC_ERROR ("Return code: expected %d, got %d\n" TC_ERROR ("Return code: expected %d, got %d\n"
"Bytes written: expected %d, got %d\n", "Bytes written: expected %d, got %d\n",
RC_TIME, rv, 0, bytesWritten); RC_TIME, rv, 0, bytesWritten);
@ -743,8 +690,7 @@ int pipePutTimeoutTest(void)
rv = task_pipe_put_wait_timeout (pipeId, txBuffer, PIPE_SIZE, rv = task_pipe_put_wait_timeout (pipeId, txBuffer, PIPE_SIZE,
&bytesWritten, _1_TO_N, ONE_SECOND); &bytesWritten, _1_TO_N, ONE_SECOND);
if ((rv != RC_TIME) || (bytesWritten != 0)) if ((rv != RC_TIME) || (bytesWritten != 0)) {
{
TC_ERROR ("Return code: expected %d, got %d\n" TC_ERROR ("Return code: expected %d, got %d\n"
"Bytes written: expected %d, got %d\n", "Bytes written: expected %d, got %d\n",
RC_TIME, rv, 0, bytesWritten); RC_TIME, rv, 0, bytesWritten);
@ -756,8 +702,7 @@ int pipePutTimeoutTest(void)
/* 2. task_pipe_put_wait() will force a context switch to AlternateTask(). */ /* 2. task_pipe_put_wait() will force a context switch to AlternateTask(). */
rv = task_pipe_put_wait_timeout (pipeId, txBuffer, PIPE_SIZE, rv = task_pipe_put_wait_timeout (pipeId, txBuffer, PIPE_SIZE,
&bytesWritten, _ALL_N, ONE_SECOND); &bytesWritten, _ALL_N, ONE_SECOND);
if ((rv != RC_OK) || (bytesWritten != PIPE_SIZE)) if ((rv != RC_OK) || (bytesWritten != PIPE_SIZE)) {
{
TC_ERROR ("Return code: expected %d, got %d\n" TC_ERROR ("Return code: expected %d, got %d\n"
"Bytes written: expected %d, got %d\n", "Bytes written: expected %d, got %d\n",
RC_OK, rv, PIPE_SIZE, bytesWritten); return TC_FAIL; } RC_OK, rv, PIPE_SIZE, bytesWritten); return TC_FAIL; }
@ -765,8 +710,7 @@ int pipePutTimeoutTest(void)
/* 3. task_pipe_put_wait() will force a context switch to AlternateTask(). */ /* 3. task_pipe_put_wait() will force a context switch to AlternateTask(). */
rv = task_pipe_put_wait_timeout (pipeId, txBuffer, PIPE_SIZE, rv = task_pipe_put_wait_timeout (pipeId, txBuffer, PIPE_SIZE,
&bytesWritten, _1_TO_N, ONE_SECOND); &bytesWritten, _1_TO_N, ONE_SECOND);
if ((rv != RC_OK) || (bytesWritten != PIPE_SIZE)) if ((rv != RC_OK) || (bytesWritten != PIPE_SIZE)) {
{
TC_ERROR ("Return code: expected %d, got %d\n" TC_ERROR ("Return code: expected %d, got %d\n"
"Bytes written: expected %d, got %d\n", "Bytes written: expected %d, got %d\n",
RC_OK, rv, PIPE_SIZE, bytesWritten); RC_OK, rv, PIPE_SIZE, bytesWritten);
@ -776,8 +720,7 @@ int pipePutTimeoutTest(void)
/* This should return immediately as _0_TO_N with a wait is an error. */ /* This should return immediately as _0_TO_N with a wait is an error. */
rv = task_pipe_put_wait (pipeId, txBuffer, PIPE_SIZE, rv = task_pipe_put_wait (pipeId, txBuffer, PIPE_SIZE,
&bytesWritten, _0_TO_N); &bytesWritten, _0_TO_N);
if ((rv != RC_FAIL) || (bytesWritten != 0)) if ((rv != RC_FAIL) || (bytesWritten != 0)) {
{
TC_ERROR ("Return code: expected %d, got %d\n" TC_ERROR ("Return code: expected %d, got %d\n"
"Bytes written: expected %d, got %d\n", "Bytes written: expected %d, got %d\n",
RC_FAIL, rv, 0, bytesWritten); RC_FAIL, rv, 0, bytesWritten);
@ -811,32 +754,26 @@ int pipeGetTest(void)
int size[] ={1, PIPE_SIZE - 1, PIPE_SIZE, PIPE_SIZE + 1}; int size[] ={1, PIPE_SIZE - 1, PIPE_SIZE, PIPE_SIZE + 1};
K_PIPE_OPTION options[] = {_ALL_N, _1_TO_N}; K_PIPE_OPTION options[] = {_ALL_N, _1_TO_N};
for (j = 0; j < ARRAY_SIZE(options); j++) for (j = 0; j < ARRAY_SIZE(options); j++) {
{ for (i = 0; i < ARRAY_SIZE(size); i++) {
for (i = 0; i < ARRAY_SIZE(size); i++)
{
rv = task_pipe_get (pipeId, rxBuffer, size[i], rv = task_pipe_get (pipeId, rxBuffer, size[i],
&bytesRead, options[j]); &bytesRead, options[j]);
if (rv != RC_FAIL) if (rv != RC_FAIL) {
{
TC_ERROR ("Expected return code %d, not %d\n", RC_FAIL, rv); TC_ERROR ("Expected return code %d, not %d\n", RC_FAIL, rv);
return TC_FAIL; return TC_FAIL;
} }
} }
} }
for (i = 0; i < ARRAY_SIZE(size); i++) for (i = 0; i < ARRAY_SIZE(size); i++) {
{
rv = task_pipe_get (pipeId, rxBuffer, size[i], rv = task_pipe_get (pipeId, rxBuffer, size[i],
&bytesRead, _0_TO_N); &bytesRead, _0_TO_N);
if (rv != RC_OK) if (rv != RC_OK) {
{
TC_ERROR ("Expected return code %d, not %d\n", RC_OK, rv); TC_ERROR ("Expected return code %d, not %d\n", RC_OK, rv);
return TC_FAIL; return TC_FAIL;
} }
if (bytesRead != 0) if (bytesRead != 0) {
{
TC_ERROR ("Expected <bytesRead> %d, not %d\n", 0, bytesRead); TC_ERROR ("Expected <bytesRead> %d, not %d\n", 0, bytesRead);
return TC_FAIL; return TC_FAIL;
} }
@ -861,8 +798,7 @@ int pipeGetWaitHelperWork(SIZE_EXPECT *items, int nItems)
int rv; /* return value from task_pipe_put_wait() */ int rv; /* return value from task_pipe_put_wait() */
int bytesSent; /* # of bytes sent to task_pipe_put_wait() */ int bytesSent; /* # of bytes sent to task_pipe_put_wait() */
for (i = 0; i < nItems; i++) for (i = 0; i < nItems; i++) {
{
/* /*
* Pipe should be empty. Most calls to task_pipe_get_wait() should * Pipe should be empty. Most calls to task_pipe_get_wait() should
* block until the call to task_pipe_put() is performed in the routine * block until the call to task_pipe_put() is performed in the routine
@ -872,8 +808,7 @@ int pipeGetWaitHelperWork(SIZE_EXPECT *items, int nItems)
bytesSent = 0; bytesSent = 0;
rv = task_pipe_put_wait (pipeId, rxBuffer, items[i].size, rv = task_pipe_put_wait (pipeId, rxBuffer, items[i].size,
&bytesSent, items[i].options); &bytesSent, items[i].options);
if ((rv != items[i].rcode) || (bytesSent != items[i].sent)) if ((rv != items[i].rcode) || (bytesSent != items[i].sent)) {
{
TC_ERROR ("Expected return value %d, got %d\n" TC_ERROR ("Expected return value %d, got %d\n"
"Expected bytesSent = %d, got %d\n", "Expected bytesSent = %d, got %d\n",
items[i].rcode, rv, 0, bytesSent); items[i].rcode, rv, 0, bytesSent);
@ -898,15 +833,13 @@ int pipeGetWaitHelper(void)
(void)task_sem_take_wait (altSem); (void)task_sem_take_wait (altSem);
rv = pipeGetWaitHelperWork (wait_all_N, ARRAY_SIZE(wait_all_N)); rv = pipeGetWaitHelperWork (wait_all_N, ARRAY_SIZE(wait_all_N));
if (rv != TC_PASS) if (rv != TC_PASS) {
{
TC_ERROR ("Failed on _ALL_N test\n"); TC_ERROR ("Failed on _ALL_N test\n");
return TC_FAIL; return TC_FAIL;
} }
rv = pipeGetWaitHelperWork (wait_one_to_N, ARRAY_SIZE(wait_one_to_N)); rv = pipeGetWaitHelperWork (wait_one_to_N, ARRAY_SIZE(wait_one_to_N));
if (rv != TC_PASS) if (rv != TC_PASS) {
{
TC_ERROR ("Failed on _1_TO_N test\n"); TC_ERROR ("Failed on _1_TO_N test\n");
return TC_FAIL; return TC_FAIL;
} }
@ -930,8 +863,7 @@ int pipeGetWaitTestWork(SIZE_EXPECT *items, int nItems)
int rv; /* return code from task_pipe_get_wait() */ int rv; /* return code from task_pipe_get_wait() */
int bytesRead; /* # of bytes read from task_pipe_get_wait() */ int bytesRead; /* # of bytes read from task_pipe_get_wait() */
for (i = 0; i < nItems; i++) for (i = 0; i < nItems; i++) {
{
/* /*
* Pipe should be empty. Most calls to task_pipe_get_wait() should * Pipe should be empty. Most calls to task_pipe_get_wait() should
* block until the call to task_pipe_put() is performed in the routine * block until the call to task_pipe_put() is performed in the routine
@ -940,8 +872,7 @@ int pipeGetWaitTestWork(SIZE_EXPECT *items, int nItems)
rv = task_pipe_get_wait (pipeId, rxBuffer, items[i].size, rv = task_pipe_get_wait (pipeId, rxBuffer, items[i].size,
&bytesRead, items[i].options); &bytesRead, items[i].options);
if ((rv != items[i].rcode) || (bytesRead != items[i].sent)) if ((rv != items[i].rcode) || (bytesRead != items[i].sent)) {
{
TC_ERROR ("Expected return value %d, got %d\n" TC_ERROR ("Expected return value %d, got %d\n"
"Expected bytesRead = %d, got %d\n", "Expected bytesRead = %d, got %d\n",
items[i].rcode, rv, 0, bytesRead); items[i].rcode, rv, 0, bytesRead);
@ -967,23 +898,20 @@ int pipeGetWaitTest(void)
task_sem_give (altSem); /* Wake AlternateTask */ task_sem_give (altSem); /* Wake AlternateTask */
rv = pipeGetWaitTestWork (wait_all_N, ARRAY_SIZE(wait_all_N)); rv = pipeGetWaitTestWork (wait_all_N, ARRAY_SIZE(wait_all_N));
if (rv != TC_PASS) if (rv != TC_PASS) {
{
TC_ERROR ("Failed on _ALL_N test\n"); TC_ERROR ("Failed on _ALL_N test\n");
return TC_FAIL; return TC_FAIL;
} }
rv = pipeGetWaitTestWork (wait_one_to_N, ARRAY_SIZE(wait_one_to_N)); rv = pipeGetWaitTestWork (wait_one_to_N, ARRAY_SIZE(wait_one_to_N));
if (rv != TC_PASS) if (rv != TC_PASS) {
{
TC_ERROR ("Failed on _1_TO_N test\n"); TC_ERROR ("Failed on _1_TO_N test\n");
return TC_FAIL; return TC_FAIL;
} }
rv = task_pipe_get_wait (pipeId, rxBuffer, PIPE_SIZE, rv = task_pipe_get_wait (pipeId, rxBuffer, PIPE_SIZE,
&bytesRead, _0_TO_N); &bytesRead, _0_TO_N);
if (rv != RC_FAIL) if (rv != RC_FAIL) {
{
TC_ERROR ("Expected return code of %d, not %d\n", RC_FAIL, rv); TC_ERROR ("Expected return code of %d, not %d\n", RC_FAIL, rv);
return TC_FAIL; return TC_FAIL;
} }
@ -1004,13 +932,11 @@ int pipeGetTimeoutTest(void)
int rv; /* return value from task_pipe_get_wait_timeout() */ int rv; /* return value from task_pipe_get_wait_timeout() */
int bytesRead; /* # of bytes read from task_pipe_get_wait_timeout() */ int bytesRead; /* # of bytes read from task_pipe_get_wait_timeout() */
for (i = 0; i < ARRAY_SIZE(timeout_cases); i++) for (i = 0; i < ARRAY_SIZE(timeout_cases); i++) {
{
rv = task_pipe_get_wait_timeout (pipeId, rxBuffer, timeout_cases[i].size, rv = task_pipe_get_wait_timeout (pipeId, rxBuffer, timeout_cases[i].size,
&bytesRead, timeout_cases[i].options, ONE_SECOND); &bytesRead, timeout_cases[i].options, ONE_SECOND);
if ((rv != timeout_cases[i].rcode) || if ((rv != timeout_cases[i].rcode) ||
(bytesRead != timeout_cases[i].sent)) (bytesRead != timeout_cases[i].sent)) {
{
TC_ERROR ("Expected return code %d, got %d\n" TC_ERROR ("Expected return code %d, got %d\n"
"Expected <bytesRead> %d, got %d\n" "Expected <bytesRead> %d, got %d\n"
"Iteration %d\n", "Iteration %d\n",
@ -1037,20 +963,17 @@ int AlternateTask(void)
int rv; /* return code from each set of test cases */ int rv; /* return code from each set of test cases */
rv = pipePutHelper (); rv = pipePutHelper ();
if (rv != TC_PASS) if (rv != TC_PASS) {
{
return TC_FAIL; return TC_FAIL;
} }
rv = pipePutWaitHelper (); rv = pipePutWaitHelper ();
if (rv != TC_PASS) if (rv != TC_PASS) {
{
return TC_FAIL; return TC_FAIL;
} }
rv = pipePutTimeoutHelper (); rv = pipePutTimeoutHelper ();
if (rv != TC_PASS) if (rv != TC_PASS) {
{
return TC_FAIL; return TC_FAIL;
} }
@ -1060,8 +983,7 @@ int AlternateTask(void)
*/ */
rv = pipeGetWaitHelper (); rv = pipeGetWaitHelper ();
if (rv != TC_PASS) if (rv != TC_PASS) {
{
return TC_FAIL; return TC_FAIL;
} }
@ -1091,43 +1013,37 @@ int RegressionTask(void)
TC_PRINT ("Testing task_pipe_put() ...\n"); TC_PRINT ("Testing task_pipe_put() ...\n");
tcRC = pipePutTest (); tcRC = pipePutTest ();
if (tcRC != TC_PASS) if (tcRC != TC_PASS) {
{
return TC_FAIL; return TC_FAIL;
} }
TC_PRINT ("Testing task_pipe_put_wait() ...\n"); TC_PRINT ("Testing task_pipe_put_wait() ...\n");
tcRC = pipePutWaitTest (); tcRC = pipePutWaitTest ();
if (tcRC != TC_PASS) if (tcRC != TC_PASS) {
{
return TC_FAIL; return TC_FAIL;
} }
TC_PRINT ("Testing task_pipe_put_wait_timeout() ...\n"); TC_PRINT ("Testing task_pipe_put_wait_timeout() ...\n");
tcRC = pipePutTimeoutTest (); tcRC = pipePutTimeoutTest ();
if (tcRC != TC_PASS) if (tcRC != TC_PASS) {
{
return TC_FAIL; return TC_FAIL;
} }
TC_PRINT ("Testing task_pipe_get() ...\n"); TC_PRINT ("Testing task_pipe_get() ...\n");
tcRC = pipeGetTest (); tcRC = pipeGetTest ();
if (tcRC != TC_PASS) if (tcRC != TC_PASS) {
{
return TC_FAIL; return TC_FAIL;
} }
TC_PRINT ("Testing task_pipe_get_wait() ...\n"); TC_PRINT ("Testing task_pipe_get_wait() ...\n");
tcRC = pipeGetWaitTest (); tcRC = pipeGetWaitTest ();
if (tcRC != TC_PASS) if (tcRC != TC_PASS) {
{
return TC_FAIL; return TC_FAIL;
} }
TC_PRINT ("Testing task_pipe_get_wait_timeout() ...\n"); TC_PRINT ("Testing task_pipe_get_wait_timeout() ...\n");
tcRC = pipeGetTimeoutTest (); tcRC = pipeGetTimeoutTest ();
if (tcRC != TC_PASS) if (tcRC != TC_PASS) {
{
return TC_FAIL; return TC_FAIL;
} }

View file

@ -62,20 +62,17 @@ void MainTask (void)
int result; int result;
/* wait for the first task to start */ /* wait for the first task to start */
result = task_sem_take_wait_timeout (SEMA1, WAIT_TOUT); result = task_sem_take_wait_timeout (SEMA1, WAIT_TOUT);
if (result != RC_OK) if (result != RC_OK) {
{
TC_ERROR ("Test task 1 did not start properly\n"); TC_ERROR ("Test task 1 did not start properly\n");
goto fail; goto fail;
} }
/* now we check the first task to perform the test and die */ /* now we check the first task to perform the test and die */
result = task_sem_take_wait_timeout (SEMA1, WAIT_TOUT); result = task_sem_take_wait_timeout (SEMA1, WAIT_TOUT);
if (result == RC_TIME) if (result == RC_TIME) {
{
TC_PRINT ("As expected, test task 1 did not continue operating \n"); TC_PRINT ("As expected, test task 1 did not continue operating \n");
TC_PRINT ("after calling memcpy_s with incorrect parameters\n"); TC_PRINT ("after calling memcpy_s with incorrect parameters\n");
} }
else else {
{
TC_ERROR ("Test task 1 unexpectedly continued\n" TC_ERROR ("Test task 1 unexpectedly continued\n"
"after calling memcpy_s with incorrect parameters\n"); "after calling memcpy_s with incorrect parameters\n");
goto fail; goto fail;
@ -83,20 +80,17 @@ void MainTask (void)
/* wait for the second task to start */ /* wait for the second task to start */
result = task_sem_take_wait_timeout (SEMA2, WAIT_TOUT); result = task_sem_take_wait_timeout (SEMA2, WAIT_TOUT);
if (result != RC_OK) if (result != RC_OK) {
{
TC_ERROR ("Test task 2 did not start properly\n"); TC_ERROR ("Test task 2 did not start properly\n");
goto fail; goto fail;
} }
/* now we check the second task to perform the test and die */ /* now we check the second task to perform the test and die */
result = task_sem_take_wait_timeout (SEMA2, WAIT_TOUT); result = task_sem_take_wait_timeout (SEMA2, WAIT_TOUT);
if (result == RC_TIME) if (result == RC_TIME) {
{
TC_PRINT ("As expected, test task 2 did not continue operating \n"); TC_PRINT ("As expected, test task 2 did not continue operating \n");
TC_PRINT ("after calling strcpy_s with incorrect parameters\n"); TC_PRINT ("after calling strcpy_s with incorrect parameters\n");
} }
else else {
{
TC_ERROR ("Test task 2 unexpectedly continued\n" TC_ERROR ("Test task 2 unexpectedly continued\n"
"after calling memcpy_s with incorrect parameters\n"); "after calling memcpy_s with incorrect parameters\n");
goto fail; goto fail;

View file

@ -89,8 +89,7 @@ ksem_t blockHpSem = BLOCK_HP_SEM;
ksem_t blockMpSem = BLOCK_MP_SEM; ksem_t blockMpSem = BLOCK_MP_SEM;
ksem_t blockLpSem = BLOCK_LP_SEM; ksem_t blockLpSem = BLOCK_LP_SEM;
ksem_t semList[] = ksem_t semList[] = {
{
GROUP_SEM1, GROUP_SEM1,
GROUP_SEM2, GROUP_SEM2,
GROUP_SEM3, GROUP_SEM3,
@ -221,8 +220,7 @@ void releaseTestFiber(void)
static void testInterruptsInit(void) static void testInterruptsInit(void)
{ {
struct isrInitInfo i = struct isrInitInfo i = {
{
{ testIsrHandler, NULL}, { testIsrHandler, NULL},
{ &testIsrInfo, NULL}, { &testIsrInfo, NULL},
}; };
@ -257,13 +255,10 @@ void MonitorTaskEntry(void)
* then issue the appropriate test case summary message * then issue the appropriate test case summary message
*/ */
for (tasksDone = 0; tasksDone < NUM_TEST_TASKS; tasksDone++) for (tasksDone = 0; tasksDone < NUM_TEST_TASKS; tasksDone++) {
{
result = task_sem_group_take_wait_timeout (resultSems, SECONDS(60)); result = task_sem_group_take_wait_timeout (resultSems, SECONDS(60));
if (result != resultSems[TC_PASS]) if (result != resultSems[TC_PASS]) {
{ if (result != resultSems[TC_FAIL]) {
if (result != resultSems[TC_FAIL])
{
TC_ERROR ("Monitor task timed out\n"); TC_ERROR ("Monitor task timed out\n");
} }
TC_END_RESULT (TC_FAIL); TC_END_RESULT (TC_FAIL);

View file

@ -91,14 +91,12 @@ int simpleSemaTest (void)
* check the signal count. * check the signal count.
*/ */
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++) {
{
trigger_isrSemaSignal (simpleSem); trigger_isrSemaSignal (simpleSem);
task_sleep (10); /* Time for low priority task to run. */ task_sleep (10); /* Time for low priority task to run. */
signalCount = task_sem_count_get (simpleSem); signalCount = task_sem_count_get (simpleSem);
if (signalCount != (i + 1)) if (signalCount != (i + 1)) {
{
TC_ERROR ("<signalCount> error. Expected %d, got %d\n", TC_ERROR ("<signalCount> error. Expected %d, got %d\n",
i + 1, signalCount); i + 1, signalCount);
return TC_FAIL; return TC_FAIL;
@ -110,13 +108,11 @@ int simpleSemaTest (void)
* check the signal count. * check the signal count.
*/ */
for (i = 5; i < 10; i++) for (i = 5; i < 10; i++) {
{
task_sem_give (simpleSem); task_sem_give (simpleSem);
signalCount = task_sem_count_get (simpleSem); signalCount = task_sem_count_get (simpleSem);
if (signalCount != (i + 1)) if (signalCount != (i + 1)) {
{
TC_ERROR ("<signalCount> error. Expected %d, got %d\n", TC_ERROR ("<signalCount> error. Expected %d, got %d\n",
i + 1, signalCount); i + 1, signalCount);
return TC_FAIL; return TC_FAIL;
@ -128,19 +124,16 @@ int simpleSemaTest (void)
* attempt (it should be decrementing by 1 each time). * attempt (it should be decrementing by 1 each time).
*/ */
for (i = 9; i >= 4; i--) for (i = 9; i >= 4; i--) {
{
status = task_sem_take (simpleSem); status = task_sem_take (simpleSem);
if (status != RC_OK) if (status != RC_OK) {
{
TC_ERROR ("task_sem_take(SIMPLE_SEM) error. Expected %d, not %d.\n", TC_ERROR ("task_sem_take(SIMPLE_SEM) error. Expected %d, not %d.\n",
RC_OK, status); RC_OK, status);
return TC_FAIL; return TC_FAIL;
} }
signalCount = task_sem_count_get (simpleSem); signalCount = task_sem_count_get (simpleSem);
if (signalCount != i) if (signalCount != i) {
{
TC_ERROR ("<signalCount> error. Expected %d, not %d\n", TC_ERROR ("<signalCount> error. Expected %d, not %d\n",
i, signalCount); i, signalCount);
return TC_FAIL; return TC_FAIL;
@ -154,19 +147,16 @@ int simpleSemaTest (void)
* semaphore without wait. It should fail. * semaphore without wait. It should fail.
*/ */
for (i = 0; i < 10; i++) for (i = 0; i < 10; i++) {
{
status = task_sem_take (simpleSem); status = task_sem_take (simpleSem);
if (status != RC_FAIL) if (status != RC_FAIL) {
{
TC_ERROR ("task_sem_take(SIMPLE_SEM) error. Expected %d, got %d.\n", TC_ERROR ("task_sem_take(SIMPLE_SEM) error. Expected %d, got %d.\n",
RC_FAIL, status); RC_FAIL, status);
return TC_FAIL; return TC_FAIL;
} }
signalCount = task_sem_count_get (simpleSem); signalCount = task_sem_count_get (simpleSem);
if (signalCount != 0) if (signalCount != 0) {
{
TC_ERROR ("<signalCount> error. Expected %d, not %d\n", TC_ERROR ("<signalCount> error. Expected %d, not %d\n",
0, signalCount); 0, signalCount);
return TC_FAIL; return TC_FAIL;
@ -188,12 +178,10 @@ int simpleSemaWaitTest (void)
int status; int status;
int i; int i;
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++) {
{
/* Wait one second for SIMPLE_SEM. Timeout is expected. */ /* Wait one second for SIMPLE_SEM. Timeout is expected. */
status = task_sem_take_wait_timeout (simpleSem, OBJ_TIMEOUT); status = task_sem_take_wait_timeout (simpleSem, OBJ_TIMEOUT);
if (status != RC_TIME) if (status != RC_TIME) {
{
TC_ERROR ("task_sem_take_wait_timeout() error. Expected %d, got %d\n", TC_ERROR ("task_sem_take_wait_timeout() error. Expected %d, got %d\n",
RC_TIME, status); RC_TIME, status);
return TC_FAIL; return TC_FAIL;
@ -209,8 +197,7 @@ int simpleSemaWaitTest (void)
task_sem_give (altSem); task_sem_give (altSem);
status = task_sem_take_wait_timeout (simpleSem, OBJ_TIMEOUT); status = task_sem_take_wait_timeout (simpleSem, OBJ_TIMEOUT);
if (status != RC_OK) if (status != RC_OK) {
{
TC_ERROR ("task_sem_take_wait_timeout() error. Expected %d, got %d\n", TC_ERROR ("task_sem_take_wait_timeout() error. Expected %d, got %d\n",
RC_OK, status); RC_OK, status);
return TC_FAIL; return TC_FAIL;
@ -228,8 +215,7 @@ int simpleSemaWaitTest (void)
*/ */
status = task_sem_take_wait_timeout (simpleSem, OBJ_TIMEOUT); status = task_sem_take_wait_timeout (simpleSem, OBJ_TIMEOUT);
if (status != RC_OK) if (status != RC_OK) {
{
TC_ERROR ("task_sem_take_wait_timeout() error. Expected %d, got %d\n", TC_ERROR ("task_sem_take_wait_timeout() error. Expected %d, got %d\n",
RC_OK, status); RC_OK, status);
return TC_FAIL; return TC_FAIL;
@ -256,11 +242,9 @@ int simpleGroupTest (void)
task_sem_group_reset (semList); task_sem_group_reset (semList);
for (i = 0; semList[i] != ENDLIST; i++) for (i = 0; semList[i] != ENDLIST; i++) {
{
status = task_sem_count_get (semList[i]); status = task_sem_count_get (semList[i]);
if (status != 0) if (status != 0) {
{
TC_ERROR ("task_sem_count_get() returned %d not %d\n", status, 0); TC_ERROR ("task_sem_count_get() returned %d not %d\n", status, 0);
return TC_FAIL; return TC_FAIL;
} }
@ -269,8 +253,7 @@ int simpleGroupTest (void)
/* Timeout while waiting for a semaphore from the group */ /* Timeout while waiting for a semaphore from the group */
value = task_sem_group_take_wait_timeout (semList, OBJ_TIMEOUT); value = task_sem_group_take_wait_timeout (semList, OBJ_TIMEOUT);
if (value != ENDLIST) if (value != ENDLIST) {
{
TC_ERROR ("task_sem_group_take_wait_timeout() returned %d not %d\n", TC_ERROR ("task_sem_group_take_wait_timeout() returned %d not %d\n",
value, ENDGROUP); value, ENDGROUP);
return TC_FAIL; return TC_FAIL;
@ -278,15 +261,12 @@ int simpleGroupTest (void)
/* Signal the semaphores in the group */ /* Signal the semaphores in the group */
for (i = 0; i < 10; i++) for (i = 0; i < 10; i++) {
{
task_sem_group_give (semList); task_sem_group_give (semList);
for (j = 0; semList[j] != ENDLIST; j++) for (j = 0; semList[j] != ENDLIST; j++) {
{
status = task_sem_count_get (semList[j]); status = task_sem_count_get (semList[j]);
if (status != i + 1) if (status != i + 1) {
{
TC_ERROR ("task_sem_count_get() returned %d not %d\n", TC_ERROR ("task_sem_count_get() returned %d not %d\n",
status, i + 1); status, i + 1);
return TC_FAIL; return TC_FAIL;
@ -296,15 +276,12 @@ int simpleGroupTest (void)
/* Get the semaphores */ /* Get the semaphores */
for (i = 9; i >= 5; i--) for (i = 9; i >= 5; i--) {
{
value = task_sem_group_take_wait_timeout (semList, 0); value = task_sem_group_take_wait_timeout (semList, 0);
for (j = 0; semList[j] != ENDLIST; j++) for (j = 0; semList[j] != ENDLIST; j++) {
{
status = task_sem_count_get (semList[j]); status = task_sem_count_get (semList[j]);
if (status != (value == semList[j] ? i : 10)) if (status != (value == semList[j] ? i : 10)) {
{
TC_ERROR ("task_sem_count_get(0x%x) returned %d not %d\n", TC_ERROR ("task_sem_count_get(0x%x) returned %d not %d\n",
semList[j], status, (value == semList[j]) ? i : 10); semList[j], status, (value == semList[j]) ? i : 10);
return TC_FAIL; return TC_FAIL;
@ -316,11 +293,9 @@ int simpleGroupTest (void)
task_sem_group_reset (semList); task_sem_group_reset (semList);
for (i = 0; semList[i] != ENDLIST; i++) for (i = 0; semList[i] != ENDLIST; i++) {
{
status = task_sem_count_get (semList[i]); status = task_sem_count_get (semList[i]);
if (status != 0) if (status != 0) {
{
TC_ERROR ("task_sem_count_get() returned %d not %d\n", status, 0); TC_ERROR ("task_sem_count_get() returned %d not %d\n", status, 0);
return TC_FAIL; return TC_FAIL;
} }
@ -351,11 +326,9 @@ int simpleGroupWaitTest (void)
* Each semaphore in the group will be tested. * Each semaphore in the group will be tested.
*/ */
for (i = 0; semList[i] != ENDLIST; i++) for (i = 0; semList[i] != ENDLIST; i++) {
{
sema = task_sem_group_take_wait (semList); sema = task_sem_group_take_wait (semList);
if (sema != semList[i]) if (sema != semList[i]) {
{
TC_ERROR ("task_sem_group_take_wait() error. Expected %d, not %d\n", TC_ERROR ("task_sem_group_take_wait() error. Expected %d, not %d\n",
(int) semList[i], (int) sema); (int) semList[i], (int) sema);
return TC_FAIL; return TC_FAIL;
@ -368,11 +341,9 @@ int simpleGroupWaitTest (void)
* group is the value that is returned, not the first. * group is the value that is returned, not the first.
*/ */
for (i = 3; i >= 0; i--) for (i = 3; i >= 0; i--) {
{
sema = task_sem_group_take_wait (semList); sema = task_sem_group_take_wait (semList);
if (sema != semList[i]) if (sema != semList[i]) {
{
TC_ERROR ("task_sem_group_take_wait() error. Expected %d, not %d\n", TC_ERROR ("task_sem_group_take_wait() error. Expected %d, not %d\n",
(int) semList[3], (int) sema); (int) semList[3], (int) sema);
return TC_FAIL; return TC_FAIL;
@ -384,11 +355,9 @@ int simpleGroupWaitTest (void)
* task will trigger an interrupt that signals the semaphore. * task will trigger an interrupt that signals the semaphore.
*/ */
for (i = 0; semList[i] != ENDLIST; i++) for (i = 0; semList[i] != ENDLIST; i++) {
{
sema = task_sem_group_take_wait (semList); sema = task_sem_group_take_wait (semList);
if (sema != semList[i]) if (sema != semList[i]) {
{
TC_ERROR ("task_sem_group_take_wait() error. Expected %d, not %d\n", TC_ERROR ("task_sem_group_take_wait() error. Expected %d, not %d\n",
(int) semList[i], (int) sema); (int) semList[i], (int) sema);
return TC_FAIL; return TC_FAIL;
@ -425,8 +394,7 @@ static int simpleFiberSemTest (void)
/* let the fiber signal the semaphore and wait on it */ /* let the fiber signal the semaphore and wait on it */
releaseTestFiber (); releaseTestFiber ();
status = task_sem_take_wait_timeout (simpleSem, OBJ_TIMEOUT); status = task_sem_take_wait_timeout (simpleSem, OBJ_TIMEOUT);
if (status != RC_OK) if (status != RC_OK) {
{
TC_ERROR ("task_sem_take_wait_timeout() error. Expected %d, got %d\n", TC_ERROR ("task_sem_take_wait_timeout() error. Expected %d, got %d\n",
RC_OK, status); RC_OK, status);
return TC_FAIL; return TC_FAIL;
@ -435,20 +403,17 @@ static int simpleFiberSemTest (void)
/* release the fiber and let it signal the semaphore N_TESTS times */ /* release the fiber and let it signal the semaphore N_TESTS times */
releaseTestFiber (); releaseTestFiber ();
signalCount = task_sem_count_get (simpleSem); signalCount = task_sem_count_get (simpleSem);
if (signalCount != N_TESTS) if (signalCount != N_TESTS) {
{
TC_ERROR ("<signalCount> error. Expected %d, got %d\n", TC_ERROR ("<signalCount> error. Expected %d, got %d\n",
N_TESTS, signalCount); N_TESTS, signalCount);
return TC_FAIL; return TC_FAIL;
} }
/* wait on the semaphore group while the fiber signals each semaphore in it */ /* wait on the semaphore group while the fiber signals each semaphore in it */
for (i = 0; semList[i] != ENDLIST; i++) for (i = 0; semList[i] != ENDLIST; i++) {
{
releaseTestFiber (); releaseTestFiber ();
sema = task_sem_group_take_wait_timeout (semList, OBJ_TIMEOUT); sema = task_sem_group_take_wait_timeout (semList, OBJ_TIMEOUT);
if (sema != semList[i]) if (sema != semList[i]) {
{
TC_ERROR ("task_sem_group_take_wait() error. Expected %d, not %d\n", TC_ERROR ("task_sem_group_take_wait() error. Expected %d, not %d\n",
(int) semList[i], (int) sema); (int) semList[i], (int) sema);
return TC_FAIL; return TC_FAIL;
@ -470,8 +435,7 @@ int HighPriTask (void)
/* Wait until task is activated */ /* Wait until task is activated */
status = task_sem_take_wait (hpSem); status = task_sem_take_wait (hpSem);
if (status != RC_OK) if (status != RC_OK) {
{
TC_ERROR ("%s priority task failed to wait on %s: %d\n", TC_ERROR ("%s priority task failed to wait on %s: %d\n",
"High", "HIGH_PRI_SEM", status); "High", "HIGH_PRI_SEM", status);
return TC_FAIL; return TC_FAIL;
@ -479,8 +443,7 @@ int HighPriTask (void)
/* Wait on a semaphore along with other tasks */ /* Wait on a semaphore along with other tasks */
status = task_sem_take_wait (manyBlockSem); status = task_sem_take_wait (manyBlockSem);
if (status != RC_OK) if (status != RC_OK) {
{
TC_ERROR ("%s priority task failed to wait on %s: %d\n", TC_ERROR ("%s priority task failed to wait on %s: %d\n",
"High", "MANY_BLOCKED_SEM", status); "High", "MANY_BLOCKED_SEM", status);
return TC_FAIL; return TC_FAIL;
@ -506,8 +469,7 @@ int LowPriTask (void)
/* Wait on a semaphore along with other tasks */ /* Wait on a semaphore along with other tasks */
status = task_sem_take_wait (manyBlockSem); status = task_sem_take_wait (manyBlockSem);
if (status != RC_OK) if (status != RC_OK) {
{
TC_ERROR ("%s priority task failed to wait on %s: %d\n", TC_ERROR ("%s priority task failed to wait on %s: %d\n",
"Low", "MANY_BLOCKED_SEM", status); "Low", "MANY_BLOCKED_SEM", status);
return TC_FAIL; return TC_FAIL;
@ -535,8 +497,7 @@ int AlternateTask (void)
/* Wait until it is time to continue */ /* Wait until it is time to continue */
status = task_sem_take_wait (altSem); status = task_sem_take_wait (altSem);
if (status != RC_OK) if (status != RC_OK) {
{
TC_ERROR ("task_sem_take_wait() error. Expected %d, got %d\n", TC_ERROR ("task_sem_take_wait() error. Expected %d, got %d\n",
RC_OK, status); RC_OK, status);
return TC_FAIL; return TC_FAIL;
@ -558,8 +519,7 @@ int AlternateTask (void)
/* Wait for RegressionTask to wake this task up */ /* Wait for RegressionTask to wake this task up */
status = task_sem_take_wait (altSem); status = task_sem_take_wait (altSem);
if (status != RC_OK) if (status != RC_OK) {
{
TC_ERROR ("task_sem_take_wait() error. Expected %d, got %d", TC_ERROR ("task_sem_take_wait() error. Expected %d, got %d",
RC_OK, status); RC_OK, status);
return TC_FAIL; return TC_FAIL;
@ -567,8 +527,7 @@ int AlternateTask (void)
/* Wait on a semaphore that will have many waiters */ /* Wait on a semaphore that will have many waiters */
status = task_sem_take_wait (manyBlockSem); status = task_sem_take_wait (manyBlockSem);
if (status != RC_OK) if (status != RC_OK) {
{
TC_ERROR ("task_sem_take_wait() error. Expected %d, got %d", TC_ERROR ("task_sem_take_wait() error. Expected %d, got %d",
RC_OK, status); RC_OK, status);
return TC_FAIL; return TC_FAIL;
@ -579,15 +538,13 @@ int AlternateTask (void)
/* Wait until the alternate task is needed again */ /* Wait until the alternate task is needed again */
status = task_sem_take_wait (altSem); status = task_sem_take_wait (altSem);
if (status != RC_OK) if (status != RC_OK) {
{
TC_ERROR ("task_sem_take_wait() error. Expected %d, got %d", TC_ERROR ("task_sem_take_wait() error. Expected %d, got %d",
RC_OK, status); RC_OK, status);
return TC_FAIL; return TC_FAIL;
} }
for (i = 0; semList[i] != ENDLIST; i++) for (i = 0; semList[i] != ENDLIST; i++) {
{
task_sem_give (semList[i]); task_sem_give (semList[i]);
/* Context switch back to Regression Task */ /* Context switch back to Regression Task */
} }
@ -595,8 +552,7 @@ int AlternateTask (void)
task_sem_group_give (semList); task_sem_group_give (semList);
/* Context switch back to Regression Task */ /* Context switch back to Regression Task */
for (i = 0; semList[i] != ENDLIST; i++) for (i = 0; semList[i] != ENDLIST; i++) {
{
trigger_isrSemaSignal (semList[i]); trigger_isrSemaSignal (semList[i]);
/* Context switch back to Regression Task */ /* Context switch back to Regression Task */
} }
@ -627,16 +583,14 @@ int RegressionTask (void)
/* Signal a semaphore that has no waiting tasks. */ /* Signal a semaphore that has no waiting tasks. */
TC_PRINT ("Signal and test a semaphore without blocking\n"); TC_PRINT ("Signal and test a semaphore without blocking\n");
tcRC = simpleSemaTest (); tcRC = simpleSemaTest ();
if (tcRC != TC_PASS) if (tcRC != TC_PASS) {
{
return TC_FAIL; return TC_FAIL;
} }
/* Wait on a semaphore. */ /* Wait on a semaphore. */
TC_PRINT ("Signal and test a semaphore with blocking\n"); TC_PRINT ("Signal and test a semaphore with blocking\n");
tcRC = simpleSemaWaitTest (); tcRC = simpleSemaWaitTest ();
if (tcRC != TC_PASS) if (tcRC != TC_PASS) {
{
return TC_FAIL; return TC_FAIL;
} }
@ -663,8 +617,7 @@ int RegressionTask (void)
task_sleep (OBJ_TIMEOUT); /* Ensure high priority task can run */ task_sleep (OBJ_TIMEOUT); /* Ensure high priority task can run */
value = task_sem_group_take_wait_timeout (semBlockList, OBJ_TIMEOUT); value = task_sem_group_take_wait_timeout (semBlockList, OBJ_TIMEOUT);
if (value != blockHpSem) if (value != blockHpSem) {
{
TC_ERROR ("%s priority task did not get semaphore: 0x%x\n", TC_ERROR ("%s priority task did not get semaphore: 0x%x\n",
"High", value); "High", value);
return TC_FAIL; return TC_FAIL;
@ -673,8 +626,7 @@ int RegressionTask (void)
task_sem_give (manyBlockSem); task_sem_give (manyBlockSem);
task_sleep (OBJ_TIMEOUT); /* Ensure medium priority task can run */ task_sleep (OBJ_TIMEOUT); /* Ensure medium priority task can run */
value = task_sem_group_take_wait_timeout (semBlockList, OBJ_TIMEOUT); value = task_sem_group_take_wait_timeout (semBlockList, OBJ_TIMEOUT);
if (value != blockMpSem) if (value != blockMpSem) {
{
TC_ERROR ("%s priority task did not get semaphore: 0x%x\n", TC_ERROR ("%s priority task did not get semaphore: 0x%x\n",
"Medium", value); "Medium", value);
return TC_FAIL; return TC_FAIL;
@ -685,16 +637,14 @@ int RegressionTask (void)
task_sleep (OBJ_TIMEOUT); /* Ensure low priority task can run */ task_sleep (OBJ_TIMEOUT); /* Ensure low priority task can run */
value = task_sem_group_take_wait_timeout (semBlockList, OBJ_TIMEOUT); value = task_sem_group_take_wait_timeout (semBlockList, OBJ_TIMEOUT);
if (value != blockLpSem) if (value != blockLpSem) {
{
TC_ERROR ("%s priority task did not get semaphore: 0x%x\n", TC_ERROR ("%s priority task did not get semaphore: 0x%x\n",
"Low", value); "Low", value);
return TC_FAIL; return TC_FAIL;
} }
value = task_sem_group_take_wait_timeout (semBlockList, OBJ_TIMEOUT); value = task_sem_group_take_wait_timeout (semBlockList, OBJ_TIMEOUT);
if (value != ENDLIST) if (value != ENDLIST) {
{
TC_ERROR ("Group test Expecting ENDLIST, but got 0x%x\n", TC_ERROR ("Group test Expecting ENDLIST, but got 0x%x\n",
value); value);
return TC_FAIL; return TC_FAIL;
@ -703,22 +653,19 @@ int RegressionTask (void)
TC_PRINT ("Testing semaphore groups without blocking\n"); TC_PRINT ("Testing semaphore groups without blocking\n");
tcRC = simpleGroupTest (); tcRC = simpleGroupTest ();
if (tcRC != TC_PASS) if (tcRC != TC_PASS) {
{
return TC_FAIL; return TC_FAIL;
} }
TC_PRINT ("Testing semaphore groups with blocking\n"); TC_PRINT ("Testing semaphore groups with blocking\n");
tcRC = simpleGroupWaitTest (); tcRC = simpleGroupWaitTest ();
if (tcRC != TC_PASS) if (tcRC != TC_PASS) {
{
return TC_FAIL; return TC_FAIL;
} }
TC_PRINT ("Testing semaphore release by fiber\n"); TC_PRINT ("Testing semaphore release by fiber\n");
tcRC = simpleFiberSemTest (); tcRC = simpleFiberSemTest ();
if (tcRC != TC_PASS) if (tcRC != TC_PASS) {
{
return TC_FAIL; return TC_FAIL;
} }

View file

@ -80,14 +80,12 @@ static void testFiberEntry (void)
/* release the semaphore for N_TESTS times */ /* release the semaphore for N_TESTS times */
nano_fiber_sem_take_wait (&fiberSem); nano_fiber_sem_take_wait (&fiberSem);
for (i = 0; i < N_TESTS; i++) for (i = 0; i < N_TESTS; i++) {
{
fiber_sem_give (simpleSem, &CMD_PKT_SET(cmdPktSet)); fiber_sem_give (simpleSem, &CMD_PKT_SET(cmdPktSet));
} }
/* signal each semaphore in the group */ /* signal each semaphore in the group */
for (i = 0; semList[i] != ENDLIST; i++) for (i = 0; semList[i] != ENDLIST; i++) {
{
nano_fiber_sem_take_wait (&fiberSem); nano_fiber_sem_take_wait (&fiberSem);
fiber_sem_give (semList[i], &CMD_PKT_SET(cmdPktSet)); fiber_sem_give (semList[i], &CMD_PKT_SET(cmdPktSet));
} }

View file

@ -70,11 +70,9 @@ This module contains the code for testing sprintf() functionality.
/* typedefs */ /* typedefs */
typedef union typedef union {
{
double d; double d;
struct struct {
{
uint32_t u1; /* This part contains the exponent */ uint32_t u1; /* This part contains the exponent */
uint32_t u2; /* This part contains the fraction */ uint32_t u2; /* This part contains the fraction */
}; };
@ -97,8 +95,7 @@ int sprintfDoubleTest(void)
var.u1 = 0x00000000; var.u1 = 0x00000000;
var.u2 = 0x7ff00000; /* Bit pattern for +INF (double) */ var.u2 = 0x7ff00000; /* Bit pattern for +INF (double) */
sprintf (buffer, "%f", var.d); sprintf (buffer, "%f", var.d);
if (strcmp (buffer, "+INF") != 0) if (strcmp (buffer, "+INF") != 0) {
{
TC_ERROR ("sprintf(+INF) - incorrect output '%s'\n", buffer); TC_ERROR ("sprintf(+INF) - incorrect output '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
@ -106,8 +103,7 @@ int sprintfDoubleTest(void)
var.u1 = 0x00000000; var.u1 = 0x00000000;
var.u2 = 0xfff00000; /* Bit pattern for -INF (double) */ var.u2 = 0xfff00000; /* Bit pattern for -INF (double) */
sprintf (buffer, "%f", var.d); sprintf (buffer, "%f", var.d);
if (strcmp (buffer, "-INF") != 0) if (strcmp (buffer, "-INF") != 0) {
{
TC_ERROR ("sprintf(-INF) - incorrect output '%s'\n", buffer); TC_ERROR ("sprintf(-INF) - incorrect output '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
@ -115,74 +111,64 @@ int sprintfDoubleTest(void)
var.u1 = 0x00000000; var.u1 = 0x00000000;
var.u2 = 0x7ff80000; /* Bit pattern for NaN (double) */ var.u2 = 0x7ff80000; /* Bit pattern for NaN (double) */
sprintf (buffer, "%f", var.d); sprintf (buffer, "%f", var.d);
if (strcmp (buffer, "NaN") != 0) if (strcmp (buffer, "NaN") != 0) {
{
TC_ERROR ("sprintf(NaN) - incorrect output '%s'\n", buffer); TC_ERROR ("sprintf(NaN) - incorrect output '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
var.d = 1.0; var.d = 1.0;
sprintf (buffer, "%f", var.d); sprintf (buffer, "%f", var.d);
if (strcmp (buffer, "1.000000") != 0) if (strcmp (buffer, "1.000000") != 0) {
{
TC_ERROR ("sprintf(1.0) - incorrect output '%s'\n", buffer); TC_ERROR ("sprintf(1.0) - incorrect output '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
sprintf (buffer, "%+f", var.d); sprintf (buffer, "%+f", var.d);
if (strcmp (buffer, "+1.000000") != 0) if (strcmp (buffer, "+1.000000") != 0) {
{
TC_ERROR ("sprintf(+1.0) - incorrect output '%s'\n", buffer); TC_ERROR ("sprintf(+1.0) - incorrect output '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
sprintf (buffer, "%.2f", var.d); sprintf (buffer, "%.2f", var.d);
if (strcmp (buffer, "1.00") != 0) if (strcmp (buffer, "1.00") != 0) {
{
TC_ERROR ("sprintf(1.00) - incorrect output '%s'\n", buffer); TC_ERROR ("sprintf(1.00) - incorrect output '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
sprintf (buffer, "%.*f", 11, var.d); sprintf (buffer, "%.*f", 11, var.d);
if (strcmp (buffer, "1.00000000000") != 0) if (strcmp (buffer, "1.00000000000") != 0) {
{
TC_ERROR ("sprintf(1.00000000000) - incorrect output '%s'\n", buffer); TC_ERROR ("sprintf(1.00000000000) - incorrect output '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
sprintf (buffer, "%12f", var.d); sprintf (buffer, "%12f", var.d);
if (strcmp (buffer, " 1.000000") != 0) if (strcmp (buffer, " 1.000000") != 0) {
{
TC_ERROR ("sprintf ( 1.000000) - incorrect output '%s'\n", buffer); TC_ERROR ("sprintf ( 1.000000) - incorrect output '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
sprintf (buffer, "%-12f", var.d); sprintf (buffer, "%-12f", var.d);
if (strcmp (buffer, "1.000000 ") != 0) if (strcmp (buffer, "1.000000 ") != 0) {
{
TC_ERROR ("sprintf(1.000000 ) - incorrect output '%s'\n", buffer); TC_ERROR ("sprintf(1.000000 ) - incorrect output '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
sprintf (buffer, "%012f", var.d); sprintf (buffer, "%012f", var.d);
if (strcmp (buffer, "00001.000000") != 0) if (strcmp (buffer, "00001.000000") != 0) {
{
TC_ERROR ("sprintf (00001.000000) - incorrect output '%s'\n", buffer); TC_ERROR ("sprintf (00001.000000) - incorrect output '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
var.d = -1.0; var.d = -1.0;
sprintf (buffer, "%f", var.d); sprintf (buffer, "%f", var.d);
if (strcmp (buffer, "-1.000000") != 0) if (strcmp (buffer, "-1.000000") != 0) {
{
TC_ERROR ("sprintf(-1.0) - incorrect output '%s'\n", buffer); TC_ERROR ("sprintf(-1.0) - incorrect output '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
var.d = 1234.56789; var.d = 1234.56789;
sprintf (buffer, "%f", var.d); sprintf (buffer, "%f", var.d);
if (strcmp (buffer, "1234.567890") != 0) if (strcmp (buffer, "1234.567890") != 0) {
{
TC_ERROR ("sprintf(-1.0) - incorrect output '%s'\n", buffer); TC_ERROR ("sprintf(-1.0) - incorrect output '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
@ -190,15 +176,13 @@ int sprintfDoubleTest(void)
/*******************/ /*******************/
var.d = 1234.0; var.d = 1234.0;
sprintf (buffer, "%e", var.d); sprintf (buffer, "%e", var.d);
if (strcmp (buffer, "1.234000e+003") != 0) if (strcmp (buffer, "1.234000e+003") != 0) {
{
TC_ERROR ("sprintf(1.234000e+003) - incorrect output '%s'\n", buffer); TC_ERROR ("sprintf(1.234000e+003) - incorrect output '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
sprintf (buffer, "%E", var.d); sprintf (buffer, "%E", var.d);
if (strcmp (buffer, "1.234000E+003") != 0) if (strcmp (buffer, "1.234000E+003") != 0) {
{
TC_ERROR ("sprintf(1.234000E+003) - incorrect output '%s'\n", buffer); TC_ERROR ("sprintf(1.234000E+003) - incorrect output '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
@ -206,15 +190,13 @@ int sprintfDoubleTest(void)
/*******************/ /*******************/
var.d = 0.1234; var.d = 0.1234;
sprintf (buffer, "%e", var.d); sprintf (buffer, "%e", var.d);
if (strcmp (buffer, "1.234000e-001") != 0) if (strcmp (buffer, "1.234000e-001") != 0) {
{
TC_ERROR ("sprintf(1.234000e-001) - incorrect output '%s'\n", buffer); TC_ERROR ("sprintf(1.234000e-001) - incorrect output '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
sprintf (buffer, "%E", var.d); sprintf (buffer, "%E", var.d);
if (strcmp (buffer, "1.234000E-001") != 0) if (strcmp (buffer, "1.234000E-001") != 0) {
{
TC_ERROR ("sprintf(1.234000E-001) - incorrect output '%s'\n", buffer); TC_ERROR ("sprintf(1.234000E-001) - incorrect output '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
@ -222,15 +204,13 @@ int sprintfDoubleTest(void)
/*******************/ /*******************/
var.d = 1234000000.0; var.d = 1234000000.0;
sprintf (buffer, "%g", var.d); sprintf (buffer, "%g", var.d);
if (strcmp (buffer, "1.234e+009") != 0) if (strcmp (buffer, "1.234e+009") != 0) {
{
TC_ERROR ("sprintf(1.234e+009) - incorrect output '%s'\n", buffer); TC_ERROR ("sprintf(1.234e+009) - incorrect output '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
sprintf (buffer, "%G", var.d); sprintf (buffer, "%G", var.d);
if (strcmp (buffer, "1.234E+009") != 0) if (strcmp (buffer, "1.234E+009") != 0) {
{
TC_ERROR ("sprintf(1.234E+009) - incorrect output '%s'\n", buffer); TC_ERROR ("sprintf(1.234E+009) - incorrect output '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
@ -246,8 +226,7 @@ int sprintfDoubleTest(void)
*/ */
sprintf (buffer, "%Lf", (long double) 1234567.0); sprintf (buffer, "%Lf", (long double) 1234567.0);
if (strcmp ("-0.000000", buffer) != 0) if (strcmp ("-0.000000", buffer) != 0) {
{
TC_ERROR ("sprintf(%%Lf). Expected '-0.000000', got '%s'\n", TC_ERROR ("sprintf(%%Lf). Expected '-0.000000', got '%s'\n",
buffer); buffer);
status = TC_FAIL; status = TC_FAIL;
@ -301,15 +280,13 @@ int vsnprintfTest(void)
*/ */
buffer[0] = '\0'; buffer[0] = '\0';
len = tvsnprintf (buffer, (size_t)(-4), "%x", DEADBEEF); len = tvsnprintf (buffer, (size_t)(-4), "%x", DEADBEEF);
if (len != strlen (DEADBEEF_LHEX_STR)) if (len != strlen (DEADBEEF_LHEX_STR)) {
{
TC_ERROR ("vsnprintf(%%x). Expected return value %d, not %d\n", TC_ERROR ("vsnprintf(%%x). Expected return value %d, not %d\n",
strlen (DEADBEEF_LHEX_STR), len); strlen (DEADBEEF_LHEX_STR), len);
status = TC_FAIL; status = TC_FAIL;
} }
if (strcmp (buffer, DEADBEEF_LHEX_STR) != 0) if (strcmp (buffer, DEADBEEF_LHEX_STR) != 0) {
{
TC_ERROR ("vsnprintf(%%x). Expected '%s', got '%s'\n", TC_ERROR ("vsnprintf(%%x). Expected '%s', got '%s'\n",
DEADBEEF_LHEX_STR, buffer); DEADBEEF_LHEX_STR, buffer);
status = TC_FAIL; status = TC_FAIL;
@ -318,15 +295,13 @@ int vsnprintfTest(void)
/*******************/ /*******************/
buffer[0] = '\0'; buffer[0] = '\0';
len = tvsnprintf (buffer, 0, "%x", DEADBEEF); len = tvsnprintf (buffer, 0, "%x", DEADBEEF);
if (len != strlen (DEADBEEF_LHEX_STR)) if (len != strlen (DEADBEEF_LHEX_STR)) {
{
TC_ERROR ("vsnprintf(%%x). Expected return value %d, not %d\n", TC_ERROR ("vsnprintf(%%x). Expected return value %d, not %d\n",
strlen (DEADBEEF_LHEX_STR), len); strlen (DEADBEEF_LHEX_STR), len);
status = TC_FAIL; status = TC_FAIL;
} }
if (strcmp (buffer, "") != 0) if (strcmp (buffer, "") != 0) {
{
TC_ERROR ("vsnprintf(%%x). Expected '%s', got '%s'\n", TC_ERROR ("vsnprintf(%%x). Expected '%s', got '%s'\n",
"", buffer); "", buffer);
status = TC_FAIL; status = TC_FAIL;
@ -334,15 +309,13 @@ int vsnprintfTest(void)
/*******************/ /*******************/
len = tvsnprintf (buffer, 4, "%x", DEADBEEF); len = tvsnprintf (buffer, 4, "%x", DEADBEEF);
if (len != strlen (DEADBEEF_LHEX_STR)) if (len != strlen (DEADBEEF_LHEX_STR)) {
{
TC_ERROR ("vsnprintf(%%x). Expected return value %d, not %d\n", TC_ERROR ("vsnprintf(%%x). Expected return value %d, not %d\n",
strlen (DEADBEEF_LHEX_STR), len); strlen (DEADBEEF_LHEX_STR), len);
status = TC_FAIL; status = TC_FAIL;
} }
if (strcmp (buffer, "dea") != 0) if (strcmp (buffer, "dea") != 0) {
{
TC_ERROR ("vsnprintf(%%x). Expected '%s', got '%s'\n", TC_ERROR ("vsnprintf(%%x). Expected '%s', got '%s'\n",
"dea", buffer); "dea", buffer);
status = TC_FAIL; status = TC_FAIL;
@ -387,15 +360,13 @@ int vsprintfTest(void)
/*******************/ /*******************/
len = tvsprintf (buffer, "%x", DEADBEEF); len = tvsprintf (buffer, "%x", DEADBEEF);
if (len != strlen (DEADBEEF_LHEX_STR)) if (len != strlen (DEADBEEF_LHEX_STR)) {
{
TC_ERROR ("sprintf(%%x). Expected %d bytes written, not %d\n", TC_ERROR ("sprintf(%%x). Expected %d bytes written, not %d\n",
strlen (DEADBEEF_LHEX_STR), len); strlen (DEADBEEF_LHEX_STR), len);
status = TC_FAIL; status = TC_FAIL;
} }
if (strcmp (buffer, DEADBEEF_LHEX_STR) != 0) if (strcmp (buffer, DEADBEEF_LHEX_STR) != 0) {
{
TC_ERROR ("sprintf(%%x). Expected '%s', got '%s'\n", TC_ERROR ("sprintf(%%x). Expected '%s', got '%s'\n",
DEADBEEF_LHEX_STR, buffer); DEADBEEF_LHEX_STR, buffer);
status = TC_FAIL; status = TC_FAIL;
@ -430,15 +401,13 @@ int snprintfTest(void)
*/ */
buffer[0] = '\0'; buffer[0] = '\0';
len = snprintf (buffer, (size_t)(-4), "%x", DEADBEEF); len = snprintf (buffer, (size_t)(-4), "%x", DEADBEEF);
if (len != strlen (DEADBEEF_LHEX_STR)) if (len != strlen (DEADBEEF_LHEX_STR)) {
{
TC_ERROR ("snprintf(%%x). Expected return value %d, not %d\n", TC_ERROR ("snprintf(%%x). Expected return value %d, not %d\n",
strlen (DEADBEEF_LHEX_STR), len); strlen (DEADBEEF_LHEX_STR), len);
status = TC_FAIL; status = TC_FAIL;
} }
if (strcmp (buffer, DEADBEEF_LHEX_STR) != 0) if (strcmp (buffer, DEADBEEF_LHEX_STR) != 0) {
{
TC_ERROR ("snprintf(%%x). Expected '%s', got '%s'\n", TC_ERROR ("snprintf(%%x). Expected '%s', got '%s'\n",
DEADBEEF_LHEX_STR, buffer); DEADBEEF_LHEX_STR, buffer);
status = TC_FAIL; status = TC_FAIL;
@ -447,15 +416,13 @@ int snprintfTest(void)
/*******************/ /*******************/
buffer[0] = '\0'; buffer[0] = '\0';
len = snprintf (buffer, 0, "%x", DEADBEEF); len = snprintf (buffer, 0, "%x", DEADBEEF);
if (len != strlen (DEADBEEF_LHEX_STR)) if (len != strlen (DEADBEEF_LHEX_STR)) {
{
TC_ERROR ("snprintf(%%x). Expected return value %d, not %d\n", TC_ERROR ("snprintf(%%x). Expected return value %d, not %d\n",
strlen (DEADBEEF_LHEX_STR), len); strlen (DEADBEEF_LHEX_STR), len);
status = TC_FAIL; status = TC_FAIL;
} }
if (strcmp (buffer, "") != 0) if (strcmp (buffer, "") != 0) {
{
TC_ERROR ("snprintf(%%x). Expected '%s', got '%s'\n", TC_ERROR ("snprintf(%%x). Expected '%s', got '%s'\n",
"", buffer); "", buffer);
status = TC_FAIL; status = TC_FAIL;
@ -463,15 +430,13 @@ int snprintfTest(void)
/*******************/ /*******************/
len = snprintf (buffer, 4, "%x", DEADBEEF); len = snprintf (buffer, 4, "%x", DEADBEEF);
if (len != strlen (DEADBEEF_LHEX_STR)) if (len != strlen (DEADBEEF_LHEX_STR)) {
{
TC_ERROR ("snprintf(%%x). Expected return value %d, not %d\n", TC_ERROR ("snprintf(%%x). Expected return value %d, not %d\n",
strlen (DEADBEEF_LHEX_STR), len); strlen (DEADBEEF_LHEX_STR), len);
status = TC_FAIL; status = TC_FAIL;
} }
if (strcmp (buffer, "dea") != 0) if (strcmp (buffer, "dea") != 0) {
{
TC_ERROR ("snprintf(%%x). Expected '%s', got '%s'\n", TC_ERROR ("snprintf(%%x). Expected '%s', got '%s'\n",
"dea", buffer); "dea", buffer);
status = TC_FAIL; status = TC_FAIL;
@ -495,8 +460,7 @@ int sprintfMiscTest(void)
/*******************/ /*******************/
sprintf (buffer, "%p", (void *) DEADBEEF); sprintf (buffer, "%p", (void *) DEADBEEF);
if (strcmp (buffer, DEADBEEF_PTR_STR) != 0) if (strcmp (buffer, DEADBEEF_PTR_STR) != 0) {
{
TC_ERROR ("sprintf(%%p). Expected '%s', got '%s'\n", TC_ERROR ("sprintf(%%p). Expected '%s', got '%s'\n",
DEADBEEF_PTR_STR, buffer); DEADBEEF_PTR_STR, buffer);
status = TC_FAIL; status = TC_FAIL;
@ -504,15 +468,13 @@ int sprintfMiscTest(void)
/*******************/ /*******************/
sprintf (buffer, "test data %n test data", &count); sprintf (buffer, "test data %n test data", &count);
if (count != 10) if (count != 10) {
{
TC_ERROR ("sprintf(%%n). Expected count to be %d, not %d\n", TC_ERROR ("sprintf(%%n). Expected count to be %d, not %d\n",
10, count); 10, count);
status = TC_FAIL; status = TC_FAIL;
} }
if (strcmp (buffer, "test data test data") != 0) if (strcmp (buffer, "test data test data") != 0) {
{
TC_ERROR ("sprintf(%%p). Expected '%s', got '%s'\n", TC_ERROR ("sprintf(%%p). Expected '%s', got '%s'\n",
"test data test data", buffer); "test data test data", buffer);
status = TC_FAIL; status = TC_FAIL;
@ -520,8 +482,7 @@ int sprintfMiscTest(void)
/*******************/ /*******************/
sprintf (buffer, "%*d", 10, 1234); sprintf (buffer, "%*d", 10, 1234);
if (strcmp (buffer, " 1234") != 0) if (strcmp (buffer, " 1234") != 0) {
{
TC_ERROR ("sprintf(%%p). Expected '%s', got '%s'\n", TC_ERROR ("sprintf(%%p). Expected '%s', got '%s'\n",
" 1234", buffer); " 1234", buffer);
status = TC_FAIL; status = TC_FAIL;
@ -529,8 +490,7 @@ int sprintfMiscTest(void)
/*******************/ /*******************/
sprintf (buffer, "%*d", -10, 1234); sprintf (buffer, "%*d", -10, 1234);
if (strcmp (buffer, "1234 ") != 0) if (strcmp (buffer, "1234 ") != 0) {
{
TC_ERROR ("sprintf(%%p). Expected '%s', got '%s'\n", TC_ERROR ("sprintf(%%p). Expected '%s', got '%s'\n",
"1234 ", buffer); "1234 ", buffer);
status = TC_FAIL; status = TC_FAIL;
@ -538,8 +498,7 @@ int sprintfMiscTest(void)
/*******************/ /*******************/
sprintf (buffer, "% d", 1234); sprintf (buffer, "% d", 1234);
if (strcmp (buffer, " 1234") != 0) if (strcmp (buffer, " 1234") != 0) {
{
TC_ERROR ("sprintf(%% d). Expected '%s', got '%s'\n", TC_ERROR ("sprintf(%% d). Expected '%s', got '%s'\n",
" 1234", buffer); " 1234", buffer);
status = TC_FAIL; status = TC_FAIL;
@ -547,16 +506,14 @@ int sprintfMiscTest(void)
/*******************/ /*******************/
sprintf (buffer, "%hx", 1234); sprintf (buffer, "%hx", 1234);
if (strcmp ("4d2", buffer) != 0) if (strcmp ("4d2", buffer) != 0) {
{
TC_ERROR ("sprintf(%%hx). Expected '4d2', got '%s'\n", buffer); TC_ERROR ("sprintf(%%hx). Expected '4d2', got '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
/*******************/ /*******************/
sprintf (buffer, "%lx", 1234ul); sprintf (buffer, "%lx", 1234ul);
if (strcmp ("4d2", buffer) != 0) if (strcmp ("4d2", buffer) != 0) {
{
TC_ERROR ("sprintf(%%lx). Expected '4d2', got '%s'\n", buffer); TC_ERROR ("sprintf(%%lx). Expected '4d2', got '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
@ -581,29 +538,25 @@ int sprintfIntegerTest(void)
/* Note: VxMicro prints hex numbers in 8 characters */ /* Note: VxMicro prints hex numbers in 8 characters */
len = sprintf (buffer, "%x", 0x11); len = sprintf (buffer, "%x", 0x11);
if (len != 2) if (len != 2) {
{
TC_ERROR ("sprintf(%%x). Expected 2 bytes written, not %d\n", len); TC_ERROR ("sprintf(%%x). Expected 2 bytes written, not %d\n", len);
status = TC_FAIL; status = TC_FAIL;
} }
if (strcmp (buffer, "11") != 0) if (strcmp (buffer, "11") != 0) {
{
TC_ERROR ("sprintf(%%x). Expected '%s', got '%s'\n", "11", buffer); TC_ERROR ("sprintf(%%x). Expected '%s', got '%s'\n", "11", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
/*******************/ /*******************/
len = sprintf (buffer, "%x", DEADBEEF); len = sprintf (buffer, "%x", DEADBEEF);
if (len != strlen (DEADBEEF_LHEX_STR)) if (len != strlen (DEADBEEF_LHEX_STR)) {
{
TC_ERROR ("sprintf(%%x). Expected %d bytes written, not %d\n", TC_ERROR ("sprintf(%%x). Expected %d bytes written, not %d\n",
strlen (DEADBEEF_LHEX_STR), len); strlen (DEADBEEF_LHEX_STR), len);
status = TC_FAIL; status = TC_FAIL;
} }
if (strcmp (buffer, DEADBEEF_LHEX_STR) != 0) if (strcmp (buffer, DEADBEEF_LHEX_STR) != 0) {
{
TC_ERROR ("sprintf(%%x). Expected '%s', got '%s'\n", TC_ERROR ("sprintf(%%x). Expected '%s', got '%s'\n",
DEADBEEF_LHEX_STR, buffer); DEADBEEF_LHEX_STR, buffer);
status = TC_FAIL; status = TC_FAIL;
@ -611,15 +564,13 @@ int sprintfIntegerTest(void)
/*******************/ /*******************/
len = sprintf (buffer, "%X", DEADBEEF); len = sprintf (buffer, "%X", DEADBEEF);
if (len != strlen (DEADBEEF_UHEX_STR)) if (len != strlen (DEADBEEF_UHEX_STR)) {
{
TC_ERROR ("sprintf(%%X). Expected %d bytes written, not %d\n", TC_ERROR ("sprintf(%%X). Expected %d bytes written, not %d\n",
strlen (DEADBEEF_UHEX_STR), len); strlen (DEADBEEF_UHEX_STR), len);
status = TC_FAIL; status = TC_FAIL;
} }
if (strcmp (buffer, DEADBEEF_UHEX_STR) != 0) if (strcmp (buffer, DEADBEEF_UHEX_STR) != 0) {
{
TC_ERROR ("sprintf(%%X). Expected '%s', got '%s'\n", TC_ERROR ("sprintf(%%X). Expected '%s', got '%s'\n",
DEADBEEF_UHEX_STR, buffer); DEADBEEF_UHEX_STR, buffer);
status = TC_FAIL; status = TC_FAIL;
@ -627,15 +578,13 @@ int sprintfIntegerTest(void)
/*******************/ /*******************/
len = sprintf (buffer, "%u", DEADBEEF); len = sprintf (buffer, "%u", DEADBEEF);
if (len != strlen (DEADBEEF_UNSIGNED_STR)) if (len != strlen (DEADBEEF_UNSIGNED_STR)) {
{
TC_ERROR ("sprintf(%%u). Expected %d bytes written, not %d\n", TC_ERROR ("sprintf(%%u). Expected %d bytes written, not %d\n",
strlen (DEADBEEF_UNSIGNED_STR), len); strlen (DEADBEEF_UNSIGNED_STR), len);
status = TC_FAIL; status = TC_FAIL;
} }
if (strcmp (buffer, DEADBEEF_UNSIGNED_STR) != 0) if (strcmp (buffer, DEADBEEF_UNSIGNED_STR) != 0) {
{
TC_ERROR ("sprintf(%%u). Expected '%s', got '%s'\n", TC_ERROR ("sprintf(%%u). Expected '%s', got '%s'\n",
DEADBEEF_UNSIGNED_STR, buffer); DEADBEEF_UNSIGNED_STR, buffer);
status = TC_FAIL; status = TC_FAIL;
@ -643,15 +592,13 @@ int sprintfIntegerTest(void)
/*******************/ /*******************/
len = sprintf (buffer, "%d", (int) DEADBEEF); len = sprintf (buffer, "%d", (int) DEADBEEF);
if (len != strlen (DEADBEEF_SIGNED_STR)) if (len != strlen (DEADBEEF_SIGNED_STR)) {
{
TC_ERROR ("sprintf(%%d). Expected %d bytes written, not %d\n", TC_ERROR ("sprintf(%%d). Expected %d bytes written, not %d\n",
strlen (DEADBEEF_SIGNED_STR), len); strlen (DEADBEEF_SIGNED_STR), len);
status = TC_FAIL; status = TC_FAIL;
} }
if (strcmp (buffer, DEADBEEF_SIGNED_STR) != 0) if (strcmp (buffer, DEADBEEF_SIGNED_STR) != 0) {
{
TC_ERROR ("sprintf(%%d). Expected '%s', got '%s'\n", TC_ERROR ("sprintf(%%d). Expected '%s', got '%s'\n",
DEADBEEF_SIGNED_STR, buffer); DEADBEEF_SIGNED_STR, buffer);
status = TC_FAIL; status = TC_FAIL;
@ -659,15 +606,13 @@ int sprintfIntegerTest(void)
/*******************/ /*******************/
len = sprintf (buffer, "%o", DEADBEEF); len = sprintf (buffer, "%o", DEADBEEF);
if (len != strlen (DEADBEEF_OCTAL_STR)) if (len != strlen (DEADBEEF_OCTAL_STR)) {
{
TC_ERROR ("sprintf(%%o). Expected %d bytes written, not %d\n", TC_ERROR ("sprintf(%%o). Expected %d bytes written, not %d\n",
strlen (DEADBEEF_OCTAL_STR), len); strlen (DEADBEEF_OCTAL_STR), len);
status = TC_FAIL; status = TC_FAIL;
} }
if (strcmp (buffer, DEADBEEF_OCTAL_STR) != 0) if (strcmp (buffer, DEADBEEF_OCTAL_STR) != 0) {
{
TC_ERROR ("sprintf(%%o). Expected '%s', got '%s'\n", TC_ERROR ("sprintf(%%o). Expected '%s', got '%s'\n",
DEADBEEF_OCTAL_STR, buffer); DEADBEEF_OCTAL_STR, buffer);
status = TC_FAIL; status = TC_FAIL;
@ -675,15 +620,13 @@ int sprintfIntegerTest(void)
/*******************/ /*******************/
len = sprintf (buffer, "%#o", DEADBEEF); len = sprintf (buffer, "%#o", DEADBEEF);
if (len != strlen (DEADBEEF_OCTAL_ALT_STR)) if (len != strlen (DEADBEEF_OCTAL_ALT_STR)) {
{
TC_ERROR ("sprintf(%%#o). Expected %d bytes written, not %d\n", TC_ERROR ("sprintf(%%#o). Expected %d bytes written, not %d\n",
strlen (DEADBEEF_OCTAL_ALT_STR), len); strlen (DEADBEEF_OCTAL_ALT_STR), len);
status = TC_FAIL; status = TC_FAIL;
} }
if (strcmp (buffer, DEADBEEF_OCTAL_ALT_STR) != 0) if (strcmp (buffer, DEADBEEF_OCTAL_ALT_STR) != 0) {
{
TC_ERROR ("sprintf(%%#o). Expected '%s', got '%s'\n", TC_ERROR ("sprintf(%%#o). Expected '%s', got '%s'\n",
DEADBEEF_OCTAL_ALT_STR, buffer); DEADBEEF_OCTAL_ALT_STR, buffer);
status = TC_FAIL; status = TC_FAIL;
@ -691,14 +634,12 @@ int sprintfIntegerTest(void)
/*******************/ /*******************/
len = sprintf (buffer, "%#x", DEADBEEF); len = sprintf (buffer, "%#x", DEADBEEF);
if (len != strlen (DEADBEEF_LHEX_ALT_STR)) if (len != strlen (DEADBEEF_LHEX_ALT_STR)) {
{
TC_ERROR ("sprintf(%%#x). Expected %d bytes written, not %d\n", TC_ERROR ("sprintf(%%#x). Expected %d bytes written, not %d\n",
strlen (DEADBEEF_LHEX_ALT_STR), len); strlen (DEADBEEF_LHEX_ALT_STR), len);
status = TC_FAIL; status = TC_FAIL;
} }
if (strcmp (buffer, DEADBEEF_LHEX_ALT_STR) != 0) if (strcmp (buffer, DEADBEEF_LHEX_ALT_STR) != 0) {
{
TC_ERROR ("sprintf(%%#x). Expected '%s', got '%s'\n", TC_ERROR ("sprintf(%%#x). Expected '%s', got '%s'\n",
DEADBEEF_LHEX_ALT_STR, buffer); DEADBEEF_LHEX_ALT_STR, buffer);
status = TC_FAIL; status = TC_FAIL;
@ -706,14 +647,12 @@ int sprintfIntegerTest(void)
/*******************/ /*******************/
len = sprintf (buffer, "%#X", DEADBEEF); len = sprintf (buffer, "%#X", DEADBEEF);
if (len != strlen (DEADBEEF_UHEX_ALT_STR)) if (len != strlen (DEADBEEF_UHEX_ALT_STR)) {
{
TC_ERROR ("sprintf(%%#X). Expected %d bytes written, not %d\n", TC_ERROR ("sprintf(%%#X). Expected %d bytes written, not %d\n",
strlen (DEADBEEF_UHEX_ALT_STR), len); strlen (DEADBEEF_UHEX_ALT_STR), len);
status = TC_FAIL; status = TC_FAIL;
} }
if (strcmp (buffer, DEADBEEF_UHEX_ALT_STR) != 0) if (strcmp (buffer, DEADBEEF_UHEX_ALT_STR) != 0) {
{
TC_ERROR ("sprintf(%%#X). Expected '%s', got '%s'\n", TC_ERROR ("sprintf(%%#X). Expected '%s', got '%s'\n",
DEADBEEF_UHEX_ALT_STR, buffer); DEADBEEF_UHEX_ALT_STR, buffer);
status = TC_FAIL; status = TC_FAIL;
@ -722,14 +661,12 @@ int sprintfIntegerTest(void)
/*******************/ /*******************/
len = sprintf (buffer, "%+d", 1); len = sprintf (buffer, "%+d", 1);
if (len != 2) if (len != 2) {
{
TC_ERROR ("sprintf(%%+d). Expected %d bytes written, not %d\n", TC_ERROR ("sprintf(%%+d). Expected %d bytes written, not %d\n",
2, len); 2, len);
status = TC_FAIL; status = TC_FAIL;
} }
if (strcmp (buffer, "+1") != 0) if (strcmp (buffer, "+1") != 0) {
{
TC_ERROR ("sprintf(%%+d). Expected '+1', got '%s'\n", buffer); TC_ERROR ("sprintf(%%+d). Expected '+1', got '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
@ -751,35 +688,30 @@ int sprintfStringTest(void)
char buffer[400]; char buffer[400];
sprintf (buffer, "%%"); sprintf (buffer, "%%");
if (strcmp (buffer, "%") != 0) if (strcmp (buffer, "%") != 0) {
{
TC_ERROR ("sprintf(%%). Expected '%%', got '%s'\n", buffer); TC_ERROR ("sprintf(%%). Expected '%%', got '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
sprintf (buffer, "%c", 't'); sprintf (buffer, "%c", 't');
if (strcmp (buffer, "t") != 0) if (strcmp (buffer, "t") != 0) {
{
TC_ERROR ("sprintf(%%c). Expected 't', got '%s'\n", buffer); TC_ERROR ("sprintf(%%c). Expected 't', got '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
sprintf (buffer, "%s", "short string"); sprintf (buffer, "%s", "short string");
if (strcmp (buffer, "short string") != 0) if (strcmp (buffer, "short string") != 0) {
{
TC_ERROR ("sprintf(%%s). Expected 'short string', got '%s'\n", buffer); TC_ERROR ("sprintf(%%s). Expected 'short string', got '%s'\n", buffer);
status = TC_FAIL; status = TC_FAIL;
} }
len = sprintf (buffer, "%s", REALLY_LONG_STRING); len = sprintf (buffer, "%s", REALLY_LONG_STRING);
if (len != PRINTF_MAX_STRING_LENGTH) if (len != PRINTF_MAX_STRING_LENGTH) {
{
TC_ERROR ("Internals changed. Max string length no longer %d\n", TC_ERROR ("Internals changed. Max string length no longer %d\n",
PRINTF_MAX_STRING_LENGTH); PRINTF_MAX_STRING_LENGTH);
status = TC_FAIL; status = TC_FAIL;
} }
if (strncmp (buffer, REALLY_LONG_STRING, PRINTF_MAX_STRING_LENGTH) != 0) if (strncmp (buffer, REALLY_LONG_STRING, PRINTF_MAX_STRING_LENGTH) != 0) {
{
TC_ERROR ("First %d characters of REALLY_LONG_STRING not printed!\n", TC_ERROR ("First %d characters of REALLY_LONG_STRING not printed!\n",
PRINTF_MAX_STRING_LENGTH); PRINTF_MAX_STRING_LENGTH);
status = TC_FAIL; status = TC_FAIL;
@ -804,45 +736,38 @@ void RegressionTask(void)
PRINT_LINE; PRINT_LINE;
TC_PRINT ("Testing sprintf() with integers ....\n"); TC_PRINT ("Testing sprintf() with integers ....\n");
if (sprintfIntegerTest () != TC_PASS) if (sprintfIntegerTest () != TC_PASS) {
{
status = TC_FAIL; status = TC_FAIL;
} }
TC_PRINT ("Testing snprintf() ....\n"); TC_PRINT ("Testing snprintf() ....\n");
if (snprintfTest () != TC_PASS) if (snprintfTest () != TC_PASS) {
{
status = TC_FAIL; status = TC_FAIL;
} }
TC_PRINT ("Testing vsprintf() ....\n"); TC_PRINT ("Testing vsprintf() ....\n");
if (vsprintfTest () != TC_PASS) if (vsprintfTest () != TC_PASS) {
{
status = TC_FAIL; status = TC_FAIL;
} }
TC_PRINT ("Testing vsnprintf() ....\n"); TC_PRINT ("Testing vsnprintf() ....\n");
if (vsnprintfTest () != TC_PASS) if (vsnprintfTest () != TC_PASS) {
{
status = TC_FAIL; status = TC_FAIL;
} }
TC_PRINT ("Testing sprintf() with strings ....\n"); TC_PRINT ("Testing sprintf() with strings ....\n");
if (sprintfStringTest () != TC_PASS) if (sprintfStringTest () != TC_PASS) {
{
status = TC_FAIL; status = TC_FAIL;
} }
TC_PRINT ("Testing sprintf() with misc options ....\n"); TC_PRINT ("Testing sprintf() with misc options ....\n");
if (sprintfMiscTest () != TC_PASS) if (sprintfMiscTest () != TC_PASS) {
{
status = TC_FAIL; status = TC_FAIL;
} }
#ifdef CONFIG_FLOAT #ifdef CONFIG_FLOAT
TC_PRINT ("Testing sprintf() with doubles ....\n"); TC_PRINT ("Testing sprintf() with doubles ....\n");
if (sprintfDoubleTest () != TC_PASS) if (sprintfDoubleTest () != TC_PASS) {
{
status = TC_FAIL; status = TC_FAIL;
} }
#endif /* CONFIG_FLOAT */ #endif /* CONFIG_FLOAT */

View file

@ -84,8 +84,7 @@ void check_input(const char *name, const char *input);
void printLoop(const char *name) void printLoop(const char *name)
{ {
while (count < 6) while (count < 6) {
{
/* A short input string to check_input. It will pass. */ /* A short input string to check_input. It will pass. */
check_input(name, "Stack ok"); check_input(name, "Stack ok");
count++; count++;
@ -177,8 +176,7 @@ void main(void)
(nano_fiber_entry_t) fiber1, 0, 0, 7, 0); (nano_fiber_entry_t) fiber1, 0, 0, 7, 0);
#endif /* ! CONFIG_MICROKERNEL */ #endif /* ! CONFIG_MICROKERNEL */
if (tcRC == TC_FAIL) if (tcRC == TC_FAIL) {
{
goto errorExit; goto errorExit;
} }

View file

@ -141,16 +141,14 @@ int nanoIdtStubTest(void)
pIdtEntry = (IDT_ENTRY *) (_idt_base_address + (TEST_SOFT_INT << 3)); pIdtEntry = (IDT_ENTRY *) (_idt_base_address + (TEST_SOFT_INT << 3));
offset = (uint16_t)((uint32_t)(&nanoIntStub) & 0xFFFF); offset = (uint16_t)((uint32_t)(&nanoIntStub) & 0xFFFF);
if (pIdtEntry->lowOffset != offset) if (pIdtEntry->lowOffset != offset) {
{
TC_ERROR ("Failed to find low offset of nanoIntStub \ TC_ERROR ("Failed to find low offset of nanoIntStub \
(0x%x) at vector %d\n", (uint32_t)offset, TEST_SOFT_INT); (0x%x) at vector %d\n", (uint32_t)offset, TEST_SOFT_INT);
return TC_FAIL; return TC_FAIL;
} }
offset = (uint16_t)((uint32_t)(&nanoIntStub) >> 16); offset = (uint16_t)((uint32_t)(&nanoIntStub) >> 16);
if (pIdtEntry->hiOffset != offset) if (pIdtEntry->hiOffset != offset) {
{
TC_ERROR ("Failed to find high offset of nanoIntStub \ TC_ERROR ("Failed to find high offset of nanoIntStub \
(0x%x) at vector %d\n", (uint32_t)offset, TEST_SOFT_INT); (0x%x) at vector %d\n", (uint32_t)offset, TEST_SOFT_INT);
return TC_FAIL; return TC_FAIL;
@ -160,16 +158,14 @@ int nanoIdtStubTest(void)
pIdtEntry = (IDT_ENTRY *) (_idt_base_address + (IV_DIVIDE_ERROR << 3)); pIdtEntry = (IDT_ENTRY *) (_idt_base_address + (IV_DIVIDE_ERROR << 3));
offset = (uint16_t)((uint32_t)(&exc_divide_error_handlerStub) & 0xFFFF); offset = (uint16_t)((uint32_t)(&exc_divide_error_handlerStub) & 0xFFFF);
if (pIdtEntry->lowOffset != offset) if (pIdtEntry->lowOffset != offset) {
{
TC_ERROR ("Failed to find low offset of exc stub \ TC_ERROR ("Failed to find low offset of exc stub \
(0x%x) at vector %d\n", (uint32_t)offset, IV_DIVIDE_ERROR); (0x%x) at vector %d\n", (uint32_t)offset, IV_DIVIDE_ERROR);
return TC_FAIL; return TC_FAIL;
} }
offset = (uint16_t)((uint32_t)(&exc_divide_error_handlerStub) >> 16); offset = (uint16_t)((uint32_t)(&exc_divide_error_handlerStub) >> 16);
if (pIdtEntry->hiOffset != offset) if (pIdtEntry->hiOffset != offset) {
{
TC_ERROR ("Failed to find high offset of exc stub \ TC_ERROR ("Failed to find high offset of exc stub \
(0x%x) at vector %d\n", (uint32_t)offset, IV_DIVIDE_ERROR); (0x%x) at vector %d\n", (uint32_t)offset, IV_DIVIDE_ERROR);
return TC_FAIL; return TC_FAIL;
@ -232,21 +228,18 @@ void main(void)
TC_PRINT ("Testing to see if IDT has address of test stubs()\n"); TC_PRINT ("Testing to see if IDT has address of test stubs()\n");
rv = nanoIdtStubTest (); rv = nanoIdtStubTest ();
if (rv != TC_PASS) if (rv != TC_PASS) {
{
goto doneTests; goto doneTests;
} }
TC_PRINT ("Testing to see interrupt handler executes properly\n"); TC_PRINT ("Testing to see interrupt handler executes properly\n");
_trigger_isrHandler(); _trigger_isrHandler();
if (intHandlerExecuted == 0) if (intHandlerExecuted == 0) {
{
TC_ERROR ("Interrupt handler did not execute\n"); TC_ERROR ("Interrupt handler did not execute\n");
rv = TC_FAIL; rv = TC_FAIL;
goto doneTests; goto doneTests;
} else if (intHandlerExecuted != 1) } else if (intHandlerExecuted != 1) {
{
TC_ERROR ("Interrupt handler executed more than once! (%d)\n", TC_ERROR ("Interrupt handler executed more than once! (%d)\n",
intHandlerExecuted); intHandlerExecuted);
rv = TC_FAIL; rv = TC_FAIL;
@ -261,14 +254,12 @@ void main(void)
*/ */
error = error / excHandlerExecuted; error = error / excHandlerExecuted;
if (excHandlerExecuted == 0) if (excHandlerExecuted == 0) {
{
TC_ERROR ("Exception handler did not execute\n"); TC_ERROR ("Exception handler did not execute\n");
rv = TC_FAIL; rv = TC_FAIL;
goto doneTests; goto doneTests;
} }
else if (excHandlerExecuted != 1) else if (excHandlerExecuted != 1) {
{
TC_ERROR ("Exception handler executed more than once! (%d)\n", TC_ERROR ("Exception handler executed more than once! (%d)\n",
excHandlerExecuted); excHandlerExecuted);
rv = TC_FAIL; rv = TC_FAIL;
@ -288,8 +279,7 @@ void main(void)
* The fiber/task should not run past where the spurious interrupt is * The fiber/task should not run past where the spurious interrupt is
* generated. Therefore spurHandlerAbortedContext should remain at 1. * generated. Therefore spurHandlerAbortedContext should remain at 1.
*/ */
if (spurHandlerAbortedContext == 0) if (spurHandlerAbortedContext == 0) {
{
TC_ERROR ("Spurious handler did not execute as expected\n"); TC_ERROR ("Spurious handler did not execute as expected\n");
rv = TC_FAIL; rv = TC_FAIL;
goto doneTests; goto doneTests;

View file

@ -62,8 +62,7 @@ This module tests the following task APIs:
/* typedefs */ /* typedefs */
typedef struct typedef struct {
{
int cmd; int cmd;
int data; int data;
} ISR_INFO; } ISR_INFO;
@ -91,8 +90,7 @@ void isr_task_command_handler(void *data)
ISR_INFO *pInfo = (ISR_INFO *) data; ISR_INFO *pInfo = (ISR_INFO *) data;
int value = -1; int value = -1;
switch (pInfo->cmd) switch (pInfo->cmd) {
{
case CMD_TASKID: case CMD_TASKID:
value = isr_task_id_get (); value = isr_task_id_get ();
break; break;
@ -116,8 +114,7 @@ int isrAPIsTest(int taskId, int taskPrio)
{ {
isrInfo.cmd = CMD_TASKID; isrInfo.cmd = CMD_TASKID;
_trigger_isrTaskCommand (); _trigger_isrTaskCommand ();
if (isrInfo.data != taskId) if (isrInfo.data != taskId) {
{
TC_ERROR ("isr_task_id_get() returned %d, not %d\n", TC_ERROR ("isr_task_id_get() returned %d, not %d\n",
isrInfo.data, taskId); isrInfo.data, taskId);
return TC_FAIL; return TC_FAIL;
@ -125,8 +122,7 @@ int isrAPIsTest(int taskId, int taskPrio)
isrInfo.cmd = CMD_PRIORITY; isrInfo.cmd = CMD_PRIORITY;
_trigger_isrTaskCommand (); _trigger_isrTaskCommand ();
if (isrInfo.data != taskPrio) if (isrInfo.data != taskPrio) {
{
TC_ERROR ("isr_task_priority_get() returned %d, not %d\n", TC_ERROR ("isr_task_priority_get() returned %d, not %d\n",
isrInfo.data, taskPrio); isrInfo.data, taskPrio);
return TC_FAIL; return TC_FAIL;
@ -147,16 +143,14 @@ int taskMacrosTest(int taskId, int taskPrio)
int value; int value;
value = task_id_get (); value = task_id_get ();
if (value != taskId) if (value != taskId) {
{
TC_ERROR ("task_id_get() returned 0x%x, not 0x%x\n", TC_ERROR ("task_id_get() returned 0x%x, not 0x%x\n",
value, taskId); value, taskId);
return TC_FAIL; return TC_FAIL;
} }
value = task_priority_get (); value = task_priority_get ();
if (value != taskPrio) if (value != taskPrio) {
{
TC_ERROR ("task_priority_get() returned %d, not %d\n", TC_ERROR ("task_priority_get() returned %d, not %d\n",
value, taskPrio); value, taskPrio);
return TC_FAIL; return TC_FAIL;
@ -174,8 +168,7 @@ int taskMacrosTest(int taskId, int taskPrio)
void microObjectsInit(void) void microObjectsInit(void)
{ {
struct isrInitInfo i = struct isrInitInfo i = {
{
{ isr_task_command_handler, NULL }, { isr_task_command_handler, NULL },
{ &isrInfo, NULL }, { &isrInfo, NULL },
}; };
@ -221,8 +214,7 @@ int taskSetPrioTest(void)
/* Lower the priority of the current task (RegressionTask) */ /* Lower the priority of the current task (RegressionTask) */
task_priority_set (RT_TASKID, RT_PRIO + 5); task_priority_set (RT_TASKID, RT_PRIO + 5);
rv = task_priority_get (); rv = task_priority_get ();
if (rv != RT_PRIO + 5) if (rv != RT_PRIO + 5) {
{
TC_ERROR ("Expected priority to be changed to %d, not %d\n", TC_ERROR ("Expected priority to be changed to %d, not %d\n",
RT_PRIO + 5, rv); RT_PRIO + 5, rv);
return TC_FAIL; return TC_FAIL;
@ -231,8 +223,7 @@ int taskSetPrioTest(void)
/* Raise the priority of the current task (RegressionTask) */ /* Raise the priority of the current task (RegressionTask) */
task_priority_set (RT_TASKID, RT_PRIO - 5); task_priority_set (RT_TASKID, RT_PRIO - 5);
rv = task_priority_get (); rv = task_priority_get ();
if (rv != RT_PRIO - 5) if (rv != RT_PRIO - 5) {
{
TC_ERROR ("Expected priority to be changed to %d, not %d\n", TC_ERROR ("Expected priority to be changed to %d, not %d\n",
RT_PRIO - 5, rv); RT_PRIO - 5, rv);
return TC_FAIL; return TC_FAIL;
@ -242,8 +233,7 @@ int taskSetPrioTest(void)
/* Restore the priority of the current task (RegressionTask) */ /* Restore the priority of the current task (RegressionTask) */
task_priority_set (RT_TASKID, RT_PRIO); task_priority_set (RT_TASKID, RT_PRIO);
rv = task_priority_get (); rv = task_priority_get ();
if (rv != RT_PRIO) if (rv != RT_PRIO) {
{
TC_ERROR ("Expected priority to be changed to %d, not %d\n", TC_ERROR ("Expected priority to be changed to %d, not %d\n",
RT_PRIO, rv); RT_PRIO, rv);
return TC_FAIL; return TC_FAIL;
@ -254,8 +244,7 @@ int taskSetPrioTest(void)
task_priority_set (HT_TASKID, HT_PRIO + 5); task_priority_set (HT_TASKID, HT_PRIO + 5);
task_sem_give (HT_SEM); task_sem_give (HT_SEM);
task_sem_take_wait (RT_SEM); task_sem_take_wait (RT_SEM);
if (helperData != HT_PRIO + 5) if (helperData != HT_PRIO + 5) {
{
TC_ERROR ("Expected priority to be changed to %d, not %d\n", TC_ERROR ("Expected priority to be changed to %d, not %d\n",
HT_PRIO + 5, helperData); HT_PRIO + 5, helperData);
return TC_FAIL; return TC_FAIL;
@ -265,8 +254,7 @@ int taskSetPrioTest(void)
task_priority_set (HT_TASKID, HT_PRIO - 5); task_priority_set (HT_TASKID, HT_PRIO - 5);
task_sem_give (HT_SEM); task_sem_give (HT_SEM);
task_sem_take_wait (RT_SEM); task_sem_take_wait (RT_SEM);
if (helperData != HT_PRIO - 5) if (helperData != HT_PRIO - 5) {
{
TC_ERROR ("Expected priority to be changed to %d, not %d\n", TC_ERROR ("Expected priority to be changed to %d, not %d\n",
HT_PRIO - 5, helperData); HT_PRIO - 5, helperData);
return TC_FAIL; return TC_FAIL;
@ -277,8 +265,7 @@ int taskSetPrioTest(void)
task_priority_set (HT_TASKID, HT_PRIO); task_priority_set (HT_TASKID, HT_PRIO);
task_sem_give (HT_SEM); task_sem_give (HT_SEM);
task_sem_take_wait (RT_SEM); task_sem_take_wait (RT_SEM);
if (helperData != HT_PRIO) if (helperData != HT_PRIO) {
{
TC_ERROR ("Expected priority to be changed to %d, not %d\n", TC_ERROR ("Expected priority to be changed to %d, not %d\n",
HT_PRIO, helperData); HT_PRIO, helperData);
return TC_FAIL; return TC_FAIL;
@ -301,8 +288,7 @@ void helperTaskSleepTest(void)
task_sem_take_wait (HT_SEM); task_sem_take_wait (HT_SEM);
firstTick = task_tick_get_32 (); firstTick = task_tick_get_32 ();
while (mainTaskNotReady) while (mainTaskNotReady) {
{
} }
helperData = task_tick_get_32 () - firstTick; helperData = task_tick_get_32 () - firstTick;
@ -321,8 +307,7 @@ int taskSleepTest(void)
int32_t tick; int32_t tick;
tick = task_tick_get_32 (); /* Busy wait to align */ tick = task_tick_get_32 (); /* Busy wait to align */
while (tick == task_tick_get_32 ()) /* to tick boundary */ while (tick == task_tick_get_32 ()) { /* to tick boundary */
{
} }
task_sem_give (HT_SEM); task_sem_give (HT_SEM);
@ -332,8 +317,7 @@ int taskSleepTest(void)
mainTaskNotReady = 0; mainTaskNotReady = 0;
task_sem_take_wait (RT_SEM); task_sem_take_wait (RT_SEM);
if (helperData != SLEEP_TIME) if (helperData != SLEEP_TIME) {
{
TC_ERROR ("task_sleep() slept for %d ticks, not %d\n", TC_ERROR ("task_sleep() slept for %d ticks, not %d\n",
helperData, SLEEP_TIME); helperData, SLEEP_TIME);
return TC_FAIL; return TC_FAIL;
@ -354,8 +338,7 @@ void helperTaskYieldTest(void)
int i; int i;
task_sem_take_wait (HT_SEM); task_sem_take_wait (HT_SEM);
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++) {
{
helperData++; helperData++;
task_yield (); task_yield ();
} }
@ -381,13 +364,11 @@ int taskYieldTest(void)
task_priority_set (HT_TASKID, RT_PRIO); task_priority_set (HT_TASKID, RT_PRIO);
task_sem_give (HT_SEM); task_sem_give (HT_SEM);
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++) {
{
prevHelperData = helperData; prevHelperData = helperData;
task_yield (); task_yield ();
if (helperData == prevHelperData) if (helperData == prevHelperData) {
{
TC_ERROR ("Iter %d. helperData did not change (%d) \n", TC_ERROR ("Iter %d. helperData did not change (%d) \n",
i + 1, helperData); i + 1, helperData);
return TC_FAIL; return TC_FAIL;
@ -440,8 +421,7 @@ int taskSuspendTest(void)
prevHelperData = helperData; prevHelperData = helperData;
task_sleep (SLEEP_TIME); task_sleep (SLEEP_TIME);
if (prevHelperData != helperData) if (prevHelperData != helperData) {
{
TC_ERROR ("Helper task did not suspend!\n"); TC_ERROR ("Helper task did not suspend!\n");
return TC_FAIL; return TC_FAIL;
} }
@ -449,8 +429,7 @@ int taskSuspendTest(void)
task_resume (HT_TASKID); task_resume (HT_TASKID);
task_sleep (SLEEP_TIME); task_sleep (SLEEP_TIME);
if (prevHelperData == helperData) if (prevHelperData == helperData) {
{
TC_ERROR ("Helper task did not resume!\n"); TC_ERROR ("Helper task did not resume!\n");
return TC_FAIL; return TC_FAIL;
} }
@ -472,8 +451,7 @@ void HelperTask(void)
task_sem_take_wait (HT_SEM); task_sem_take_wait (HT_SEM);
rv = isrAPIsTest (HT_TASKID, HT_PRIO); rv = isrAPIsTest (HT_TASKID, HT_PRIO);
if (rv != TC_PASS) if (rv != TC_PASS) {
{
tcRC = TC_FAIL; tcRC = TC_FAIL;
return; return;
} }
@ -481,8 +459,7 @@ void HelperTask(void)
task_sem_take_wait (HT_SEM); task_sem_take_wait (HT_SEM);
rv = taskMacrosTest (HT_TASKID, HT_PRIO); rv = taskMacrosTest (HT_TASKID, HT_PRIO);
if (rv != TC_PASS) if (rv != TC_PASS) {
{
tcRC = TC_FAIL; tcRC = TC_FAIL;
return; return;
} }
@ -516,8 +493,7 @@ void RegressionTask(void)
TC_PRINT ("Testing isr_task_id_get() and isr_task_priority_get()\n"); TC_PRINT ("Testing isr_task_id_get() and isr_task_priority_get()\n");
rv = isrAPIsTest (RT_TASKID, RT_PRIO); rv = isrAPIsTest (RT_TASKID, RT_PRIO);
if (rv != TC_PASS) if (rv != TC_PASS) {
{
tcRC = TC_FAIL; tcRC = TC_FAIL;
goto errorReturn; goto errorReturn;
} }
@ -527,8 +503,7 @@ void RegressionTask(void)
TC_PRINT ("Testing task_id_get() and task_priority_get()\n"); TC_PRINT ("Testing task_id_get() and task_priority_get()\n");
rv = taskMacrosTest (RT_TASKID, RT_PRIO); rv = taskMacrosTest (RT_TASKID, RT_PRIO);
if (rv != TC_PASS) if (rv != TC_PASS) {
{
tcRC = TC_FAIL; tcRC = TC_FAIL;
goto errorReturn; goto errorReturn;
} }
@ -537,29 +512,25 @@ void RegressionTask(void)
task_sem_take_wait (RT_SEM); task_sem_take_wait (RT_SEM);
TC_PRINT ("Testing task_priority_set()\n"); TC_PRINT ("Testing task_priority_set()\n");
if (taskSetPrioTest () != TC_PASS) if (taskSetPrioTest () != TC_PASS) {
{
tcRC = TC_FAIL; tcRC = TC_FAIL;
goto errorReturn; goto errorReturn;
} }
TC_PRINT ("Testing task_sleep()\n"); TC_PRINT ("Testing task_sleep()\n");
if (taskSleepTest () != TC_PASS) if (taskSleepTest () != TC_PASS) {
{
tcRC = TC_FAIL; tcRC = TC_FAIL;
goto errorReturn; goto errorReturn;
} }
TC_PRINT ("Testing task_yield()\n"); TC_PRINT ("Testing task_yield()\n");
if (taskYieldTest () != TC_PASS) if (taskYieldTest () != TC_PASS) {
{
tcRC = TC_FAIL; tcRC = TC_FAIL;
goto errorReturn; goto errorReturn;
} }
TC_PRINT ("Testing task_suspend() and task_resume()\n"); TC_PRINT ("Testing task_suspend() and task_resume()\n");
if (taskSuspendTest () != TC_PASS) if (taskSuspendTest () != TC_PASS) {
{
tcRC = TC_FAIL; tcRC = TC_FAIL;
goto errorReturn; goto errorReturn;
} }

View file

@ -103,10 +103,8 @@ void registerWait (void)
/* Wait for the 2 tasks to finish registering their IRQ objects*/ /* Wait for the 2 tasks to finish registering their IRQ objects*/
for (tasksDone = 0; tasksDone < NUM_TEST_TASKS - 1; tasksDone++) for (tasksDone = 0; tasksDone < NUM_TEST_TASKS - 1; tasksDone++) {
{ if (task_sem_take_wait_timeout (SEM_RDY, TIMEOUT) != RC_OK) {
if (task_sem_take_wait_timeout (SEM_RDY, TIMEOUT) != RC_OK)
{
TC_ERROR ("Monitor task timed out\n"); TC_ERROR ("Monitor task timed out\n");
task_sem_give (resultSems[TC_FAIL]); task_sem_give (resultSems[TC_FAIL]);
return; return;
@ -114,8 +112,7 @@ void registerWait (void)
} }
TC_PRINT ("Generating interrupts for all allocated IRQ objects...\n"); TC_PRINT ("Generating interrupts for all allocated IRQ objects...\n");
for (irq_obj = 0; irq_obj < NUM_TASK_IRQS; irq_obj++) for (irq_obj = 0; irq_obj < NUM_TASK_IRQS; irq_obj++) {
{
if (task_irq_object[irq_obj].irq != INVALID_VECTOR) if (task_irq_object[irq_obj].irq != INVALID_VECTOR)
raiseInt((uint8_t)task_irq_object[irq_obj].vector); raiseInt((uint8_t)task_irq_object[irq_obj].vector);
} }
@ -148,13 +145,10 @@ void MonitorTaskEntry (void)
* then issue the appropriate test case summary message * then issue the appropriate test case summary message
*/ */
for (tasksDone = 0; tasksDone < NUM_TEST_TASKS; tasksDone++) for (tasksDone = 0; tasksDone < NUM_TEST_TASKS; tasksDone++) {
{
result = task_sem_group_take_wait_timeout (resultSems, TIMEOUT); result = task_sem_group_take_wait_timeout (resultSems, TIMEOUT);
if (result != resultSems[TC_PASS]) if (result != resultSems[TC_PASS]) {
{ if (result != resultSems[TC_FAIL]) {
if (result != resultSems[TC_FAIL])
{
TC_ERROR ("Monitor task timed out\n"); TC_ERROR ("Monitor task timed out\n");
} }
TC_END_RESULT (TC_FAIL); TC_END_RESULT (TC_FAIL);

View file

@ -78,15 +78,13 @@ exercises the task_irq_free() API.
int taskA(ksem_t semRdy) int taskA(ksem_t semRdy)
{ {
if (task_irq_alloc (DEV1_ID, DEV1_IRQ, 1) == INVALID_VECTOR) if (task_irq_alloc (DEV1_ID, DEV1_IRQ, 1) == INVALID_VECTOR) {
{
TC_ERROR ("Not able to allocate IRQ object\n"); TC_ERROR ("Not able to allocate IRQ object\n");
return TC_FAIL; return TC_FAIL;
} }
TC_PRINT ("IRQ object %d using IRQ%d allocated\n", DEV1_ID, DEV1_IRQ); TC_PRINT ("IRQ object %d using IRQ%d allocated\n", DEV1_ID, DEV1_IRQ);
if (task_irq_alloc (DEV2_ID, DEV2_IRQ, 2) == INVALID_VECTOR) if (task_irq_alloc (DEV2_ID, DEV2_IRQ, 2) == INVALID_VECTOR) {
{
TC_ERROR ("Not able to allocate IRQ object\n"); TC_ERROR ("Not able to allocate IRQ object\n");
return TC_FAIL; return TC_FAIL;
} }
@ -96,16 +94,14 @@ int taskA(ksem_t semRdy)
task_sem_give (semRdy); task_sem_give (semRdy);
if (task_irq_test_wait (DEV1_ID) != RC_OK) if (task_irq_test_wait (DEV1_ID) != RC_OK) {
{
TC_ERROR ("Not able to test IRQ object event\n"); TC_ERROR ("Not able to test IRQ object event\n");
return TC_FAIL; return TC_FAIL;
} }
TC_PRINT ("Received event for IRQ object %d\n", DEV1_ID); TC_PRINT ("Received event for IRQ object %d\n", DEV1_ID);
task_irq_ack (DEV1_ID); task_irq_ack (DEV1_ID);
if (task_irq_test_wait (DEV2_ID) != RC_OK) if (task_irq_test_wait (DEV2_ID) != RC_OK) {
{
TC_ERROR ("Not able to test IRQ object event\n"); TC_ERROR ("Not able to test IRQ object event\n");
return TC_FAIL; return TC_FAIL;
} }
@ -118,8 +114,7 @@ int taskA(ksem_t semRdy)
TC_PRINT ("\nAttempt to allocate an IRQ object that\n"); TC_PRINT ("\nAttempt to allocate an IRQ object that\n");
TC_PRINT ("is already allocated by another task...\n"); TC_PRINT ("is already allocated by another task...\n");
if (task_irq_alloc (DEV4_ID, DEV4_IRQ, 1) != INVALID_VECTOR) if (task_irq_alloc (DEV4_ID, DEV4_IRQ, 1) != INVALID_VECTOR) {
{
TC_ERROR ("Error: Was able to allocate\n\n"); TC_ERROR ("Error: Was able to allocate\n\n");
return TC_FAIL; return TC_FAIL;
} }
@ -127,8 +122,7 @@ int taskA(ksem_t semRdy)
TC_PRINT ("\nAttempt to allocate an IRQ that\n" TC_PRINT ("\nAttempt to allocate an IRQ that\n"
"is already allocated by another task...\n"); "is already allocated by another task...\n");
if (task_irq_alloc (DEV5_ID, DEV4_IRQ, 1) != INVALID_VECTOR) if (task_irq_alloc (DEV5_ID, DEV4_IRQ, 1) != INVALID_VECTOR) {
{
TC_ERROR ("Error: Was able to allocate\n\n"); TC_ERROR ("Error: Was able to allocate\n\n");
return TC_FAIL; return TC_FAIL;
} }
@ -154,15 +148,13 @@ int taskA(ksem_t semRdy)
int taskB(ksem_t semRdy) int taskB(ksem_t semRdy)
{ {
if (task_irq_alloc (DEV3_ID, DEV3_IRQ, 1) == INVALID_VECTOR) if (task_irq_alloc (DEV3_ID, DEV3_IRQ, 1) == INVALID_VECTOR) {
{
TC_ERROR ("Not able to allocate IRQ object\n"); TC_ERROR ("Not able to allocate IRQ object\n");
return TC_FAIL; return TC_FAIL;
} }
TC_PRINT ("IRQ object %d using IRQ%d allocated\n", DEV3_ID, DEV3_IRQ); TC_PRINT ("IRQ object %d using IRQ%d allocated\n", DEV3_ID, DEV3_IRQ);
if (task_irq_alloc (DEV4_ID, DEV4_IRQ, 1) == INVALID_VECTOR) if (task_irq_alloc (DEV4_ID, DEV4_IRQ, 1) == INVALID_VECTOR) {
{
TC_ERROR ("Not able to allocate IRQ object\n"); TC_ERROR ("Not able to allocate IRQ object\n");
return TC_FAIL; return TC_FAIL;
} }
@ -172,16 +164,14 @@ int taskB(ksem_t semRdy)
task_sem_give (semRdy); task_sem_give (semRdy);
if (task_irq_test_wait (DEV3_ID) != RC_OK) if (task_irq_test_wait (DEV3_ID) != RC_OK) {
{
TC_ERROR ("Not able to test IRQ object event\n"); TC_ERROR ("Not able to test IRQ object event\n");
return TC_FAIL; return TC_FAIL;
} }
TC_PRINT ("Received event for IRQ object %d\n", DEV3_ID); TC_PRINT ("Received event for IRQ object %d\n", DEV3_ID);
task_irq_ack (DEV3_ID); task_irq_ack (DEV3_ID);
if (task_irq_test_wait (DEV4_ID) != RC_OK) if (task_irq_test_wait (DEV4_ID) != RC_OK) {
{
TC_ERROR ("Not able to test IRQ object event\n"); TC_ERROR ("Not able to test IRQ object event\n");
return TC_FAIL; return TC_FAIL;
} }

View file

@ -118,8 +118,7 @@ void ticklessTestTask (void)
/* initialize the timer, if necessary */ /* initialize the timer, if necessary */
_TIMESTAMP_OPEN(); _TIMESTAMP_OPEN();
for (i = 0; i < CAL_REPS; i++) for (i = 0; i < CAL_REPS; i++) {
{
/* /*
* Do a single tick sleep to get us as close to a tick boundary * Do a single tick sleep to get us as close to a tick boundary
* as we can. * as we can.
@ -149,8 +148,7 @@ void ticklessTestTask (void)
printk("Going idle for %d ticks...\n", SLEEP_TICKS); printk("Going idle for %d ticks...\n", SLEEP_TICKS);
for (i = 0; i < CAL_REPS; i++) for (i = 0; i < CAL_REPS; i++) {
{
/* /*
* Do a single tick sleep to get us as close to a tick boundary * Do a single tick sleep to get us as close to a tick boundary
* as we can. * as we can.
@ -190,13 +188,11 @@ void ticklessTestTask (void)
printk("variance in time stamp diff: %d percent\n", (int32_t)diff_per); printk("variance in time stamp diff: %d percent\n", (int32_t)diff_per);
if (diff_ticks != SLEEP_TICKS) if (diff_ticks != SLEEP_TICKS) {
{
printk("* TEST FAILED. TICK COUNT INCORRECT *\n"); printk("* TEST FAILED. TICK COUNT INCORRECT *\n");
TC_END_REPORT(TC_FAIL); TC_END_REPORT(TC_FAIL);
} }
else else {
{
TC_END_REPORT(TC_PASS); TC_END_REPORT(TC_PASS);
} }

View file

@ -121,15 +121,13 @@ uint32_t _TimestampRead (void)
/* handle rollover for every other read (end of sleep) */ /* handle rollover for every other read (end of sleep) */
if ((cnt % 2) && (timerVal > lastTimerVal)) if ((cnt % 2) && (timerVal > lastTimerVal)) {
{
lastTimerVal = timerVal; lastTimerVal = timerVal;
/* convert to extended up-counter value */ /* convert to extended up-counter value */
timerVal = _TIMESTAMP_EXT + (_TIMESTAMP_MAX - timerVal); timerVal = _TIMESTAMP_EXT + (_TIMESTAMP_MAX - timerVal);
} }
else else {
{
lastTimerVal = timerVal; lastTimerVal = timerVal;
/* convert to up-counter value */ /* convert to up-counter value */
@ -245,16 +243,14 @@ uint32_t _TimestampRead (void)
/* ensure a valid reading */ /* ensure a valid reading */
while (prescale1 != prescale2) while (prescale1 != prescale2) {
{
prescale1 = _TIMESTAMP_PRESCALE; prescale1 = _TIMESTAMP_PRESCALE;
prescale2 = _TIMESTAMP_PRESCALE; prescale2 = _TIMESTAMP_PRESCALE;
} }
/* handle prescale rollover @ 0x8000 for every other read (end of sleep) */ /* handle prescale rollover @ 0x8000 for every other read (end of sleep) */
if ((cnt % 2) && (prescale1 < lastPrescale)) if ((cnt % 2) && (prescale1 < lastPrescale)) {
{
prescale1 += 0x8000; prescale1 += 0x8000;
} }

View file

@ -78,10 +78,8 @@ void RegressionTaskEntry (void)
TC_PRINT ("Test globals\n"); TC_PRINT ("Test globals\n");
/* Array should be filled with monotomically incrementing values */ /* Array should be filled with monotomically incrementing values */
for (i = 0; i < XIP_TEST_ARRAY_SZ; i++) for (i = 0; i < XIP_TEST_ARRAY_SZ; i++) {
{ if (xip_array[i] != (i+1)) {
if (xip_array[i] != (i+1))
{
TC_PRINT ("xip_array[%d] != %d\n", i, i+1); TC_PRINT ("xip_array[%d] != %d\n", i, i+1);
tcRC = TC_FAIL; tcRC = TC_FAIL;
goto exitRtn; goto exitRtn;

View file

@ -45,5 +45,5 @@ test.
* This array is deliberately defined outside of the scope of the main test * This array is deliberately defined outside of the scope of the main test
* module to avoid optimization issues. * module to avoid optimization issues.
*/ */
uint32_t xip_array[XIP_TEST_ARRAY_SZ] = uint32_t xip_array[XIP_TEST_ARRAY_SZ] = {
{TEST_VAL_1, TEST_VAL_2, TEST_VAL_3, TEST_VAL_4}; TEST_VAL_1, TEST_VAL_2, TEST_VAL_3, TEST_VAL_4};

View file

@ -86,8 +86,7 @@ NANO_CPU_INT_REGISTER (isrDummyIntStub, TEST_SOFT_INT, 0);
static char pStack[FIBER_STACK_SIZE]; static char pStack[FIBER_STACK_SIZE];
/* pointer array ensures specified functions are linked into the image */ /* pointer array ensures specified functions are linked into the image */
volatile pfunc func_array[] = volatile pfunc func_array[] = {
{
/* nano timer functions */ /* nano timer functions */
(pfunc)nano_timer_init, (pfunc)nano_timer_init,
(pfunc)nano_fiber_timer_start, (pfunc)nano_fiber_timer_start,
@ -193,8 +192,7 @@ void main (void)
(int) func_array, 10, 0); (int) func_array, 10, 0);
#endif /* !TEST_min */ #endif /* !TEST_min */
while (1) while (1) {
{
i++; i++;
} }
} }

View file

@ -74,8 +74,7 @@ void lifo_fiber1 (
ARG_UNUSED (par1); ARG_UNUSED (par1);
for (i = 0; i < par2 / 2; i++) for (i = 0; i < par2 / 2; i++) {
{
pelement = (int *) nano_fiber_lifo_get_wait (&nanoLifo1); pelement = (int *) nano_fiber_lifo_get_wait (&nanoLifo1);
if (pelement[1] != 2 * i) if (pelement[1] != 2 * i)
break; break;
@ -111,8 +110,7 @@ void lifo_fiber2 (
int * pelement; int * pelement;
int * pcounter = (int *) par1; int * pcounter = (int *) par1;
for (i = 0; i < par2; i++) for (i = 0; i < par2; i++) {
{
element[1] = i; element[1] = i;
nano_fiber_lifo_put (&nanoLifo1, element); nano_fiber_lifo_put (&nanoLifo1, element);
pelement = (int *) nano_fiber_lifo_get_wait (&nanoLifo2); pelement = (int *) nano_fiber_lifo_get_wait (&nanoLifo2);
@ -143,8 +141,7 @@ void lifo_fiber3 (
int * pelement; int * pelement;
int * pcounter = (int *) par1; int * pcounter = (int *) par1;
for (i = 0; i < par2; i++) for (i = 0; i < par2; i++) {
{
element[1] = i; element[1] = i;
nano_fiber_lifo_put (&nanoLifo1, element); nano_fiber_lifo_put (&nanoLifo1, element);
while (NULL == (pelement = (int *) nano_fiber_lifo_get (&nanoLifo2))) while (NULL == (pelement = (int *) nano_fiber_lifo_get (&nanoLifo2)))
@ -244,8 +241,7 @@ int lifo_test (void)
task_fiber_start (fiber_stack1, STACK_SIZE, lifo_fiber1, 0, task_fiber_start (fiber_stack1, STACK_SIZE, lifo_fiber1, 0,
NUMBER_OF_LOOPS, 3, 0); NUMBER_OF_LOOPS, 3, 0);
for (i = 0; i < NUMBER_OF_LOOPS / 2; i++) for (i = 0; i < NUMBER_OF_LOOPS / 2; i++) {
{
int element[2]; int element[2];
int * pelement; int * pelement;
element[1] = 2 * i; element[1] = 2 * i;

View file

@ -73,8 +73,7 @@ void fifo_fiber1 (
int * pelement; int * pelement;
ARG_UNUSED (par1); ARG_UNUSED (par1);
for (i = 0; i < par2; i++) for (i = 0; i < par2; i++) {
{
pelement = (int *) nano_fiber_fifo_get_wait (&nanoFifo1); pelement = (int *) nano_fiber_fifo_get_wait (&nanoFifo1);
if (pelement[1] != i) if (pelement[1] != i)
break; break;
@ -105,8 +104,7 @@ void fifo_fiber2 (
int * pelement; int * pelement;
int * pcounter = (int *) par1; int * pcounter = (int *) par1;
for (i = 0; i < par2; i++) for (i = 0; i < par2; i++) {
{
element[1] = i; element[1] = i;
nano_fiber_fifo_put (&nanoFifo1, element); nano_fiber_fifo_put (&nanoFifo1, element);
pelement = (int *) nano_fiber_fifo_get_wait (&nanoFifo2); pelement = (int *) nano_fiber_fifo_get_wait (&nanoFifo2);
@ -138,8 +136,7 @@ void fifo_fiber3 (
int * pelement; int * pelement;
int * pcounter = (int *) par1; int * pcounter = (int *) par1;
for (i = 0; i < par2; i++) for (i = 0; i < par2; i++) {
{
element[1] = i; element[1] = i;
nano_fiber_fifo_put (&nanoFifo1, element); nano_fiber_fifo_put (&nanoFifo1, element);
while (NULL == (pelement = (int *) nano_fiber_fifo_get (&nanoFifo2))) while (NULL == (pelement = (int *) nano_fiber_fifo_get (&nanoFifo2)))
@ -243,8 +240,7 @@ int fifo_test (void)
NUMBER_OF_LOOPS / 2, 3, 0); NUMBER_OF_LOOPS / 2, 3, 0);
task_fiber_start (fiber_stack2, STACK_SIZE, fifo_fiber1, 0, task_fiber_start (fiber_stack2, STACK_SIZE, fifo_fiber1, 0,
NUMBER_OF_LOOPS / 2, 3, 0); NUMBER_OF_LOOPS / 2, 3, 0);
for (i = 0; i < NUMBER_OF_LOOPS / 2; i++) for (i = 0; i < NUMBER_OF_LOOPS / 2; i++) {
{
int element[2]; int element[2];
int * pelement; int * pelement;
element[1] = i; element[1] = i;

View file

@ -69,8 +69,7 @@ void sema_fiber1 (
ARG_UNUSED (par1); ARG_UNUSED (par1);
for (i = 0; i < par2; i++) for (i = 0; i < par2; i++) {
{
nano_fiber_sem_take_wait (&nanoSem1); nano_fiber_sem_take_wait (&nanoSem1);
nano_fiber_sem_give (&nanoSem2); nano_fiber_sem_give (&nanoSem2);
} }
@ -94,8 +93,7 @@ void sema_fiber2 (
int i; int i;
int * pcounter = (int *) par1; int * pcounter = (int *) par1;
for (i = 0; i < par2; i++) for (i = 0; i < par2; i++) {
{
nano_fiber_sem_give (&nanoSem1); nano_fiber_sem_give (&nanoSem1);
nano_fiber_sem_take_wait (&nanoSem2); nano_fiber_sem_take_wait (&nanoSem2);
(*pcounter)++; (*pcounter)++;
@ -119,8 +117,7 @@ void sema_fiber3 (
int i; int i;
int * pcounter = (int *) par1; int * pcounter = (int *) par1;
for (i = 0; i < par2; i++) for (i = 0; i < par2; i++) {
{
nano_fiber_sem_give (&nanoSem1); nano_fiber_sem_give (&nanoSem1);
while (!nano_fiber_sem_take (&nanoSem2)) while (!nano_fiber_sem_take (&nanoSem2))
fiber_yield (); fiber_yield ();
@ -200,8 +197,7 @@ int sema_test (void)
task_fiber_start (fiber_stack1, STACK_SIZE, sema_fiber1, 0, task_fiber_start (fiber_stack1, STACK_SIZE, sema_fiber1, 0,
NUMBER_OF_LOOPS, 3, 0); NUMBER_OF_LOOPS, 3, 0);
for (i = 0; i < NUMBER_OF_LOOPS; i++) for (i = 0; i < NUMBER_OF_LOOPS; i++) {
{
nano_task_sem_give (&nanoSem1); nano_task_sem_give (&nanoSem1);
nano_task_sem_take_wait (&nanoSem2); nano_task_sem_take_wait (&nanoSem2);
} }

View file

@ -73,8 +73,7 @@ void stack_fiber1 (
ARG_UNUSED (par1); ARG_UNUSED (par1);
for (i = 0; i < par2 / 2; i++) for (i = 0; i < par2 / 2; i++) {
{
data = nano_fiber_stack_pop_wait (&nanoChannel1); data = nano_fiber_stack_pop_wait (&nanoChannel1);
if (data != 2 * i) if (data != 2 * i)
break; break;
@ -107,8 +106,7 @@ void stack_fiber2 (
uint32_t data; uint32_t data;
int * pcounter = (int *) par1; int * pcounter = (int *) par1;
for (i = 0; i < par2; i++) for (i = 0; i < par2; i++) {
{
data = i; data = i;
nano_fiber_stack_push (&nanoChannel1, data); nano_fiber_stack_push (&nanoChannel1, data);
data = nano_fiber_stack_pop_wait (&nanoChannel2); data = nano_fiber_stack_pop_wait (&nanoChannel2);
@ -137,8 +135,7 @@ void stack_fiber3 (
uint32_t data; uint32_t data;
int * pcounter = (int *) par1; int * pcounter = (int *) par1;
for (i = 0; i < par2; i++) for (i = 0; i < par2; i++) {
{
data = i; data = i;
nano_fiber_stack_push (&nanoChannel1, data); nano_fiber_stack_push (&nanoChannel1, data);
data = 0xffffffff; data = 0xffffffff;
@ -227,8 +224,7 @@ int stack_test (void)
task_fiber_start (fiber_stack1, STACK_SIZE, stack_fiber1, 0, task_fiber_start (fiber_stack1, STACK_SIZE, stack_fiber1, 0,
NUMBER_OF_LOOPS, 3, 0); NUMBER_OF_LOOPS, 3, 0);
for (i = 0; i < NUMBER_OF_LOOPS / 2; i++) for (i = 0; i < NUMBER_OF_LOOPS / 2; i++) {
{
uint32_t data; uint32_t data;
data = 2 * i; data = 2 * i;
nano_task_stack_push (&nanoChannel1, data); nano_task_stack_push (&nanoChannel1, data);

View file

@ -113,16 +113,14 @@ int check_result (
bench_test_end checks tCheck static variable. bench_test_end checks tCheck static variable.
bench_test_start modifies it bench_test_start modifies it
*/ */
if (bench_test_end () != 0) if (bench_test_end () != 0) {
{
fprintf (output_file, sz_case_result_fmt, sz_fail); fprintf (output_file, sz_case_result_fmt, sz_fail);
fprintf (output_file, sz_case_details_fmt, fprintf (output_file, sz_case_details_fmt,
"timer tick happened. Results are inaccurate"); "timer tick happened. Results are inaccurate");
fprintf (output_file, sz_case_end_fmt); fprintf (output_file, sz_case_end_fmt);
return 0; return 0;
} }
if (i != NUMBER_OF_LOOPS) if (i != NUMBER_OF_LOOPS) {
{
fprintf (output_file, sz_case_result_fmt, sz_fail); fprintf (output_file, sz_case_result_fmt, sz_fail);
fprintf (output_file, sz_case_details_fmt, "loop counter = "); fprintf (output_file, sz_case_details_fmt, "loop counter = ");
fprintf (output_file, "%i !!!", i); fprintf (output_file, "%i !!!", i);
@ -211,8 +209,7 @@ void main (void)
init_output (&continuously); init_output (&continuously);
bench_test_init (); bench_test_init ();
do do {
{
fprintf (output_file, sz_module_title_fmt, "Nanokernel API test"); fprintf (output_file, sz_module_title_fmt, "Nanokernel API test");
fprintf (output_file, sz_kernel_ver_fmt, kernel_version_get ()); fprintf (output_file, sz_kernel_ver_fmt, kernel_version_get ());
fprintf (output_file, fprintf (output_file,
@ -226,8 +223,7 @@ void main (void)
test_result += fifo_test (); test_result += fifo_test ();
test_result += stack_test (); test_result += stack_test ();
if (test_result) if (test_result) {
{
/* sema, lifo, fifo, stack account for twelve tests in total */ /* sema, lifo, fifo, stack account for twelve tests in total */
if (test_result == 12) if (test_result == 12)
fprintf (output_file, sz_module_result_fmt, sz_success); fprintf (output_file, sz_module_result_fmt, sz_success);

View file

@ -104,8 +104,7 @@ void main (void)
{ {
TC_START ("Test Cortex-M3 IRQ installed directly in vector table"); TC_START ("Test Cortex-M3 IRQ installed directly in vector table");
for (int ii = 0; ii < 3; ii++) for (int ii = 0; ii < 3; ii++) {
{
irq_enable(ii); irq_enable(ii);
irq_priority_set(ii, _EXC_IRQ_DEFAULT_PRIO); irq_priority_set(ii, _EXC_IRQ_DEFAULT_PRIO);
nano_sem_init(&sem[ii]); nano_sem_init(&sem[ii]);
@ -132,7 +131,6 @@ get_out:
} }
typedef void (*vth)(void); /* Vector Table Handler */ typedef void (*vth)(void); /* Vector Table Handler */
vth __irq_vector_table _irq_vector_table[CONFIG_NUM_IRQS] = vth __irq_vector_table _irq_vector_table[CONFIG_NUM_IRQS] = {
{
isr0, isr1, isr2 isr0, isr1, isr2
}; };

View file

@ -90,12 +90,10 @@ This module tests the following CPU and context related routines:
/* typedefs */ /* typedefs */
typedef struct typedef struct {
{
int command; /* command to process */ int command; /* command to process */
int error; /* error value (if any) */ int error; /* error value (if any) */
union union {
{
void *data; /* pointer to data to use or return */ void *data; /* pointer to data to use or return */
int value; /* value to be passed or returned */ int value; /* value to be passed or returned */
}; };
@ -140,8 +138,7 @@ void isr_handler(void *data)
{ {
ARG_UNUSED (data); ARG_UNUSED (data);
switch (isrInfo.command) switch (isrInfo.command) {
{
case CTX_SELF_CMD: case CTX_SELF_CMD:
isrInfo.data = (void *) context_self_get (); isrInfo.data = (void *) context_self_get ();
break; break;
@ -198,8 +195,7 @@ int initNanoObjects(void)
nanoCpuExcConnect (IV_DIVIDE_ERROR, exc_divide_error_handler, nanoExcStub); nanoCpuExcConnect (IV_DIVIDE_ERROR, exc_divide_error_handler, nanoExcStub);
#endif #endif
struct isrInitInfo i = struct isrInitInfo i = {
{
{isr_handler, NULL}, {isr_handler, NULL},
{&isrInfo, NULL}, {&isrInfo, NULL},
}; };
@ -226,17 +222,14 @@ int nano_cpu_idleTest(void)
/* Align to a "tick boundary". */ /* Align to a "tick boundary". */
tick = nano_tick_get_32 (); tick = nano_tick_get_32 ();
while (tick == nano_tick_get_32 ()) while (tick == nano_tick_get_32 ()) {
{
} }
tick = nano_tick_get_32 (); tick = nano_tick_get_32 ();
for (i = 0; i < 5; i++) /* Repeat the test five times */ for (i = 0; i < 5; i++) { /* Repeat the test five times */
{
nano_cpu_idle (); nano_cpu_idle ();
tick++; tick++;
if (nano_tick_get_32 () != tick) if (nano_tick_get_32 () != tick) {
{
return TC_FAIL; return TC_FAIL;
} }
} }
@ -343,13 +336,11 @@ int nanoCpuDisableInterruptsTest(disable_interrupt_func disableRtn,
/* Align to a "tick boundary" */ /* Align to a "tick boundary" */
tick = nano_tick_get_32 (); tick = nano_tick_get_32 ();
while (nano_tick_get_32 () == tick) while (nano_tick_get_32 () == tick) {
{
} }
tick++; tick++;
while (nano_tick_get_32 () == tick) while (nano_tick_get_32 () == tick) {
{
count++; count++;
} }
@ -364,8 +355,7 @@ int nanoCpuDisableInterruptsTest(disable_interrupt_func disableRtn,
imask = disableRtn (irq); imask = disableRtn (irq);
tick = nano_tick_get_32 (); tick = nano_tick_get_32 ();
for (i = 0; i < count; i++) for (i = 0; i < count; i++) {
{
nano_tick_get_32 (); nano_tick_get_32 ();
} }
@ -378,14 +368,12 @@ int nanoCpuDisableInterruptsTest(disable_interrupt_func disableRtn,
enableRtn (imask); enableRtn (imask);
if (tick2 != tick) if (tick2 != tick) {
{
return TC_FAIL; return TC_FAIL;
} }
/* Now repeat with interrupts unlocked. */ /* Now repeat with interrupts unlocked. */
for (i = 0; i < count; i++) for (i = 0; i < count; i++) {
{
nano_tick_get_32 (); nano_tick_get_32 ();
} }
@ -412,8 +400,7 @@ int nanoCtxTaskTest(void)
isrInfo.command = CTX_SELF_CMD; isrInfo.command = CTX_SELF_CMD;
isrInfo.error = 0; isrInfo.error = 0;
_trigger_isrHandler (); _trigger_isrHandler ();
if ((isrInfo.error != 0) || (isrInfo.data != (void *) ctxId)) if ((isrInfo.error != 0) || (isrInfo.data != (void *) ctxId)) {
{
/* /*
* Either the ISR detected an error, or the ISR context ID does not * Either the ISR detected an error, or the ISR context ID does not
* match the interrupted task's context ID. * match the interrupted task's context ID.
@ -425,14 +412,12 @@ int nanoCtxTaskTest(void)
isrInfo.command = CTX_TYPE_CMD; isrInfo.command = CTX_TYPE_CMD;
isrInfo.error = 0; isrInfo.error = 0;
_trigger_isrHandler (); _trigger_isrHandler ();
if ((isrInfo.error != 0) || (isrInfo.value != NANO_CTX_ISR)) if ((isrInfo.error != 0) || (isrInfo.value != NANO_CTX_ISR)) {
{
return TC_FAIL; return TC_FAIL;
} }
TC_PRINT ("Testing context_type_get() from a task\n"); TC_PRINT ("Testing context_type_get() from a task\n");
if (context_type_get() != NANO_CTX_TASK) if (context_type_get() != NANO_CTX_TASK) {
{
return TC_FAIL; return TC_FAIL;
} }
@ -461,8 +446,7 @@ int nanoCtxFiberTest(nano_context_id_t taskCtxId)
nano_context_id_t ctxId; nano_context_id_t ctxId;
ctxId = context_self_get (); ctxId = context_self_get ();
if (ctxId == taskCtxId) if (ctxId == taskCtxId) {
{
fiberDetectedError = 1; fiberDetectedError = 1;
return TC_FAIL; return TC_FAIL;
} }
@ -470,8 +454,7 @@ int nanoCtxFiberTest(nano_context_id_t taskCtxId)
isrInfo.command = CTX_SELF_CMD; isrInfo.command = CTX_SELF_CMD;
isrInfo.error = 0; isrInfo.error = 0;
_trigger_isrHandler (); _trigger_isrHandler ();
if ((isrInfo.error != 0) || (isrInfo.data != (void *) ctxId)) if ((isrInfo.error != 0) || (isrInfo.data != (void *) ctxId)) {
{
/* /*
* Either the ISR detected an error, or the ISR context ID does not * Either the ISR detected an error, or the ISR context ID does not
* match the interrupted fiber's context ID. * match the interrupted fiber's context ID.
@ -483,14 +466,12 @@ int nanoCtxFiberTest(nano_context_id_t taskCtxId)
isrInfo.command = CTX_TYPE_CMD; isrInfo.command = CTX_TYPE_CMD;
isrInfo.error = 0; isrInfo.error = 0;
_trigger_isrHandler (); _trigger_isrHandler ();
if ((isrInfo.error != 0) || (isrInfo.value != NANO_CTX_ISR)) if ((isrInfo.error != 0) || (isrInfo.value != NANO_CTX_ISR)) {
{
fiberDetectedError = 3; fiberDetectedError = 3;
return TC_FAIL; return TC_FAIL;
} }
if (context_type_get() != NANO_CTX_FIBER) if (context_type_get() != NANO_CTX_FIBER) {
{
fiberDetectedError = 4; fiberDetectedError = 4;
return TC_FAIL; return TC_FAIL;
} }
@ -568,8 +549,8 @@ int fiber_yieldTest(void)
fiber_fiber_start (fiberStack2, FIBER_STACKSIZE, fiberHelper, fiber_fiber_start (fiberStack2, FIBER_STACKSIZE, fiberHelper,
0, 0, FIBER_PRIORITY - 1, 0); 0, 0, FIBER_PRIORITY - 1, 0);
if (fiberEvidence != 0) if (fiberEvidence != 0) {
{ /* ERROR! Helper spawned at higher */ /* ERROR! Helper spawned at higher */
fiberDetectedError = 10; /* priority ran prematurely. */ fiberDetectedError = 10; /* priority ran prematurely. */
return TC_FAIL; return TC_FAIL;
} }
@ -581,14 +562,14 @@ int fiber_yieldTest(void)
fiber_yield (); fiber_yield ();
if (fiberEvidence == 0) if (fiberEvidence == 0) {
{ /* ERROR! Did not yield to higher */ /* ERROR! Did not yield to higher */
fiberDetectedError = 11; /* priority fiber. */ fiberDetectedError = 11; /* priority fiber. */
return TC_FAIL; return TC_FAIL;
} }
if (fiberEvidence > 1) if (fiberEvidence > 1) {
{ /* ERROR! Helper did not yield to */ /* ERROR! Helper did not yield to */
fiberDetectedError = 12; /* equal priority fiber. */ fiberDetectedError = 12; /* equal priority fiber. */
return TC_FAIL; return TC_FAIL;
} }
@ -601,8 +582,8 @@ int fiber_yieldTest(void)
ctxId->prio--; ctxId->prio--;
fiber_yield (); fiber_yield ();
if (fiberEvidence != 1) if (fiberEvidence != 1) {
{ /* ERROR! Context switched to a lower */ /* ERROR! Context switched to a lower */
fiberDetectedError = 13; /* priority fiber! */ fiberDetectedError = 13; /* priority fiber! */
return TC_FAIL; return TC_FAIL;
} }
@ -639,8 +620,7 @@ static void fiberEntry(int taskCtxId, int arg1)
nano_fiber_sem_take_wait (&wakeFiber); nano_fiber_sem_take_wait (&wakeFiber);
rv = nanoCtxFiberTest ((nano_context_id_t) taskCtxId); rv = nanoCtxFiberTest ((nano_context_id_t) taskCtxId);
if (rv != TC_PASS) if (rv != TC_PASS) {
{
return; return;
} }
@ -648,8 +628,7 @@ static void fiberEntry(int taskCtxId, int arg1)
nano_fiber_sem_take_wait (&wakeFiber); nano_fiber_sem_take_wait (&wakeFiber);
rv = fiber_yieldTest (); rv = fiber_yieldTest ();
if (rv != TC_PASS) if (rv != TC_PASS) {
{
return; return;
} }
} }
@ -671,23 +650,20 @@ void main(void)
TC_PRINT ("Initializing nanokernel objects\n"); TC_PRINT ("Initializing nanokernel objects\n");
rv = initNanoObjects (); rv = initNanoObjects ();
if (rv != TC_PASS) if (rv != TC_PASS) {
{
goto doneTests; goto doneTests;
} }
TC_PRINT ("Testing nano_cpu_idle()\n"); TC_PRINT ("Testing nano_cpu_idle()\n");
rv = nano_cpu_idleTest (); rv = nano_cpu_idleTest ();
if (rv != TC_PASS) if (rv != TC_PASS) {
{
goto doneTests; goto doneTests;
} }
TC_PRINT ("Testing interrupt locking and unlocking\n"); TC_PRINT ("Testing interrupt locking and unlocking\n");
rv = nanoCpuDisableInterruptsTest (irq_lockWrapper, rv = nanoCpuDisableInterruptsTest (irq_lockWrapper,
irq_unlockWrapper, -1); irq_unlockWrapper, -1);
if (rv != TC_PASS) if (rv != TC_PASS) {
{
goto doneTests; goto doneTests;
} }
@ -695,8 +671,7 @@ void main(void)
TC_PRINT ("Testing inline interrupt locking and unlocking\n"); TC_PRINT ("Testing inline interrupt locking and unlocking\n");
rv = nanoCpuDisableInterruptsTest (irq_lock_inlineWrapper, rv = nanoCpuDisableInterruptsTest (irq_lock_inlineWrapper,
irq_unlock_inlineWrapper, -1); irq_unlock_inlineWrapper, -1);
if (rv != TC_PASS) if (rv != TC_PASS) {
{
goto doneTests; goto doneTests;
} }
@ -716,15 +691,13 @@ void main(void)
TC_PRINT ("Testing irq_disable() and irq_enable()\n"); TC_PRINT ("Testing irq_disable() and irq_enable()\n");
rv = nanoCpuDisableInterruptsTest (irq_disableWrapper, rv = nanoCpuDisableInterruptsTest (irq_disableWrapper,
irq_enableWrapper, TICK_IRQ); irq_enableWrapper, TICK_IRQ);
if (rv != TC_PASS) if (rv != TC_PASS) {
{
goto doneTests; goto doneTests;
} }
#endif #endif
rv = nanoCtxTaskTest (); rv = nanoCtxTaskTest ();
if (rv != TC_PASS) if (rv != TC_PASS) {
{
goto doneTests; goto doneTests;
} }
@ -733,8 +706,7 @@ void main(void)
task_fiber_start (fiberStack1, FIBER_STACKSIZE, fiberEntry, task_fiber_start (fiberStack1, FIBER_STACKSIZE, fiberEntry,
(int) context_self_get (), 0, FIBER_PRIORITY, 0); (int) context_self_get (), 0, FIBER_PRIORITY, 0);
if (fiberEvidence != 1) if (fiberEvidence != 1) {
{
rv = TC_FAIL; rv = TC_FAIL;
TC_ERROR (" - fiber did not execute as expected!\n"); TC_ERROR (" - fiber did not execute as expected!\n");
goto doneTests; goto doneTests;
@ -744,8 +716,7 @@ void main(void)
TC_PRINT ("Fiber to test context_self_get() and context_type_get\n"); TC_PRINT ("Fiber to test context_self_get() and context_type_get\n");
nano_task_sem_give (&wakeFiber); nano_task_sem_give (&wakeFiber);
if (fiberDetectedError != 0) if (fiberDetectedError != 0) {
{
rv = TC_FAIL; rv = TC_FAIL;
TC_ERROR (" - failure detected in fiber; fiberDetectedError = %d\n", TC_ERROR (" - failure detected in fiber; fiberDetectedError = %d\n",
fiberDetectedError); fiberDetectedError);
@ -755,8 +726,7 @@ void main(void)
TC_PRINT ("Fiber to test fiber_yield()\n"); TC_PRINT ("Fiber to test fiber_yield()\n");
nano_task_sem_give (&wakeFiber); nano_task_sem_give (&wakeFiber);
if (fiberDetectedError != 0) if (fiberDetectedError != 0) {
{
rv = TC_FAIL; rv = TC_FAIL;
TC_ERROR (" - failure detected in fiber; fiberDetectedError = %d\n", TC_ERROR (" - failure detected in fiber; fiberDetectedError = %d\n",
fiberDetectedError); fiberDetectedError);

View file

@ -84,8 +84,7 @@ in ISR context.
/* typedefs */ /* typedefs */
typedef struct typedef struct {
{
struct nano_fifo *channel; /* FIFO channel */ struct nano_fifo *channel; /* FIFO channel */
void *data; /* pointer to data to add */ void *data; /* pointer to data to add */
} ISR_FIFO_INFO; } ISR_FIFO_INFO;
@ -117,16 +116,14 @@ void * const pMyFifoData2 = (void *)myFifoData2;
void * const pMyFifoData3 = (void *)myFifoData3; void * const pMyFifoData3 = (void *)myFifoData3;
void * const pMyFifoData4 = (void *)myFifoData4; void * const pMyFifoData4 = (void *)myFifoData4;
void * const pPutList1[NUM_FIFO_ELEMENT] = void * const pPutList1[NUM_FIFO_ELEMENT] = {
{
(void *)myFifoData1, (void *)myFifoData1,
(void *)myFifoData2, (void *)myFifoData2,
(void *)myFifoData3, (void *)myFifoData3,
(void *)myFifoData4 (void *)myFifoData4
}; };
void * const pPutList2[NUM_FIFO_ELEMENT] = void * const pPutList2[NUM_FIFO_ELEMENT] = {
{
(void *)myFifoData4, (void *)myFifoData4,
(void *)myFifoData3, (void *)myFifoData3,
(void *)myFifoData2, (void *)myFifoData2,
@ -207,8 +204,7 @@ void fiber1(void)
/* Wait for data to be added to <nanoFifoObj> by task */ /* Wait for data to be added to <nanoFifoObj> by task */
pData = nano_fiber_fifo_get_wait (&nanoFifoObj); pData = nano_fiber_fifo_get_wait (&nanoFifoObj);
if (pData != pPutList1[0]) if (pData != pPutList1[0]) {
{
TC_ERROR ("fiber1 (1) - expected 0x%x, got 0x%x\n", TC_ERROR ("fiber1 (1) - expected 0x%x, got 0x%x\n",
pPutList1[0], pData); pPutList1[0], pData);
retCode = TC_FAIL; retCode = TC_FAIL;
@ -217,8 +213,7 @@ void fiber1(void)
/* Wait for data to be added to <nanoFifoObj2> by fiber3 */ /* Wait for data to be added to <nanoFifoObj2> by fiber3 */
pData = nano_fiber_fifo_get_wait (&nanoFifoObj2); pData = nano_fiber_fifo_get_wait (&nanoFifoObj2);
if (pData != pPutList2[0]) if (pData != pPutList2[0]) {
{
TC_ERROR ("fiber1 (2) - expected 0x%x, got 0x%x\n", TC_ERROR ("fiber1 (2) - expected 0x%x, got 0x%x\n",
pPutList2[0], pData); pPutList2[0], pData);
retCode = TC_FAIL; retCode = TC_FAIL;
@ -229,11 +224,9 @@ void fiber1(void)
TC_PRINT("Test Fiber FIFO Get\n\n"); TC_PRINT("Test Fiber FIFO Get\n\n");
/* Get all FIFOs */ /* Get all FIFOs */
while ((pData = nano_fiber_fifo_get(&nanoFifoObj)) != NULL) while ((pData = nano_fiber_fifo_get(&nanoFifoObj)) != NULL) {
{
TC_PRINT("FIBER FIFO Get: count = %d, ptr is %p\n", count, pData); TC_PRINT("FIBER FIFO Get: count = %d, ptr is %p\n", count, pData);
if((count >= NUM_FIFO_ELEMENT) || (pData != pPutList1[count])) if((count >= NUM_FIFO_ELEMENT) || (pData != pPutList1[count])) {
{
TCERR1(count); TCERR1(count);
retCode = TC_FAIL; retCode = TC_FAIL;
return; return;
@ -250,8 +243,7 @@ void fiber1(void)
*/ */
TC_PRINT("Test Fiber FIFO Put\n"); TC_PRINT("Test Fiber FIFO Put\n");
TC_PRINT("\nFIBER FIFO Put Order: "); TC_PRINT("\nFIBER FIFO Put Order: ");
for (int i=0; i<NUM_FIFO_ELEMENT; i++) for (int i=0; i<NUM_FIFO_ELEMENT; i++) {
{
nano_fiber_fifo_put(&nanoFifoObj, pPutList2[i]); nano_fiber_fifo_put(&nanoFifoObj, pPutList2[i]);
TC_PRINT(" %p,", pPutList2[i]); TC_PRINT(" %p,", pPutList2[i]);
} }
@ -283,8 +275,7 @@ void testFiberFifoGetW(void)
pGetData = nano_fiber_fifo_get_wait(&nanoFifoObj2); pGetData = nano_fiber_fifo_get_wait(&nanoFifoObj2);
TC_PRINT("FIBER FIFO Get from queue2: %p\n", pGetData); TC_PRINT("FIBER FIFO Get from queue2: %p\n", pGetData);
/* Verify results */ /* Verify results */
if (pGetData != pMyFifoData1) if (pGetData != pMyFifoData1) {
{
retCode = TC_FAIL; retCode = TC_FAIL;
TCERR2; TCERR2;
return; return;
@ -297,8 +288,7 @@ void testFiberFifoGetW(void)
pGetData = nano_fiber_fifo_get_wait(&nanoFifoObj2); pGetData = nano_fiber_fifo_get_wait(&nanoFifoObj2);
TC_PRINT("FIBER FIFO Get from queue2: %p\n", pGetData); TC_PRINT("FIBER FIFO Get from queue2: %p\n", pGetData);
/* Verify results */ /* Verify results */
if (pGetData != pMyFifoData3) if (pGetData != pMyFifoData3) {
{
retCode = TC_FAIL; retCode = TC_FAIL;
TCERR2; TCERR2;
return; return;
@ -336,8 +326,7 @@ void testIsrFifoFromFiber(void)
pGetData = isrFifoInfo.data; pGetData = isrFifoInfo.data;
TC_PRINT("ISR FIFO Get from queue1: %p\n", pGetData); TC_PRINT("ISR FIFO Get from queue1: %p\n", pGetData);
if (isrFifoInfo.data != pMyFifoData4) if (isrFifoInfo.data != pMyFifoData4) {
{
retCode = TC_FAIL; retCode = TC_FAIL;
TCERR2; TCERR2;
return; return;
@ -347,8 +336,7 @@ void testIsrFifoFromFiber(void)
_trigger_nano_isr_fifo_get(); _trigger_nano_isr_fifo_get();
pGetData = isrFifoInfo.data; pGetData = isrFifoInfo.data;
if (pGetData != NULL) if (pGetData != NULL) {
{
TC_PRINT("Get from queue1: %p\n", pGetData); TC_PRINT("Get from queue1: %p\n", pGetData);
retCode = TC_FAIL; retCode = TC_FAIL;
TCERR3; TCERR3;
@ -357,8 +345,7 @@ void testIsrFifoFromFiber(void)
/* Put more item into queue */ /* Put more item into queue */
TC_PRINT("\nISR FIFO (running in fiber context) Put Order: \n"); TC_PRINT("\nISR FIFO (running in fiber context) Put Order: \n");
for (int i=0; i<NUM_FIFO_ELEMENT; i++) for (int i=0; i<NUM_FIFO_ELEMENT; i++) {
{
isrFifoInfo.data = pPutList1[i]; isrFifoInfo.data = pPutList1[i];
TC_PRINT(" %p,", pPutList1[i]); TC_PRINT(" %p,", pPutList1[i]);
_trigger_nano_isr_fifo_put(); _trigger_nano_isr_fifo_put();
@ -396,11 +383,9 @@ void testIsrFifoFromTask(void)
_trigger_nano_isr_fifo_get(); _trigger_nano_isr_fifo_get();
pGetData = isrFifoInfo.data; pGetData = isrFifoInfo.data;
while (pGetData != NULL) while (pGetData != NULL) {
{
TC_PRINT("Get from queue1: count = %d, ptr is %p\n", count, pGetData); TC_PRINT("Get from queue1: count = %d, ptr is %p\n", count, pGetData);
if ((count >= NUM_FIFO_ELEMENT) || (pGetData != pPutList1[count])) if ((count >= NUM_FIFO_ELEMENT) || (pGetData != pPutList1[count])) {
{
TCERR1(count); TCERR1(count);
retCode = TC_FAIL; retCode = TC_FAIL;
return; return;
@ -423,14 +408,12 @@ void testIsrFifoFromTask(void)
_trigger_nano_isr_fifo_get(); _trigger_nano_isr_fifo_get();
pGetData = isrFifoInfo.data; pGetData = isrFifoInfo.data;
/* Verify data */ /* Verify data */
if (pGetData != pPutData) if (pGetData != pPutData) {
{
retCode = TC_FAIL; retCode = TC_FAIL;
TCERR2; TCERR2;
return; return;
} }
else else {
{
TC_PRINT("\nTest ISR FIFO (invoked from Task) - put %p and get back %p\n", TC_PRINT("\nTest ISR FIFO (invoked from Task) - put %p and get back %p\n",
pPutData, pGetData); pPutData, pGetData);
} }
@ -455,8 +438,7 @@ void fiber2(void)
/* Wait for data to be added to <nanoFifoObj> */ /* Wait for data to be added to <nanoFifoObj> */
pData = nano_fiber_fifo_get_wait (&nanoFifoObj); pData = nano_fiber_fifo_get_wait (&nanoFifoObj);
if (pData != pPutList1[1]) if (pData != pPutList1[1]) {
{
TC_ERROR ("fiber2 (1) - expected 0x%x, got 0x%x\n", TC_ERROR ("fiber2 (1) - expected 0x%x, got 0x%x\n",
pPutList1[1], pData); pPutList1[1], pData);
retCode = TC_FAIL; retCode = TC_FAIL;
@ -465,8 +447,7 @@ void fiber2(void)
/* Wait for data to be added to <nanoFifoObj2> by fiber3 */ /* Wait for data to be added to <nanoFifoObj2> by fiber3 */
pData = nano_fiber_fifo_get_wait (&nanoFifoObj2); pData = nano_fiber_fifo_get_wait (&nanoFifoObj2);
if (pData != pPutList2[1]) if (pData != pPutList2[1]) {
{
TC_ERROR ("fiber2 (2) - expected 0x%x, got 0x%x\n", TC_ERROR ("fiber2 (2) - expected 0x%x, got 0x%x\n",
pPutList2[1], pData); pPutList2[1], pData);
retCode = TC_FAIL; retCode = TC_FAIL;
@ -476,11 +457,9 @@ void fiber2(void)
nano_fiber_sem_take_wait (&nanoSemObj2); /* Wait for fiber2 to be reactivated */ nano_fiber_sem_take_wait (&nanoSemObj2); /* Wait for fiber2 to be reactivated */
/* Fiber #2 has been reactivated by main task */ /* Fiber #2 has been reactivated by main task */
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++) {
{
pData = nano_fiber_fifo_get_wait (&nanoFifoObj); pData = nano_fiber_fifo_get_wait (&nanoFifoObj);
if (pData != pPutList1[i]) if (pData != pPutList1[i]) {
{
TC_ERROR ("fiber2 (3) - iteration %d expected 0x%x, got 0x%x\n", TC_ERROR ("fiber2 (3) - iteration %d expected 0x%x, got 0x%x\n",
i, pPutList1[i], pData); i, pPutList1[i], pData);
retCode = TC_FAIL; retCode = TC_FAIL;
@ -521,8 +500,7 @@ void fiber3(void)
/* Immediately get the data from <nanoFifoObj2>. */ /* Immediately get the data from <nanoFifoObj2>. */
pData = nano_fiber_fifo_get_wait (&nanoFifoObj2); pData = nano_fiber_fifo_get_wait (&nanoFifoObj2);
if (pData != pPutList2[0]) if (pData != pPutList2[0]) {
{
retCode = TC_FAIL; retCode = TC_FAIL;
TC_ERROR ("fiber3 (1) - got 0x%x from <nanoFifoObj2>, expected 0x%x\n", TC_ERROR ("fiber3 (1) - got 0x%x from <nanoFifoObj2>, expected 0x%x\n",
pData, pPutList2[0]); pData, pPutList2[0]);
@ -572,8 +550,7 @@ void testTaskFifoGetW(void)
pGetData = nano_task_fifo_get_wait(&nanoFifoObj); pGetData = nano_task_fifo_get_wait(&nanoFifoObj);
TC_PRINT("TASK FIFO Get from queue1: %p\n", pGetData); TC_PRINT("TASK FIFO Get from queue1: %p\n", pGetData);
/* Verify results */ /* Verify results */
if (pGetData != pMyFifoData2) if (pGetData != pMyFifoData2) {
{
retCode = TC_FAIL; retCode = TC_FAIL;
TCERR2; TCERR2;
return; return;
@ -597,8 +574,7 @@ void testTaskFifoGetW(void)
void initNanoObjects(void) void initNanoObjects(void)
{ {
struct isrInitInfo i = struct isrInitInfo i = {
{
{isr_fifo_put, isr_fifo_get}, {isr_fifo_put, isr_fifo_get},
{&isrFifoInfo, &isrFifoInfo}, {&isrFifoInfo, &isrFifoInfo},
}; };
@ -671,11 +647,9 @@ void main(void)
nano_task_fifo_put (&nanoFifoObj2, pPutList2[0]); nano_task_fifo_put (&nanoFifoObj2, pPutList2[0]);
nano_task_sem_give (&nanoSemObj3); /* Reactivate fiber #3 */ nano_task_sem_give (&nanoSemObj3); /* Reactivate fiber #3 */
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++) {
{
pData = nano_task_fifo_get_wait (&nanoFifoObj2); pData = nano_task_fifo_get_wait (&nanoFifoObj2);
if (pData != pPutList2[i]) if (pData != pPutList2[i]) {
{
TC_ERROR ("nano_task_fifo_get_wait() expected 0x%x, got 0x%x\n", TC_ERROR ("nano_task_fifo_get_wait() expected 0x%x, got 0x%x\n",
pPutList2[i], pData); pPutList2[i], pData);
goto exit; goto exit;
@ -683,8 +657,7 @@ void main(void)
} }
/* Add items to <nanoFifoObj> for fiber #2 */ /* Add items to <nanoFifoObj> for fiber #2 */
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++) {
{
nano_task_fifo_put (&nanoFifoObj, pPutList1[i]); nano_task_fifo_put (&nanoFifoObj, pPutList1[i]);
} }
@ -693,8 +666,7 @@ void main(void)
/* Wait for fibers to finish */ /* Wait for fibers to finish */
nano_task_sem_take_wait (&nanoSemObjTask); nano_task_sem_take_wait (&nanoSemObjTask);
if (retCode == TC_FAIL) if (retCode == TC_FAIL) {
{
goto exit; goto exit;
} }
@ -705,8 +677,7 @@ void main(void)
TC_PRINT("Test Task FIFO Put\n"); TC_PRINT("Test Task FIFO Put\n");
TC_PRINT("\nTASK FIFO Put Order: "); TC_PRINT("\nTASK FIFO Put Order: ");
for (int i=0; i<NUM_FIFO_ELEMENT; i++) for (int i=0; i<NUM_FIFO_ELEMENT; i++) {
{
nano_task_fifo_put(&nanoFifoObj, pPutList1[i]); nano_task_fifo_put(&nanoFifoObj, pPutList1[i]);
TC_PRINT(" %p,", pPutList1[i]); TC_PRINT(" %p,", pPutList1[i]);
} }
@ -716,8 +687,7 @@ void main(void)
nano_task_sem_give (&nanoSemObj1); /* Activate fiber1 */ nano_task_sem_give (&nanoSemObj1); /* Activate fiber1 */
if (retCode == TC_FAIL) if (retCode == TC_FAIL) {
{
goto exit; goto exit;
} }
@ -730,11 +700,9 @@ void main(void)
TC_PRINT("Test Task FIFO Get\n"); TC_PRINT("Test Task FIFO Get\n");
/* Get all FIFOs */ /* Get all FIFOs */
while ((pData = nano_task_fifo_get(&nanoFifoObj)) != NULL) while ((pData = nano_task_fifo_get(&nanoFifoObj)) != NULL) {
{
TC_PRINT("TASK FIFO Get: count = %d, ptr is %p\n", count, pData); TC_PRINT("TASK FIFO Get: count = %d, ptr is %p\n", count, pData);
if ((count >= NUM_FIFO_ELEMENT) || (pData != pPutList2[count])) if ((count >= NUM_FIFO_ELEMENT) || (pData != pPutList2[count])) {
{
TCERR1(count); TCERR1(count);
retCode = TC_FAIL; retCode = TC_FAIL;
goto exit; goto exit;

View file

@ -70,14 +70,12 @@ These scenarios will be tested using a combinations of tasks, fibers and ISRs.
/* typedefs */ /* typedefs */
typedef struct typedef struct {
{
struct nano_lifo *channel; /* LIFO channel */ struct nano_lifo *channel; /* LIFO channel */
void *data; /* pointer to data to add */ void *data; /* pointer to data to add */
} ISR_LIFO_INFO; } ISR_LIFO_INFO;
typedef struct typedef struct {
{
uint32_t link; /* 32-bit word for LIFO to use as a link */ uint32_t link; /* 32-bit word for LIFO to use as a link */
uint32_t data; /* miscellaneous data put on LIFO (not important) */ uint32_t data; /* miscellaneous data put on LIFO (not important) */
} LIFO_ITEM; } LIFO_ITEM;
@ -85,8 +83,7 @@ typedef struct
/* locals */ /* locals */
/* Items to be added/removed from LIFO during the test */ /* Items to be added/removed from LIFO during the test */
static LIFO_ITEM lifoItem[4] = static LIFO_ITEM lifoItem[4] = {
{
{0, 1}, {0, 1},
{0, 2}, {0, 2},
{0, 3}, {0, 3},
@ -171,16 +168,14 @@ int fiberLifoWaitTest(void)
TC_PRINT ("Fiber waiting on an empty LIFO\n"); TC_PRINT ("Fiber waiting on an empty LIFO\n");
nano_fiber_sem_give (&taskWaitSem); nano_fiber_sem_give (&taskWaitSem);
data = nano_fiber_lifo_get_wait (&lifoChannel); data = nano_fiber_lifo_get_wait (&lifoChannel);
if (data != &lifoItem[0]) if (data != &lifoItem[0]) {
{
fiberDetectedFailure = 1; fiberDetectedFailure = 1;
return -1; return -1;
} }
nano_fiber_sem_take_wait (&fiberWaitSem); nano_fiber_sem_take_wait (&fiberWaitSem);
data = nano_fiber_lifo_get_wait (&lifoChannel); data = nano_fiber_lifo_get_wait (&lifoChannel);
if (data != &lifoItem[2]) if (data != &lifoItem[2]) {
{
fiberDetectedFailure = 1; fiberDetectedFailure = 1;
return -1; return -1;
} }
@ -228,21 +223,18 @@ int fiberLifoNonWaitTest(void)
/* The LIFO has two items in it; retrieve them both */ /* The LIFO has two items in it; retrieve them both */
data = nano_fiber_lifo_get (&lifoChannel); data = nano_fiber_lifo_get (&lifoChannel);
if (data != (void *) &lifoItem[3]) if (data != (void *) &lifoItem[3]) {
{
goto errorReturn; goto errorReturn;
} }
data = nano_fiber_lifo_get (&lifoChannel); data = nano_fiber_lifo_get (&lifoChannel);
if (data != (void *) &lifoItem[2]) if (data != (void *) &lifoItem[2]) {
{
goto errorReturn; goto errorReturn;
} }
/* LIFO should be empty--verify. */ /* LIFO should be empty--verify. */
data = nano_fiber_lifo_get (&lifoChannel); data = nano_fiber_lifo_get (&lifoChannel);
if (data != NULL) if (data != NULL) {
{
goto errorReturn; goto errorReturn;
} }
@ -270,21 +262,18 @@ int fiberLifoNonWaitTest(void)
*/ */
_trigger_nano_isr_lifo_get(); _trigger_nano_isr_lifo_get();
if (isrLifoInfo.data != &lifoItem[1]) if (isrLifoInfo.data != &lifoItem[1]) {
{
goto errorReturn; goto errorReturn;
} }
_trigger_nano_isr_lifo_get(); _trigger_nano_isr_lifo_get();
if (isrLifoInfo.data != &lifoItem[3]) if (isrLifoInfo.data != &lifoItem[3]) {
{
goto errorReturn; goto errorReturn;
} }
/* The LIFO should now be empty--verify */ /* The LIFO should now be empty--verify */
_trigger_nano_isr_lifo_get(); _trigger_nano_isr_lifo_get();
if (isrLifoInfo.data != NULL) if (isrLifoInfo.data != NULL) {
{
goto errorReturn; goto errorReturn;
} }
@ -317,8 +306,7 @@ static void fiberEntry(int arg1, int arg2)
rv = fiberLifoWaitTest (); rv = fiberLifoWaitTest ();
if (rv == 0) if (rv == 0) {
{
fiberLifoNonWaitTest (); fiberLifoNonWaitTest ();
} }
@ -356,8 +344,7 @@ int taskLifoWaitTest(void)
/* Check that the fiber got the correct item (lifoItem[0]) */ /* Check that the fiber got the correct item (lifoItem[0]) */
if (fiberDetectedFailure) if (fiberDetectedFailure) {
{
TC_ERROR (" *** nano_task_lifo_put()/nano_fiber_lifo_get_wait() failure\n"); TC_ERROR (" *** nano_task_lifo_put()/nano_fiber_lifo_get_wait() failure\n");
return TC_FAIL; return TC_FAIL;
} }
@ -366,15 +353,13 @@ int taskLifoWaitTest(void)
TC_PRINT ("Task waiting on an empty LIFO\n"); TC_PRINT ("Task waiting on an empty LIFO\n");
data = nano_task_lifo_get_wait (&lifoChannel); data = nano_task_lifo_get_wait (&lifoChannel);
if (data != (void *) &lifoItem[1]) if (data != (void *) &lifoItem[1]) {
{
TC_ERROR (" *** nano_task_lifo_get_wait()/nano_fiber_lifo_put() failure\n"); TC_ERROR (" *** nano_task_lifo_get_wait()/nano_fiber_lifo_put() failure\n");
return TC_FAIL; return TC_FAIL;
} }
data = nano_task_lifo_get_wait (&lifoChannel); data = nano_task_lifo_get_wait (&lifoChannel);
if (data != (void *) &lifoItem[3]) if (data != (void *) &lifoItem[3]) {
{
TC_ERROR (" *** nano_task_lifo_get_wait()/nano_fiber_lifo_put() failure\n"); TC_ERROR (" *** nano_task_lifo_get_wait()/nano_fiber_lifo_put() failure\n");
return TC_FAIL; return TC_FAIL;
} }
@ -410,8 +395,7 @@ int taskLifoNonWaitTest(void)
nano_task_sem_give (&fiberWaitSem); /* Wake the fiber */ nano_task_sem_give (&fiberWaitSem); /* Wake the fiber */
/* Check that fiber received the items correctly */ /* Check that fiber received the items correctly */
if (fiberDetectedFailure) if (fiberDetectedFailure) {
{
TC_ERROR (" *** nano_task_lifo_put()/nano_fiber_lifo_get() failure\n"); TC_ERROR (" *** nano_task_lifo_put()/nano_fiber_lifo_get() failure\n");
return TC_FAIL; return TC_FAIL;
} }
@ -420,22 +404,19 @@ int taskLifoNonWaitTest(void)
nano_task_sem_take_wait (&taskWaitSem); nano_task_sem_take_wait (&taskWaitSem);
data = nano_task_lifo_get (&lifoChannel); data = nano_task_lifo_get (&lifoChannel);
if (data != (void *) &lifoItem[1]) if (data != (void *) &lifoItem[1]) {
{
TC_ERROR (" *** nano_task_lifo_get()/nano_fiber_lifo_put() failure\n"); TC_ERROR (" *** nano_task_lifo_get()/nano_fiber_lifo_put() failure\n");
return TC_FAIL; return TC_FAIL;
} }
data = nano_task_lifo_get (&lifoChannel); data = nano_task_lifo_get (&lifoChannel);
if (data != (void *) &lifoItem[0]) if (data != (void *) &lifoItem[0]) {
{
TC_ERROR (" *** nano_task_lifo_get()/nano_fiber_lifo_put() failure\n"); TC_ERROR (" *** nano_task_lifo_get()/nano_fiber_lifo_put() failure\n");
return TC_FAIL; return TC_FAIL;
} }
data = nano_task_lifo_get (&lifoChannel); data = nano_task_lifo_get (&lifoChannel);
if (data != NULL) if (data != NULL) {
{
TC_ERROR (" *** nano_task_lifo_get()/nano_fiber_lifo_put() failure\n"); TC_ERROR (" *** nano_task_lifo_get()/nano_fiber_lifo_put() failure\n");
return TC_FAIL; return TC_FAIL;
} }
@ -459,8 +440,7 @@ int taskLifoNonWaitTest(void)
nano_task_sem_give (&fiberWaitSem); /* Wake the fiber */ nano_task_sem_give (&fiberWaitSem); /* Wake the fiber */
if (fiberDetectedFailure) if (fiberDetectedFailure) {
{
TC_ERROR (" *** nano_isr_lifo_put()/nano_isr_lifo_get() failure\n"); TC_ERROR (" *** nano_isr_lifo_put()/nano_isr_lifo_get() failure\n");
return TC_FAIL; return TC_FAIL;
} }
@ -479,8 +459,7 @@ int taskLifoNonWaitTest(void)
void initNanoObjects(void) void initNanoObjects(void)
{ {
struct isrInitInfo i = struct isrInitInfo i = {
{
{isr_lifo_put, isr_lifo_get}, {isr_lifo_put, isr_lifo_get},
{&isrLifoInfo, &isrLifoInfo}, {&isrLifoInfo, &isrLifoInfo},
}; };
@ -638,13 +617,11 @@ void main(void)
rv = taskLifoWaitTest (); rv = taskLifoWaitTest ();
if (rv == TC_PASS) if (rv == TC_PASS) {
{
rv = taskLifoNonWaitTest (); rv = taskLifoNonWaitTest ();
} }
if (rv == TC_PASS) if (rv == TC_PASS) {
{
rv = test_multiple_waiters(); rv = test_multiple_waiters();
} }

View file

@ -68,14 +68,12 @@ Scenario #3:
/* typedefs */ /* typedefs */
typedef struct typedef struct {
{
struct nano_sem *sem; /* ptr to semaphore */ struct nano_sem *sem; /* ptr to semaphore */
int data; /* data */ int data; /* data */
} ISR_SEM_INFO; } ISR_SEM_INFO;
typedef enum typedef enum {
{
STS_INIT = -1, STS_INIT = -1,
STS_TASK_WOKE_FIBER, STS_TASK_WOKE_FIBER,
STS_FIBER_WOKE_TASK, STS_FIBER_WOKE_TASK,
@ -160,22 +158,18 @@ int testSemFiberNoWait(void)
* taken that many times. * taken that many times.
*/ */
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++) {
{
nano_fiber_sem_give (&testSem); nano_fiber_sem_give (&testSem);
} }
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++) {
{ if (nano_fiber_sem_take (&testSem) != 1) {
if (nano_fiber_sem_take (&testSem) != 1)
{
TC_ERROR (" *** Expected nano_fiber_sem_take() to succeed, not fail\n"); TC_ERROR (" *** Expected nano_fiber_sem_take() to succeed, not fail\n");
goto errorReturn; goto errorReturn;
} }
} }
if (nano_fiber_sem_take (&testSem) != 0) if (nano_fiber_sem_take (&testSem) != 0) {
{
TC_ERROR (" *** Expected nano_fiber_sem_take() to fail, not succeed\n"); TC_ERROR (" *** Expected nano_fiber_sem_take() to fail, not succeed\n");
goto errorReturn; goto errorReturn;
} }
@ -208,8 +202,7 @@ static void fiberEntry(int arg1, int arg2)
ARG_UNUSED (arg2); ARG_UNUSED (arg2);
rv = testSemFiberNoWait (); rv = testSemFiberNoWait ();
if (rv != TC_PASS) if (rv != TC_PASS) {
{
return; return;
} }
@ -274,8 +267,7 @@ static void fiberEntry(int arg1, int arg2)
void initNanoObjects(void) void initNanoObjects(void)
{ {
struct isrInitInfo i = struct isrInitInfo i = {
{
{isr_sem_give, isr_sem_take}, {isr_sem_give, isr_sem_take},
{&isrSemInfo, &isrSemInfo}, {&isrSemInfo, &isrSemInfo},
}; };
@ -312,25 +304,21 @@ int testSemIsrNoWait(void)
*/ */
isrSemInfo.sem = &testSem; isrSemInfo.sem = &testSem;
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++) {
{
_trigger_nano_isr_sem_give (); _trigger_nano_isr_sem_give ();
} }
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++) {
{
isrSemInfo.data = 0; isrSemInfo.data = 0;
_trigger_nano_isr_sem_take (); _trigger_nano_isr_sem_take ();
if (isrSemInfo.data != 1) if (isrSemInfo.data != 1) {
{
TC_ERROR (" *** Expected nano_isr_sem_take() to succeed, not fail\n"); TC_ERROR (" *** Expected nano_isr_sem_take() to succeed, not fail\n");
goto errorReturn; goto errorReturn;
} }
} }
_trigger_nano_isr_sem_take (); _trigger_nano_isr_sem_take ();
if (isrSemInfo.data != 0) if (isrSemInfo.data != 0) {
{
TC_ERROR (" *** Expected nano_isr_sem_take() to fail, not succeed!\n"); TC_ERROR (" *** Expected nano_isr_sem_take() to fail, not succeed!\n");
goto errorReturn; goto errorReturn;
} }
@ -362,22 +350,18 @@ int testSemTaskNoWait(void)
* taken that many times. * taken that many times.
*/ */
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++) {
{
nano_task_sem_give (&testSem); nano_task_sem_give (&testSem);
} }
for (i = 0; i < 32; i++) for (i = 0; i < 32; i++) {
{ if (nano_task_sem_take (&testSem) != 1) {
if (nano_task_sem_take (&testSem) != 1)
{
TC_ERROR (" *** Expected nano_task_sem_take() to succeed, not fail\n"); TC_ERROR (" *** Expected nano_task_sem_take() to succeed, not fail\n");
goto errorReturn; goto errorReturn;
} }
} }
if (nano_task_sem_take (&testSem) != 0) if (nano_task_sem_take (&testSem) != 0) {
{
TC_ERROR (" *** Expected nano_task_sem_take() to fail, not succeed!\n"); TC_ERROR (" *** Expected nano_task_sem_take() to fail, not succeed!\n");
goto errorReturn; goto errorReturn;
} }
@ -400,16 +384,14 @@ errorReturn:
int testSemWait(void) int testSemWait(void)
{ {
if (fiberDetectedFailure != 0) if (fiberDetectedFailure != 0) {
{
TC_ERROR (" *** Failure detected in the fiber."); TC_ERROR (" *** Failure detected in the fiber.");
return TC_FAIL; return TC_FAIL;
} }
nano_task_sem_give (&testSem); /* Wake the fiber. */ nano_task_sem_give (&testSem); /* Wake the fiber. */
if (semTestState != STS_TASK_WOKE_FIBER) if (semTestState != STS_TASK_WOKE_FIBER) {
{
TC_ERROR (" *** Expected task to wake fiber. It did not.\n"); TC_ERROR (" *** Expected task to wake fiber. It did not.\n");
return TC_FAIL; return TC_FAIL;
} }
@ -418,8 +400,7 @@ int testSemWait(void)
nano_task_sem_take_wait (&testSem); /* Wait on <testSem> */ nano_task_sem_take_wait (&testSem); /* Wait on <testSem> */
if (semTestState != STS_FIBER_WOKE_TASK) if (semTestState != STS_FIBER_WOKE_TASK) {
{
TC_ERROR (" *** Expected fiber to wake task. It did not.\n"); TC_ERROR (" *** Expected fiber to wake task. It did not.\n");
return TC_FAIL; return TC_FAIL;
} }
@ -428,8 +409,7 @@ int testSemWait(void)
nano_task_sem_take_wait (&testSem); /* Wait on <testSem> again. */ nano_task_sem_take_wait (&testSem); /* Wait on <testSem> again. */
if (semTestState != STS_ISR_WOKE_TASK) if (semTestState != STS_ISR_WOKE_TASK) {
{
TC_ERROR (" *** Expected ISR to wake task. It did not.\n"); TC_ERROR (" *** Expected ISR to wake task. It did not.\n");
return TC_FAIL; return TC_FAIL;
} }
@ -559,14 +539,12 @@ void main(void)
initNanoObjects (); initNanoObjects ();
rv = testSemTaskNoWait (); rv = testSemTaskNoWait ();
if (rv != TC_PASS) if (rv != TC_PASS) {
{
goto doneTests; goto doneTests;
} }
rv = testSemIsrNoWait (); rv = testSemIsrNoWait ();
if (rv != TC_PASS) if (rv != TC_PASS) {
{
goto doneTests; goto doneTests;
} }
@ -581,14 +559,12 @@ void main(void)
0, 0, FIBER_PRIORITY, 0); 0, 0, FIBER_PRIORITY, 0);
rv = testSemWait (); rv = testSemWait ();
if (rv != TC_PASS) if (rv != TC_PASS) {
{
goto doneTests; goto doneTests;
} }
rv = test_multiple_waiters(); rv = test_multiple_waiters();
if (rv != TC_PASS) if (rv != TC_PASS) {
{
goto doneTests; goto doneTests;
} }

View file

@ -85,8 +85,7 @@ these are run in ISR context.
/* typedefs */ /* typedefs */
typedef struct typedef struct {
{
struct nano_stack *channel; /* STACK channel */ struct nano_stack *channel; /* STACK channel */
uint32_t data; /* data to add */ uint32_t data; /* data to add */
} ISR_STACK_INFO; } ISR_STACK_INFO;
@ -149,8 +148,7 @@ void testIsrStackFromTask(void);
void initData(void) void initData(void)
{ {
for (int i=0; i< NUM_STACK_ELEMENT; i++) for (int i=0; i< NUM_STACK_ELEMENT; i++) {
{
myData[i] = (STARTNUM + i) * MULTIPLIER; myData[i] = (STARTNUM + i) * MULTIPLIER;
myIsrData[i] = myData[i] + MYNUMBER; myIsrData[i] = myData[i] + MYNUMBER;
} }
@ -193,8 +191,7 @@ void isr_stack_pop(void *parameter)
{ {
ISR_STACK_INFO *pInfo = (ISR_STACK_INFO *) parameter; ISR_STACK_INFO *pInfo = (ISR_STACK_INFO *) parameter;
if (nano_isr_stack_pop (pInfo->channel, &(pInfo->data)) == 0) if (nano_isr_stack_pop (pInfo->channel, &(pInfo->data)) == 0) {
{
/* the stack is empty, set data to INVALID_DATA */ /* the stack is empty, set data to INVALID_DATA */
pInfo->data = INVALID_DATA; pInfo->data = INVALID_DATA;
} }
@ -220,11 +217,9 @@ void fiber1(void)
TC_PRINT("Test Fiber STACK Pop\n\n"); TC_PRINT("Test Fiber STACK Pop\n\n");
/* Get all data */ /* Get all data */
while (nano_fiber_stack_pop(&nanoStackObj, &data) != 0) while (nano_fiber_stack_pop(&nanoStackObj, &data) != 0) {
{
TC_PRINT("FIBER STACK Pop: count = %d, data is %d\n", count, data); TC_PRINT("FIBER STACK Pop: count = %d, data is %d\n", count, data);
if((count >= NUM_STACK_ELEMENT) || (data != myData[NUM_STACK_ELEMENT - 1 - count])) if((count >= NUM_STACK_ELEMENT) || (data != myData[NUM_STACK_ELEMENT - 1 - count])) {
{
TCERR1(count); TCERR1(count);
retCode = TC_FAIL; retCode = TC_FAIL;
return; return;
@ -238,8 +233,7 @@ void fiber1(void)
/* Put data */ /* Put data */
TC_PRINT("Test Fiber STACK Push\n"); TC_PRINT("Test Fiber STACK Push\n");
TC_PRINT("\nFIBER STACK Put Order: "); TC_PRINT("\nFIBER STACK Put Order: ");
for (int i=NUM_STACK_ELEMENT; i>0; i--) for (int i=NUM_STACK_ELEMENT; i>0; i--) {
{
nano_fiber_stack_push(&nanoStackObj, myData[i-1]); nano_fiber_stack_push(&nanoStackObj, myData[i-1]);
TC_PRINT(" %d,", myData[i-1]); TC_PRINT(" %d,", myData[i-1]);
} }
@ -271,8 +265,7 @@ void testFiberStackPopW(void)
data = nano_fiber_stack_pop_wait(&nanoStackObj2); data = nano_fiber_stack_pop_wait(&nanoStackObj2);
TC_PRINT("FIBER STACK Pop from queue2: %d\n", data); TC_PRINT("FIBER STACK Pop from queue2: %d\n", data);
/* Verify results */ /* Verify results */
if (data != myData[0]) if (data != myData[0]) {
{
retCode = TC_FAIL; retCode = TC_FAIL;
TCERR2; TCERR2;
return; return;
@ -285,8 +278,7 @@ void testFiberStackPopW(void)
data = nano_fiber_stack_pop_wait(&nanoStackObj2); data = nano_fiber_stack_pop_wait(&nanoStackObj2);
TC_PRINT("FIBER STACK Pop from queue2: %d\n", data); TC_PRINT("FIBER STACK Pop from queue2: %d\n", data);
/* Verify results */ /* Verify results */
if (data != myData[2]) if (data != myData[2]) {
{
retCode = TC_FAIL; retCode = TC_FAIL;
TCERR2; TCERR2;
return; return;
@ -321,11 +313,9 @@ void testIsrStackFromFiber(void)
/* This is data pushed by function testFiberStackPopW */ /* This is data pushed by function testFiberStackPopW */
_trigger_nano_isr_stack_pop(); _trigger_nano_isr_stack_pop();
result = isrStackInfo.data; result = isrStackInfo.data;
if (result != INVALID_DATA) if (result != INVALID_DATA) {
{
TC_PRINT("ISR STACK (running in fiber context) Pop from queue1: %d\n", result); TC_PRINT("ISR STACK (running in fiber context) Pop from queue1: %d\n", result);
if (result != myData[3]) if (result != myData[3]) {
{
retCode = TC_FAIL; retCode = TC_FAIL;
TCERR2; TCERR2;
return; return;
@ -335,8 +325,7 @@ void testIsrStackFromFiber(void)
/* Verify that the STACK is empty */ /* Verify that the STACK is empty */
_trigger_nano_isr_stack_pop(); _trigger_nano_isr_stack_pop();
result = isrStackInfo.data; result = isrStackInfo.data;
if (result != INVALID_DATA) if (result != INVALID_DATA) {
{
TC_PRINT("Pop from queue1: %d\n", result); TC_PRINT("Pop from queue1: %d\n", result);
retCode = TC_FAIL; retCode = TC_FAIL;
TCERR3; TCERR3;
@ -345,8 +334,7 @@ void testIsrStackFromFiber(void)
/* Put more data into STACK */ /* Put more data into STACK */
TC_PRINT("ISR STACK (running in fiber context) Push to queue1: \n"); TC_PRINT("ISR STACK (running in fiber context) Push to queue1: \n");
for (int i=0; i<NUM_STACK_ELEMENT; i++) for (int i=0; i<NUM_STACK_ELEMENT; i++) {
{
isrStackInfo.data = myIsrData[i]; isrStackInfo.data = myIsrData[i];
TC_PRINT(" %d, ", myIsrData[i]); TC_PRINT(" %d, ", myIsrData[i]);
_trigger_nano_isr_stack_push(); _trigger_nano_isr_stack_push();
@ -383,11 +371,9 @@ void testIsrStackFromTask(void)
_trigger_nano_isr_stack_pop(); _trigger_nano_isr_stack_pop();
result = isrStackInfo.data; result = isrStackInfo.data;
while (result != INVALID_DATA) while (result != INVALID_DATA) {
{
TC_PRINT(" Pop from queue1: count = %d, data is %d\n", count, result); TC_PRINT(" Pop from queue1: count = %d, data is %d\n", count, result);
if ((count >= NUM_STACK_ELEMENT) || (result != myIsrData[NUM_STACK_ELEMENT - count - 1])) if ((count >= NUM_STACK_ELEMENT) || (result != myIsrData[NUM_STACK_ELEMENT - count - 1])) {
{
TCERR1(count); TCERR1(count);
retCode = TC_FAIL; retCode = TC_FAIL;
return; return;
@ -408,14 +394,12 @@ void testIsrStackFromTask(void)
_trigger_nano_isr_stack_pop(); _trigger_nano_isr_stack_pop();
result = isrStackInfo.data; result = isrStackInfo.data;
/* Verify data */ /* Verify data */
if (result != myIsrData[3]) if (result != myIsrData[3]) {
{
TCERR2; TCERR2;
retCode = TC_FAIL; retCode = TC_FAIL;
return; return;
} }
else else {
{
TC_PRINT("\nTest ISR STACK (invoked from Task) - push %d and pop back %d\n", TC_PRINT("\nTest ISR STACK (invoked from Task) - push %d and pop back %d\n",
myIsrData[3], result); myIsrData[3], result);
} }
@ -469,8 +453,7 @@ void testTaskStackPopW(void)
data = nano_task_stack_pop_wait(&nanoStackObj); data = nano_task_stack_pop_wait(&nanoStackObj);
TC_PRINT("TASK STACK Pop from queue1: %d\n", data); TC_PRINT("TASK STACK Pop from queue1: %d\n", data);
/* Verify results */ /* Verify results */
if (data != myData[1]) if (data != myData[1]) {
{
retCode = TC_FAIL; retCode = TC_FAIL;
TCERR2; TCERR2;
return; return;
@ -511,8 +494,7 @@ void fiber3(void)
void initNanoObjects(void) void initNanoObjects(void)
{ {
struct isrInitInfo i = struct isrInitInfo i = {
{
{isr_stack_push, isr_stack_pop}, {isr_stack_push, isr_stack_pop},
{&isrStackInfo, &isrStackInfo}, {&isrStackInfo, &isrStackInfo},
}; };
@ -567,8 +549,7 @@ void main(void)
/* Put data */ /* Put data */
TC_PRINT("Test Task STACK Push\n"); TC_PRINT("Test Task STACK Push\n");
TC_PRINT("\nTASK STACK Put Order: "); TC_PRINT("\nTASK STACK Put Order: ");
for (int i=0; i<NUM_STACK_ELEMENT; i++) for (int i=0; i<NUM_STACK_ELEMENT; i++) {
{
nano_task_stack_push(&nanoStackObj, myData[i]); nano_task_stack_push(&nanoStackObj, myData[i]);
TC_PRINT(" %d,", myData[i]); TC_PRINT(" %d,", myData[i]);
} }
@ -580,8 +561,7 @@ void main(void)
task_fiber_start (&fiberStack1[0], STACKSIZE, task_fiber_start (&fiberStack1[0], STACKSIZE,
(nano_fiber_entry_t) fiber1, 0, 0, 7, 0); (nano_fiber_entry_t) fiber1, 0, 0, 7, 0);
if (retCode == TC_FAIL) if (retCode == TC_FAIL) {
{
goto exit; goto exit;
} }
@ -594,11 +574,9 @@ void main(void)
TC_PRINT("Test Task STACK Pop\n"); TC_PRINT("Test Task STACK Pop\n");
/* Get all data */ /* Get all data */
while (nano_task_stack_pop(&nanoStackObj, &data) != 0) while (nano_task_stack_pop(&nanoStackObj, &data) != 0) {
{
TC_PRINT("TASK STACK Pop: count = %d, data is %d\n", count, data); TC_PRINT("TASK STACK Pop: count = %d, data is %d\n", count, data);
if ((count >= NUM_STACK_ELEMENT) || (data != myData[count])) if ((count >= NUM_STACK_ELEMENT) || (data != myData[count])) {
{
TCERR1(count); TCERR1(count);
retCode = TC_FAIL; retCode = TC_FAIL;
goto exit; goto exit;
@ -609,8 +587,7 @@ void main(void)
/* Test Task Stack Pop Wait interfaces*/ /* Test Task Stack Pop Wait interfaces*/
testTaskStackPopW(); testTaskStackPopW();
if (retCode == TC_FAIL) if (retCode == TC_FAIL) {
{
goto exit; goto exit;
} }

View file

@ -143,8 +143,7 @@ int basicTimerWait(timer_start_func startRtn, timer_getw_func waitRtn,
TC_PRINT (" - test expected to take four seconds\n"); TC_PRINT (" - test expected to take four seconds\n");
tick = nano_tick_get_32(); tick = nano_tick_get_32();
while (nano_tick_get_32() == tick) while (nano_tick_get_32() == tick) {
{
/* Align to a tick boundary */ /* Align to a tick boundary */
} }
@ -163,31 +162,27 @@ int basicTimerWait(timer_start_func startRtn, timer_getw_func waitRtn,
*/ */
if ((result != pTimerData) || if ((result != pTimerData) ||
(duration - elapsed_32 > 1) || ((duration - ticks) > 1)) (duration - elapsed_32 > 1) || ((duration - ticks) > 1)) {
{
return TC_FAIL; return TC_FAIL;
} }
/* Check that the non-wait-timer-get routine works properly. */ /* Check that the non-wait-timer-get routine works properly. */
tick = nano_tick_get_32(); tick = nano_tick_get_32();
while (nano_tick_get_32() == tick) while (nano_tick_get_32() == tick) {
{
/* Align to a tick boundary */ /* Align to a tick boundary */
} }
tick++; tick++;
(void) nano_tick_delta (&reftime); (void) nano_tick_delta (&reftime);
startRtn (pTimer, ticks); /* Start the timer */ startRtn (pTimer, ticks); /* Start the timer */
while ((result = getRtn (pTimer)) == NULL) while ((result = getRtn (pTimer)) == NULL) {
{
busywaited = 1; busywaited = 1;
} }
elapsed = nano_tick_delta (&reftime); elapsed = nano_tick_delta (&reftime);
duration = nano_tick_get_32 () - tick; duration = nano_tick_get_32 () - tick;
if ((busywaited != 1) || (result != pTimerData) || if ((busywaited != 1) || (result != pTimerData) ||
(duration - elapsed > 1) || ((duration - ticks) > 1)) (duration - elapsed > 1) || ((duration - ticks) > 1)) {
{
return TC_FAIL; return TC_FAIL;
} }
@ -216,8 +211,7 @@ void startTimers(timer_start_func startRtn)
int tick; /* current tick */ int tick; /* current tick */
tick = nano_tick_get_32 (); tick = nano_tick_get_32 ();
while (nano_tick_get_32 () == tick) while (nano_tick_get_32 () == tick) {
{
/* Wait for the end of the tick */ /* Wait for the end of the tick */
} }
@ -250,14 +244,11 @@ int busyWaitTimers(timer_get_func getRtn)
TC_PRINT (" - test expected to take five or six seconds\n"); TC_PRINT (" - test expected to take five or six seconds\n");
ticks = nano_tick_get_32 () + SIX_SECONDS; ticks = nano_tick_get_32 () + SIX_SECONDS;
while ((numExpired != 4) && (nano_tick_get_32 () < ticks)) while ((numExpired != 4) && (nano_tick_get_32 () < ticks)) {
{
result = getRtn (&timer); result = getRtn (&timer);
if (result != NULL) if (result != NULL) {
{
numExpired++; numExpired++;
if ((result != timerData) || (numExpired != 2)) if ((result != timerData) || (numExpired != 2)) {
{
TC_ERROR ("Expected <timer> to expire 2nd, not 0x%x\n", TC_ERROR ("Expected <timer> to expire 2nd, not 0x%x\n",
result); result);
return TC_FAIL; return TC_FAIL;
@ -265,11 +256,9 @@ int busyWaitTimers(timer_get_func getRtn)
} }
result = getRtn (&shortTimer); result = getRtn (&shortTimer);
if (result != NULL) if (result != NULL) {
{
numExpired++; numExpired++;
if ((result != shortTimerData) || (numExpired != 1)) if ((result != shortTimerData) || (numExpired != 1)) {
{
TC_ERROR ("Expected <shortTimer> to expire 1st, not 0x%x\n", TC_ERROR ("Expected <shortTimer> to expire 1st, not 0x%x\n",
result); result);
return TC_FAIL; return TC_FAIL;
@ -277,11 +266,9 @@ int busyWaitTimers(timer_get_func getRtn)
} }
result = getRtn (&midTimer); result = getRtn (&midTimer);
if (result != NULL) if (result != NULL) {
{
numExpired++; numExpired++;
if ((result != midTimerData) || (numExpired != 3)) if ((result != midTimerData) || (numExpired != 3)) {
{
TC_ERROR ("Expected <midTimer> to expire 3rd, not 0x%x\n", TC_ERROR ("Expected <midTimer> to expire 3rd, not 0x%x\n",
result); result);
return TC_FAIL; return TC_FAIL;
@ -289,11 +276,9 @@ int busyWaitTimers(timer_get_func getRtn)
} }
result = getRtn (&longTimer); result = getRtn (&longTimer);
if (result != NULL) if (result != NULL) {
{
numExpired++; numExpired++;
if ((result != longTimerData) || (numExpired != 4)) if ((result != longTimerData) || (numExpired != 4)) {
{
TC_ERROR ("Expected <longTimer> to expire 4th, not 0x%x\n", TC_ERROR ("Expected <longTimer> to expire 4th, not 0x%x\n",
result); result);
return TC_FAIL; return TC_FAIL;
@ -333,17 +318,14 @@ int stopTimers(timer_stop_func stopRtn, timer_get_func getRtn)
TC_PRINT (" - test expected to take six seconds\n"); TC_PRINT (" - test expected to take six seconds\n");
startTick = nano_tick_get_32 (); startTick = nano_tick_get_32 ();
while (nano_tick_get_32 () == startTick) while (nano_tick_get_32 () == startTick) {
{
} }
startTick++; startTick++;
endTick = startTick + SIX_SECONDS; endTick = startTick + SIX_SECONDS;
while (nano_tick_get_32 () < endTick) while (nano_tick_get_32 () < endTick) {
{
if ((getRtn (&timer) != NULL) || (getRtn (&shortTimer) != NULL) || if ((getRtn (&timer) != NULL) || (getRtn (&shortTimer) != NULL) ||
(getRtn (&midTimer) != NULL) || (getRtn (&longTimer) != NULL)) (getRtn (&midTimer) != NULL) || (getRtn (&longTimer) != NULL)) {
{
return TC_FAIL; return TC_FAIL;
} }
} }
@ -399,8 +381,7 @@ static void fiberEntry(int arg1, int arg2)
nano_fiber_timer_test, &timer, timerData, TWO_SECONDS); nano_fiber_timer_test, &timer, timerData, TWO_SECONDS);
nano_fiber_sem_give (&wakeTask); nano_fiber_sem_give (&wakeTask);
if (rv != TC_PASS) if (rv != TC_PASS) {
{
fiberDetectedError = 1; fiberDetectedError = 1;
return; return;
} }
@ -411,8 +392,7 @@ static void fiberEntry(int arg1, int arg2)
startTimers (nano_fiber_timer_start); startTimers (nano_fiber_timer_start);
rv = busyWaitTimers (nano_fiber_timer_test); rv = busyWaitTimers (nano_fiber_timer_test);
nano_fiber_sem_give (&wakeTask); nano_fiber_sem_give (&wakeTask);
if (rv != TC_PASS) if (rv != TC_PASS) {
{
fiberDetectedError = 2; fiberDetectedError = 2;
return; return;
} }
@ -423,8 +403,7 @@ static void fiberEntry(int arg1, int arg2)
startTimers (nano_fiber_timer_start); startTimers (nano_fiber_timer_start);
rv = stopTimers (nano_fiber_timer_stop, nano_fiber_timer_test); rv = stopTimers (nano_fiber_timer_stop, nano_fiber_timer_test);
nano_fiber_sem_give (&wakeTask); nano_fiber_sem_give (&wakeTask);
if (rv != TC_PASS) if (rv != TC_PASS) {
{
fiberDetectedError = 3; fiberDetectedError = 3;
return; return;
} }
@ -437,8 +416,7 @@ static void fiberEntry(int arg1, int arg2)
nano_fiber_timer_start (&timer, TWO_SECONDS); /* Start timer */ nano_fiber_timer_start (&timer, TWO_SECONDS); /* Start timer */
result = nano_fiber_timer_wait (&timer); /* Wait on timer */ result = nano_fiber_timer_wait (&timer); /* Wait on timer */
/* Control switches to newly created fiber #2 before coming back. */ /* Control switches to newly created fiber #2 before coming back. */
if (result != NULL) if (result != NULL) {
{
fiberDetectedError = 4; fiberDetectedError = 4;
nano_fiber_sem_give (&wakeTask); nano_fiber_sem_give (&wakeTask);
return; return;
@ -449,8 +427,7 @@ static void fiberEntry(int arg1, int arg2)
nano_fiber_sem_give (&wakeTask); nano_fiber_sem_give (&wakeTask);
nano_fiber_timer_start (&timer, TWO_SECONDS); nano_fiber_timer_start (&timer, TWO_SECONDS);
result = nano_fiber_timer_wait (&timer); result = nano_fiber_timer_wait (&timer);
if (result != NULL) if (result != NULL) {
{
fiberDetectedError = 5; fiberDetectedError = 5;
return; return;
} }
@ -472,13 +449,11 @@ int nano_cycle_get_32Test(void)
int i; int i;
timeStamp2 = nano_cycle_get_32 (); timeStamp2 = nano_cycle_get_32 ();
for (i = 0; i < 1000000; i++) for (i = 0; i < 1000000; i++) {
{
timeStamp1 = timeStamp2; timeStamp1 = timeStamp2;
timeStamp2 = nano_cycle_get_32 (); timeStamp2 = nano_cycle_get_32 ();
if (timeStamp2 < timeStamp1) if (timeStamp2 < timeStamp1) {
{
TC_ERROR ("Timestamp value not increasing with successive calls\n"); TC_ERROR ("Timestamp value not increasing with successive calls\n");
return TC_FAIL; return TC_FAIL;
} }
@ -507,8 +482,7 @@ void main(void)
TC_PRINT ("Task testing basic timer functionality\n"); TC_PRINT ("Task testing basic timer functionality\n");
rv = basicTimerWait (nano_task_timer_start, nano_task_timer_wait, rv = basicTimerWait (nano_task_timer_start, nano_task_timer_wait,
nano_task_timer_test, &timer, timerData, TWO_SECONDS); nano_task_timer_test, &timer, timerData, TWO_SECONDS);
if (rv != TC_PASS) if (rv != TC_PASS) {
{
TC_ERROR ("Task-level of waiting for timers failed\n"); TC_ERROR ("Task-level of waiting for timers failed\n");
goto doneTests; goto doneTests;
} }
@ -517,8 +491,7 @@ void main(void)
TC_PRINT ("Task testing timers expire in the correct order\n"); TC_PRINT ("Task testing timers expire in the correct order\n");
startTimers (nano_task_timer_start); startTimers (nano_task_timer_start);
rv = busyWaitTimers (nano_task_timer_test); rv = busyWaitTimers (nano_task_timer_test);
if (rv != TC_PASS) if (rv != TC_PASS) {
{
TC_ERROR ("Task-level timer expiration order failed\n"); TC_ERROR ("Task-level timer expiration order failed\n");
goto doneTests; goto doneTests;
} }
@ -527,8 +500,7 @@ void main(void)
TC_PRINT ("Task testing the stopping of timers\n"); TC_PRINT ("Task testing the stopping of timers\n");
startTimers (nano_task_timer_start); startTimers (nano_task_timer_start);
rv = stopTimers (nano_task_timer_stop, nano_task_timer_test); rv = stopTimers (nano_task_timer_stop, nano_task_timer_test);
if (rv != TC_PASS) if (rv != TC_PASS) {
{
TC_ERROR ("Task-level stopping of timers test failed\n"); TC_ERROR ("Task-level stopping of timers test failed\n");
goto doneTests; goto doneTests;
} }
@ -543,8 +515,7 @@ void main(void)
nano_task_sem_take_wait (&wakeTask); nano_task_sem_take_wait (&wakeTask);
if (fiberDetectedError == 1) if (fiberDetectedError == 1) {
{
TC_ERROR ("Fiber-level of waiting for timers failed\n"); TC_ERROR ("Fiber-level of waiting for timers failed\n");
rv = TC_FAIL; rv = TC_FAIL;
goto doneTests; goto doneTests;
@ -553,8 +524,7 @@ void main(void)
nano_task_sem_give (&wakeFiber); nano_task_sem_give (&wakeFiber);
nano_task_sem_take_wait (&wakeTask); nano_task_sem_take_wait (&wakeTask);
if (fiberDetectedError == 2) if (fiberDetectedError == 2) {
{
TC_ERROR ("Fiber-level timer expiration order failed\n"); TC_ERROR ("Fiber-level timer expiration order failed\n");
rv = TC_FAIL; rv = TC_FAIL;
goto doneTests; goto doneTests;
@ -563,8 +533,7 @@ void main(void)
nano_task_sem_give (&wakeFiber); nano_task_sem_give (&wakeFiber);
nano_task_sem_take_wait (&wakeTask); nano_task_sem_take_wait (&wakeTask);
if (fiberDetectedError == 3) if (fiberDetectedError == 3) {
{
TC_ERROR ("Fiber-level stopping of timers test failed\n"); TC_ERROR ("Fiber-level stopping of timers test failed\n");
rv = TC_FAIL; rv = TC_FAIL;
goto doneTests; goto doneTests;
@ -572,16 +541,14 @@ void main(void)
nano_task_sem_give (&wakeFiber); nano_task_sem_give (&wakeFiber);
nano_task_sem_take_wait (&wakeTask); nano_task_sem_take_wait (&wakeTask);
if (fiberDetectedError == 4) if (fiberDetectedError == 4) {
{
TC_ERROR ("Fiber stopping a timer waited upon by a fiber failed\n"); TC_ERROR ("Fiber stopping a timer waited upon by a fiber failed\n");
rv = TC_FAIL; rv = TC_FAIL;
goto doneTests; goto doneTests;
} }
nano_task_timer_stop (&timer); nano_task_timer_stop (&timer);
if (fiberDetectedError == 5) if (fiberDetectedError == 5) {
{
TC_ERROR ("Task stopping a timer waited upon by a fiber failed\n"); TC_ERROR ("Task stopping a timer waited upon by a fiber failed\n");
rv = TC_FAIL; rv = TC_FAIL;
goto doneTests; goto doneTests;
@ -602,8 +569,7 @@ void main(void)
TC_PRINT ("Task testing of nano_cycle_get_32()\n"); TC_PRINT ("Task testing of nano_cycle_get_32()\n");
rv = nano_cycle_get_32Test (); rv = nano_cycle_get_32Test ();
if (rv != TC_PASS) if (rv != TC_PASS) {
{
TC_ERROR ("nano_cycle_get_32Test() failed\n"); TC_ERROR ("nano_cycle_get_32Test() failed\n");
goto doneTests; goto doneTests;
} }

View file

@ -69,8 +69,7 @@ extern"C"
* too deeply.) * too deeply.)
*/ */
typedef struct idtEntry typedef struct idtEntry {
{
unsigned short lowOffset; unsigned short lowOffset;
unsigned short segmentSelector; unsigned short segmentSelector;
unsigned short reserved:5; unsigned short reserved:5;