aboutsummaryrefslogtreecommitdiff
path: root/test_context.c
diff options
context:
space:
mode:
authorRichard Levitte <richard@levitte.org>2021-02-22 06:08:55 +0100
committerDmitry Belyavskiy <beldmit@users.noreply.github.com>2021-02-22 09:30:54 +0100
commitb56b7ee05276b92c282efa412ae94163b88ec350 (patch)
tree2b7e81802f7213e72091a1889d691b072d366046 /test_context.c
parentbc111014be6390ae8f3674d05b76eb205ab4c49b (diff)
downloadgost-engine-b56b7ee05276b92c282efa412ae94163b88ec350.zip
gost-engine-b56b7ee05276b92c282efa412ae94163b88ec350.tar.gz
gost-engine-b56b7ee05276b92c282efa412ae94163b88ec350.tar.bz2
Always cNORM before "\n"
Using cNORM after "\n" may or may not work, probably because of the line buffered nature of standard output. If an error is displayed immediately after a printf that has cNORM after "\n", the error output sometimes "overrides" the cNORM, and you may end up with a surprisingly colorful error message, not to mention that this may also affect your prompt in the same manner. The lesson is to always output cNORM before the ending "\n".
Diffstat (limited to 'test_context.c')
-rw-r--r--test_context.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/test_context.c b/test_context.c
index 2348f59..0db2163 100644
--- a/test_context.c
+++ b/test_context.c
@@ -28,9 +28,9 @@
#define cDBLUE "\033[0;34m"
#define cNORM "\033[m"
#define TEST_ASSERT(e) {if ((test = (e))) \
- printf(cRED " Test FAILED\n" cNORM); \
+ printf(cRED " Test FAILED" cNORM "\n"); \
else \
- printf(cGREEN " Test passed\n" cNORM);}
+ printf(cGREEN " Test passed" cNORM "\n");}
static void hexdump(const void *ptr, size_t len)
{
@@ -61,7 +61,7 @@ static int test_contexts_cipher(int nid, const int enc, int acpkm)
const EVP_CIPHER *type = EVP_get_cipherbynid(nid);
const char *name = EVP_CIPHER_name(type);
- printf(cBLUE "%s test for %s (nid %d)\n" cNORM,
+ printf(cBLUE "%s test for %s (nid %d)" cNORM "\n",
enc ? "Encryption" : "Decryption", name, nid);
/* produce base encryption */
@@ -137,7 +137,7 @@ static int test_contexts_digest(int nid, int mac)
const EVP_MD *type = EVP_get_digestbynid(nid);
const char *name = EVP_MD_name(type);
- printf(cBLUE "Digest test for %s (nid %d)\n" cNORM, name, nid);
+ printf(cBLUE "Digest test for %s (nid %d)" cNORM "\n", name, nid);
/* produce base digest */
EVP_MD_CTX *ctx, *save;
@@ -267,8 +267,8 @@ int main(int argc, char **argv)
ENGINE_free(eng);
if (ret)
- printf(cDRED "= Some tests FAILED!\n" cNORM);
+ printf(cDRED "= Some tests FAILED!" cNORM "\n");
else
- printf(cDGREEN "= All tests passed!\n" cNORM);
+ printf(cDGREEN "= All tests passed!" cNORM "\n");
return ret;
}