Difference between test and punishment outcome. Hardship can be a test, an expiation of sins, an elevation of rank, or a punishment. If it draws a person closer to Allah through patience and repentance, it is a blessing; if it leads to rebellion and distance, it serves as a punishment or warning.

Ustadh AbdulAziz al-Haqqan
You know it by your own response, if it brings you to patience, repentance and contentment it is mercy and a raising of rank, and if it brings you to complaint and rebellion then fear that it is a punishment. Imam Ibn Baz said the believer is his own physician and his own opponent.