Skip to content

Commit 8273845

Browse files
keith-packardnashif
authored andcommitted
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 <[email protected]> Signed-off-by: Anas Nashif <[email protected]>
1 parent 521e571 commit 8273845

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ static float test_floats[] = {
2929
};
3030
#define NUM_TEST_FLOATS (sizeof(test_floats)/sizeof(float))
3131

32+
#if __SIZEOF_DOUBLE__ == 8
3233
static double test_doubles[] = {
3334
1.0, 2.0, 3.0, 4.0,
3435
5.0, 6.0, 7.0, 8.0, 9.0, /* numbers across the decade */
@@ -59,6 +60,7 @@ static int isnan(double x)
5960
((ieee754.u & 0x000fffffffffffff) != 0);
6061
}
6162
#endif
63+
#endif /* __SIZEOF_DOUBLE__ == 8 */
6264

6365
#ifndef isinff
6466
static int isinff(float x)
@@ -147,6 +149,10 @@ int32_t *p_root_squared = (int32_t *)&root_squared;
147149

148150
ZTEST(libc_common, test_sqrt)
149151
{
152+
#if __SIZEOF_DOUBLE__ != 8
153+
TC_PRINT("test_sqrt skipped, double not 64 bits\n");
154+
ztest_test_skip();
155+
#else
150156
int i;
151157
double resd, error, square, root_squared, exponent;
152158
uint64_t max_error;
@@ -202,4 +208,5 @@ int64_t *p_root_squared = (int64_t *)&root_squared;
202208
zassert_true(max_error < 0x04, "huge errors in sqrt implementation");
203209
/* print the max error */
204210
TC_PRINT("test_sqrt max error %d counts\n", (uint32_t)max_error);
211+
#endif
205212
}

0 commit comments

Comments
 (0)