You can program the GPIO at the initialization of the board it takes minimun time.
First you need to export the GPIO you want to test to the user space:
echo XX > /sys/class/gpio/export
XX shall be determined by the following algorithm:
GPIOA_[B] is the GPIO you want to export, where "A" is the GPIO bank and "B" is the offset of the pin in the bank.
if the first available GPIO bank is 0 // (iMX.28, for example)
XX = A*32 + B;
else // first GPIO bank is 1
XX = (A-1)*32 + B;