Here's the code I use to test all the CPLD boards before they get packaged and shipped out.
The code tests all IO pins of the CPLD and one of the clock pins.
The output of each [number] pin is connected physically connected to the corresponding input [number] pin using a prototype vero board. So, IN[0] is physically connected to OUT[0].... and IN[7] is physically connected to OUT[7], and so on.
This allows the real value of OUT[x] to be read by IN[x].
At every positive clock edge that value of all the input pins are read and copied to the next number output pin. eg IN[3] -> OUT[4]. This is done for all pins except OUT[0] is set to be the opposite state of IN[13]. This creates a cool 'light chaser affect'.
If there is an issue with a pin (short or open circuit) the light chaser effect will not work properly, and the problem pin(s) can be easily identified and corrected.
For the clock source I have programmed an Atmel ATtiny85 to quickly toggle one of it's pins on and off.