diff options
author | Safey A.Halim <safey.allah@gmail.com> | 2011-01-16 21:51:12 +0000 |
---|---|---|
committer | Safey A.Halim <safey.allah@gmail.com> | 2011-01-16 21:51:12 +0000 |
commit | 08e3df5862d1ce437be0ba4eaaa0aa61a48b3658 (patch) | |
tree | ebaad98830b6b8c77b39990b213840960c4e161e | |
parent | edbbe838a5348d89c54e2f1036919da8d855dcb0 (diff) | |
download | gnunet-08e3df5862d1ce437be0ba4eaaa0aa61a48b3658.tar.gz gnunet-08e3df5862d1ce437be0ba4eaaa0aa61a48b3658.zip |
Expression Database API, and Action API (without implementation).
-rw-r--r-- | src/include/Makefile.am | 3 | ||||
-rw-r--r-- | src/include/gnunet_monkey_action.h | 50 | ||||
-rw-r--r-- | src/include/gnunet_monkey_edb.h | 33 | ||||
-rw-r--r-- | src/monkey/Makefile.am | 38 | ||||
-rw-r--r-- | src/monkey/action_api.c | 59 | ||||
-rw-r--r-- | src/monkey/edb_api.c | 64 | ||||
-rw-r--r-- | src/monkey/seaspider/org/gnunet/seaspider/ExpressionDatabaseHandler.java | 8 | ||||
-rw-r--r-- | src/monkey/test.db | bin | 0 -> 7168 bytes | |||
-rw-r--r-- | src/monkey/test_monkey_edb.c | 69 |
9 files changed, 281 insertions, 43 deletions
diff --git a/src/include/Makefile.am b/src/include/Makefile.am index 2bdc4e1fa..bdfa677c6 100644 --- a/src/include/Makefile.am +++ b/src/include/Makefile.am | |||
@@ -65,4 +65,5 @@ gnunetinclude_HEADERS = \ | |||
65 | gnunet_transport_plugin.h \ | 65 | gnunet_transport_plugin.h \ |
66 | gnunet_upnp_service.h \ | 66 | gnunet_upnp_service.h \ |
67 | gnunet_util_lib.h \ | 67 | gnunet_util_lib.h \ |
68 | gnunet_monkey_edb.h | 68 | gnunet_monkey_edb.h \ |
69 | gnunet_monkey_action.h | ||
diff --git a/src/include/gnunet_monkey_action.h b/src/include/gnunet_monkey_action.h new file mode 100644 index 000000000..da8f85396 --- /dev/null +++ b/src/include/gnunet_monkey_action.h | |||
@@ -0,0 +1,50 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet | ||
3 | (C) 2010, 2011 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file monkey/gnunet_monkey_action.h | ||
23 | * @brief Monkey API for actions taken by Monkey while debugging | ||
24 | */ | ||
25 | |||
26 | #ifndef GNUNET_MONKEY_ACTION_H | ||
27 | #define GNUNET_MONKEY_ACTION_H | ||
28 | |||
29 | #ifdef __cplusplus | ||
30 | extern "C" | ||
31 | { | ||
32 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
33 | } | ||
34 | #endif | ||
35 | #endif | ||
36 | |||
37 | int GNUNET_MONKEY_ACTION_report_file(); | ||
38 | int GNUNET_MONKEY_ACTION_report_email(); | ||
39 | int GNUNET_MONKEY_ACTION_rerun_with_valgrind(); | ||
40 | int GNUNET_MONKEY_ACTION_rerun_with_gdb(); | ||
41 | int GNUNET_MONKEY_ACTION_check_bug_redundancy(); | ||
42 | |||
43 | |||
44 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
45 | { | ||
46 | #endif | ||
47 | #ifdef __cplusplus | ||
48 | } | ||
49 | #endif | ||
50 | #endif | ||
diff --git a/src/include/gnunet_monkey_edb.h b/src/include/gnunet_monkey_edb.h index 380ba4ade..af5142a82 100644 --- a/src/include/gnunet_monkey_edb.h +++ b/src/include/gnunet_monkey_edb.h | |||
@@ -29,7 +29,7 @@ | |||
29 | #ifdef __cplusplus | 29 | #ifdef __cplusplus |
30 | extern "C" | 30 | extern "C" |
31 | { | 31 | { |
32 | #if 0 /* keep Emacsens' auto-indent happy */ | 32 | #if 0 /* keep Emacsens' auto-indent happy */ |
33 | } | 33 | } |
34 | #endif | 34 | #endif |
35 | #endif | 35 | #endif |
@@ -53,16 +53,16 @@ struct GNUNET_MONKEY_EDB_Context *GNUNET_MONKEY_EDB_connect (const char | |||
53 | * @param context context | 53 | * @param context context |
54 | * @return GNUNET_OK on success, GNUNET_NO on failure | 54 | * @return GNUNET_OK on success, GNUNET_NO on failure |
55 | */ | 55 | */ |
56 | int GNUNET_MONKEY_EDB_disconnect (struct GNUNET_MONKEY_EDB_Context *context); | 56 | int GNUNET_MONKEY_EDB_disconnect (struct GNUNET_MONKEY_EDB_Context *cntxt); |
57 | 57 | ||
58 | 58 | ||
59 | typedef int (*GNUNET_MONKEY_ExpressionIterator)(void *cls, const char *expression, int begin_line); | 59 | typedef int (*GNUNET_MONKEY_ExpressionIterator) (void *, int, char **, |
60 | char **); | ||
60 | 61 | ||
61 | 62 | ||
62 | /** | 63 | /** |
63 | * Update the context with a list of expressions. | 64 | * Run an SQLite query to retrieve those expressions that are previous to |
64 | * The list is the initializations of sub-expressions | 65 | * given expression and are in the same scope of the given expression |
65 | * of the expression pointed to by start_line_no and end_line_no | ||
66 | * For example, consider the following code snippet: | 66 | * For example, consider the following code snippet: |
67 | * { | 67 | * { |
68 | * struct Something whole; // line no.1 | 68 | * struct Something whole; // line no.1 |
@@ -71,29 +71,27 @@ typedef int (*GNUNET_MONKEY_ExpressionIterator)(void *cls, const char *expressio | |||
71 | * whole.part->member = 1; // line no.4 | 71 | * whole.part->member = 1; // line no.4 |
72 | * } | 72 | * } |
73 | * If the expression supplied to the function is that of line no.4 "whole.part->member = 1;" | 73 | * If the expression supplied to the function is that of line no.4 "whole.part->member = 1;" |
74 | * The returned list of expressions will be: whole.part = part (line no.3), | 74 | * The returned list of expressions will be: whole.part (line no.4), whole.part->member (line no.4), |
75 | * struct SomethingElse part (line no.2), and struct Something whole (line no.1), | 75 | * whole (line no.3), whole.part (line no.3), &part (line no.3), whole.part = &part (line no.3) |
76 | * which are the initialization expressions of the building components of the expression in question | 76 | * |
77 | * | 77 | * @param cntxt context containing the Expression Database handle. |
78 | * @param context the returned expessions will be available in it. | ||
79 | * expression_list_head, and expression_list_tail must be null, | ||
80 | * otherwise GNUNET_NO will be returned | ||
81 | * @param file_name path to the file in which the expression in question exists | 78 | * @param file_name path to the file in which the expression in question exists |
82 | * @param start_line_no expression beginning line | 79 | * @param start_line_no expression beginning line |
83 | * @param end_line_no expression end line | 80 | * @param end_line_no line number for the expression's scope end |
84 | * @param iter callback function, iterator for expressions returned from the Database | 81 | * @param iter callback function, iterator for expressions returned from the Database |
85 | * @param iter_cls closure for the expression iterator | 82 | * @param iter_cls closure for the expression iterator |
86 | * @return GNUNET_OK success, GNUNET_NO failure | 83 | * @return GNUNET_OK success, GNUNET_NO failure |
87 | */ | 84 | */ |
88 | int | 85 | int |
89 | GNUNET_MONKEY_EDB_get_expressions (struct GNUNET_MONKEY_EDB_Context *context, | 86 | GNUNET_MONKEY_EDB_get_expressions (struct GNUNET_MONKEY_EDB_Context *cntxt, |
90 | const char *file_name, int start_line_no, | 87 | const char *file_name, int start_line_no, |
91 | int end_line_no, | 88 | int end_line_no, |
92 | GNUNET_MONKEY_ExpressionIterator iter, void *iter_cls); | 89 | GNUNET_MONKEY_ExpressionIterator iter, |
90 | void *iter_cls); | ||
93 | 91 | ||
94 | 92 | ||
95 | 93 | ||
96 | #if 0 /* keep Emacsens' auto-indent happy */ | 94 | #if 0 /* keep Emacsens' auto-indent happy */ |
97 | { | 95 | { |
98 | #endif | 96 | #endif |
99 | #ifdef __cplusplus | 97 | #ifdef __cplusplus |
@@ -101,4 +99,3 @@ GNUNET_MONKEY_EDB_get_expressions (struct GNUNET_MONKEY_EDB_Context *context, | |||
101 | #endif | 99 | #endif |
102 | 100 | ||
103 | #endif | 101 | #endif |
104 | |||
diff --git a/src/monkey/Makefile.am b/src/monkey/Makefile.am index 39e5f8d5d..308a40866 100644 --- a/src/monkey/Makefile.am +++ b/src/monkey/Makefile.am | |||
@@ -14,6 +14,28 @@ if !MINGW | |||
14 | if HAVE_ESMTP | 14 | if HAVE_ESMTP |
15 | if HAVE_OPENSSL | 15 | if HAVE_OPENSSL |
16 | 16 | ||
17 | |||
18 | lib_LTLIBRARIES = libmonkeyedb.la \ | ||
19 | libmonkeyaction.la | ||
20 | |||
21 | libmonkeyedb_la_SOURCES = \ | ||
22 | edb_api.c \ | ||
23 | gnunet_monkey_edb.h | ||
24 | |||
25 | libmonkeyedb_la_LIBADD = \ | ||
26 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
27 | -lsqlite3 \ | ||
28 | $(GN_LIBINTL) $(XLIB) | ||
29 | |||
30 | libmonkeyaction_la_SOURCES = \ | ||
31 | action_api.c \ | ||
32 | gnunet_monkey_action.h | ||
33 | |||
34 | libmonkeyaction_la_LIBADD = \ | ||
35 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
36 | $(GN_LIBINTL) $(XLIB) | ||
37 | |||
38 | |||
17 | bin_PROGRAMS = \ | 39 | bin_PROGRAMS = \ |
18 | gnunet-monkey \ | 40 | gnunet-monkey \ |
19 | gnunet-service-monkey | 41 | gnunet-service-monkey |
@@ -39,11 +61,12 @@ gnunet_monkey_SOURCES = \ | |||
39 | gdbmi_thread.c \ | 61 | gdbmi_thread.c \ |
40 | gdbmi_var_obj.c \ | 62 | gdbmi_var_obj.c \ |
41 | gnunet-monkey.c \ | 63 | gnunet-monkey.c \ |
42 | mail_sender.c \ | 64 | mail_sender.c |
43 | edb_api.c | ||
44 | 65 | ||
45 | gnunet_monkey_LDADD = \ | 66 | gnunet_monkey_LDADD = \ |
46 | $(top_builddir)/src/util/libgnunetutil.la \ | 67 | $(top_builddir)/src/util/libgnunetutil.la \ |
68 | $(top_builddir)/src/monkey/libmonkeyedb.la \ | ||
69 | $(top_builddir)/src/monkey/libmonkeyaction.la \ | ||
47 | -lesmtp \ | 70 | -lesmtp \ |
48 | $(GN_LIBINTL) | 71 | $(GN_LIBINTL) |
49 | 72 | ||
@@ -59,13 +82,21 @@ bug_null_pointer_exception: | |||
59 | gcc -g -O0 -o bug_null_pointer_exception bug_null_pointer_exception.c | 82 | gcc -g -O0 -o bug_null_pointer_exception bug_null_pointer_exception.c |
60 | 83 | ||
61 | check_PROGRAMS = \ | 84 | check_PROGRAMS = \ |
62 | bug_null_pointer_exception | 85 | bug_null_pointer_exception \ |
86 | test_monkey_edb | ||
63 | #test_gnunet_monkey | 87 | #test_gnunet_monkey |
64 | 88 | ||
65 | if !DISABLE_TEST_RUN | 89 | if !DISABLE_TEST_RUN |
66 | # TESTS = $(check_SCRIPTS) | 90 | # TESTS = $(check_SCRIPTS) |
91 | TESTS = $(check_PROGRAMS) | ||
67 | endif | 92 | endif |
68 | 93 | ||
94 | test_monkey_edb_SOURCES = \ | ||
95 | test_monkey_edb.c | ||
96 | test_monkey_edb_LDADD = \ | ||
97 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
98 | $(top_builddir)/src/monkey/libmonkeyedb.la | ||
99 | |||
69 | #test_gnunet_monkey_SOURCES = \ | 100 | #test_gnunet_monkey_SOURCES = \ |
70 | #test_gnunet_monkey.c | 101 | #test_gnunet_monkey.c |
71 | #test_gnunet_monkey_LDADD = \ | 102 | #test_gnunet_monkey_LDADD = \ |
@@ -84,4 +115,3 @@ check_SCRIPTS = \ | |||
84 | endif | 115 | endif |
85 | endif | 116 | endif |
86 | endif | 117 | endif |
87 | |||
diff --git a/src/monkey/action_api.c b/src/monkey/action_api.c new file mode 100644 index 000000000..c1f39e788 --- /dev/null +++ b/src/monkey/action_api.c | |||
@@ -0,0 +1,59 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2010, 2011 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file monkey/action_api.c | ||
23 | * @brief Monkey API for actions taken by Monkey while debugging | ||
24 | */ | ||
25 | |||
26 | #include "platform.h" | ||
27 | #include "gnunet_common.h" | ||
28 | #include "gnunet_monkey_action.h" | ||
29 | |||
30 | |||
31 | int GNUNET_MONKEY_ACTION_report_file() | ||
32 | { | ||
33 | return GNUNET_OK; | ||
34 | } | ||
35 | |||
36 | |||
37 | int GNUNET_MONKEY_ACTION_report_email() | ||
38 | { | ||
39 | return GNUNET_OK; | ||
40 | } | ||
41 | |||
42 | |||
43 | |||
44 | int GNUNET_MONKEY_ACTION_rerun_with_valgrind() | ||
45 | { | ||
46 | return GNUNET_OK; | ||
47 | } | ||
48 | |||
49 | |||
50 | int GNUNET_MONKEY_ACTION_rerun_with_gdb() | ||
51 | { | ||
52 | return GNUNET_OK; | ||
53 | } | ||
54 | |||
55 | |||
56 | int GNUNET_MONKEY_ACTION_check_bug_redundancy() | ||
57 | { | ||
58 | return GNUNET_OK; | ||
59 | } | ||
diff --git a/src/monkey/edb_api.c b/src/monkey/edb_api.c index 3e7de2d09..78a340cd5 100644 --- a/src/monkey/edb_api.c +++ b/src/monkey/edb_api.c | |||
@@ -50,46 +50,76 @@ struct GNUNET_MONKEY_EDB_Context | |||
50 | struct GNUNET_MONKEY_EDB_Context * | 50 | struct GNUNET_MONKEY_EDB_Context * |
51 | GNUNET_MONKEY_EDB_connect (const char *db_file_name) | 51 | GNUNET_MONKEY_EDB_connect (const char *db_file_name) |
52 | { | 52 | { |
53 | /* TODO: Implementation */ | 53 | int err; |
54 | return NULL; | 54 | struct GNUNET_MONKEY_EDB_Context *ctxt = |
55 | GNUNET_malloc (sizeof (struct GNUNET_MONKEY_EDB_Context)); | ||
56 | |||
57 | err = sqlite3_open (db_file_name, &ctxt->db_handle); | ||
58 | if (err) | ||
59 | { | ||
60 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
61 | "Cannot open Expression Database. `%s'\n", | ||
62 | sqlite3_errmsg (ctxt->db_handle)); | ||
63 | return NULL; | ||
64 | } | ||
65 | return ctxt; | ||
55 | } | 66 | } |
56 | 67 | ||
57 | 68 | ||
58 | /** | 69 | /** |
59 | * Disconnect from Database, and cleanup resources | 70 | * Disconnect from Database, and cleanup resources |
60 | * | 71 | * |
61 | * @param context context | 72 | * @param context context containing the Expression Database handle |
62 | * @return GNUNET_OK on success, GNUNET_NO on failure | 73 | * @return GNUNET_OK on success, GNUNET_NO on failure |
63 | */ | 74 | */ |
64 | int | 75 | int |
65 | GNUNET_MONKEY_EDB_disconnect (struct GNUNET_MONKEY_EDB_Context *context) | 76 | GNUNET_MONKEY_EDB_disconnect (struct GNUNET_MONKEY_EDB_Context *cntxt) |
66 | { | 77 | { |
67 | /* TODO: Implementation */ | 78 | sqlite3_close (cntxt->db_handle); |
68 | return GNUNET_OK; | 79 | GNUNET_free (cntxt); |
80 | return GNUNET_OK; | ||
69 | } | 81 | } |
70 | 82 | ||
71 | 83 | ||
72 | /** | 84 | /** |
73 | * Update the context with a list of expressions. | 85 | * Run an SQLite query to retrieve those expressions that are previous to |
74 | * The list is the initializations of sub-expressions | 86 | * given expression and are in the same scope of the given expression |
75 | * of the expression pointed to by start_line_no and end_line_no | ||
76 | * | 87 | * |
77 | * @param context the returned expessions will be available in it. | 88 | * @param cntxt context containing the Expression Database handle. |
78 | * expression_list_head and expression_list_tail must be NULL, | ||
79 | * otherwise GNUNET_NO will be returned | ||
80 | * @param file_name path to the file in which the expression in question exists | 89 | * @param file_name path to the file in which the expression in question exists |
81 | * @param start_line_no expression beginning line | 90 | * @param start_line_no expression beginning line |
82 | * @param end_line_no expression end line | 91 | * @param end_line_no line number for the expression's scope end |
83 | * @param iter callback function, iterator for expressions returned from the Database | 92 | * @param iter callback function, iterator for expressions returned from the Database |
84 | * @param iter_cls closure for the expression iterator | 93 | * @param iter_cls closure for the expression iterator |
85 | * @return GNUNET_OK success, GNUNET_NO failure | 94 | * @return GNUNET_OK success, GNUNET_NO failure |
86 | */ | 95 | */ |
87 | int | 96 | int |
88 | GNUNET_MONKEY_EDB_get_expressions (struct GNUNET_MONKEY_EDB_Context *context, | 97 | GNUNET_MONKEY_EDB_get_expressions (struct GNUNET_MONKEY_EDB_Context *cntxt, |
89 | const char *file_name, int start_line_no, | 98 | const char *file_name, int start_line_no, |
90 | int end_line_no, | 99 | int end_line_no, |
91 | GNUNET_MONKEY_ExpressionIterator iter, void *iter_cls) | 100 | GNUNET_MONKEY_ExpressionIterator iter, |
101 | void *iter_cls) | ||
92 | { | 102 | { |
93 | /* TODO: Implementation */ | 103 | int err; |
94 | return GNUNET_OK; | 104 | char *errMsg; |
105 | char *query; | ||
106 | if (asprintf | ||
107 | (&query, | ||
108 | "select expr_syntax, start_lineno from Expression where file_name = \'%s\' and start_lineno < %d and end_lineno = %d", | ||
109 | file_name, start_line_no, end_line_no) == -1) | ||
110 | { | ||
111 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
112 | "Memory allocation problem occurred."); | ||
113 | return GNUNET_NO; | ||
114 | } | ||
115 | |||
116 | err = sqlite3_exec (cntxt->db_handle, query, iter, iter_cls, &errMsg); | ||
117 | if (err) | ||
118 | { | ||
119 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
120 | "Error occurred while executing Database query. `%s'", | ||
121 | errMsg); | ||
122 | return GNUNET_NO; | ||
123 | } | ||
124 | return GNUNET_OK; | ||
95 | } | 125 | } |
diff --git a/src/monkey/seaspider/org/gnunet/seaspider/ExpressionDatabaseHandler.java b/src/monkey/seaspider/org/gnunet/seaspider/ExpressionDatabaseHandler.java index 2c1df1b54..b9a1e2cf8 100644 --- a/src/monkey/seaspider/org/gnunet/seaspider/ExpressionDatabaseHandler.java +++ b/src/monkey/seaspider/org/gnunet/seaspider/ExpressionDatabaseHandler.java | |||
@@ -38,7 +38,7 @@ public class ExpressionDatabaseHandler { | |||
38 | private static Stack<HashMap<String, Integer>> expressionStack = new Stack<HashMap<String, Integer>>(); | 38 | private static Stack<HashMap<String, Integer>> expressionStack = new Stack<HashMap<String, Integer>>(); |
39 | 39 | ||
40 | public static void createExpressionDatabase(String databasePath) { | 40 | public static void createExpressionDatabase(String databasePath) { |
41 | String createTableQuery = "CREATE TABLE Expression ( expr_ID INT NOT NULL PRIMARY KEY , " | 41 | String createTableQuery = "CREATE TABLE Expression ( expr_ID INTEGER PRIMARY KEY AUTOINCREMENT, " |
42 | + "file_name TEXT NOT NULL , expr_syntax TEXT NOT NULL ," | 42 | + "file_name TEXT NOT NULL , expr_syntax TEXT NOT NULL ," |
43 | + " start_lineno INT, end_lineno INT)"; | 43 | + " start_lineno INT, end_lineno INT)"; |
44 | 44 | ||
@@ -79,7 +79,7 @@ public class ExpressionDatabaseHandler { | |||
79 | if (DEBUG) | 79 | if (DEBUG) |
80 | System.out.println(fileName + ":[" + startLineNo + "-" | 80 | System.out.println(fileName + ":[" + startLineNo + "-" |
81 | + endLineNo + "]: " + expressionSyntax); | 81 | + endLineNo + "]: " + expressionSyntax); |
82 | table.insert(currentFileName, expressionSyntax, startLineNo, | 82 | table.insert(null, currentFileName, expressionSyntax, startLineNo, |
83 | endLineNo); | 83 | endLineNo); |
84 | } catch (SqlJetException e) { | 84 | } catch (SqlJetException e) { |
85 | e.printStackTrace(); | 85 | e.printStackTrace(); |
@@ -195,7 +195,9 @@ public class ExpressionDatabaseHandler { | |||
195 | .println("Error:Database handle is not initialized. Program will exit now!"); | 195 | .println("Error:Database handle is not initialized. Program will exit now!"); |
196 | System.exit(1); | 196 | System.exit(1); |
197 | } | 197 | } |
198 | 198 | ||
199 | String[] fileNameArr = fileName.split("src/"); | ||
200 | fileName = fileNameArr[1]; | ||
199 | insertExpression(fileName, expressionSyntax, startLineNo, endLineNo); | 201 | insertExpression(fileName, expressionSyntax, startLineNo, endLineNo); |
200 | } | 202 | } |
201 | } | 203 | } |
diff --git a/src/monkey/test.db b/src/monkey/test.db new file mode 100644 index 000000000..6d15e709f --- /dev/null +++ b/src/monkey/test.db | |||
Binary files differ | |||
diff --git a/src/monkey/test_monkey_edb.c b/src/monkey/test_monkey_edb.c new file mode 100644 index 000000000..b418bee9a --- /dev/null +++ b/src/monkey/test_monkey_edb.c | |||
@@ -0,0 +1,69 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2010 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file monkey/test_monkey_edb.c | ||
22 | * @brief testcase for edb_api.c | ||
23 | */ | ||
24 | #include "platform.h" | ||
25 | #include "gnunet_common.h" | ||
26 | #include "gnunet_monkey_edb.h" | ||
27 | |||
28 | |||
29 | static const char *ref[16] = | ||
30 | { "args", "32", "argv", "32", "whole", "42", "whole.member", "42", | ||
31 | "whole.member=1", "42", "whole.part", "43", "&part", "43", | ||
32 | "whole.part=&part", "43" | ||
33 | }; | ||
34 | |||
35 | static int refCount = 0; | ||
36 | static int ret = 1; | ||
37 | |||
38 | int | ||
39 | expressionIterator (void *cls, int colNum, char **colValues, char **colNames) | ||
40 | { | ||
41 | int i; | ||
42 | for (i = 0; i < colNum; i++) | ||
43 | { | ||
44 | if (strcmp (colValues[i], ref[refCount]) != 0) | ||
45 | return 1; | ||
46 | refCount++; | ||
47 | } | ||
48 | |||
49 | return 0; | ||
50 | } | ||
51 | |||
52 | |||
53 | int | ||
54 | main (int args, const char *argv[]) | ||
55 | { | ||
56 | struct GNUNET_MONKEY_EDB_Context *cntxt; | ||
57 | cntxt = GNUNET_MONKEY_EDB_connect ("test.db"); | ||
58 | ret = | ||
59 | GNUNET_MONKEY_EDB_get_expressions (cntxt, | ||
60 | "monkey/seaspider/SeaspiderTest.c", 44, | ||
61 | 83, &expressionIterator, NULL); | ||
62 | GNUNET_MONKEY_EDB_disconnect (cntxt); | ||
63 | |||
64 | if (ret == GNUNET_OK) | ||
65 | { | ||
66 | return 0; | ||
67 | } | ||
68 | return 1; | ||
69 | } | ||