ike_sa_manager_t *isam;
} td;
-static void successful_thread(ike_sa_id_t *ike_sa_id)
+static void test1_thread(ike_sa_id_t *ike_sa_id)
{
ike_sa_t *ike_sa;
status_t status;
td.tester->assert_true(td.tester, (status == SUCCESS), "checkin of a requested ike_sa");
}
-static void failed_thread(ike_sa_id_t *ike_sa_id)
+
+static void test2_thread(ike_sa_id_t *ike_sa_id)
+{
+ ike_sa_t *ike_sa;
+ status_t status;
+
+ status = td.isam->checkout(td.isam, ike_sa_id, &ike_sa);
+ td.tester->assert_true(td.tester, (status == NOT_FOUND), "IKE_SA already deleted");
+}
+
+static void test3_thread(ike_sa_id_t *ike_sa_id)
{
ike_sa_t *ike_sa;
status_t status;
status = td.isam->checkout(td.isam, ike_sa_id, &ike_sa);
td.tester->assert_true(td.tester, (status == NOT_FOUND), "IKE_SA already deleted");
+
+ ike_sa_id->destroy(ike_sa_id);
}
+
+
+
void test_ike_sa_manager(tester_t *tester)
{
status_t status;
spi_t initiator, responder;
- ike_sa_id_t *ike_sa_id;
+ ike_sa_id_t *ike_sa_id, *sa_id;
ike_sa_t *ike_sa;
int thread_count = 200;
- int sa_count = 50;
+ int sa_count = 100;
int i;
pthread_t threads[thread_count];
-
/* First Test:
* we play initiator for IKE_SA_INIT first
* create an IKE_SA,
* this is usually done be the response from the communication partner,
* but we don't have one...
*/
- ike_sa_id->destroy(ike_sa_id);
- ike_sa_id = ike_sa->get_id(ike_sa);
responder.low = 123;
- ike_sa_id->set_responder_spi(ike_sa_id, responder);
+
+ sa_id = ike_sa->get_id(ike_sa);
+ sa_id->set_responder_spi(sa_id, responder);
/* check in, so we should have a "completed" sa, specified by ike_sa_id */
status = td.isam->checkin(td.isam, ike_sa);
tester->assert_true(tester, (status == SUCCESS), "checkin modified IKE_SA");
/* now we check it out and start some other threads */
status = td.isam->checkout(td.isam, ike_sa_id, &ike_sa);
tester->assert_true(tester, (status == SUCCESS), "checkout existing IKE_SA 1");
-
-
-
+
for (i = 0; i < thread_count; i++)
{
- if (pthread_create(&threads[i], NULL, (void*(*)(void*))successful_thread, (void*)ike_sa_id))
+ if (pthread_create(&threads[i], NULL, (void*(*)(void*))test1_thread, (void*)ike_sa_id))
{
/* failed, decrease list */
thread_count--;
pthread_join(threads[i], NULL);
}
- //ike_sa_id->destroy(ike_sa_id);
-
-
-
+ ike_sa_id->destroy(ike_sa_id);
/* Second Test:
* so we are the responder.
*
*/
-
memset(&initiator, 0, sizeof(initiator));
memset(&responder, 0, sizeof(responder));
tester->assert_true(tester, (status == SUCCESS), "checkout unexisting IKE_SA 2");
for (i = 0; i < thread_count; i++)
{
- if (pthread_create(&threads[i], NULL, (void*(*)(void*))failed_thread, (void*)ike_sa_id))
+ if (pthread_create(&threads[i], NULL, (void*(*)(void*))test2_thread, (void*)ike_sa_id))
{
/* failed, decrease list */
thread_count--;
pthread_join(threads[i], NULL);
}
- //ike_sa_id->destroy(ike_sa_id);
+ ike_sa_id->destroy(ike_sa_id);
/* Third Test:
* put in a lot of IKE_SAs, check it out, set a thread waiting
* and destroy the manager...
*/
-
+
memset(&initiator, 0, sizeof(initiator));
memset(&responder, 0, sizeof(responder));
status = td.isam->checkout(td.isam, ike_sa_id, &ike_sa);
tester->assert_true(tester, (status == SUCCESS), "checkout unexisting IKE_SA 3");
- if (pthread_create(&threads[i], NULL, (void*(*)(void*))failed_thread, (void*)ike_sa_id))
+ if (pthread_create(&threads[i], NULL, (void*(*)(void*))test3_thread, (void*)ike_sa_id))
{
/* failed, decrease list */
thread_count--;
}
- //ike_sa_id->destroy(ike_sa_id);
}
/* let them go acquiring */
pthread_join(threads[i], NULL);
}
+
}