https://gist.github.com/meinside/0538087cc60a2f0654bb
for testing external HDD with smartctl,
install smartmontools
$ sudo apt-get install smartmontools
start test,
$ sudo smartctl -t short -d sat /dev/sda $ sudo smartctl -t long -d sat /dev/sda -T permissive
then it will say
Testing has begun. Please wait 100 minutes for test to complete. Test will complete after Thu Oct 6 11:36:22 2016
so wait for it…
After its completion,
$ sudo smartctl -l selftest -d sat /dev/sda -T permissive
to see the test result.