summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/Test_encoding.c16
-rw-r--r--tests/Test_errors.c7
-rw-r--r--tests/Test_indefinite.c15
-rw-r--r--tests/Test_overflow.c27
-rw-r--r--tests/Test_parser.c22
-rw-r--r--tests/Test_tree.c44
-rwxr-xr-xtests/crlf2
7 files changed, 95 insertions, 38 deletions
diff --git a/tests/Test_encoding.c b/tests/Test_encoding.c
index 370864b..6b3e7bb 100644
--- a/tests/Test_encoding.c
+++ b/tests/Test_encoding.c
@@ -36,18 +36,24 @@ int data_size = sizeof (data);
int
main (int argc, char *argv[])
{
- int result;
+ int result, verbose = 0;
asn1_node_t definitions = NULL;
asn1_node_t asn1_element = NULL;
char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE];
const char *treefile = getenv ("ASN1ENCODING");
+ if (argc > 1)
+ verbose = 1;
+
if (!treefile)
treefile = "Test_encoding.asn";
- printf ("\n\n/****************************************/\n");
- printf ("/* Test sequence : coding-decoding */\n");
- printf ("/****************************************/\n\n");
+ if (verbose != 0)
+ {
+ printf ("\n\n/****************************************/\n");
+ printf ("/* Test sequence : coding-decoding */\n");
+ printf ("/****************************************/\n\n");
+ }
/* Check version */
if (asn1_check_version ("0.3.3") == NULL)
@@ -124,6 +130,6 @@ main (int argc, char *argv[])
asn1_delete_structure (&asn1_element);
- printf ("Success\n");
+ if (verbose) printf ("Success\n");
exit (0);
}
diff --git a/tests/Test_errors.c b/tests/Test_errors.c
index 8480b22..fcd1704 100644
--- a/tests/Test_errors.c
+++ b/tests/Test_errors.c
@@ -25,11 +25,16 @@ main (int argc, char *argv[])
{
int ec = 0;
const char *errstr;
+ int verbose = 0;
+
+ if (argc > 1)
+ verbose = 1;
do
{
errstr = asn1_strerror (ec);
- asn1_perror (ec);
+ if (verbose != 0)
+ asn1_perror (ec);
ec++;
}
while (errstr);
diff --git a/tests/Test_indefinite.c b/tests/Test_indefinite.c
index 3387a11..e951b46 100644
--- a/tests/Test_indefinite.c
+++ b/tests/Test_indefinite.c
@@ -48,6 +48,10 @@ main (int argc, char *argv[])
ssize_t size;
const char *treefile = getenv ("ASN1PKIX");
const char *indeffile = getenv ("ASN1INDEF");
+ int verbose = 0;
+
+ if (argc > 1)
+ verbose = 1;
if (!treefile)
treefile = "pkix.asn";
@@ -55,10 +59,13 @@ main (int argc, char *argv[])
if (!indeffile)
indeffile = "TestIndef.p12";
- printf ("\n\n/****************************************/\n");
- printf ("/* Test sequence : Test_indefinite */\n");
- printf ("/****************************************/\n\n");
- printf ("ASN1TREE: %s\n", treefile);
+ if (verbose)
+ {
+ printf ("\n\n/****************************************/\n");
+ printf ("/* Test sequence : Test_indefinite */\n");
+ printf ("/****************************************/\n\n");
+ printf ("ASN1TREE: %s\n", treefile);
+ }
/* Check version */
if (asn1_check_version ("0.2.11") == NULL)
diff --git a/tests/Test_overflow.c b/tests/Test_overflow.c
index cbf9381..6f81dc5 100644
--- a/tests/Test_overflow.c
+++ b/tests/Test_overflow.c
@@ -28,10 +28,15 @@
#include "libtasn1.h"
int
-main (void)
+main (int argc, char** argv)
{
/* Test that values larger than long are rejected. This has worked
fine with all versions of libtasn1. */
+ int verbose = 0;
+
+ if (argc > 1)
+ verbose = 1;
+
{
unsigned char der[] = "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF";
long l;
@@ -40,7 +45,9 @@ main (void)
l = asn1_get_length_der (der, sizeof der, &len);
if (l == -2L)
- puts ("OK: asn1_get_length_der bignum");
+ {
+ if (verbose) puts ("OK: asn1_get_length_der bignum");
+ }
else
{
printf ("ERROR: asn1_get_length_der bignum (l %ld len %d)\n", l, len);
@@ -63,7 +70,9 @@ main (void)
l = asn1_get_length_der (der, der_len, &len);
if (l == -2L)
- puts ("OK: asn1_get_length_der intnum");
+ {
+ if (verbose) puts ("OK: asn1_get_length_der intnum");
+ }
else
{
printf ("ERROR: asn1_get_length_der intnum (l %ld len %d)\n", l,
@@ -87,7 +96,9 @@ main (void)
l = asn1_get_length_der (der, der_len, &len);
if (l == -4L)
- puts ("OK: asn1_get_length_der overflow-small");
+ {
+ if (verbose) puts ("OK: asn1_get_length_der overflow-small");
+ }
else
{
printf ("ERROR: asn1_get_length_der overflow-small (l %ld len %d)\n", l,
@@ -111,7 +122,9 @@ main (void)
l = asn1_get_length_der (der, der_len, &len);
if (l == -4L)
- puts ("OK: asn1_get_length_der overflow-large1");
+ {
+ if (verbose) puts ("OK: asn1_get_length_der overflow-large1");
+ }
else
{
printf ("ERROR: asn1_get_length_der overflow-large1 (l %ld len %d)\n", l,
@@ -135,7 +148,9 @@ main (void)
l = asn1_get_length_der (der, der_len, &len);
if (l == -2L)
- puts ("OK: asn1_get_length_der overflow-large2");
+ {
+ if (verbose) puts ("OK: asn1_get_length_der overflow-large2");
+ }
else
{
printf ("ERROR: asn1_get_length_der overflow-large2 (l %ld len %d)\n", l,
diff --git a/tests/Test_parser.c b/tests/Test_parser.c
index 062fc2f..6b9ef70 100644
--- a/tests/Test_parser.c
+++ b/tests/Test_parser.c
@@ -152,15 +152,22 @@ main (int argc, char *argv[])
char errorDescription[ASN1_MAX_ERROR_DESCRIPTION_SIZE];
test_type *test;
int errorCounter = 0, testCounter = 0;
+ int verbose = 0;
+
+ if (argc > 1)
+ verbose = 1;
fileCorrectName = getenv ("ASN1PARSER");
if (!fileCorrectName)
fileCorrectName = "Test_parser.asn";
- printf ("\n\n/****************************************/\n");
- printf ("/* Test sequence : Test_parser */\n");
- printf ("/****************************************/\n\n");
- printf ("ASN1PARSER: %s\n", fileCorrectName);
+ if (verbose != 0)
+ {
+ printf ("\n\n/****************************************/\n");
+ printf ("/* Test sequence : Test_parser */\n");
+ printf ("/****************************************/\n\n");
+ printf ("ASN1PARSER: %s\n", fileCorrectName);
+ }
result = asn1_parser2tree (fileCorrectName, &definitions, errorDescription);
@@ -207,8 +214,11 @@ main (int argc, char *argv[])
}
- printf ("Total tests : %d\n", testCounter);
- printf ("Total errors: %d\n", errorCounter);
+ if (verbose != 0)
+ {
+ printf ("Total tests : %d\n", testCounter);
+ printf ("Total errors: %d\n", errorCounter);
+ }
if (errorCounter > 0)
return 1;
diff --git a/tests/Test_tree.c b/tests/Test_tree.c
index 32c57e1..70b6df4 100644
--- a/tests/Test_tree.c
+++ b/tests/Test_tree.c
@@ -442,17 +442,23 @@ main (int argc, char *argv[])
unsigned char value[1024], der[1024];
int valueLen, tag = 0, class = 0;
int k;
- int start, end;
+ int start, end, verbose = 0;
const char *str_p = NULL;
const char *treefile = getenv ("ASN1TREE");
+
+ if (argc > 1)
+ verbose = 1;
if (!treefile)
treefile = "Test_tree.asn";
- printf ("\n\n/****************************************/\n");
- printf ("/* Test sequence : Test_tree */\n");
- printf ("/****************************************/\n\n");
- printf ("ASN1TREE: %s\n", treefile);
+ if (verbose != 0)
+ {
+ printf ("\n\n/****************************************/\n");
+ printf ("/* Test sequence : Test_tree */\n");
+ printf ("/****************************************/\n\n");
+ printf ("ASN1TREE: %s\n", treefile);
+ }
/* Check version */
if (asn1_check_version ("0.2.11") == NULL)
@@ -571,16 +577,22 @@ main (int argc, char *argv[])
str_p = asn1_find_structure_from_oid (definitions, test->par1);
break;
case ACT_VISIT:
- asn1_print_structure (out, asn1_element, test->par1, test->par3);
- fprintf (out, "\n");
+ if (verbose)
+ {
+ asn1_print_structure (out, asn1_element, test->par1, test->par3);
+ fprintf (out, "\n");
+ }
result = ASN1_SUCCESS;
break;
case ACT_PRINT_DER:
- printf ("DER encoding len:%i\n", der_len);
- printf ("DER encoding: ");
- for (k = 0; k < der_len; k++)
- printf ("%02x ", der[k]);
- printf ("\n\n");
+ if (verbose)
+ {
+ printf ("DER encoding len:%i\n", der_len);
+ printf ("DER encoding: ");
+ for (k = 0; k < der_len; k++)
+ printf ("%02x ", der[k]);
+ printf ("\n\n");
+ }
result = ASN1_SUCCESS;
break;
case ACT_SET_DER:
@@ -757,9 +769,11 @@ main (int argc, char *argv[])
}
- printf ("Total tests : %d\n", testCounter);
- printf ("Total errors: %d\n", errorCounter);
-
+ if (verbose != 0)
+ {
+ printf ("Total tests : %d\n", testCounter);
+ printf ("Total errors: %d\n", errorCounter);
+ }
/* Clear the definition structures */
asn1_delete_structure (&definitions);
diff --git a/tests/crlf b/tests/crlf
index be92dcf..7d74c8b 100755
--- a/tests/crlf
+++ b/tests/crlf
@@ -32,4 +32,4 @@ ASN1DECODING=../src/asn1Decoding${EXEEXT}
$ASN1DECODING \
$srcdir/../examples/pkix.asn \
$srcdir/crlf.cer \
- PKIX1Implicit88.Certificate
+ PKIX1Implicit88.Certificate >/dev/null