dropshell/runner/minimal_test.sh
Your Name b5bc7b611d
Some checks failed
Dropshell Test / Build_and_Test (push) Failing after 21s
Runner.
2025-05-10 12:43:25 +12:00

96 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
echo "Running minimal libssh test to diagnose linking issues"
echo "===================================================="
# Create test directory
TESTDIR="ssh_test_tmp"
mkdir -p $TESTDIR
cd $TESTDIR
# Create minimal C program that uses libssh
cat > test.c << 'EOF'
#include <stdio.h>
#include <stdlib.h>
#include <libssh/libssh.h>
int main() {
ssh_session session = ssh_new();
if (session == NULL) {
fprintf(stderr, "Failed to create SSH session\n");
return 1;
}
printf("Successfully created SSH session\n");
ssh_free(session);
return 0;
}
EOF
echo "Created minimal test program. Attempting to compile..."
# Check pkg-config first
if command -v pkg-config &> /dev/null && pkg-config --exists libssh; then
CFLAGS=$(pkg-config --cflags libssh)
LIBS=$(pkg-config --libs libssh)
echo "Found libssh with pkg-config:"
echo " CFLAGS: $CFLAGS"
echo " LIBS: $LIBS"
echo
echo "Compiling with pkg-config flags..."
gcc -o test_pkg test.c $CFLAGS $LIBS
if [ $? -eq 0 ]; then
echo "Compilation successful!"
echo "Running the test program:"
./test_pkg
else
echo "Compilation failed with pkg-config flags."
fi
echo
fi
# Try with simple -lssh flag
echo "Compiling with simple -lssh flag..."
gcc -o test_simple test.c -lssh
if [ $? -eq 0 ]; then
echo "Compilation successful with -lssh!"
echo "Running the test program:"
./test_simple
else
echo "Compilation failed with simple -lssh flag."
echo "This indicates your libssh installation might not be in the standard location."
fi
echo
# Try to find libssh manually
echo "Searching for libssh.so in common locations..."
LIBSSH_PATHS=$(find /usr/lib /usr/local/lib /usr/lib/x86_64-linux-gnu -name "libssh.so*" 2>/dev/null)
if [ -n "$LIBSSH_PATHS" ]; then
echo "Found libssh in the following locations:"
echo "$LIBSSH_PATHS" | sed 's/^/ - /'
# Extract directory of first result
LIBSSH_DIR=$(dirname $(echo "$LIBSSH_PATHS" | head -1))
echo
echo "For CMake, you can try:"
echo " cmake -DLIBSSH_LIBRARY=$LIBSSH_DIR/libssh.so -DLIBSSH_INCLUDE_DIR=/usr/include .."
else
echo "Could not find libssh.so."
echo "Consider installing libssh-dev package:"
echo " sudo apt install libssh-dev"
fi
# Clean up
cd ..
echo
echo "Cleaning up..."
rm -rf $TESTDIR
echo
echo "Test completed. Use this information to troubleshoot your libssh configuration."