What version of OS X do you have, and is it the original version or did you upgrade? Which Mac machine are you running? Did it happen after you installed a new piece of hardware/software?
If you can get into OS X, launch Disk Utility, select the OS X partition (possibly labeled “Macintosh HD”), select Verify Disk. If you get any errors with that step, we can proceed from there. If no errors occur, select Repair Permissions, which should end with a message saying Permissions were successfully repaired. By doing these steps, you are doing basic hard drive tests. More may be beneficial.