Test which direction ERR_get_error reads from the error queue.

ERR_get_error returns the least recent error, not the most recent error.
Nothing in err_test was actually asserting on that.

Change-Id: Ia49e29c231de4bbec77d037860ad1ffa8cce4779
Reviewed-on: https://boringssl-review.googlesource.com/2750
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/err/err_test.c b/crypto/err/err_test.c
index 214f4f2..09dc1f6 100644
--- a/crypto/err/err_test.c
+++ b/crypto/err/err_test.c
@@ -23,11 +23,15 @@
   unsigned i;
 
   for (i = 0; i < ERR_NUM_ERRORS*2; i++) {
-    ERR_put_error(1, 2, 3, "test", 1);
+    ERR_put_error(1, 2, i+1, "test", 1);
   }
 
   for (i = 0; i < ERR_NUM_ERRORS - 1; i++) {
-    if (ERR_get_error() == 0) {
+    uint32_t err = ERR_get_error();
+    /* Errors are returned in order they were pushed, with the least recent ones
+     * removed, up to |ERR_NUM_ERRORS - 1| errors. So the errors returned are
+     * |ERR_NUM_ERRORS + 2| through |ERR_NUM_ERRORS * 2|, inclusive. */
+    if (err == 0 || ERR_GET_REASON(err) != i + ERR_NUM_ERRORS + 2) {
       fprintf(stderr, "ERR_get_error failed at %u\n", i);
       return 0;
     }