unit-tests: perform a first ECDSA test case if ECDSA is supported

This commit is contained in:
Martin Willi
2013-06-21 10:53:21 +02:00
parent 200f38ad4c
commit d18ff88faf
4 changed files with 58 additions and 1 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ test_runner_SOURCES = \
test_runner.c test_runner.h test_suite.h \
test_linked_list.c test_enumerator.c test_linked_list_enumerator.c \
test_bio_reader.c test_bio_writer.c test_chunk.c test_enum.c test_hashtable.c \
test_identification.c test_threading.c test_utils.c test_vectors.c
test_identification.c test_threading.c test_utils.c test_vectors.c test_ecdsa.c
test_runner_CFLAGS = \
-I$(top_srcdir)/src/libstrongswan \
+52
View File
@@ -0,0 +1,52 @@
/*
* Copyright (C) 2013 Martin Willi
* Copyright (C) 2013 revosec AG
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include "test_suite.h"
/**
* ECDSA key sizes to test
*/
static int key_sizes[] = {
256, 384, 521,
};
START_TEST(test_gen)
{
private_key_t *privkey;
public_key_t *pubkey;
privkey = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_ECDSA,
BUILD_KEY_SIZE, key_sizes[_i], BUILD_END);
ck_assert(privkey != NULL);
pubkey = privkey->get_public_key(privkey);
ck_assert(pubkey != NULL);
pubkey->destroy(pubkey);
privkey->destroy(privkey);
}
END_TEST
Suite *ecdsa_suite_create()
{
Suite *s;
TCase *tc;
s = suite_create("ecdsa");
tc = tcase_create("generate");
tcase_add_loop_test(tc, test_gen, 0, countof(key_sizes));
suite_add_tcase(s, tc);
return s;
}
+4
View File
@@ -83,6 +83,10 @@ int main()
srunner_add_suite(sr, threading_suite_create());
srunner_add_suite(sr, utils_suite_create());
srunner_add_suite(sr, vectors_suite_create());
if (has_feature(PLUGIN_DEPENDS(PRIVKEY_GEN, KEY_ECDSA)))
{
srunner_add_suite(sr, ecdsa_suite_create());
}
srunner_run_all(sr, CK_NORMAL);
nf = srunner_ntests_failed(sr);
+1
View File
@@ -30,5 +30,6 @@ Suite *identification_suite_create();
Suite *threading_suite_create();
Suite *utils_suite_create();
Suite *vectors_suite_create();
Suite *ecdsa_suite_create();
#endif /** TEST_RUNNER_H_ */