aboutsummaryrefslogtreecommitdiffstats
path: root/src/charon/plugins/unit_tester
diff options
context:
space:
mode:
Diffstat (limited to 'src/charon/plugins/unit_tester')
-rw-r--r--src/charon/plugins/unit_tester/tests.h2
-rw-r--r--src/charon/plugins/unit_tester/tests/test_agent.c8
-rw-r--r--src/charon/plugins/unit_tester/tests/test_auth_info.c10
-rw-r--r--src/charon/plugins/unit_tester/tests/test_cert.c12
-rw-r--r--src/charon/plugins/unit_tester/tests/test_chunk.c20
-rw-r--r--src/charon/plugins/unit_tester/tests/test_curl.c4
-rw-r--r--src/charon/plugins/unit_tester/tests/test_enumerator.c34
-rw-r--r--src/charon/plugins/unit_tester/tests/test_id.c22
-rw-r--r--src/charon/plugins/unit_tester/tests/test_med_db.c2
-rw-r--r--src/charon/plugins/unit_tester/tests/test_mutex.c14
-rw-r--r--src/charon/plugins/unit_tester/tests/test_mysql.c2
-rw-r--r--src/charon/plugins/unit_tester/tests/test_pool.c14
-rw-r--r--src/charon/plugins/unit_tester/tests/test_rsa_gen.c4
-rw-r--r--src/charon/plugins/unit_tester/tests/test_sqlite.c2
-rw-r--r--src/charon/plugins/unit_tester/unit_tester.c16
-rw-r--r--src/charon/plugins/unit_tester/unit_tester.h2
16 files changed, 84 insertions, 84 deletions
diff --git a/src/charon/plugins/unit_tester/tests.h b/src/charon/plugins/unit_tester/tests.h
index b99940c1a..96313d390 100644
--- a/src/charon/plugins/unit_tester/tests.h
+++ b/src/charon/plugins/unit_tester/tests.h
@@ -14,7 +14,7 @@
*/
/**
- * @defgroup tests tests
+ * @defgroup tests tests
* @{ @ingroup unit_tester
*/
diff --git a/src/charon/plugins/unit_tester/tests/test_agent.c b/src/charon/plugins/unit_tester/tests/test_agent.c
index fd76b9cf5..21cb8b777 100644
--- a/src/charon/plugins/unit_tester/tests/test_agent.c
+++ b/src/charon/plugins/unit_tester/tests/test_agent.c
@@ -25,14 +25,14 @@ bool test_agent()
chunk_t sig, data = chunk_from_buf(buf);
private_key_t *private;
public_key_t *public;
-
+
path = getenv("SSH_AUTH_SOCK");
if (!path)
{
DBG1(DBG_CFG, "ssh-agent not found.");
return FALSE;
}
-
+
private = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
BUILD_AGENT_SOCKET, path, BUILD_END);
if (!private)
@@ -58,10 +58,10 @@ bool test_agent()
{
return FALSE;
}
-
+
private->destroy(private);
public->destroy(public);
-
+
return TRUE;
}
diff --git a/src/charon/plugins/unit_tester/tests/test_auth_info.c b/src/charon/plugins/unit_tester/tests/test_auth_info.c
index 37bdd1087..6de34b2a1 100644
--- a/src/charon/plugins/unit_tester/tests/test_auth_info.c
+++ b/src/charon/plugins/unit_tester/tests/test_auth_info.c
@@ -83,7 +83,7 @@ bool test_auth_cfg()
int round = 0;
void *value;
auth_rule_t type;
-
+
c1 = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
BUILD_BLOB_ASN1_DER, certchunk,
BUILD_END);
@@ -91,7 +91,7 @@ bool test_auth_cfg()
{
return FALSE;
}
-
+
auth->add(auth, AUTH_RULE_SUBJECT_CERT, c1->get_ref(c1));
c2 = auth->get(auth, AUTH_RULE_SUBJECT_CERT);
if (!c2)
@@ -102,7 +102,7 @@ bool test_auth_cfg()
{
return FALSE;
}
-
+
enumerator = auth->create_enumerator(auth);
while (enumerator->enumerate(enumerator, &type, &value))
{
@@ -114,11 +114,11 @@ bool test_auth_cfg()
return FALSE;
}
enumerator->destroy(enumerator);
-
+
auth2 = auth_cfg_create();
auth2->add(auth2, AUTH_RULE_CA_CERT, c1->get_ref(c1));
auth2->merge(auth2, auth, FALSE);
-
+
round = 0;
enumerator = auth2->create_enumerator(auth2);
while (enumerator->enumerate(enumerator, &type, &value))
diff --git a/src/charon/plugins/unit_tester/tests/test_cert.c b/src/charon/plugins/unit_tester/tests/test_cert.c
index 95ab289df..3b00421f8 100644
--- a/src/charon/plugins/unit_tester/tests/test_cert.c
+++ b/src/charon/plugins/unit_tester/tests/test_cert.c
@@ -28,10 +28,10 @@ bool test_cert_x509()
identification_t *issuer, *subject;
u_int32_t serial = htonl(0);
chunk_t encoding;
-
+
issuer = identification_create_from_string("CN=CA, OU=Test, O=strongSwan");
subject = identification_create_from_string("CN=Peer, OU=Test, O=strongSwan");
-
+
ca_key = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
BUILD_KEY_SIZE, 1024, BUILD_END);
peer_key = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
@@ -50,7 +50,7 @@ bool test_cert_x509()
{
return FALSE;
}
-
+
encoding = ca_cert->get_encoding(ca_cert);
parsed = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
BUILD_BLOB_ASN1_DER, encoding,
@@ -65,7 +65,7 @@ bool test_cert_x509()
return FALSE;
}
parsed->destroy(parsed);
-
+
serial = htonl(ntohl(serial) + 1);
public = peer_key->get_public_key(peer_key);
peer_cert = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
@@ -80,7 +80,7 @@ bool test_cert_x509()
{
return FALSE;
}
-
+
encoding = peer_cert->get_encoding(peer_cert);
parsed = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
BUILD_BLOB_ASN1_DER, encoding,
@@ -95,7 +95,7 @@ bool test_cert_x509()
return FALSE;
}
parsed->destroy(parsed);
-
+
ca_cert->destroy(ca_cert);
ca_key->destroy(ca_key);
peer_cert->destroy(peer_cert);
diff --git a/src/charon/plugins/unit_tester/tests/test_chunk.c b/src/charon/plugins/unit_tester/tests/test_chunk.c
index 5356c1d96..2e0905b2c 100644
--- a/src/charon/plugins/unit_tester/tests/test_chunk.c
+++ b/src/charon/plugins/unit_tester/tests/test_chunk.c
@@ -31,12 +31,12 @@ bool test_chunk_base64()
* BASE64("fooba") = "Zm9vYmE="
* BASE64("foobar") = "Zm9vYmFy"
*/
-
+
typedef struct {
char *in;
char *out;
} testdata_t;
-
+
testdata_t test[] = {
{"", ""},
{"f", "Zg=="},
@@ -47,31 +47,31 @@ bool test_chunk_base64()
{"foobar", "Zm9vYmFy"},
};
int i;
-
+
for (i = 0; i < countof(test); i++)
{
chunk_t out;
-
+
out = chunk_to_base64(chunk_create(test[i].in, strlen(test[i].in)), NULL);
-
+
if (!streq(out.ptr, test[i].out))
{
- DBG1(DBG_CFG, "base64 conversion error - should %s, is %s",
+ DBG1(DBG_CFG, "base64 conversion error - should %s, is %s",
test[i].out, out.ptr);
return FALSE;
}
free(out.ptr);
}
-
+
for (i = 0; i < countof(test); i++)
{
chunk_t out;
-
+
out = chunk_from_base64(chunk_create(test[i].out, strlen(test[i].out)), NULL);
-
+
if (!strneq(out.ptr, test[i].in, out.len))
{
- DBG1(DBG_CFG, "base64 conversion error - should %s, is %#B",
+ DBG1(DBG_CFG, "base64 conversion error - should %s, is %#B",
test[i].in, &out);
return FALSE;
}
diff --git a/src/charon/plugins/unit_tester/tests/test_curl.c b/src/charon/plugins/unit_tester/tests/test_curl.c
index c011617a7..21656a94e 100644
--- a/src/charon/plugins/unit_tester/tests/test_curl.c
+++ b/src/charon/plugins/unit_tester/tests/test_curl.c
@@ -25,14 +25,14 @@
bool test_curl_get()
{
chunk_t chunk;
-
+
if (lib->fetcher->fetch(lib->fetcher, "http://www.strongswan.org",
&chunk, FETCH_END) != SUCCESS)
{
return FALSE;
}
free(chunk.ptr);
-
+
if (lib->fetcher->fetch(lib->fetcher, "http://www.google.com",
&chunk, FETCH_END) != SUCCESS)
{
diff --git a/src/charon/plugins/unit_tester/tests/test_enumerator.c b/src/charon/plugins/unit_tester/tests/test_enumerator.c
index 6898084fc..edbf0f5bb 100644
--- a/src/charon/plugins/unit_tester/tests/test_enumerator.c
+++ b/src/charon/plugins/unit_tester/tests/test_enumerator.c
@@ -23,7 +23,7 @@ bool test_list_remove()
{
void *a = (void*)1, *b = (void*)2;
linked_list_t *list;
-
+
list = linked_list_create();
list->insert_last(list, a);
if (list->remove(list, a, NULL) != 1)
@@ -67,15 +67,15 @@ bool test_enumerate()
void *a = (void*)4, *b = (void*)3, *c = (void*)2, *d = (void*)5, *e = (void*)1;
linked_list_t *list;
enumerator_t *enumerator;
-
+
list = linked_list_create();
-
+
list->insert_last(list, a);
list->insert_first(list, b);
list->insert_first(list, c);
list->insert_last(list, d);
list->insert_first(list, e);
-
+
round = 1;
enumerator = list->create_enumerator(list);
while (enumerator->enumerate(enumerator, &x))
@@ -87,7 +87,7 @@ bool test_enumerate()
round++;
}
enumerator->destroy(enumerator);
-
+
list->destroy(list);
return TRUE;
}
@@ -122,7 +122,7 @@ bool test_enumerate_nested()
void *a = (void*)1, *b = (void*)2, *c = (void*)3, *d = (void*)4, *e = (void*)5;
linked_list_t *list, *l1, *l2, *l3;
enumerator_t *enumerator;
-
+
bad_data = FALSE;
list = linked_list_create();
l1 = linked_list_create();
@@ -131,13 +131,13 @@ bool test_enumerate_nested()
list->insert_last(list, l1);
list->insert_last(list, l2);
list->insert_last(list, l3);
-
+
l1->insert_last(l1, a);
l1->insert_last(l1, b);
l3->insert_last(l3, c);
l3->insert_last(l3, d);
l3->insert_last(l3, e);
-
+
round = 1;
enumerator = enumerator_create_nested(list->create_enumerator(list),
(void*)create_inner, (void*)101, destroy_data);
@@ -150,7 +150,7 @@ bool test_enumerate_nested()
round++;
}
enumerator->destroy(enumerator);
-
+
list->destroy(list);
l1->destroy(l1);
l2->destroy(l2);
@@ -185,16 +185,16 @@ bool test_enumerate_filtered()
void *a = (void*)1, *b = (void*)2, *c = (void*)3, *d = (void*)4, *e = (void*)5;
linked_list_t *list;
enumerator_t *enumerator;
-
+
bad_data = FALSE;
list = linked_list_create();
-
+
list->insert_last(list, a);
list->insert_last(list, b);
list->insert_last(list, c);
list->insert_last(list, d);
list->insert_last(list, e);
-
+
round = 1;
enumerator = enumerator_create_filter(list->create_enumerator(list),
(void*)filter, (void*)101, destroy_data);
@@ -208,7 +208,7 @@ bool test_enumerate_filtered()
round++;
}
enumerator->destroy(enumerator);
-
+
list->destroy(list);
return !bad_data;
}
@@ -216,7 +216,7 @@ bool test_enumerate_filtered()
/*******************************************************************************
* token parser test
******************************************************************************/
-
+
bool test_enumerate_token()
{
enumerator_t *enumerator;
@@ -240,7 +240,7 @@ bool test_enumerate_token()
{"a.b,c", ",.", ""},
{" a b c ", " ", " "},
};
-
+
for (num = 0; num < countof(tests1); num++)
{
i = 0;
@@ -270,7 +270,7 @@ bool test_enumerate_token()
}
enumerator->destroy(enumerator);
}
-
+
for (num = 0; num < countof(tests2); num++)
{
i = 0;
@@ -300,7 +300,7 @@ bool test_enumerate_token()
}
enumerator->destroy(enumerator);
}
-
+
return TRUE;
}
diff --git a/src/charon/plugins/unit_tester/tests/test_id.c b/src/charon/plugins/unit_tester/tests/test_id.c
index a1ef76be8..868a2ca8b 100644
--- a/src/charon/plugins/unit_tester/tests/test_id.c
+++ b/src/charon/plugins/unit_tester/tests/test_id.c
@@ -25,9 +25,9 @@ bool test_id_parts()
id_part_t part;
chunk_t data;
int i = 0;
-
+
id = identification_create_from_string("C=CH, O=strongSwan, CN=tester");
-
+
enumerator = id->create_part_enumerator(id);
while (enumerator->enumerate(enumerator, &part, &data))
{
@@ -75,7 +75,7 @@ static bool test_id_wildcards_has(char *string)
{
identification_t *id;
bool contains;
-
+
id = identification_create_from_string(string);
contains = id->contains_wildcards(id);
id->destroy(id);
@@ -115,7 +115,7 @@ static bool test_id_equals_one(identification_t *a, char *b_str)
{
identification_t *b;
bool equals;
-
+
b = identification_create_from_string(b_str);
equals = a->equals(a, b);
b->destroy(b);
@@ -127,10 +127,10 @@ bool test_id_equals()
identification_t *a;
chunk_t encoding, fuzzed;
int i;
-
+
a = identification_create_from_string(
"C=CH, E=martin@strongswan.org, CN=martin");
-
+
if (!test_id_equals_one(a, "C=CH, E=martin@strongswan.org, CN=martin"))
{
return FALSE;
@@ -153,7 +153,7 @@ bool test_id_equals()
}
encoding = chunk_clone(a->get_encoding(a));
a->destroy(a);
-
+
/* simple fuzzing, increment each byte of encoding */
for (i = 0; i < encoding.len; i++)
{
@@ -171,7 +171,7 @@ bool test_id_equals()
a->destroy(a);
free(fuzzed.ptr);
}
-
+
/* and decrement each byte of encoding */
for (i = 0; i < encoding.len; i++)
{
@@ -201,7 +201,7 @@ static id_match_t test_id_matches_one(identification_t *a, char *b_str)
{
identification_t *b;
id_match_t match;
-
+
b = identification_create_from_string(b_str);
match = a->matches(a, b);
b->destroy(b);
@@ -211,10 +211,10 @@ static id_match_t test_id_matches_one(identification_t *a, char *b_str)
bool test_id_matches()
{
identification_t *a;
-
+
a = identification_create_from_string(
"C=CH, E=martin@strongswan.org, CN=martin");
-
+
if (test_id_matches_one(a, "C=CH, E=martin@strongswan.org, CN=martin")
!= ID_MATCH_PERFECT)
{
diff --git a/src/charon/plugins/unit_tester/tests/test_med_db.c b/src/charon/plugins/unit_tester/tests/test_med_db.c
index da517958e..c5c15d1c2 100644
--- a/src/charon/plugins/unit_tester/tests/test_med_db.c
+++ b/src/charon/plugins/unit_tester/tests/test_med_db.c
@@ -36,7 +36,7 @@ bool test_med_db()
public_key_t *public;
auth_cfg_t *auth;
bool good = FALSE;
-
+
id = identification_create_from_encoding(ID_KEY_ID, keyid);
enumerator = charon->credentials->create_public_enumerator(
charon->credentials, KEY_ANY, id, NULL);
diff --git a/src/charon/plugins/unit_tester/tests/test_mutex.c b/src/charon/plugins/unit_tester/tests/test_mutex.c
index cb315276b..cfe00cc7c 100644
--- a/src/charon/plugins/unit_tester/tests/test_mutex.c
+++ b/src/charon/plugins/unit_tester/tests/test_mutex.c
@@ -46,7 +46,7 @@ static void* run(void* null)
if (locked > 1)
{
failed = TRUE;
- }
+ }
locked--;
mutex->unlock(mutex);
mutex->unlock(mutex);
@@ -64,9 +64,9 @@ bool test_mutex()
{
int i;
pthread_t threads[THREADS];
-
+
mutex = mutex_create(MUTEX_TYPE_RECURSIVE);
-
+
for (i = 0; i < 10; i++)
{
mutex->lock(mutex);
@@ -80,9 +80,9 @@ bool test_mutex()
{
mutex->unlock(mutex);
}
-
+
pthread_barrier_init(&barrier, NULL, THREADS);
-
+
for (i = 0; i < THREADS; i++)
{
pthread_create(&threads[i], NULL, run, NULL);
@@ -92,9 +92,9 @@ bool test_mutex()
pthread_join(threads[i], NULL);
}
pthread_barrier_destroy(&barrier);
-
+
mutex->destroy(mutex);
-
+
return !failed;
}
diff --git a/src/charon/plugins/unit_tester/tests/test_mysql.c b/src/charon/plugins/unit_tester/tests/test_mysql.c
index ff3d38ad8..cd63a5f78 100644
--- a/src/charon/plugins/unit_tester/tests/test_mysql.c
+++ b/src/charon/plugins/unit_tester/tests/test_mysql.c
@@ -31,7 +31,7 @@ bool test_mysql()
char *qtxt;
bool good = FALSE;
enumerator_t *enumerator;
-
+
db = lib->db->create(lib->db, "mysql://testuser:testpass@localhost/test");
if (!db)
{
diff --git a/src/charon/plugins/unit_tester/tests/test_pool.c b/src/charon/plugins/unit_tester/tests/test_pool.c
index f32cd5820..f9a776a82 100644
--- a/src/charon/plugins/unit_tester/tests/test_pool.c
+++ b/src/charon/plugins/unit_tester/tests/test_pool.c
@@ -27,33 +27,33 @@ static void* testing(void *thread)
int i;
host_t *addr[ALLOCS];
identification_t *id[ALLOCS];
-
+
/* prepare identities */
for (i = 0; i < ALLOCS; i++)
{
char buf[256];
-
+
snprintf(buf, sizeof(buf), "%d-%d@strongswan.org", (uintptr_t)thread, i);
id[i] = identification_create_from_string(buf);
}
-
+
/* allocate addresses */
for (i = 0; i < ALLOCS; i++)
{
- addr[i] = charon->attributes->acquire_address(charon->attributes,
+ addr[i] = charon->attributes->acquire_address(charon->attributes,
"test", id[i], NULL);
if (!addr[i])
{
return (void*)FALSE;
}
}
-
+
/* release addresses */
for (i = 0; i < ALLOCS; i++)
{
charon->attributes->release_address(charon->attributes, "test", addr[i], id[i]);
}
-
+
/* cleanup */
for (i = 0; i < ALLOCS; i++)
{
@@ -72,7 +72,7 @@ bool test_pool()
uintptr_t i;
void *res;
pthread_t thread[THREADS];
-
+
for (i = 0; i < THREADS; i++)
{
if (pthread_create(&thread[i], NULL, (void*)testing, (void*)i) < 0)
diff --git a/src/charon/plugins/unit_tester/tests/test_rsa_gen.c b/src/charon/plugins/unit_tester/tests/test_rsa_gen.c
index 1b7af63ee..a449112ec 100644
--- a/src/charon/plugins/unit_tester/tests/test_rsa_gen.c
+++ b/src/charon/plugins/unit_tester/tests/test_rsa_gen.c
@@ -26,7 +26,7 @@ bool test_rsa_gen()
private_key_t *private;
public_key_t *public;
u_int key_size;
-
+
for (key_size = 512; key_size <= 2048; key_size *= 2)
{
private = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
@@ -113,7 +113,7 @@ bool test_rsa_load_any()
{
chunk_t chunk = chunk_from_buf(public_any);
public_key_t *public;
-
+
public = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_ANY,
BUILD_BLOB_ASN1_DER, chunk,
BUILD_END);
diff --git a/src/charon/plugins/unit_tester/tests/test_sqlite.c b/src/charon/plugins/unit_tester/tests/test_sqlite.c
index d152fc594..4dcc5bad1 100644
--- a/src/charon/plugins/unit_tester/tests/test_sqlite.c
+++ b/src/charon/plugins/unit_tester/tests/test_sqlite.c
@@ -36,7 +36,7 @@ bool test_sqlite()
char *qtxt;
bool good = FALSE;
enumerator_t *enumerator;
-
+
db = lib->db->create(lib->db, "sqlite://" DBFILE);
if (!db)
{
diff --git a/src/charon/plugins/unit_tester/unit_tester.c b/src/charon/plugins/unit_tester/unit_tester.c
index c9651e601..3c39688c6 100644
--- a/src/charon/plugins/unit_tester/unit_tester.c
+++ b/src/charon/plugins/unit_tester/unit_tester.c
@@ -33,17 +33,17 @@ struct private_unit_tester_t {
};
struct unit_test_t {
-
+
/**
* name of the test
*/
char *name;
-
+
/**
* test function
*/
bool (*test)(void);
-
+
/**
* run the test?
*/
@@ -62,10 +62,10 @@ static unit_test_t tests[] = {
static void run_tests(private_unit_tester_t *this)
{
int i, run = 0, failed = 0, success = 0, skipped = 0;
-
+
DBG1(DBG_CFG, "running unit tests, %d tests registered",
sizeof(tests)/sizeof(unit_test_t));
-
+
for (i = 0; i < sizeof(tests)/sizeof(unit_test_t); i++)
{
if (tests[i].enabled)
@@ -106,11 +106,11 @@ static void destroy(private_unit_tester_t *this)
plugin_t *plugin_create()
{
private_unit_tester_t *this = malloc_thing(private_unit_tester_t);
-
+
this->public.plugin.destroy = (void(*)(plugin_t*))destroy;
-
+
run_tests(this);
-
+
return &this->public.plugin;
}
diff --git a/src/charon/plugins/unit_tester/unit_tester.h b/src/charon/plugins/unit_tester/unit_tester.h
index 33b13313d..79d5bc021 100644
--- a/src/charon/plugins/unit_tester/unit_tester.h
+++ b/src/charon/plugins/unit_tester/unit_tester.h
@@ -28,7 +28,7 @@ typedef struct unit_tester_t unit_tester_t;
/**
* Unit testing plugin.
*
- * The unit testing plugin runs tests on plugin initialization. Tests are
+ * The unit testing plugin runs tests on plugin initialization. Tests are
* defined in tests.h using the DEFINE_TEST macro. Implementation of the
* tests is done in the tests folder. Each test has uses a function which
* returns TRUE for success or FALSE for failure.