How to run Apple Hardware Test on older Mac
I followed 'Drew Reece' instructions below which was given in apple discussion forum. https://discussions.apple.com/message/27529118#27529118
and it worked fine for me without messing my machine. even AHT test passed in loop mode, still sometimes I get freeze while using safari and only option to recover is to restart the machine.
Not sure whether AHT test is through and I have no hardware issue or its El Capitan issue on my mid 2007 24" iMac.

Grab the AHT disk image from Apple.com, github has a list be sure you have the correct model.
https://github.com/upekkha/AppleHardwareTest
In Terminal view the output of these two lines…
sysctl hw.model | awk '{ print $2 }'
ioreg -l | grep board-id | awk -F\" '{ print $4 }'
… and compare to the github list

Inside an admin account (it needs to use sudo for 'blessing' the system).
Grab my script, open the ZIP file. In the folder that is created (probably called 2e5eed7dbfbd5dd7e929-6ddeffa80174801842f729c8657e3c460e0ed540 !) drag that script onto Terminal. Then drag the AHT disk image onto Terminal &amp; finally drag the destination disk (a USB disk formatted to Macintosh OS Extended).

It should look a bit like…

[~/]$ /Users/USERNAME/Downloads/2e5eed7dbfbd5dd7e929-6ddeffa80174801842f729c8657e3c460e0ed540/AHT-my- disk.sh /Users/USERNAME/Downloads/AHTdiskimage.dmg /Volumes/path-to-USB

NB: The bold parts will be specific to your system, there are spaces between the file paths.
If you are unsure paste the command here &amp; we can try to confirm it is correct, Terminal correctly escapes spaces &amp; other special characters in file paths if you use drag &amp; drop, so it should complete them correctly for you.

Hit return &amp; it should ask for confirmation and then copy over the AHT disk &amp; offer to bless the tool for use on next boot.

I haven't tested this on 10.11 &amp; I cannot do so at present, sorry. If it fails it is possible to copy over by hand, but that takes a lot of describing. The script just uses the cp command to copy the relevant files over after mounting the disk image. The USB destination is not erased, but avoid copying it to a disk that has valuable data (just in case, have a backup).

It may also appear as a bootable disk in the 'boot picker' (hold alt at startup), this seems to vary on some models.