Browse Source

tests/c_lib: Skip double sqrt test when double is not 64 bits

This test only works for 64-bit values. On targets which use 32 bits for
double, skip this version. The float test will check the 32-bit math for
that.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
pull/90417/head
Keith Packard 2 months ago committed by Anas Nashif
parent
commit
74c9e7afab
  1. 7
      tests/lib/c_lib/common/src/test_sqrt.c

7
tests/lib/c_lib/common/src/test_sqrt.c

@ -29,6 +29,7 @@ static float test_floats[] = { @@ -29,6 +29,7 @@ static float test_floats[] = {
};
#define NUM_TEST_FLOATS (sizeof(test_floats)/sizeof(float))
#if __SIZEOF_DOUBLE__ == 8
static double test_doubles[] = {
1.0, 2.0, 3.0, 4.0,
5.0, 6.0, 7.0, 8.0, 9.0, /* numbers across the decade */
@ -59,6 +60,7 @@ static int isnan(double x) @@ -59,6 +60,7 @@ static int isnan(double x)
((ieee754.u & 0x000fffffffffffff) != 0);
}
#endif
#endif /* __SIZEOF_DOUBLE__ == 8 */
#ifndef isinff
static int isinff(float x)
@ -147,6 +149,10 @@ int32_t *p_root_squared = (int32_t *)&root_squared; @@ -147,6 +149,10 @@ int32_t *p_root_squared = (int32_t *)&root_squared;
ZTEST(libc_common, test_sqrt)
{
#if __SIZEOF_DOUBLE__ != 8
TC_PRINT("test_sqrt skipped, double not 64 bits\n");
ztest_test_skip();
#else
int i;
double resd, error, square, root_squared, exponent;
uint64_t max_error;
@ -202,4 +208,5 @@ int64_t *p_root_squared = (int64_t *)&root_squared; @@ -202,4 +208,5 @@ int64_t *p_root_squared = (int64_t *)&root_squared;
zassert_true(max_error < 0x04, "huge errors in sqrt implementation");
/* print the max error */
TC_PRINT("test_sqrt max error %d counts\n", (uint32_t)max_error);
#endif
}

Loading…
Cancel
Save