On 13 May 2026, at 14:27, Pratik Farkase via lists.openembedded.org 
<[email protected]> wrote:
> 
> Add ptest support for libffi using all upstream test suites: bhaible,
> call, closures, complex, go, and threads.
> 
> Tests are compiled on-target against the installed libffi. Headers
> (including the generated fficonfig.h) and a linker symlink are installed
> in the ptest directory to avoid depending on libffi-dev.

The point of ptests is to do integration testing of what we build, which this 
does not do.  As you’re manually doing the compilation in run-ptest, why can’t 
this be done at build time?

> +CC="gcc"
> +CXX="g++"
> +if ! command -v gcc >/dev/null 2>&1; then
> +    CC=$(find /usr/bin -name "*-gcc" | head -n 1)
> +    CXX=$(find /usr/bin -name "*-g++" | head -n 1)
> +fi

Please don’t be so overly defensive. If you were to continue with compilation 
on the target, then just RDEPEND on gcc-symlinks and then gcc is on PATH.

> +CFLAGS="-O2 -Wall -I$PTEST_DIR/include -L$PTEST_DIR/lib"
> +
> +# bhaible tests validate by comparing paired output lines
> +for t in test-call test-callback; do
> +    src="$PTEST_DIR/testsuite/libffi.bhaible/$t.c"
> +    if $CC $CFLAGS -o "$PTEST_DIR/$t" "$src" -lffi 2>&1; then
> +        "$PTEST_DIR/$t" > "$PTEST_DIR/$t.out" 2>&1
> +        if ! LC_ALL=C uniq -u < "$PTEST_DIR/$t.out" | grep -q .; then
> +            echo "PASS: libffi.bhaible/$t"
> +        else
> +            echo "FAIL: libffi.bhaible/$t"
> +            cat "$PTEST_DIR/$t.out"
> +        fi
> +    else
> +        echo "SKIP: libffi.bhaible/$t"
> +    fi
> +    rm -f "$PTEST_DIR/$t" "$PTEST_DIR/$t.out"
> +done
> +
> +# Individual test programs from upstream dejagnu suites
> +for suite in libffi.call libffi.closures libffi.complex libffi.go 
> libffi.threads; do
> +    dir="$PTEST_DIR/testsuite/$suite"
> +    [ -d "$dir" ] || continue
> +
> +    extra=""
> +    [ "$suite" = "libffi.threads" ] && extra="-lpthread"
> +
> +    for src in "$dir"/*.c "$dir"/*.cc; do
> +        [ -f "$src" ] || continue
> +        grep -q "dg-do run" "$src" || continue
> +
> +        name=$(basename "${src%.*}")
> +
> + # complex_int uses non-standard _Complex int, fails on some arches (riscv64)
> +        [ "$name" = "complex_int" ] && continue
> +        case "$src" in
> +            *.cc) cc="$CXX";;
> +            *)    cc="$CC";;
> +        esac
> +
> +        if $cc $CFLAGS -o "$PTEST_DIR/$name" "$src" -lffi $extra 2>&1; then
> +            if "$PTEST_DIR/$name" 2>&1; then
> +                echo "PASS: $suite/$name"
> +            else
> +                echo "FAIL: $suite/$name"
> +            fi
> +        else
> +            echo "SKIP: $suite/$name"
> +        fi
> +        rm -f "$PTEST_DIR/$name"
> +    done
> +done

This is a _lot_ of logic that we have to maintain forever to run some 
integration tests…

Ross
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#237454): 
https://lists.openembedded.org/g/openembedded-core/message/237454
Mute This Topic: https://lists.openembedded.org/mt/119296973/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to