This post explains how to do SPI loopback testing in RaspberryPi.
This is the pinout of RaspbeyyPi GPIO header.
Next short the MOSI and MISO pins (GPIO10 and GPIO09)
Now download SPI test code from below link
gcc -o spidev_test spidev_test.c
Run the code using spi dev
./spidev_test -D /dev/spidev0.0
If you are getting the hex characters as shown in screenshot, the SPI loopback is working.