[evolution-data-server/treitter-client-gdbus] Add tests to stress-test the addressbook factory.
- From: Travis Reitter <treitter src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [evolution-data-server/treitter-client-gdbus] Add tests to stress-test the addressbook factory.
- Date: Tue, 29 Dec 2009 01:20:40 +0000 (UTC)
commit fbbef1e7240dba046eda5ef0bf8e236ce8ed1bc6
Author: Travis Reitter <treitter gmail com>
Date: Mon Dec 28 17:16:09 2009 -0800
Add tests to stress-test the addressbook factory.
addressbook/tests/ebook/Makefile.am | 9 +++++
addressbook/tests/ebook/ebook-test-utils.c | 25 +++++++++----
addressbook/tests/ebook/ebook-test-utils.h | 3 ++
.../tests/ebook/test-ebook-stress-factory--fifo.c | 33 ++++++++++++++++++
.../ebook/test-ebook-stress-factory--serial.c | 29 ++++++++++++++++
.../ebook/test-ebook-stress-factory--single-book.c | 35 ++++++++++++++++++++
6 files changed, 126 insertions(+), 8 deletions(-)
---
diff --git a/addressbook/tests/ebook/Makefile.am b/addressbook/tests/ebook/Makefile.am
index 5a476de..cf04e2d 100644
--- a/addressbook/tests/ebook/Makefile.am
+++ b/addressbook/tests/ebook/Makefile.am
@@ -35,6 +35,9 @@ TESTS = \
test-ebook-remove-contact \
test-ebook-remove-contact-by-id \
test-ebook-remove-contacts \
+ test-ebook-stress-factory--serial \
+ test-ebook-stress-factory--fifo \
+ test-ebook-stress-factory--single-book \
$(NULL)
noinst_PROGRAMS = \
@@ -91,6 +94,12 @@ test_ebook_remove_contact_by_id_LDADD=$(TEST_LIBS)
test_ebook_remove_contact_by_id_CPPFLAGS=$(TEST_CPPFLAGS)
test_ebook_remove_contacts_LDADD=$(TEST_LIBS)
test_ebook_remove_contacts_CPPFLAGS=$(TEST_CPPFLAGS)
+test_ebook_stress_factory__fifo_LDADD=$(TEST_LIBS)
+test_ebook_stress_factory__fifo_CPPFLAGS=$(TEST_CPPFLAGS)
+test_ebook_stress_factory__serial_LDADD=$(TEST_LIBS)
+test_ebook_stress_factory__serial_CPPFLAGS=$(TEST_CPPFLAGS)
+test_ebook_stress_factory__single_book_LDADD=$(TEST_LIBS)
+test_ebook_stress_factory__single_book_CPPFLAGS=$(TEST_CPPFLAGS)
test_changes_LDADD=$(TEST_LIBS)
test_changes_CPPFLAGS=$(TEST_CPPFLAGS)
test_categories_LDADD=$(TEST_LIBS)
diff --git a/addressbook/tests/ebook/ebook-test-utils.c b/addressbook/tests/ebook/ebook-test-utils.c
index 66c73cc..46e03c2 100644
--- a/addressbook/tests/ebook/ebook-test-utils.c
+++ b/addressbook/tests/ebook/ebook-test-utils.c
@@ -624,6 +624,22 @@ ebook_test_utils_book_async_remove_contacts (EBook *book,
}
EBook*
+ebook_test_utils_book_new_from_uri (const char *uri)
+{
+ EBook *book;
+ GError *error = NULL;
+
+ test_print ("loading addressbook\n");
+ book = e_book_new_from_uri (uri, &error);
+ if (!book) {
+ g_error ("failed to create addressbook: `%s': %s", uri,
+ error->message);
+ }
+
+ return book;
+}
+
+EBook*
ebook_test_utils_book_new_temp (char **uri)
{
EBook *book;
@@ -643,14 +659,7 @@ ebook_test_utils_book_new_temp (char **uri)
}
g_free (file_template);
- /* create a temp addressbook in /tmp */
- test_print ("loading addressbook\n");
- book = e_book_new_from_uri (uri_result, &error);
- if (!book) {
- g_warning ("failed to create addressbook: `%s': %s", *uri,
- error->message);
- exit(1);
- }
+ book = ebook_test_utils_book_new_from_uri (uri_result);
if (uri)
*uri = g_strdup (uri_result);
diff --git a/addressbook/tests/ebook/ebook-test-utils.h b/addressbook/tests/ebook/ebook-test-utils.h
index 5cb36b7..47f33eb 100644
--- a/addressbook/tests/ebook/ebook-test-utils.h
+++ b/addressbook/tests/ebook/ebook-test-utils.h
@@ -55,6 +55,9 @@ ebook_test_utils_contacts_are_equal_shallow (EContact *a,
EContact *b);
EBook*
+ebook_test_utils_book_new_from_uri (const char *uri);
+
+EBook*
ebook_test_utils_book_new_temp (char **uri);
const char*
diff --git a/addressbook/tests/ebook/test-ebook-stress-factory--fifo.c b/addressbook/tests/ebook/test-ebook-stress-factory--fifo.c
new file mode 100644
index 0000000..cf8e03e
--- /dev/null
+++ b/addressbook/tests/ebook/test-ebook-stress-factory--fifo.c
@@ -0,0 +1,33 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <stdlib.h>
+#include <libebook/e-book.h>
+
+#include "ebook-test-utils.h"
+
+#define NUM_BOOKS 200
+
+gint
+main (gint argc, gchar **argv)
+{
+ char *uri = NULL;
+ EBook *books[NUM_BOOKS];
+ gint i;
+
+ g_type_init ();
+
+ /* Create and open many books; then remove each of them */
+
+ for (i = 0; i < NUM_BOOKS; i++) {
+ books[i] = ebook_test_utils_book_new_temp (&uri);
+ ebook_test_utils_book_open (books[i], FALSE);
+
+ g_free (uri);
+ }
+
+ for (i = 0; i < NUM_BOOKS; i++) {
+ ebook_test_utils_book_remove (books[i]);
+ }
+
+ return 0;
+}
diff --git a/addressbook/tests/ebook/test-ebook-stress-factory--serial.c b/addressbook/tests/ebook/test-ebook-stress-factory--serial.c
new file mode 100644
index 0000000..64bfc34
--- /dev/null
+++ b/addressbook/tests/ebook/test-ebook-stress-factory--serial.c
@@ -0,0 +1,29 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <libebook/e-book.h>
+
+#include "ebook-test-utils.h"
+
+#define NUM_BOOKS 200
+
+gint
+main (gint argc, gchar **argv)
+{
+ char *uri = NULL;
+ gint i;
+
+ g_type_init ();
+
+ /* Serially create, open, (close), and remove many books */
+ for (i = 0; i < NUM_BOOKS; i++) {
+ EBook *book;
+
+ book = ebook_test_utils_book_new_temp (&uri);
+ ebook_test_utils_book_open (book, FALSE);
+ ebook_test_utils_book_remove (book);
+
+ g_free (uri);
+ }
+
+ return 0;
+}
diff --git a/addressbook/tests/ebook/test-ebook-stress-factory--single-book.c b/addressbook/tests/ebook/test-ebook-stress-factory--single-book.c
new file mode 100644
index 0000000..9e3e9be
--- /dev/null
+++ b/addressbook/tests/ebook/test-ebook-stress-factory--single-book.c
@@ -0,0 +1,35 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+#include <stdlib.h>
+#include <libebook/e-book.h>
+
+#include "ebook-test-utils.h"
+
+#define NUM_OPENS 200
+
+gint
+main (gint argc, gchar **argv)
+{
+ char *uri = NULL;
+ EBook *book;
+ gint i;
+
+ g_type_init ();
+
+ book = ebook_test_utils_book_new_temp (&uri);
+ g_object_unref (book);
+
+ /* open and close the same book repeatedly */
+ for (i = 0; i < NUM_OPENS-1; i++) {
+ book = ebook_test_utils_book_new_from_uri (uri);
+ ebook_test_utils_book_open (book, FALSE);
+ g_object_unref (book);
+ }
+
+ book = ebook_test_utils_book_new_from_uri (uri);
+ ebook_test_utils_book_remove (book);
+
+ g_free (uri);
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]