[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-libc-dev] regression test preview
From: |
Dmitry K. |
Subject: |
Re: [avr-libc-dev] regression test preview |
Date: |
Tue, 15 Nov 2005 08:52:11 +1000 |
User-agent: |
KMail/1.5 |
On Tuesday 15 November 2005 05:38, Peeter Vois wrote:
> Hi all
>
> I had some time and I prepared regression test preview package:
Beautifuly!
In addition.
It is possible and some other approach to construction of
base tests. Below I have resulted a part of one of tests which
I have written, being engaged in correction of a bug #11511 (I try
to release a full subnormals functionality). The test represents
the finished C-program. The code of return serves as the indicator
of success. As a rule, as an error code I substitute a serial number
of the test table.
Advantage of such approach: without any changes the test can be
checked up on a usual computer. Unprofitable expenses are minimal:
as a rule, the unique function used in the test, it 'exit'. I resort
to use of PROGMEM memory only in case of long tables, for this
purpose serves 'progmem.h'.
Sometimes such tests are automaticaly builded. An example -
patch #3851, subdirectory tests/auto.
Regards,
Dmitry.
Test case example:
~~~~~~~~~~~~~~~~~
/* Test of subnormals, multiplication.
*/
#include <stdio.h>
#include <stdlib.h>
#include "progmem.h"
union lofl_u {
long lo;
float fl;
};
volatile union lofl_u v = { .lo = 1 };
PROGMEM const struct { /* Table of test cases: x * y = z */
union lofl_u x, y, z;
} t[] = {
{ { 0x00000001 }, { 0x00000000 }, { 0x00000000 } },
/* subnormal * subnormal --> 0 */
{ { 0x00000001 }, { 0x00000001 }, { 0x00000000 } },
{ { 0x80000001 }, { 0x00000001 }, { 0x00000000 } },
{ { 0x00000001 }, { 0x80000001 }, { 0x00000000 } },
{ { 0x80000001 }, { 0x80000001 }, { 0x00000000 } },
{ { 0x00000100 }, { 0x00000100 }, { 0x00000000 } },
{ { 0x80000100 }, { 0x00000100 }, { 0x00000000 } },
{ { 0x00000100 }, { 0x80000100 }, { 0x00000000 } },
{ { 0x80000100 }, { 0x80000100 }, { 0x00000000 } },
{ { 0x00010000 }, { 0x00010000 }, { 0x00000000 } },
{ { 0x80010000 }, { 0x00010000 }, { 0x00000000 } },
{ { 0x00010000 }, { 0x80010000 }, { 0x00000000 } },
{ { 0x80010000 }, { 0x80010000 }, { 0x00000000 } },
{ { 0x007fffff }, { 0x807fffff }, { 0x00000000 } },
{ { 0x807fffff }, { 0x007fffff }, { 0x00000000 } },
/* normal * subnormal --> subnormal */
{ { 0x3f800000 }, { 0x00000001 }, { 0x00000001 } }, /* 1.0 */
{ { 0x3f000000 }, { 0x00000002 }, { 0x00000001 } }, /* 0.5 */
{ { 0x3e800000 }, { 0x00000004 }, { 0x00000001 } },
{ { 0x40000000 }, { 0x00000001 }, { 0x00000002 } },
{ { 0x3f800000 }, { 0x00000002 }, { 0x00000002 } },
{ { 0x3f000000 }, { 0x00000004 }, { 0x00000002 } },
... And so on ...
};
void x_exit (int index)
{
#ifndef __AVR__
fprintf (stderr, "t[%d]: %#lx\n", index - 1, v.lo);
#endif
exit (index ? index : -1);
}
int main ()
{
union lofl_u x,y,z;
int i;
for (i = 0; i < (int) (sizeof(t) / sizeof(t[0])); i++) {
x.lo = pgm_read_dword (& t[i].x);
y.lo = pgm_read_dword (& t[i].y);
z.lo = pgm_read_dword (& t[i].z);
v.fl = x.fl * y.fl;
/* Float comparison: Glibc is possible -0.0 */
if (v.fl != z.fl)
x_exit (i+1);
}
return 0;
}
progmem.h:
~~~~~~~~~
#ifdef __AVR__
# include <avr/pgmspace.h>
#else
# define PROGMEM
# define pgm_read_dword(addr) (*(long *)addr)
#endif