Skip to content

Commit bee44a7

Browse files
committed
tests: check the posemath parallel tests as a plain program
tests/blendmath compiled blendmath.c into a userspace program with -DULAPI. Since blendmath.c exports pmCircleEffectiveMinRadius() (#4643), EXPORT_SYMBOL is undefined there, which GCC 13 lets through as an implicit int and GCC 14 rejects. The two functions it checks are posemath's now, and posemath uses neither RTAPI nor ULAPI, so it becomes tests/posemath-parallel: a program linked with libposemath, with no blendmath.c to compile and nothing exported from a module for the test. The checks themselves are unchanged.
1 parent aa616ca commit bee44a7

8 files changed

Lines changed: 97 additions & 117 deletions

File tree

‎tests/blendmath/checkresult‎

Lines changed: 0 additions & 2 deletions
This file was deleted.

‎tests/blendmath/skip‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎tests/blendmath/test.sh‎

Lines changed: 0 additions & 17 deletions
This file was deleted.

‎tests/blendmath/test_blendmath.c‎

Lines changed: 0 additions & 93 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
grep -q "all parallel checks passed" "$1" && ! grep -q "FAIL" "$1"

‎tests/posemath-parallel/skip‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
# Builds a program against the run-in-place headers and library. Skip
3+
# when testing installed packages.
4+
[ -z "$SYSTEM_BUILD" ]

‎tests/posemath-parallel/test.sh‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# posemath uses neither RTAPI nor ULAPI, so a plain program linked with
5+
# libposemath checks it; the realtime build's extra maths flags only
6+
# change calls to sin and cos, which these two functions do not make
7+
gcc -O2 -Wall -I"$HEADERS" -o test_parallel test_parallel.c \
8+
-L"$LIBDIR" -Wl,-rpath,"$LIBDIR" -lposemath -lm
9+
10+
./test_parallel
11+
rm -f test_parallel
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* Checks of the posemath parallel and anti-parallel vector tests.
3+
*
4+
* Salvaged from the retired meson-only unit_tests/tp/test_blendmath.c
5+
* (originally by Robert W. Ellenberg). A plain program linked with
6+
* libposemath, which needs neither RTAPI nor ULAPI.
7+
*/
8+
9+
#include <math.h>
10+
#include <stdio.h>
11+
#include <posemath.h>
12+
13+
/* the tolerance the planner's blends use, ANGLE_EPSILON */
14+
#define ANGLE_EPSILON 1e-6
15+
#define ANGLE_EPSILON_SQ (ANGLE_EPSILON * ANGLE_EPSILON)
16+
17+
static int failures = 0;
18+
19+
#define CHECK(cond) do { \
20+
if (!(cond)) { \
21+
printf("FAIL %s:%d: %s\n", __FILE__, __LINE__, #cond); \
22+
failures++; \
23+
} \
24+
} while (0)
25+
26+
#define CHECK_FALSE(cond) CHECK(!(cond))
27+
28+
static void test_pmCartCartParallel_numerical(void)
29+
{
30+
PmCartesian u0 = {1, 0, 0};
31+
PmCartesian u_close = {cos(ANGLE_EPSILON), sin(ANGLE_EPSILON), 0};
32+
int k;
33+
34+
CHECK(pmCartCartParallel(&u0, &u0, ANGLE_EPSILON_SQ));
35+
CHECK_FALSE(pmCartCartParallel(&u0, &u_close, 0.0));
36+
37+
/* Test that the tolerance makes sense */
38+
CHECK_FALSE(pmCartCartParallel(&u0, &u_close, 0.5 * ANGLE_EPSILON_SQ));
39+
CHECK(pmCartCartParallel(&u0, &u_close, 1.5 * ANGLE_EPSILON_SQ));
40+
41+
/* Try a bunch of other angles including anti-parallel */
42+
for (k = 1; k <= 7; ++k) {
43+
PmCartesian u_far = {cos(PM_PI_4 * k), sin(PM_PI_4 * k), 0};
44+
CHECK_FALSE(pmCartCartParallel(&u0, &u_far, ANGLE_EPSILON_SQ));
45+
}
46+
}
47+
48+
static void test_pmCartCartAntiParallel_numerical(void)
49+
{
50+
PmCartesian u0 = {1, 0, 0};
51+
PmCartesian u_close = {-cos(ANGLE_EPSILON), sin(ANGLE_EPSILON), 0};
52+
PmCartesian u_opposite = {-1, 0, 0};
53+
int k;
54+
55+
CHECK(pmCartCartAntiParallel(&u0, &u_opposite, ANGLE_EPSILON_SQ));
56+
CHECK_FALSE(pmCartCartAntiParallel(&u0, &u_close, 0.0));
57+
58+
/* Test that the tolerance makes sense */
59+
CHECK_FALSE(pmCartCartAntiParallel(&u0, &u_close, 0.5 * ANGLE_EPSILON_SQ));
60+
CHECK(pmCartCartAntiParallel(&u0, &u_close, 1.5 * ANGLE_EPSILON_SQ));
61+
62+
/* Try a bunch of other angles including anti-parallel */
63+
for (k = 1; k <= 7; ++k) {
64+
PmCartesian u_far = {-cos(PM_PI_4 * k), sin(PM_PI_4 * k), 0};
65+
CHECK_FALSE(pmCartCartAntiParallel(&u0, &u_far, ANGLE_EPSILON_SQ));
66+
}
67+
}
68+
69+
int main(void)
70+
{
71+
test_pmCartCartParallel_numerical();
72+
test_pmCartCartAntiParallel_numerical();
73+
74+
if (failures) {
75+
printf("%d check(s) FAILED\n", failures);
76+
return 1;
77+
}
78+
printf("all parallel checks passed\n");
79+
return 0;
80+
}

0 commit comments

Comments
 (0)