Revision 1847
| trunk/nntpgrab_core/download_queue.c (revision 1847) | ||
|---|---|---|
| 864 | 864 | 
                  {
                 | 
              
| 865 | 865 | 
                  GList *list;  | 
              
| 866 | 866 | 
                  NNTPCollection *collection;  | 
              
| 867 | 
                  int i;  | 
              |
| 867 | 868 | 
                   | 
              
| 868 | 869 | 
                  g_static_mutex_lock(&mutex);  | 
              
| 869 | 870 | 
                   | 
              
| ... | ... | |
| 918 | 919 | 
                   | 
              
| 919 | 920 | 
                  download_thread_awaken_if_needed();  | 
              
| 920 | 921 | 
                   | 
              
| 922 | 
                  /* We can't rely on the contents of the server positions cache, so reset it */  | 
              |
| 923 | 
                              for (i = 0; i < MAX_NNTP_SERVERS; i++) {
                 | 
              |
| 924 | 
                  reset_server_positions(i);  | 
              |
| 925 | 
                  }  | 
              |
| 926 | 
                   | 
              |
| 921 | 927 | 
                  return TRUE;  | 
              
| 922 | 928 | 
                  }  | 
              
| 923 | 929 | 
                   | 
              
| ... | ... | |
| 1814 | 1820 | 
                  GList *list= NULL;  | 
              
| 1815 | 1821 | 
                  GList *list2 = NULL;  | 
              
| 1816 | 1822 | 
                  GList *par2files = NULL;  | 
              
| 1823 | 
                  int i;  | 
              |
| 1817 | 1824 | 
                   | 
              
| 1818 | 1825 | 
                  /* Only download optional PAR2 files when the intelligent PAR2 downloading feature is enabled */  | 
              
| 1819 | 1826 | 
                      if (!opts.enable_intelligent_par2_downloading) {
                 | 
              
| ... | ... | |
| 1915 | 1922 | 
                  list = g_list_next(list);  | 
              
| 1916 | 1923 | 
                  }  | 
              
| 1917 | 1924 | 
                  g_list_free(par2files);  | 
              
| 1925 | 
                   | 
              |
| 1926 | 
                  /* We can't rely on the contents of the server positions cache, so reset it */  | 
              |
| 1927 | 
                      for (i = 0; i < MAX_NNTP_SERVERS; i++) {
                 | 
              |
| 1928 | 
                  reset_server_positions(i);  | 
              |
| 1929 | 
                  }  | 
              |
| 1918 | 1930 | 
                  }  | 
              
| 1919 | 1931 | 
                   | 
              
| 1920 | 1932 | 
                  void  | 
              
| trunk/tests/test_download_queue_one_server.c (revision 1847) | ||
|---|---|---|
| 1 | 
                  /*  | 
              |
| 2 | 
                  Copyright (C) 2005-2011 Erik van Pienbroek  | 
              |
| 3 | 
                   | 
              |
| 4 | 
                  This program is free software; you can redistribute it and/or modify  | 
              |
| 5 | 
                  it under the terms of the GNU General Public License as published by  | 
              |
| 6 | 
                  the Free Software Foundation; either version 2 of the License, or  | 
              |
| 7 | 
                  (at your option) any later version.  | 
              |
| 8 | 
                   | 
              |
| 9 | 
                  This program is distributed in the hope that it will be useful,  | 
              |
| 10 | 
                  but WITHOUT ANY WARRANTY; without even the implied warranty of  | 
              |
| 11 | 
                  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  | 
              |
| 12 | 
                  GNU General Public License for more details.  | 
              |
| 13 | 
                   | 
              |
| 14 | 
                  You should have received a copy of the GNU General Public License  | 
              |
| 15 | 
                  along with this program; if not, write to the Free Software  | 
              |
| 16 | 
                  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  | 
              |
| 17 | 
                  */  | 
              |
| 18 | 
                   | 
              |
| 19 | 
                  #include  | 
              |
| 20 | 
                  #include  | 
              |
| 21 | 
                  #include  | 
              |
| 22 | 
                   | 
              |
| 23 | 
                  #include "common.h"  | 
              |
| 24 | 
                  #include "test_download_queue.h"  | 
              |
| 25 | 
                   | 
              |
| 26 | 
                  #include "nntpgrab_utils.h"  | 
              |
| 27 | 
                  #include "download_queue.h"  | 
              |
| 28 | 
                   | 
              |
| 29 | 
                  void  | 
              |
| 30 | 
                  test_download_queue_setup_one_server_before(void *data, gconstpointer user_data)  | 
              |
| 31 | 
                  {
                 | 
              |
| 32 | 
                  char *errmsg = NULL;  | 
              |
| 33 | 
                  NGConfigServer server;  | 
              |
| 34 | 
                   | 
              |
| 35 | 
                  g_assert(configuration_get_avail_servers(config) == NULL);  | 
              |
| 36 | 
                   | 
              |
| 37 | 
                  memset(&server, 0, sizeof(server));  | 
              |
| 38 | 
                  strcpy(server.servername, "server1");  | 
              |
| 39 | 
                  strcpy(server.hostname, "host1");  | 
              |
| 40 | 
                  server.port = 119;  | 
              |
| 41 | 
                  server.enabled = TRUE;  | 
              |
| 42 | 
                  server.max_threads = 3;  | 
              |
| 43 | 
                  server.priority = SERVER_PRIORITY_HIGH;  | 
              |
| 44 | 
                   | 
              |
| 45 | 
                      if (!configuration_add_server(config, server, &errmsg)) {
                 | 
              |
| 46 | 
                          FAIL_TEST("Unable to add server: %s\n", errmsg);
                 | 
              |
| 47 | 
                  g_free(errmsg);  | 
              |
| 48 | 
                  return;  | 
              |
| 49 | 
                  }  | 
              |
| 50 | 
                   | 
              |
| 51 | 
                  fill_queue_with_dummy_data();  | 
              |
| 52 | 
                  }  | 
              |
| 53 | 
                   | 
              |
| 54 | 
                  void  | 
              |
| 55 | 
                  test_download_queue_setup_one_server_after(void *data, gconstpointer user_data)  | 
              |
| 56 | 
                  {
                 | 
              |
| 57 | 
                  char *errmsg = NULL;  | 
              |
| 58 | 
                  NGConfigServer server;  | 
              |
| 59 | 
                   | 
              |
| 60 | 
                  g_assert(configuration_get_avail_servers(config) == NULL);  | 
              |
| 61 | 
                   | 
              |
| 62 | 
                  memset(&server, 0, sizeof(server));  | 
              |
| 63 | 
                  strcpy(server.servername, "server1");  | 
              |
| 64 | 
                  strcpy(server.hostname, "host1");  | 
              |
| 65 | 
                  server.port = 119;  | 
              |
| 66 | 
                  server.enabled = TRUE;  | 
              |
| 67 | 
                  server.max_threads = 1;  | 
              |
| 68 | 
                  server.priority = SERVER_PRIORITY_HIGH;  | 
              |
| 69 | 
                   | 
              |
| 70 | 
                  fill_queue_with_dummy_data();  | 
              |
| 71 | 
                   | 
              |
| 72 | 
                      if (!configuration_add_server(config, server, &errmsg)) {
                 | 
              |
| 73 | 
                          FAIL_TEST("Unable to add server: %s\n", errmsg);
                 | 
              |
| 74 | 
                  g_free(errmsg);  | 
              |
| 75 | 
                  return;  | 
              |
| 76 | 
                  }  | 
              |
| 77 | 
                  }  | 
              |
| 78 | 
                   | 
              |
| 79 | 
                  void  | 
              |
| 80 | 
                  test_download_queue_teardown_one_server(void *data, gconstpointer user_data)  | 
              |
| 81 | 
                  {
                 | 
              |
| 82 | 
                  char *errmsg = NULL;  | 
              |
| 83 | 
                   | 
              |
| 84 | 
                  g_assert(configuration_get_avail_servers(config) != NULL);  | 
              |
| 85 | 
                   | 
              |
| 86 | 
                  drop_dummy_data_from_queue();  | 
              |
| 87 | 
                   | 
              |
| 88 | 
                      if (!configuration_del_server(config, "server1", &errmsg)) {
                 | 
              |
| 89 | 
                          FAIL_TEST("Unable to remove server: %s\n", errmsg);
                 | 
              |
| 90 | 
                  g_free(errmsg);  | 
              |
| 91 | 
                  return;  | 
              |
| 92 | 
                  }  | 
              |
| 93 | 
                  }  | 
              |
| 94 | 
                  static void  | 
              |
| 95 | 
                  test_download_queue_one_server_generic(gboolean all_available)  | 
              |
| 96 | 
                  {
                 | 
              |
| 97 | 
                  /* There should be 10 files with 4 parts each in the download queue now */  | 
              |
| 98 | 
                  int i, j;  | 
              |
| 99 | 
                   | 
              |
| 100 | 
                  NNTPCollection *prev_collection = NULL;  | 
              |
| 101 | 
                  NNTPFile *prev_file = NULL;  | 
              |
| 102 | 
                   | 
              |
| 103 | 
                  NNTPCollection *collection = NULL;  | 
              |
| 104 | 
                  NNTPFile *file = NULL;  | 
              |
| 105 | 
                  NNTPPart *part = NULL;  | 
              |
| 106 | 
                  gboolean nothing_to_download_or_active = FALSE;  | 
              |
| 107 | 
                   | 
              |
| 108 | 
                  GList *list, *files = NULL;  | 
              |
| 109 | 
                   | 
              |
| 110 | 
                      for (i = 1; i <= 10; i++) {
                 | 
              |
| 111 | 
                  prev_file = NULL;  | 
              |
| 112 | 
                   | 
              |
| 113 | 
                          for (j = 1; j <= 4; j++) {
                 | 
              |
| 114 | 
                  /* There is 1 server configured at the moment, so a request for the next part for server_id 0  | 
              |
| 115 | 
                  * should return TRUE and nothing_do_download should_or_active be FALSE */  | 
              |
| 116 | 
                              if (!download_queue_get_next_part_to_download(&collection, &file, &part, 0, ¬hing_to_download_or_active)) {
                 | 
              |
| 117 | 
                                  g_test_message("nothing_to_download = %i", nothing_to_download_or_active);
                 | 
              |
| 118 | 
                                  FAIL_TEST("download_queue_get_next_part_to_download returned FALSE while it isn't expected");
                 | 
              |
| 119 | 
                  return;  | 
              |
| 120 | 
                              } else {
                 | 
              |
| 121 | 
                                  char *expected_subject = g_strdup_printf("file %i", i);
                 | 
              |
| 122 | 
                   | 
              |
| 123 | 
                  g_assert_cmpint(nothing_to_download_or_active, ==, FALSE);  | 
              |
| 124 | 
                  g_assert(collection != NULL);  | 
              |
| 125 | 
                  g_assert(file != NULL);  | 
              |
| 126 | 
                  g_assert(part != NULL);  | 
              |
| 127 | 
                   | 
              |
| 128 | 
                  g_assert_cmpint(part->part_num, ==, j);  | 
              |
| 129 | 
                  g_assert_cmpstr(file->subject, ==, expected_subject);  | 
              |
| 130 | 
                   | 
              |
| 131 | 
                  g_free(expected_subject);  | 
              |
| 132 | 
                   | 
              |
| 133 | 
                                  if (prev_collection == NULL) {
                 | 
              |
| 134 | 
                  prev_collection = collection;  | 
              |
| 135 | 
                                  } else {
                 | 
              |
| 136 | 
                  g_assert(prev_collection == collection);  | 
              |
| 137 | 
                  }  | 
              |
| 138 | 
                   | 
              |
| 139 | 
                                  if (prev_file == NULL) {
                 | 
              |
| 140 | 
                  prev_file = file;  | 
              |
| 141 | 
                  files = g_list_append(files, file);  | 
              |
| 142 | 
                                  } else {
                 | 
              |
| 143 | 
                  g_assert(prev_file == file);  | 
              |
| 144 | 
                  }  | 
              |
| 145 | 
                  }  | 
              |
| 146 | 
                   | 
              |
| 147 | 
                  /* Update the status of the part */  | 
              |
| 148 | 
                              if (!all_available && j % 2 == 0) {
                 | 
              |
| 149 | 
                  /* Indicate the every second part isn't available on the server and it shouldn't be retried again */  | 
              |
| 150 | 
                                  download_queue_update_part_status("server1", 0, collection, file, part, 0, FALSE, FALSE, TRUE);
                 | 
              |
| 151 | 
                              } else {
                 | 
              |
| 152 | 
                  /* Indicate that the file was downloaded succesfully */  | 
              |
| 153 | 
                                  download_queue_update_part_status("server1", 0, collection, file, part, 0, TRUE, FALSE, FALSE);
                 | 
              |
| 154 | 
                  }  | 
              |
| 155 | 
                   | 
              |
| 156 | 
                  collection = NULL;  | 
              |
| 157 | 
                  file = NULL;  | 
              |
| 158 | 
                  part = NULL;  | 
              |
| 159 | 
                  }  | 
              |
| 160 | 
                  }  | 
              |
| 161 | 
                   | 
              |
| 162 | 
                  /* We processed all files now. If we try to request another part it should indicate that there's nothing to download anymore */  | 
              |
| 163 | 
                      if (!download_queue_get_next_part_to_download(&collection, &file, &part, 0, ¬hing_to_download_or_active)) {
                 | 
              |
| 164 | 
                  /* Nothing is returned which is good */  | 
              |
| 165 | 
                  /* The flag nothing_to_download_or_active should be FALSE as all files are downloaded, but not decoded yet */  | 
              |
| 166 | 
                  g_assert_cmpint(nothing_to_download_or_active, ==, FALSE);  | 
              |
| 167 | 
                  g_assert(collection == NULL);  | 
              |
| 168 | 
                  g_assert(file == NULL);  | 
              |
| 169 | 
                  g_assert(part == NULL);  | 
              |
| 170 | 
                      } else {
                 | 
              |
| 171 | 
                          FAIL_TEST("download_queue_get_next_part_to_download returned TRUE while it isn't expected");
                 | 
              |
| 172 | 
                  return;  | 
              |
| 173 | 
                  }  | 
              |
| 174 | 
                   | 
              |
| 175 | 
                  /* Mark all files as finished (downloaded+decoded) */  | 
              |
| 176 | 
                  list = files;  | 
              |
| 177 | 
                      while (list) {
                 | 
              |
| 178 | 
                  file = (NNTPFile*) list->data;  | 
              |
| 179 | 
                   | 
              |
| 180 | 
                          if (!all_available && g_list_index(files, file) % 2 == 0) {
                 | 
              |
| 181 | 
                  /* Indicate that not all parts were available */  | 
              |
| 182 | 
                  download_queue_mark_file_as_decoded_and_unref(prev_collection, file, "somefilename", TASK_STATE_FINISHED_INCOMPLETE);  | 
              |
| 183 | 
                          } else {
                 | 
              |
| 184 | 
                  /* Indicate that all parts were decoded succesfully */  | 
              |
| 185 | 
                  download_queue_mark_file_as_decoded_and_unref(prev_collection, file, "somefilename", TASK_STATE_FINISHED_COMPLETE);  | 
              |
| 186 | 
                  }  | 
              |
| 187 | 
                   | 
              |
| 188 | 
                  list = g_list_next(list);  | 
              |
| 189 | 
                  }  | 
              |
| 190 | 
                  g_list_free(files);  | 
              |
| 191 | 
                   | 
              |
| 192 | 
                  /* Verify that nothing_to_download_or_active is TRUE now */  | 
              |
| 193 | 
                      if (!download_queue_get_next_part_to_download(&collection, &file, &part, 0, ¬hing_to_download_or_active)) {
                 | 
              |
| 194 | 
                  /* Nothing is returned which is good */  | 
              |
| 195 | 
                  g_assert_cmpint(nothing_to_download_or_active, ==, TRUE);  | 
              |
| 196 | 
                  g_assert(collection == NULL);  | 
              |
| 197 | 
                  g_assert(file == NULL);  | 
              |
| 198 | 
                  g_assert(part == NULL);  | 
              |
| 199 | 
                      } else {
                 | 
              |
| 200 | 
                          FAIL_TEST("download_queue_get_next_part_to_download returned TRUE while it isn't expected");
                 | 
              |
| 201 | 
                  return;  | 
              |
| 202 | 
                  }  | 
              |
| 203 | 
                  }  | 
              |
| 204 | 
                   | 
              |
| 205 | 
                  void  | 
              |
| 206 | 
                  test_download_queue_one_server_all_available(void *data, gconstpointer user_data)  | 
              |
| 207 | 
                  {
                 | 
              |
| 208 | 
                  /* Assume for this testcase that all parts are available on the server */  | 
              |
| 209 | 
                  test_download_queue_one_server_generic(TRUE);  | 
              |
| 210 | 
                  }  | 
              |
| 211 | 
                   | 
              |
| 212 | 
                  void  | 
              |
| 213 | 
                  test_download_queue_one_server_some_available(void *data, gconstpointer user_data)  | 
              |
| 214 | 
                  {
                 | 
              |
| 215 | 
                  /* Assume for this testcase that some parts are available on the server */  | 
              |
| 216 | 
                  test_download_queue_one_server_generic(FALSE);  | 
              |
| 217 | 
                  }  | 
              |
| trunk/tests/test_download_queue.c (revision 1847) | ||
|---|---|---|
| 21 | 21 | 
                  #include  | 
              
| 22 | 22 | 
                   | 
              
| 23 | 23 | 
                  #include "common.h"  | 
              
| 24 | 
                  #include "test_download_queue.h"  | 
              |
| 25 | 
                   | 
              |
| 24 | 26 | 
                  #include "nntpgrab_utils.h"  | 
              
| 25 | 27 | 
                  #include "download_queue.h"  | 
              
| 26 | 28 | 
                   | 
              
| 27 | 
                  static Configuration *config = NULL;  | 
              |
| 28 | 
                   | 
              |
| 29 | 29 | 
                  /* Fake placeholders */  | 
              
| 30 | 30 | 
                  void  | 
              
| 31 | 31 | 
                  ng_plugin_emit_log_msg(NGPlugin *plugin_data, NGLogLevel log_level, const char *format, ...)  | 
              
| ... | ... | |
| 133 | 133 | 
                  ng_list_free(groups);  | 
              
| 134 | 134 | 
                  }  | 
              
| 135 | 135 | 
                   | 
              
| 136 | 
                  void  | 
              |
| 137 | 
                  fill_queue_with_dummy_data(void)  | 
              |
| 138 | 
                  {
                 | 
              |
| 139 | 
                  int i;  | 
              |
| 140 | 
                  char *errmsg = NULL;  | 
              |
| 141 | 
                  char *collection_name = "some collection";  | 
              |
| 142 | 
                   | 
              |
| 143 | 
                      for (i = 1; i <= 10; i++) {
                 | 
              |
| 144 | 
                  char *subject;  | 
              |
| 145 | 
                  char *poster;  | 
              |
| 146 | 
                  time_t stamp;  | 
              |
| 147 | 
                  guint64 file_size = 0;  | 
              |
| 148 | 
                  NGList *list_parts;  | 
              |
| 149 | 
                  NGList *list_groups;  | 
              |
| 150 | 
                   | 
              |
| 151 | 
                          subject = g_strdup_printf("file %i", i);
                 | 
              |
| 152 | 
                  poster = "some poster";  | 
              |
| 153 | 
                  stamp = 1185657196;  | 
              |
| 154 | 
                   | 
              |
| 155 | 
                  list_parts = generate_part_list(&file_size);  | 
              |
| 156 | 
                          list_groups = ng_list_append(NULL, g_strdup("alt.binaries.x"));
                 | 
              |
| 157 | 
                          list_groups = ng_list_append(list_groups, g_strdup("alt.binaries.nl"));
                 | 
              |
| 158 | 
                   | 
              |
| 159 | 
                          if (!download_queue_add_file_to_queue(collection_name, subject, poster, stamp, file_size, list_groups, list_parts, &errmsg)) {
                 | 
              |
| 160 | 
                              FAIL_TEST("Unable to add file to download queue: %s\n", errmsg);
                 | 
              |
| 161 | 
                  g_free(errmsg);  | 
              |
| 162 | 
                  return;  | 
              |
| 163 | 
                  }  | 
              |
| 164 | 
                   | 
              |
| 165 | 
                  free_part_list(list_parts);  | 
              |
| 166 | 
                  free_group_list(list_groups);  | 
              |
| 167 | 
                   | 
              |
| 168 | 
                  g_free(subject);  | 
              |
| 169 | 
                  }  | 
              |
| 170 | 
                  }  | 
              |
| 171 | 
                   | 
              |
| 172 | 
                  void  | 
              |
| 173 | 
                  drop_dummy_data_from_queue(void)  | 
              |
| 174 | 
                  {
                 | 
              |
| 175 | 
                  int i;  | 
              |
| 176 | 
                  char *errmsg = NULL;  | 
              |
| 177 | 
                  char *collection_name = "some collection";  | 
              |
| 178 | 
                   | 
              |
| 179 | 
                      for (i = 1; i <= 10; i++) {
                 | 
              |
| 180 | 
                  char *subject;  | 
              |
| 181 | 
                   | 
              |
| 182 | 
                          subject = g_strdup_printf("file %i", i);
                 | 
              |
| 183 | 
                   | 
              |
| 184 | 
                          if (!download_queue_del_file_from_queue(collection_name, subject, &errmsg)) {
                 | 
              |
| 185 | 
                              FAIL_TEST("Unable to remove file from download queue: %s\n", errmsg);
                 | 
              |
| 186 | 
                  g_free(errmsg);  | 
              |
| 187 | 
                  return;  | 
              |
| 188 | 
                  }  | 
              |
| 189 | 
                   | 
              |
| 190 | 
                  g_free(subject);  | 
              |
| 191 | 
                  }  | 
              |
| 192 | 
                  }  | 
              |
| 193 | 
                   | 
              |
| 136 | 194 | 
                  /* Testcases */  | 
              
| 137 | 195 | 
                  static void  | 
              
| 138 | 196 | 
                  test_download_queue_add_file_to_queue(void)  | 
              
| ... | ... | |
| 276 | 334 | 
                  }  | 
              
| 277 | 335 | 
                   | 
              
| 278 | 336 | 
                  static void  | 
              
| 279 | 
                  test_download_queue_get_next_part_to_download_setup(void *data, gconstpointer user_data)  | 
              |
| 337 | 
                  test_download_queue_setup_no_servers(void *data, gconstpointer user_data)  | 
              |
| 280 | 338 | 
                  {
                 | 
              
| 281 | 
                  int i;  | 
              |
| 282 | 
                  char *errmsg = NULL;  | 
              |
| 283 | 
                  char *collection_name = "some collection";  | 
              |
| 284 | 
                   | 
              |
| 285 | 
                      for (i = 1; i <= 10; i++) {
                 | 
              |
| 286 | 
                  char *subject;  | 
              |
| 287 | 
                  char *poster;  | 
              |
| 288 | 
                  time_t stamp;  | 
              |
| 289 | 
                  guint64 file_size = 0;  | 
              |
| 290 | 
                  NGList *list_parts;  | 
              |
| 291 | 
                  NGList *list_groups;  | 
              |
| 292 | 
                   | 
              |
| 293 | 
                          subject = g_strdup_printf("file %i", i);
                 | 
              |
| 294 | 
                  poster = "some poster";  | 
              |
| 295 | 
                  stamp = 1185657196;  | 
              |
| 296 | 
                   | 
              |
| 297 | 
                  list_parts = generate_part_list(&file_size);  | 
              |
| 298 | 
                          list_groups = ng_list_append(NULL, g_strdup("alt.binaries.x"));
                 | 
              |
| 299 | 
                          list_groups = ng_list_append(list_groups, g_strdup("alt.binaries.nl"));
                 | 
              |
| 300 | 
                   | 
              |
| 301 | 
                          if (!download_queue_add_file_to_queue(collection_name, subject, poster, stamp, file_size, list_groups, list_parts, &errmsg)) {
                 | 
              |
| 302 | 
                              FAIL_TEST("Unable to add file to download queue: %s\n", errmsg);
                 | 
              |
| 303 | 
                  g_free(errmsg);  | 
              |
| 304 | 
                  return;  | 
              |
| 305 | 
                  }  | 
              |
| 306 | 
                   | 
              |
| 307 | 
                  free_part_list(list_parts);  | 
              |
| 308 | 
                  free_group_list(list_groups);  | 
              |
| 309 | 
                   | 
              |
| 310 | 
                  g_free(subject);  | 
              |
| 311 | 
                  }  | 
              |
| 312 | 
                  }  | 
              |
| 313 | 
                   | 
              |
| 314 | 
                  static void  | 
              |
| 315 | 
                  test_download_queue_get_next_part_to_download_setup_no_servers(void *data, gconstpointer user_data)  | 
              |
| 316 | 
                  {
                 | 
              |
| 317 | 339 | 
                  g_assert(configuration_get_avail_servers(config) == NULL);  | 
              
| 318 | 340 | 
                   | 
              
| 319 | 
                  test_download_queue_get_next_part_to_download_setup(data, user_data);  | 
              |
| 341 | 
                  fill_queue_with_dummy_data();  | 
              |
| 320 | 342 | 
                  }  | 
              
| 321 | 343 | 
                   | 
              
| 322 | 344 | 
                  static void  | 
              
| 323 | 
                  test_download_queue_get_next_part_to_download_setup_one_server_before(void *data, gconstpointer user_data)  | 
              |
| 345 | 
                  test_download_queue_teardown_no_servers(void *data, gconstpointer user_data)  | 
              |
| 324 | 346 | 
                  {
                 | 
              
| 325 | 
                  char *errmsg = NULL;  | 
              |
| 326 | 
                  NGConfigServer server;  | 
              |
| 327 | 
                   | 
              |
| 328 | 347 | 
                  g_assert(configuration_get_avail_servers(config) == NULL);  | 
              
| 329 | 348 | 
                   | 
              
| 330 | 
                  memset(&server, 0, sizeof(server));  | 
              |
| 331 | 
                  strcpy(server.servername, "server1");  | 
              |
| 332 | 
                  strcpy(server.hostname, "host1");  | 
              |
| 333 | 
                  server.port = 119;  | 
              |
| 334 | 
                  server.enabled = TRUE;  | 
              |
| 335 | 
                  server.max_threads = 3;  | 
              |
| 336 | 
                   | 
              |
| 337 | 
                      if (!configuration_add_server(config, server, &errmsg)) {
                 | 
              |
| 338 | 
                          FAIL_TEST("Unable to add server: %s\n", errmsg);
                 | 
              |
| 339 | 
                  g_free(errmsg);  | 
              |
| 340 | 
                  return;  | 
              |
| 341 | 
                  }  | 
              |
| 342 | 
                   | 
              |
| 343 | 
                  test_download_queue_get_next_part_to_download_setup(data, user_data);  | 
              |
| 349 | 
                  drop_dummy_data_from_queue();  | 
              |
| 344 | 350 | 
                  }  | 
              
| 345 | 351 | 
                   | 
              
| 346 | 352 | 
                  static void  | 
              
| 347 | 
                  test_download_queue_get_next_part_to_download_setup_one_server_after(void *data, gconstpointer user_data)  | 
              |
| 353 | 
                  test_download_queue_no_servers(void *data, gconstpointer user_data)  | 
              |
| 348 | 354 | 
                  {
                 | 
              
| 349 | 
                  char *errmsg = NULL;  | 
              |
| 350 | 
                  NGConfigServer server;  | 
              |
| 351 | 
                   | 
              |
| 352 | 
                  g_assert(configuration_get_avail_servers(config) == NULL);  | 
              |
| 353 | 
                   | 
              |
| 354 | 
                  memset(&server, 0, sizeof(server));  | 
              |
| 355 | 
                  strcpy(server.servername, "server1");  | 
              |
| 356 | 
                  strcpy(server.hostname, "host1");  | 
              |
| 357 | 
                  server.port = 119;  | 
              |
| 358 | 
                  server.enabled = TRUE;  | 
              |
| 359 | 
                  server.max_threads = 1;  | 
              |
| 360 | 
                   | 
              |
| 361 | 
                  test_download_queue_get_next_part_to_download_setup(data, user_data);  | 
              |
| 362 | 
                   | 
              |
| 363 | 
                      if (!configuration_add_server(config, server, &errmsg)) {
                 | 
              |
| 364 | 
                          FAIL_TEST("Unable to add server: %s\n", errmsg);
                 | 
              |
| 365 | 
                  g_free(errmsg);  | 
              |
| 366 | 
                  return;  | 
              |
| 367 | 
                  }  | 
              |
| 368 | 
                  }  | 
              |
| 369 | 
                   | 
              |
| 370 | 
                  static void  | 
              |
| 371 | 
                  test_download_queue_get_next_part_to_download_teardown(void *data, gconstpointer user_data)  | 
              |
| 372 | 
                  {
                 | 
              |
| 373 | 
                  int i;  | 
              |
| 374 | 
                  char *errmsg = NULL;  | 
              |
| 375 | 
                  char *collection_name = "some collection";  | 
              |
| 376 | 
                   | 
              |
| 377 | 
                      for (i = 1; i <= 10; i++) {
                 | 
              |
| 378 | 
                  char *subject;  | 
              |
| 379 | 
                   | 
              |
| 380 | 
                          subject = g_strdup_printf("file %i", i);
                 | 
              |
| 381 | 
                   | 
              |
| 382 | 
                          if (!download_queue_del_file_from_queue(collection_name, subject, &errmsg)) {
                 | 
              |
| 383 | 
                              FAIL_TEST("Unable to remove file from download queue: %s\n", errmsg);
                 | 
              |
| 384 | 
                  g_free(errmsg);  | 
              |
| 385 | 
                  return;  | 
              |
| 386 | 
                  }  | 
              |
| 387 | 
                   | 
              |
| 388 | 
                  g_free(subject);  | 
              |
| 389 | 
                  }  | 
              |
| 390 | 
                  }  | 
              |
| 391 | 
                   | 
              |
| 392 | 
                  static void  | 
              |
| 393 | 
                  test_download_queue_get_next_part_to_download_teardown_no_servers(void *data, gconstpointer user_data)  | 
              |
| 394 | 
                  {
                 | 
              |
| 395 | 
                  g_assert(configuration_get_avail_servers(config) == NULL);  | 
              |
| 396 | 
                   | 
              |
| 397 | 
                  test_download_queue_get_next_part_to_download_teardown(data, user_data);  | 
              |
| 398 | 
                  }  | 
              |
| 399 | 
                   | 
              |
| 400 | 
                  static void  | 
              |
| 401 | 
                  test_download_queue_get_next_part_to_download_teardown_one_server(void *data, gconstpointer user_data)  | 
              |
| 402 | 
                  {
                 | 
              |
| 403 | 
                  char *errmsg = NULL;  | 
              |
| 404 | 
                   | 
              |
| 405 | 
                  g_assert(configuration_get_avail_servers(config) != NULL);  | 
              |
| 406 | 
                   | 
              |
| 407 | 
                  test_download_queue_get_next_part_to_download_teardown(data, user_data);  | 
              |
| 408 | 
                   | 
              |
| 409 | 
                      if (!configuration_del_server(config, "server1", &errmsg)) {
                 | 
              |
| 410 | 
                          FAIL_TEST("Unable to remove server: %s\n", errmsg);
                 | 
              |
| 411 | 
                  g_free(errmsg);  | 
              |
| 412 | 
                  return;  | 
              |
| 413 | 
                  }  | 
              |
| 414 | 
                  }  | 
              |
| 415 | 
                   | 
              |
| 416 | 
                  static void  | 
              |
| 417 | 
                  test_download_queue_get_next_part_to_download_no_servers(void *data, gconstpointer user_data)  | 
              |
| 418 | 
                  {
                 | 
              |
| 419 | 355 | 
                  NNTPCollection *collection = NULL;  | 
              
| 420 | 356 | 
                  NNTPFile *file = NULL;  | 
              
| 421 | 357 | 
                  NNTPPart *part = NULL;  | 
              
| ... | ... | |
| 433 | 369 | 
                  }  | 
              
| 434 | 370 | 
                  }  | 
              
| 435 | 371 | 
                   | 
              
| 436 | 
                  static void  | 
              |
| 437 | 
                  test_download_queue_get_next_part_to_download_one_server_generic(gboolean all_available)  | 
              |
| 438 | 
                  {
                 | 
              |
| 439 | 
                  /* There should be 10 files with 4 parts each in the download queue now */  | 
              |
| 440 | 
                  int i, j;  | 
              |
| 441 | 
                   | 
              |
| 442 | 
                  NNTPCollection *prev_collection = NULL;  | 
              |
| 443 | 
                  NNTPFile *prev_file = NULL;  | 
              |
| 444 | 
                   | 
              |
| 445 | 
                  NNTPCollection *collection = NULL;  | 
              |
| 446 | 
                  NNTPFile *file = NULL;  | 
              |
| 447 | 
                  NNTPPart *part = NULL;  | 
              |
| 448 | 
                  gboolean nothing_to_download_or_active = FALSE;  | 
              |
| 449 | 
                   | 
              |
| 450 | 
                  GList *list, *files = NULL;  | 
              |
| 451 | 
                   | 
              |
| 452 | 
                      for (i = 1; i <= 10; i++) {
                 | 
              |
| 453 | 
                  prev_file = NULL;  | 
              |
| 454 | 
                   | 
              |
| 455 | 
                          for (j = 1; j <= 4; j++) {
                 | 
              |
| 456 | 
                  /* There 1 server configured at the moment, so a request for the next part for server_id 0  | 
              |
| 457 | 
                  * should return TRUE and nothing_do_download should_or_active be FALSE */  | 
              |
| 458 | 
                              if (!download_queue_get_next_part_to_download(&collection, &file, &part, 0, ¬hing_to_download_or_active)) {
                 | 
              |
| 459 | 
                                  g_test_message("nothing_to_download = %i", nothing_to_download_or_active);
                 | 
              |
| 460 | 
                                  FAIL_TEST("download_queue_get_next_part_to_download returned FALSE while it isn't expected");
                 | 
              |
| 461 | 
                  return;  | 
              |
| 462 | 
                              } else {
                 | 
              |
| 463 | 
                                  char *expected_subject = g_strdup_printf("file %i", i);
                 | 
              |
| 464 | 
                   | 
              |
| 465 | 
                  g_assert_cmpint(nothing_to_download_or_active, ==, FALSE);  | 
              |
| 466 | 
                  g_assert(collection != NULL);  | 
              |
| 467 | 
                  g_assert(file != NULL);  | 
              |
| 468 | 
                  g_assert(part != NULL);  | 
              |
| 469 | 
                   | 
              |
| 470 | 
                  g_assert_cmpint(part->part_num, ==, j);  | 
              |
| 471 | 
                  g_assert_cmpstr(file->subject, ==, expected_subject);  | 
              |
| 472 | 
                   | 
              |
| 473 | 
                  g_free(expected_subject);  | 
              |
| 474 | 
                   | 
              |
| 475 | 
                                  if (prev_collection == NULL) {
                 | 
              |
| 476 | 
                  prev_collection = collection;  | 
              |
| 477 | 
                                  } else {
                 | 
              |
| 478 | 
                  g_assert(prev_collection == collection);  | 
              |
| 479 | 
                  }  | 
              |
| 480 | 
                   | 
              |
| 481 | 
                                  if (prev_file == NULL) {
                 | 
              |
| 482 | 
                  prev_file = file;  | 
              |
| 483 | 
                  files = g_list_append(files, file);  | 
              |
| 484 | 
                                  } else {
                 | 
              |
| 485 | 
                  g_assert(prev_file == file);  | 
              |
| 486 | 
                  }  | 
              |
| 487 | 
                  }  | 
              |
| 488 | 
                   | 
              |
| 489 | 
                  /* Update the status of the part */  | 
              |
| 490 | 
                              if (!all_available && j % 2 == 0) {
                 | 
              |
| 491 | 
                  /* Indicate the every second part isn't available on the server and it shouldn't be retried again */  | 
              |
| 492 | 
                                  download_queue_update_part_status("server1", 0, collection, file, part, 0, FALSE, FALSE, TRUE);
                 | 
              |
| 493 | 
                              } else {
                 | 
              |
| 494 | 
                  /* Indicate that the file was downloaded succesfully */  | 
              |
| 495 | 
                                  download_queue_update_part_status("server1", 0, collection, file, part, 0, TRUE, FALSE, FALSE);
                 | 
              |
| 496 | 
                  }  | 
              |
| 497 | 
                   | 
              |
| 498 | 
                  collection = NULL;  | 
              |
| 499 | 
                  file = NULL;  | 
              |
| 500 | 
                  part = NULL;  | 
              |
| 501 | 
                  }  | 
              |
| 502 | 
                  }  | 
              |
| 503 | 
                   | 
              |
| 504 | 
                  /* We processed all files now. If we try to request another part it should indicate that there's nothing to download anymore */  | 
              |
| 505 | 
                      if (!download_queue_get_next_part_to_download(&collection, &file, &part, 0, ¬hing_to_download_or_active)) {
                 | 
              |
| 506 | 
                  /* Nothing is returned which is good */  | 
              |
| 507 | 
                  /* The flag nothing_to_download_or_active should be FALSE as all files are downloaded, but not decoded yet */  | 
              |
| 508 | 
                  g_assert_cmpint(nothing_to_download_or_active, ==, FALSE);  | 
              |
| 509 | 
                  g_assert(collection == NULL);  | 
              |
| 510 | 
                  g_assert(file == NULL);  | 
              |
| 511 | 
                  g_assert(part == NULL);  | 
              |
| 512 | 
                      } else {
                 | 
              |
| 513 | 
                          FAIL_TEST("download_queue_get_next_part_to_download returned TRUE while it isn't expected");
                 | 
              |
| 514 | 
                  return;  | 
              |
| 515 | 
                  }  | 
              |
| 516 | 
                   | 
              |
| 517 | 
                  /* Mark all files as finished (downloaded+decoded) */  | 
              |
| 518 | 
                  list = files;  | 
              |
| 519 | 
                      while (list) {
                 | 
              |
| 520 | 
                  file = (NNTPFile*) list->data;  | 
              |
| 521 | 
                   | 
              |
| 522 | 
                          if (!all_available && g_list_index(files, file) % 2 == 0) {
                 | 
              |
| 523 | 
                  /* Indicate that not all parts were available */  | 
              |
| 524 | 
                  download_queue_mark_file_as_decoded_and_unref(prev_collection, file, "somefilename", TASK_STATE_FINISHED_INCOMPLETE);  | 
              |
| 525 | 
                          } else {
                 | 
              |
| 526 | 
                  /* Indicate that all parts were decoded succesfully */  | 
              |
| 527 | 
                  download_queue_mark_file_as_decoded_and_unref(prev_collection, file, "somefilename", TASK_STATE_FINISHED_COMPLETE);  | 
              |
| 528 | 
                  }  | 
              |
| 529 | 
                   | 
              |
| 530 | 
                  list = g_list_next(list);  | 
              |
| 531 | 
                  }  | 
              |
| 532 | 
                  g_list_free(files);  | 
              |
| 533 | 
                   | 
              |
| 534 | 
                  /* Verify that nothing_to_download_or_active is TRUE now */  | 
              |
| 535 | 
                      if (!download_queue_get_next_part_to_download(&collection, &file, &part, 0, ¬hing_to_download_or_active)) {
                 | 
              |
| 536 | 
                  /* Nothing is returned which is good */  | 
              |
| 537 | 
                  g_assert_cmpint(nothing_to_download_or_active, ==, TRUE);  | 
              |
| 538 | 
                  g_assert(collection == NULL);  | 
              |
| 539 | 
                  g_assert(file == NULL);  | 
              |
| 540 | 
                  g_assert(part == NULL);  | 
              |
| 541 | 
                      } else {
                 | 
              |
| 542 | 
                          FAIL_TEST("download_queue_get_next_part_to_download returned TRUE while it isn't expected");
                 | 
              |
| 543 | 
                  return;  | 
              |
| 544 | 
                  }  | 
              |
| 545 | 
                  }  | 
              |
| 546 | 
                   | 
              |
| 547 | 
                  static void  | 
              |
| 548 | 
                  test_download_queue_get_next_part_to_download_one_server_all_available(void *data, gconstpointer user_data)  | 
              |
| 549 | 
                  {
                 | 
              |
| 550 | 
                  /* Assume for this testcase that all parts are available on the server */  | 
              |
| 551 | 
                  test_download_queue_get_next_part_to_download_one_server_generic(TRUE);  | 
              |
| 552 | 
                  }  | 
              |
| 553 | 
                   | 
              |
| 554 | 
                  static void  | 
              |
| 555 | 
                  test_download_queue_get_next_part_to_download_one_server_some_available(void *data, gconstpointer user_data)  | 
              |
| 556 | 
                  {
                 | 
              |
| 557 | 
                  /* Assume for this testcase that some parts are available on the server */  | 
              |
| 558 | 
                  test_download_queue_get_next_part_to_download_one_server_generic(FALSE);  | 
              |
| 559 | 
                  }  | 
              |
| 560 | 
                   | 
              |
| 561 | 372 | 
                  int  | 
              
| 562 | 373 | 
                  main(int argc, char **argv)  | 
              
| 563 | 374 | 
                  {
                 | 
              
| ... | ... | |
| 583 | 394 | 
                      g_test_add_func("/download_queue/add_file_to_queue", test_download_queue_add_file_to_queue);
                 | 
              
| 584 | 395 | 
                      g_test_add_func("/download_queue/restart_file", test_download_queue_restart_file);
                 | 
              
| 585 | 396 | 
                      g_test_add_func("/download_queue/del_file_from_queue", test_download_queue_del_file_from_queue);
                 | 
              
| 586 | 
                      g_test_add("/download_queue/get_next_part_to_download/no_servers", void, NULL,
                 | 
              |
| 587 | 
                  test_download_queue_get_next_part_to_download_setup_no_servers,  | 
              |
| 588 | 
                  test_download_queue_get_next_part_to_download_no_servers,  | 
              |
| 589 | 
                  test_download_queue_get_next_part_to_download_teardown_no_servers);  | 
              |
| 590 | 
                      g_test_add("/download_queue/get_next_part_to_download/one_server/before/all_available", void, NULL,
                 | 
              |
| 591 | 
                  test_download_queue_get_next_part_to_download_setup_one_server_before,  | 
              |
| 592 | 
                  test_download_queue_get_next_part_to_download_one_server_all_available,  | 
              |
| 593 | 
                  test_download_queue_get_next_part_to_download_teardown_one_server);  | 
              |
| 594 | 
                      g_test_add("/download_queue/get_next_part_to_download/one_server/after/all_available", void, NULL,
                 | 
              |
| 595 | 
                  test_download_queue_get_next_part_to_download_setup_one_server_after,  | 
              |
| 596 | 
                  test_download_queue_get_next_part_to_download_one_server_all_available,  | 
              |
| 597 | 
                  test_download_queue_get_next_part_to_download_teardown_one_server);  | 
              |
| 598 | 
                      g_test_add("/download_queue/get_next_part_to_download/one_server/before/some_available", void, NULL,
                 | 
              |
| 599 | 
                  test_download_queue_get_next_part_to_download_setup_one_server_before,  | 
              |
| 600 | 
                  test_download_queue_get_next_part_to_download_one_server_some_available,  | 
              |
| 601 | 
                  test_download_queue_get_next_part_to_download_teardown_one_server);  | 
              |
| 602 | 
                      g_test_add("/download_queue/get_next_part_to_download/one_server/after/some_available", void, NULL,
                 | 
              |
| 603 | 
                  test_download_queue_get_next_part_to_download_setup_one_server_after,  | 
              |
| 604 | 
                  test_download_queue_get_next_part_to_download_one_server_all_available,  | 
              |
| 605 | 
                  test_download_queue_get_next_part_to_download_teardown_one_server);  | 
              |
| 606 | 397 | 
                   | 
              
| 398 | 
                  /* No servers */  | 
              |
| 399 | 
                      g_test_add("/download_queue/no_servers", void, NULL,
                 | 
              |
| 400 | 
                  test_download_queue_setup_no_servers,  | 
              |
| 401 | 
                  test_download_queue_no_servers,  | 
              |
| 402 | 
                  test_download_queue_teardown_no_servers);  | 
              |
| 403 | 
                   | 
              |
| 404 | 
                  /* One server */  | 
              |
| 405 | 
                      g_test_add("/download_queue/one_server/before/all_available", void, NULL,
                 | 
              |
| 406 | 
                  test_download_queue_setup_one_server_before,  | 
              |
| 407 | 
                  test_download_queue_one_server_all_available,  | 
              |
| 408 | 
                  test_download_queue_teardown_one_server);  | 
              |
| 409 | 
                      g_test_add("/download_queue/one_server/after/all_available", void, NULL,
                 | 
              |
| 410 | 
                  test_download_queue_setup_one_server_after,  | 
              |
| 411 | 
                  test_download_queue_one_server_all_available,  | 
              |
| 412 | 
                  test_download_queue_teardown_one_server);  | 
              |
| 413 | 
                      g_test_add("/download_queue/one_server/before/some_available", void, NULL,
                 | 
              |
| 414 | 
                  test_download_queue_setup_one_server_before,  | 
              |
| 415 | 
                  test_download_queue_one_server_some_available,  | 
              |
| 416 | 
                  test_download_queue_teardown_one_server);  | 
              |
| 417 | 
                      g_test_add("/download_queue/one_server/after/some_available", void, NULL,
                 | 
              |
| 418 | 
                  test_download_queue_setup_one_server_after,  | 
              |
| 419 | 
                  test_download_queue_one_server_all_available,  | 
              |
| 420 | 
                  test_download_queue_teardown_one_server);  | 
              |
| 421 | 
                   | 
              |
| 422 | 
                  /* Two servers with equal priority */  | 
              |
| 423 | 
                      g_test_add("/download_queue/two_servers_equal_prio/before/all_available_on_one", void, NULL,
                 | 
              |
| 424 | 
                  test_download_queue_setup_two_servers_equal_prio_before,  | 
              |
| 425 | 
                  test_download_queue_two_servers_equal_prio_all_available_on_one,  | 
              |
| 426 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 427 | 
                      g_test_add("/download_queue/two_servers_equal_prio/after/all_available_on_one", void, NULL,
                 | 
              |
| 428 | 
                  test_download_queue_setup_two_servers_equal_prio_after,  | 
              |
| 429 | 
                  test_download_queue_two_servers_equal_prio_all_available_on_one,  | 
              |
| 430 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 431 | 
                   | 
              |
| 432 | 
                      g_test_add("/download_queue/two_servers_equal_prio/before/all_available_on_one/server_two_added_between", void, NULL,
                 | 
              |
| 433 | 
                  test_download_queue_setup_two_servers_before_one_initial,  | 
              |
| 434 | 
                  test_download_queue_two_servers_equal_prio_all_available_on_one_server_two_added_between,  | 
              |
| 435 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 436 | 
                      g_test_add("/download_queue/two_servers_equal_prio/after/all_available_on_one/server_two_added_between", void, NULL,
                 | 
              |
| 437 | 
                  test_download_queue_setup_two_servers_after_one_initial,  | 
              |
| 438 | 
                  test_download_queue_two_servers_equal_prio_all_available_on_one_server_two_added_between,  | 
              |
| 439 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 440 | 
                   | 
              |
| 441 | 
                      g_test_add("/download_queue/two_servers_equal_prio/before/some_available_on_one_all_on_two", void, NULL,
                 | 
              |
| 442 | 
                  test_download_queue_setup_two_servers_equal_prio_before,  | 
              |
| 443 | 
                  test_download_queue_two_servers_equal_prio_some_available_on_one_all_on_two,  | 
              |
| 444 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 445 | 
                      g_test_add("/download_queue/two_servers_equal_prio/after/some_available_on_one_all_on_two", void, NULL,
                 | 
              |
| 446 | 
                  test_download_queue_setup_two_servers_equal_prio_after,  | 
              |
| 447 | 
                  test_download_queue_two_servers_equal_prio_some_available_on_one_all_on_two,  | 
              |
| 448 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 449 | 
                   | 
              |
| 450 | 
                      g_test_add("/download_queue/two_servers_equal_prio/before/some_available_on_one_all_on_two/server_two_added_between", void, NULL,
                 | 
              |
| 451 | 
                  test_download_queue_setup_two_servers_before_one_initial,  | 
              |
| 452 | 
                  test_download_queue_two_servers_equal_prio_some_available_on_one_all_on_two_server_two_added_between,  | 
              |
| 453 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 454 | 
                      g_test_add("/download_queue/two_servers_equal_prio/after/some_available_on_one_all_on_two/server_two_added_between", void, NULL,
                 | 
              |
| 455 | 
                  test_download_queue_setup_two_servers_after_one_initial,  | 
              |
| 456 | 
                  test_download_queue_two_servers_equal_prio_some_available_on_one_all_on_two_server_two_added_between,  | 
              |
| 457 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 458 | 
                   | 
              |
| 459 | 
                      g_test_add("/download_queue/two_servers_equal_prio/before/some_available_on_one_some_on_two", void, NULL,
                 | 
              |
| 460 | 
                  test_download_queue_setup_two_servers_equal_prio_before,  | 
              |
| 461 | 
                  test_download_queue_two_servers_equal_prio_some_available_on_one_some_on_two,  | 
              |
| 462 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 463 | 
                      g_test_add("/download_queue/two_servers_equal_prio/after/some_available_on_one_some_on_two", void, NULL,
                 | 
              |
| 464 | 
                  test_download_queue_setup_two_servers_equal_prio_after,  | 
              |
| 465 | 
                  test_download_queue_two_servers_equal_prio_some_available_on_one_some_on_two,  | 
              |
| 466 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 467 | 
                   | 
              |
| 468 | 
                      g_test_add("/download_queue/two_servers_equal_prio/before/some_available_on_one_some_on_two/server_two_added_between", void, NULL,
                 | 
              |
| 469 | 
                  test_download_queue_setup_two_servers_before_one_initial,  | 
              |
| 470 | 
                  test_download_queue_two_servers_equal_prio_some_available_on_one_some_on_two_server_two_added_between,  | 
              |
| 471 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 472 | 
                      g_test_add("/download_queue/two_servers_equal_prio/after/some_available_on_one_some_on_two/server_two_added_between", void, NULL,
                 | 
              |
| 473 | 
                  test_download_queue_setup_two_servers_after_one_initial,  | 
              |
| 474 | 
                  test_download_queue_two_servers_equal_prio_some_available_on_one_some_on_two_server_two_added_between,  | 
              |
| 475 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 476 | 
                   | 
              |
| 477 | 
                  /* Two servers with different priority */  | 
              |
| 478 | 
                      g_test_add("/download_queue/two_servers_different_prio/before/all_available_on_one", void, NULL,
                 | 
              |
| 479 | 
                  test_download_queue_setup_two_servers_different_prio_before,  | 
              |
| 480 | 
                  test_download_queue_two_servers_different_prio_all_available_on_one,  | 
              |
| 481 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 482 | 
                      g_test_add("/download_queue/two_servers_different_prio/after/all_available_on_one", void, NULL,
                 | 
              |
| 483 | 
                  test_download_queue_setup_two_servers_different_prio_after,  | 
              |
| 484 | 
                  test_download_queue_two_servers_different_prio_all_available_on_one,  | 
              |
| 485 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 486 | 
                   | 
              |
| 487 | 
                      g_test_add("/download_queue/two_servers_different_prio/before/all_available_on_one/server_two_added_between", void, NULL,
                 | 
              |
| 488 | 
                  test_download_queue_setup_two_servers_before_one_initial,  | 
              |
| 489 | 
                  test_download_queue_two_servers_different_prio_all_available_on_one_server_two_added_between,  | 
              |
| 490 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 491 | 
                      g_test_add("/download_queue/two_servers_different_prio/after/all_available_on_one/server_two_added_between", void, NULL,
                 | 
              |
| 492 | 
                  test_download_queue_setup_two_servers_after_one_initial,  | 
              |
| 493 | 
                  test_download_queue_two_servers_different_prio_all_available_on_one_server_two_added_between,  | 
              |
| 494 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 495 | 
                   | 
              |
| 496 | 
                      g_test_add("/download_queue/two_servers_different_prio/before/some_available_on_one_all_on_two", void, NULL,
                 | 
              |
| 497 | 
                  test_download_queue_setup_two_servers_different_prio_before,  | 
              |
| 498 | 
                  test_download_queue_two_servers_different_prio_some_available_on_one_all_on_two,  | 
              |
| 499 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 500 | 
                      g_test_add("/download_queue/two_servers_different_prio/after/some_available_on_one_all_on_two", void, NULL,
                 | 
              |
| 501 | 
                  test_download_queue_setup_two_servers_different_prio_after,  | 
              |
| 502 | 
                  test_download_queue_two_servers_different_prio_some_available_on_one_all_on_two,  | 
              |
| 503 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 504 | 
                   | 
              |
| 505 | 
                      g_test_add("/download_queue/two_servers_different_prio/before/some_available_on_one_all_on_two/server_two_added_between", void, NULL,
                 | 
              |
| 506 | 
                  test_download_queue_setup_two_servers_before_one_initial,  | 
              |
| 507 | 
                  test_download_queue_two_servers_different_prio_some_available_on_one_all_on_two_server_two_added_between,  | 
              |
| 508 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 509 | 
                      g_test_add("/download_queue/two_servers_different_prio/after/some_available_on_one_all_on_two/server_two_added_between", void, NULL,
                 | 
              |
| 510 | 
                  test_download_queue_setup_two_servers_after_one_initial,  | 
              |
| 511 | 
                  test_download_queue_two_servers_different_prio_some_available_on_one_all_on_two_server_two_added_between,  | 
              |
| 512 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 513 | 
                   | 
              |
| 514 | 
                      g_test_add("/download_queue/two_servers_different_prio/before/some_available_on_one_some_on_two", void, NULL,
                 | 
              |
| 515 | 
                  test_download_queue_setup_two_servers_different_prio_before,  | 
              |
| 516 | 
                  test_download_queue_two_servers_different_prio_some_available_on_one_some_on_two,  | 
              |
| 517 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 518 | 
                      g_test_add("/download_queue/two_servers_different_prio/after/some_available_on_one_some_on_two", void, NULL,
                 | 
              |
| 519 | 
                  test_download_queue_setup_two_servers_different_prio_after,  | 
              |
| 520 | 
                  test_download_queue_two_servers_different_prio_some_available_on_one_some_on_two,  | 
              |
| 521 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 522 | 
                   | 
              |
| 523 | 
                      g_test_add("/download_queue/two_servers_different_prio/before/some_available_on_one_some_on_two/server_two_added_between", void, NULL,
                 | 
              |
| 524 | 
                  test_download_queue_setup_two_servers_before_one_initial,  | 
              |
| 525 | 
                  test_download_queue_two_servers_different_prio_some_available_on_one_some_on_two_server_two_added_between,  | 
              |
| 526 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 527 | 
                      g_test_add("/download_queue/two_servers_different_prio/after/some_available_on_one_some_on_two/server_two_added_between", void, NULL,
                 | 
              |
| 528 | 
                  test_download_queue_setup_two_servers_after_one_initial,  | 
              |
| 529 | 
                  test_download_queue_two_servers_different_prio_some_available_on_one_some_on_two_server_two_added_between,  | 
              |
| 530 | 
                  test_download_queue_teardown_two_servers);  | 
              |
| 531 | 
                   | 
              |
| 607 | 532 | 
                  /* Perform the tests */  | 
              
| 608 | 533 | 
                  ret = g_test_run();  | 
              
| 609 | 534 | 
                   | 
              
| trunk/tests/test_download_queue_two_servers.c (revision 1847) | ||
|---|---|---|
| 1 | 
                  /*  | 
              |
| 2 | 
                  Copyright (C) 2005-2011 Erik van Pienbroek  | 
              |
| 3 | 
                   | 
              |
| 4 | 
                  This program is free software; you can redistribute it and/or modify  | 
              |
| 5 | 
                  it under the terms of the GNU General Public License as published by  | 
              |
| 6 | 
                  the Free Software Foundation; either version 2 of the License, or  | 
              |
| 7 | 
                  (at your option) any later version.  | 
              |
| 8 | 
                   | 
              |
| 9 | 
                  This program is distributed in the hope that it will be useful,  | 
              |
| 10 | 
                  but WITHOUT ANY WARRANTY; without even the implied warranty of  | 
              |
| 11 | 
                  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  | 
              |
| 12 | 
                  GNU General Public License for more details.  | 
              |
| 13 | 
                   | 
              |
| 14 | 
                  You should have received a copy of the GNU General Public License  | 
              |
| 15 | 
                  along with this program; if not, write to the Free Software  | 
              |
| 16 | 
                  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  | 
              |
| 17 | 
                  */  | 
              |
| 18 | 
                   | 
              |
| 19 | 
                  #include  | 
              |
| 20 | 
                  #include  | 
              |
| 21 | 
                  #include  | 
              |
| 22 | 
                   | 
              |
| 23 | 
                  #include "common.h"  | 
              |
| 24 | 
                  #include "test_download_queue.h"  | 
              |
| 25 | 
                   | 
              |
| 26 | 
                  #include "nntpgrab_utils.h"  | 
              |
| 27 | 
                  #include "download_queue.h"  | 
              |
| 28 | 
                   | 
              |
| 29 | 
                  static void  | 
              |
| 30 | 
                  add_servers(gboolean add_server_before, gboolean equal_priority)  | 
              |
| 31 | 
                  {
                 | 
              |
| 32 | 
                  char *errmsg = NULL;  | 
              |
| 33 | 
                  NGConfigServer server;  | 
              |
| 34 | 
                   | 
              |
| 35 | 
                  g_assert(configuration_get_avail_servers(config) == NULL);  | 
              |
| 36 | 
                   | 
              |
| 37 | 
                  if (!add_server_before) fill_queue_with_dummy_data();  | 
              |
| 38 | 
                   | 
              |
| 39 | 
                  memset(&server, 0, sizeof(server));  | 
              |
| 40 | 
                  strcpy(server.servername, "server1");  | 
              |
| 41 | 
                  strcpy(server.hostname, "host1");  | 
              |
| 42 | 
                  server.port = 119;  | 
              |
| 43 | 
                  server.enabled = TRUE;  | 
              |
| 44 | 
                  server.max_threads = 3;  | 
              |
| 45 | 
                  server.priority = SERVER_PRIORITY_HIGH;  | 
              |
| 46 | 
                   | 
              |
| 47 | 
                      if (!configuration_add_server(config, server, &errmsg)) {
                 | 
              |
| 48 | 
                          FAIL_TEST("Unable to add server: %s\n", errmsg);
                 | 
              |
| 49 | 
                  g_free(errmsg);  | 
              |
| 50 | 
                  return;  | 
              |
| 51 | 
                  }  | 
              |
| 52 | 
                   | 
              |
| 53 | 
                  memset(&server, 0, sizeof(server));  | 
              |
| 54 | 
                  strcpy(server.servername, "server2");  | 
              |
| 55 | 
                  strcpy(server.hostname, "host2");  | 
              |
| 56 | 
                  server.port = 119;  | 
              |
| 57 | 
                  server.enabled = TRUE;  | 
              |
| 58 | 
                  server.max_threads = 3;  | 
              |
| 59 | 
                  server.priority = (equal_priority ? SERVER_PRIORITY_HIGH : SERVER_PRIORITY_NORMAL);  | 
              |
| 60 | 
                   | 
              |
| 61 | 
                      if (!configuration_add_server(config, server, &errmsg)) {
                 | 
              |
| 62 | 
                          FAIL_TEST("Unable to add server: %s\n", errmsg);
                 | 
              |
| 63 | 
                  g_free(errmsg);  | 
              |
| 64 | 
                  return;  | 
              |
| 65 | 
                  }  | 
              |
| 66 | 
                   | 
              |
| 67 | 
                  if (add_server_before) fill_queue_with_dummy_data();  | 
              |
| 68 | 
                  }  | 
              |
| 69 | 
                   | 
              |
| 70 | 
                  void  | 
              |
| 71 | 
                  test_download_queue_setup_two_servers_equal_prio_before(void *data, gconstpointer user_data)  | 
              |
| 72 | 
                  {
                 | 
              |
| 73 | 
                  add_servers(TRUE, TRUE);  | 
              |
| 74 | 
                  }  | 
              |
| 75 | 
                   | 
              |
| 76 | 
                  void  | 
              |
| 77 | 
                  test_download_queue_setup_two_servers_different_prio_before(void *data, gconstpointer user_data)  | 
              |
| 78 | 
                  {
                 | 
              |
| 79 | 
                  add_servers(TRUE, FALSE);  | 
              |
| 80 | 
                  }  | 
              |
| 81 | 
                   | 
              |
| 82 | 
                  void  | 
              |
| 83 | 
                  test_download_queue_setup_two_servers_equal_prio_after(void *data, gconstpointer user_data)  | 
              |
| 84 | 
                  {
                 | 
              |
| 85 | 
                  add_servers(FALSE, TRUE);  | 
              |
| 86 | 
                  }  | 
              |
| 87 | 
                   | 
              |
| 88 | 
                  void  | 
              |
| 89 | 
                  test_download_queue_setup_two_servers_different_prio_after(void *data, gconstpointer user_data)  | 
              |
| 90 | 
                  {
                 | 
              |
| 91 | 
                  add_servers(FALSE, FALSE);  | 
              |
| 92 | 
                  }  | 
              |
| 93 | 
                   | 
              |
| 94 | 
                  void  | 
              |
| 95 | 
                  test_download_queue_setup_two_servers_before_one_initial(void *data, gconstpointer user_data)  | 
              |
| 96 | 
                  {
                 | 
              |
| 97 | 
                  test_download_queue_setup_one_server_before(data, user_data);  | 
              |
| 98 | 
                  }  | 
              |
| 99 | 
                   | 
              |
| 100 | 
                  void  | 
              |
| 101 | 
                  test_download_queue_setup_two_servers_after_one_initial(void *data, gconstpointer user_data)  | 
              |
| 102 | 
                  {
                 | 
              |
| 103 | 
                  test_download_queue_setup_one_server_after(data, user_data);  | 
              |
| 104 | 
                  }  | 
              |
| 105 | 
                   | 
              |
| 106 | 
                  void  | 
              |
| 107 | 
                  test_download_queue_teardown_two_servers(void *data, gconstpointer user_data)  | 
              |
| 108 | 
                  {
                 | 
              |
| 109 | 
                  char *errmsg = NULL;  | 
              |
| 110 | 
                   | 
              |
| 111 | 
                  g_assert(configuration_get_avail_servers(config) != NULL);  | 
              |
| 112 | 
                   | 
              |
| 113 | 
                  drop_dummy_data_from_queue();  | 
              |
| 114 | 
                   | 
              |
| 115 | 
                      if (!configuration_del_server(config, "server2", &errmsg)) {
                 | 
              |
| 116 | 
                          FAIL_TEST("Unable to remove server: %s\n", errmsg);
                 | 
              |
| 117 | 
                  g_free(errmsg);  | 
              |
| 118 | 
                  return;  | 
              |
| 119 | 
                  }  | 
              |
| 120 | 
                   | 
              |
| 121 | 
                      if (!configuration_del_server(config, "server1", &errmsg)) {
                 | 
              |
| 122 | 
                          FAIL_TEST("Unable to remove server: %s\n", errmsg);
                 | 
              |
| 123 | 
                  g_free(errmsg);  | 
              |
| 124 | 
                  return;  | 
              |
| 125 | 
                  }  | 
              |
| 126 | 
                  }  | 
              |
| 127 | 
                  static void  | 
              |
| 128 | 
                  test_download_queue_two_servers_generic(gboolean all_available_on_one, gboolean all_available_on_two, gboolean equal_priority, gboolean server_added_between)  | 
              |
| 129 | 
                  {
                 | 
              |
| 130 | 
                  /* There should be 10 files with 4 parts each in the download queue now */  | 
              |
| 131 | 
                  int i, server_id;  | 
              |
| 132 | 
                  int num_iterations, num_iterations_server1, num_servers;  | 
              |
| 133 | 
                   | 
              |
| 134 | 
                  NNTPCollection *prev_collection = NULL;  | 
              |
| 135 | 
                  NNTPFile *prev_file = NULL;  | 
              |
| 136 | 
                   | 
              |
| 137 | 
                  NNTPCollection *collection = NULL;  | 
              |
| 138 | 
                  NNTPFile *file = NULL;  | 
              |
| 139 | 
                  NNTPPart *part = NULL;  | 
              |
| 140 | 
                  gboolean nothing_to_download_or_active = FALSE;  | 
              |
| 141 | 
                  gboolean task_returned;  | 
              |
| 142 | 
                   | 
              |
| 143 | 
                  gboolean server2_available = !server_added_between;  | 
              |
| 144 | 
                  GList *list, *files = NULL;  | 
              |
| 145 | 
                   | 
              |
| 146 | 
                      if (equal_priority && all_available_on_one) {
                 | 
              |
| 147 | 
                  num_iterations = 40;  | 
              |
| 148 | 
                      } else if (equal_priority && !all_available_on_one) {
                 | 
              |
| 149 | 
                  num_iterations = 54;  | 
              |
| 150 | 
                      } else {
                 | 
              |
| 151 | 
                  num_iterations = 80;  | 
              |
| 152 | 
                  }  | 
              |
| 153 | 
                   | 
              |
| 154 | 
                  num_iterations_server1 = 0;  | 
              |
| 155 | 
                  num_servers = (server_added_between ? 1 : 2);  | 
              |
| 156 | 
                   | 
              |
| 157 | 
                      g_test_message("Num iterations for this testcase = %i", num_iterations);
                 | 
              |
| 158 | 
                      g_test_message("Server2 available = %i", server2_available);
                 | 
              |
| 159 | 
                   | 
              |
| 160 | 
                      for (i = 0; i < num_iterations; i++) {
                 | 
              |
| 161 | 
                          g_test_message("Iteration %i", i);
                 | 
              |
| 162 | 
                   | 
              |
| 163 | 
                  /* Try server 1 first, then server 2 (if it's available), then server 1, etc */  | 
              |
| 164 | 
                          if (num_iterations_server1 == 40) {     /* Don't try to consult server 1 anymore once it has been tried for all files+parts */
                 | 
              |
| 165 | 
                  server_id = 1;  | 
              |
| 166 | 
                          } else if (server2_available) {
                 | 
              |
| 167 | 
                  server_id = i % 2;  | 
              |
| 168 | 
                          } else {
                 | 
              |
| 169 | 
                  server_id = 0;  | 
              |
| 170 | 
                  }  | 
              |
| 171 | 
                   | 
              |
| 172 | 
                  task_returned = download_queue_get_next_part_to_download(&collection, &file, &part, server_id, ¬hing_to_download_or_active);  | 
              |
| 173 | 
                          if (!task_returned) {
                 | 
              |
| 174 | 
                              if (server_id == 1) {
                 | 
              |
| 175 | 
                  /* This is okay */  | 
              |
| 176 | 
                  /* TODO: Implement */  | 
              |
| 177 | 
                                  g_test_message("Nothing was returned for server_id %i", server_id);
                 | 
              |
| 178 | 
                  continue;  | 
              |
| 179 | 
                              } else {
                 | 
              |
| 180 | 
                                  g_test_message("i = %i", i);
                 | 
              |
| 181 | 
                                  g_test_message("server_id = %i", server_id);
                 | 
              |
| 182 | 
                                  g_test_message("nothing_to_download = %i", nothing_to_download_or_active);
                 | 
              |
| 183 | 
                                  FAIL_TEST("download_queue_get_next_part_to_download returned FALSE while it isn't expected");
                 | 
              |
| 184 | 
                  return;  | 
              |
| 185 | 
                  }  | 
              |
| 186 | 
                          } else {
                 | 
              |
| 187 | 
                  g_assert_cmpint(nothing_to_download_or_active, ==, FALSE);  | 
              |
| 188 | 
                  g_assert(collection != NULL);  | 
              |
| 189 | 
                  g_assert(file != NULL);  | 
              |
| 190 | 
                  g_assert(part != NULL);  | 
              |
| 191 | 
                   | 
              |
| 192 | 
                              if (equal_priority) {
                 | 
              |
| 193 | 
                                  if (all_available_on_one) {
                 | 
              |
| 194 | 
                                      char *expected_subject = g_strdup_printf("file %i", (int) (i / 4) + 1);
                 | 
              |
| 195 | 
                  g_assert_cmpint(part->part_num, ==, (i % 4) + 1);  | 
              |
| 196 | 
                  g_assert_cmpstr(file->subject, ==, expected_subject);  | 
              |
| 197 | 
                  g_free(expected_subject);  | 
              |
| 198 | 
                                  } else {
                 | 
              |
| 199 | 
                  /* The first server has marked each 2nd file as being unavailable so it will  | 
              |
| 200 | 
                  * be retried by the second server */  | 
              |
| 201 | 
                  /* TODO: Implement */  | 
              |
| 202 | 
                  }  | 
              |
| 203 | 
                              } else {
                 | 
              |
| 204 | 
                  /* TODO: Implement */  | 
              |
| 205 | 
                  }  | 
              |
| 206 | 
                   | 
              |
| 207 | 
                              if (prev_collection == NULL) {
                 | 
              |
| 208 | 
                  prev_collection = collection;  | 
              |
| 209 | 
                              } else {
                 | 
              |
| 210 | 
                  g_assert(prev_collection == collection);  | 
              |
| 211 | 
                  }  | 
              |
| 212 | 
                   | 
              |
| 213 | 
                              if (prev_file != file) {
                 | 
              |
| 214 | 
                  prev_file = file;  | 
              |
| 215 | 
                  files = g_list_append(files, file);  | 
              |
| 216 | 
                  }  | 
              |
| 217 | 
                  }  | 
              |
| 218 | 
                   | 
              |
| 219 | 
                  /* Update the status of the part */  | 
              |
| 220 | 
                  if ((server_id == 0 && !all_available_on_one && num_iterations_server1 % 2 == 0) ||  | 
              |
| 221 | 
                               (server_id == 1 && !all_available_on_two && i % 4 == 0)) {
                 | 
              |
| 222 | 
                   | 
              |
| 223 | 
                  /* Indicate the every second part isn't available on the server and it shouldn't be retried again */  | 
              |
| 224 | 
                              g_test_message("Subject '%s' part %i was marked as being unavailable for server_id %i", file->subject, part->part_num, server_id);
                 | 
              |
| 225 | 
                              download_queue_update_part_status("dummy", 0, collection, file, part, server_id, FALSE, FALSE, TRUE);
                 | 
              |
| 226 | 
                          } else {
                 | 
              |
| 227 | 
                  /* Indicate that the file was downloaded succesfully */  | 
              |
| 228 | 
                              g_test_message("Subject '%s' part %i was marked as download successfully for server_id %i", file->subject, part->part_num, server_id);
                 | 
              |
| 229 | 
                              download_queue_update_part_status("dummy", 0, collection, file, part, server_id, TRUE, FALSE, FALSE);
                 | 
              |
| 230 | 
                  }  | 
              |
| 231 | 
                   | 
              |
| 232 | 
                  /* If we're halfway, add a new server if necessary */  | 
              |
| 233 | 
                          if (server_added_between && i == 10) {
                 | 
              |
| 234 | 
                  char *errmsg = NULL;  | 
              |
| 235 | 
                  NGConfigServer server;  | 
              |
| 236 | 
                   | 
              |
| 237 | 
                  memset(&server, 0, sizeof(server));  | 
              |
| 238 | 
                  strcpy(server.servername, "server2");  | 
              |
| 239 | 
                  strcpy(server.hostname, "host2");  | 
              |
| 240 | 
                  server.port = 119;  | 
              |
| 241 | 
                  server.enabled = TRUE;  | 
              |
| 242 | 
                  server.max_threads = 1;  | 
              |
| 243 | 
                   | 
              |
| 244 | 
                              if (!configuration_add_server(config, server, &errmsg)) {
                 | 
              |
| 245 | 
                                  FAIL_TEST("Unable to add server: %s\n", errmsg);
                 | 
              |
| 246 | 
                  g_free(errmsg);  | 
              |
| 247 | 
                  return;  | 
              |
| 248 | 
                  }  | 
              |
| 249 | 
                  }  | 
              |
| 250 | 
                   | 
              |
| 251 | 
                          if (server_id == 0) {
                 | 
              |
| 252 | 
                  num_iterations_server1++;  | 
              |
| 253 | 
                  }  | 
              |
| 254 | 
                  }  | 
              |
| 255 | 
                   | 
              |
| 256 | 
                  /* We processed all files now. If we try to request another part it should indicate that there's nothing to download anymore */  | 
              |
| 257 | 
                      if (!download_queue_get_next_part_to_download(&collection, &file, &part, 0, ¬hing_to_download_or_active)) {
                 | 
              |
| 258 | 
                  /* Nothing is returned which is good */  | 
              |
| 259 | 
                  /* The flag nothing_to_download_or_active should be FALSE as all files are downloaded, but not decoded yet */  | 
              |
| 260 | 
                  g_assert_cmpint(nothing_to_download_or_active, ==, FALSE);  | 
              |
| 261 | 
                  g_assert(collection == NULL);  | 
              |
| 262 | 
                  g_assert(file == NULL);  | 
              |
| 263 | 
                  g_assert(part == NULL);  | 
              |
| 264 | 
                      } else {
                 | 
              |
| 265 | 
                          FAIL_TEST("download_queue_get_next_part_to_download returned TRUE while it isn't expected");
                 | 
              |
| 266 | 
                  return;  | 
              |
| 267 | 
                  }  | 
              |
| 268 | 
                   | 
              |
| 269 | 
                  /* Mark all files as finished (downloaded+decoded) */  | 
              |
| 270 | 
                  list = files;  | 
              |
| 271 | 
                      while (list) {
                 | 
              |
| 272 | 
                  file = (NNTPFile*) list->data;  | 
              |
| 273 | 
                   | 
              |
| 274 | 
                          if (!all_available_on_one && g_list_index(files, file) % 2 == 0) {
                 | 
              |
| 275 | 
                  /* Indicate that not all parts were available */  | 
              |
| 276 | 
                  download_queue_mark_file_as_decoded_and_unref(prev_collection, file, "somefilename", TASK_STATE_FINISHED_INCOMPLETE);  | 
              |
| 277 | 
                          } else {
                 | 
              |
| 278 | 
                  /* Indicate that all parts were decoded succesfully */  | 
              |
| 279 | 
                  download_queue_mark_file_as_decoded_and_unref(prev_collection, file, "somefilename", TASK_STATE_FINISHED_COMPLETE);  | 
              |
| 280 | 
                  }  | 
              |
| 281 | 
                   | 
              |
| 282 | 
                  list = g_list_next(list);  | 
              |
| 283 | 
                  }  | 
              |
| 284 | 
                  g_list_free(files);  | 
              |
| 285 | 
                   | 
              |
| 286 | 
                  /* Verify that nothing_to_download_or_active is TRUE now */  | 
              |
| 287 | 
                      if (!download_queue_get_next_part_to_download(&collection, &file, &part, 0, ¬hing_to_download_or_active)) {
                 | 
              |
| 288 | 
                  /* Nothing is returned which is good */  | 
              |
| 289 | 
                  g_assert_cmpint(nothing_to_download_or_active, ==, TRUE);  | 
              |
| 290 | 
                  g_assert(collection == NULL);  | 
              |
| 291 | 
                  g_assert(file == NULL);  | 
              |
| 292 | 
                  g_assert(part == NULL);  | 
              |
| 293 | 
                      } else {
                 | 
              |
| 294 | 
                          FAIL_TEST("download_queue_get_next_part_to_download returned TRUE while it isn't expected");
                 | 
              |
| 295 | 
                  return;  | 
              |
| 296 | 
                  }  | 
              |
| 297 | 
                  }  | 
              |
| 298 | 
                   | 
              |
| 299 | 
                  void  | 
              |
| 300 | 
                  test_download_queue_two_servers_equal_prio_all_available_on_one(void *data, gconstpointer user_data)  | 
              |
| 301 | 
                  {
                 | 
              |
| 302 | 
                  /* Assume for this testcase that all parts are available on server one.  | 
              |
| 303 | 
                  * Both servers have an equal priority */  | 
              |
| 304 | 
                  test_download_queue_two_servers_generic(TRUE, FALSE, TRUE, FALSE);  | 
              |
| 305 | 
                  }  | 
              |
| 306 | 
                   | 
              |
| 307 | 
                  void  | 
              |
| 308 | 
                  test_download_queue_two_servers_equal_prio_all_available_on_one_server_two_added_between(void *data, gconstpointer user_data)  | 
              |
| 309 | 
                  {
                 | 
              |
| 310 | 
                  /* Assume for this testcase that all parts are available on server one  | 
              |
| 311 | 
                  * and that a new server is added halfway. Both servers have an equal priority */  | 
              |
| 312 | 
                  test_download_queue_two_servers_generic(TRUE, FALSE, TRUE, TRUE);  | 
              |
| 313 | 
                  }  | 
              |
| 314 | 
                   | 
              |
| 315 | 
                  void  | 
              |
| 316 | 
                  test_download_queue_two_servers_equal_prio_some_available_on_one_all_on_two(void *data, gconstpointer user_data)  | 
              |
| 317 | 
                  {
                 | 
              |
| 318 | 
                  /* Assume for this testcase that some parts are available on server one  | 
              |
| 319 | 
                  * and the rest is all available on server two. Both servers have an equal priority */  | 
              |
| 320 | 
                  test_download_queue_two_servers_generic(FALSE, TRUE, TRUE, FALSE);  | 
              |
| 321 | 
                  }  | 
              |
| 322 | 
                   | 
              |
| 323 | 
                  void  | 
              |
| 324 | 
                  test_download_queue_two_servers_equal_prio_some_available_on_one_all_on_two_server_two_added_between(void *data, gconstpointer user_data)  | 
              |
| 325 | 
                  {
                 | 
              |
| 326 | 
                  /* Assume for this testcase that some parts are available on server one  | 
              |
| 327 | 
                  * and the rest is available on server two which is added halfway.  | 
              |
| 328 | 
                  * Both servers have an equal priority */  | 
              |
| 329 | 
                  test_download_queue_two_servers_generic(FALSE, TRUE, TRUE, TRUE);  | 
              |
| 330 | 
                  }  | 
              |
| 331 | 
                   | 
              |
| 332 | 
                  void  | 
              |
| 333 | 
                  test_download_queue_two_servers_equal_prio_some_available_on_one_some_on_two(void *data, gconstpointer user_data)  | 
              |
| 334 | 
                  {
                 | 
              |
| 335 | 
                  /* Assume for this testcase that some parts are available on server one  | 
              |
| 336 | 
                  * and some are available on server two. Both servers have an equal priority */  | 
              |
| 337 | 
                  test_download_queue_two_servers_generic(FALSE, FALSE, TRUE, FALSE);  | 
              |
| 338 | 
                  }  | 
              |
| 339 | 
                   | 
              |
| 340 | 
                  void  | 
              |
| 341 | 
                  test_download_queue_two_servers_equal_prio_some_available_on_one_some_on_two_server_two_added_between(void *data, gconstpointer user_data)  | 
              |
| 342 | 
                  {
                 | 
              |
| 343 | 
                  /* Assume for this testcase that some parts are available on server one  | 
              |
| 344 | 
                  * and some are available on server two which is added halfway.  | 
              |
| 345 | 
                  * Both servers have an equal priority */  | 
              |
| 346 | 
                  test_download_queue_two_servers_generic(FALSE, FALSE, TRUE, TRUE);  | 
              |
| 347 | 
                  }  | 
              |
| 348 | 
                   | 
              |
| 349 | 
                  void  | 
              |
| 350 | 
                  test_download_queue_two_servers_different_prio_all_available_on_one(void *data, gconstpointer user_data)  | 
              |
| 351 | 
                  {
                 | 
              |
| 352 | 
                  /* Assume for this testcase that all parts are available on server one.  | 
              |
| 353 | 
                  * Both servers have a different priority */  | 
              |
| 354 | 
                  test_download_queue_two_servers_generic(TRUE, FALSE, FALSE, FALSE);  | 
              |
| 355 | 
                  }  | 
              |
| 356 | 
                   | 
              |
| 357 | 
                  void  | 
              |
| 358 | 
                  test_download_queue_two_servers_different_prio_all_available_on_one_server_two_added_between(void *data, gconstpointer user_data)  | 
              |
| 359 | 
                  {
                 | 
              |
| 360 | 
                  /* Assume for this testcase that all parts are available on server one  | 
              |
| 361 | 
                  * and that a new server is added halfway. Both servers have a different priority */  | 
              |
| 362 | 
                  test_download_queue_two_servers_generic(TRUE, FALSE, FALSE, TRUE);  | 
              |
| 363 | 
                  }  | 
              |
| 364 | 
                   | 
              |
| 365 | 
                  void  | 
              |
| 366 | 
                  test_download_queue_two_servers_different_prio_some_available_on_one_all_on_two(void *data, gconstpointer user_data)  | 
              |
| 367 | 
                  {
                 | 
              |
| 368 | 
                  /* Assume for this testcase that some parts are available on server one  | 
              |
| 369 | 
                  * and the rest is all available on server two. Both servers have a different priority */  | 
              |
| 370 | 
                  test_download_queue_two_servers_generic(FALSE, TRUE, FALSE, FALSE);  | 
              |
| 371 | 
                  }  | 
              |
| 372 | 
                   | 
              |
| 373 | 
                  void  | 
              |
| 374 | 
                  test_download_queue_two_servers_different_prio_some_available_on_one_all_on_two_server_two_added_between(void *data, gconstpointer user_data)  | 
              |
| 375 | 
                  {
                 | 
              |
| 376 | 
                  /* Assume for this testcase that some parts are available on server one  | 
              |
| 377 | 
                  * and the rest is available on server two which is added halfway.  | 
              |
| 378 | 
                  * Both servers have a different priority */  | 
              |
| 379 | 
                  test_download_queue_two_servers_generic(FALSE, TRUE, FALSE, TRUE);  | 
              |
| 380 | 
                  }  | 
              |
| 381 | 
                   | 
              |
| 382 | 
                  void  | 
              |
| 383 | 
                  test_download_queue_two_servers_different_prio_some_available_on_one_some_on_two(void *data, gconstpointer user_data)  | 
              |
| 384 | 
                  {
                 | 
              |
| 385 | 
                  /* Assume for this testcase that some parts are available on server one  | 
              |
| 386 | 
                  * and some are available on server two. Both servers have a different priority */  | 
              |
| 387 | 
                  test_download_queue_two_servers_generic(FALSE, FALSE, FALSE, FALSE);  | 
              |
| 388 | 
                  }  | 
              |
| 389 | 
                   | 
              |
| 390 | 
                  void  | 
              |
| 391 | 
                  test_download_queue_two_servers_different_prio_some_available_on_one_some_on_two_server_two_added_between(void *data, gconstpointer user_data)  | 
              |
| 392 | 
                  {
                 | 
              |
| 393 | 
                  /* Assume for this testcase that some parts are available on server one  | 
              |
| 394 | 
                  * and some are available on server two which is added halfway.  | 
              |
| 395 | 
                  * Both servers have a different priority */  | 
              |
| 396 | 
                  test_download_queue_two_servers_generic(FALSE, FALSE, FALSE, TRUE);  | 
              |
| 397 | 
                  }  | 
              |
| trunk/tests/test_download_queue.h (revision 1847) | ||
|---|---|---|
| 1 | 
                  /*  | 
              |
| 2 | 
                  Copyright (C) 2005-2011 Erik van Pienbroek  | 
              |
| 3 | 
                   | 
              |
| 4 | 
                  This program is free software; you can redistribute it and/or modify  | 
              |
| 5 | 
                  it under the terms of the GNU General Public License as published by  | 
              |
| 6 | 
                  the Free Software Foundation; either version 2 of the License, or  | 
              |
| 7 | 
                  (at your option) any later version.  | 
              |
| 8 | 
                   | 
              |
| 9 | 
                  This program is distributed in the hope that it will be useful,  | 
              |
| 10 | 
                  but WITHOUT ANY WARRANTY; without even the implied warranty of  | 
              |
| 11 | 
                  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  | 
              |
| 12 | 
                  GNU General Public License for more details.  | 
              |
| 13 | 
                   | 
              |
| 14 | 
                  You should have received a copy of the GNU General Public License  | 
              |
| 15 | 
                  along with this program; if not, write to the Free Software  | 
              |
| 16 | 
                  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA  | 
              |
| 17 | 
                  */  | 
              |
| 18 | 
                   | 
              |
| 19 | 
                  #ifndef _TEST_DOWNLOAD_QUEUE_H_  | 
              |
| 20 | 
                  #define _TEST_DOWNLOAD_QUEUE_H_  | 
              |
| 21 | 
                   | 
              |
| 22 | 
                  /* test_download_queue.c */  | 
              |
| 23 | 
                  void fill_queue_with_dummy_data(void);  | 
              |
| 24 | 
                  void drop_dummy_data_from_queue(void);  | 
              |
| 25 | 
                   | 
              |
| 26 | 
                  /* test_download_queue_one_server.c */  | 
              |
| 27 | 
                  void test_download_queue_setup_one_server_before(void *data, gconstpointer user_data);  | 
              |
| 28 | 
                  void test_download_queue_setup_one_server_after(void *data, gconstpointer user_data);  | 
              |
| 29 | 
                  void test_download_queue_teardown_one_server(void *data, gconstpointer user_data);  | 
              |
| 30 | 
                   | 
              |
| 31 | 
                  void test_download_queue_one_server_all_available(void *data, gconstpointer user_data);  | 
              |
| 32 | 
                  void test_download_queue_one_server_some_available(void *data, gconstpointer user_data);  | 
              |
| 33 | 
                   | 
              |
| 34 | 
                  /* test_download_queue_two_servers.c */  | 
              |
| 35 | 
                  void test_download_queue_setup_two_servers_equal_prio_before(void *data, gconstpointer user_data);  | 
              |
| 36 | 
                  void test_download_queue_setup_two_servers_equal_prio_after(void *data, gconstpointer user_data);  | 
              |
| 37 | 
                   | 
              |
| 38 | 
                  void test_download_queue_setup_two_servers_different_prio_before(void *data, gconstpointer user_data);  | 
              |
| 39 | 
                  void test_download_queue_setup_two_servers_different_prio_after(void *data, gconstpointer user_data);  | 
              |
| 40 | 
                   | 
              |
| 41 | 
                  void test_download_queue_setup_two_servers_before_one_initial(void *data, gconstpointer user_data);  | 
              |
| 42 | 
                  void test_download_queue_setup_two_servers_after_one_initial(void *data, gconstpointer user_data);  | 
              |
| 43 | 
                   | 
              |
| 44 | 
                  void test_download_queue_teardown_two_servers(void *data, gconstpointer user_data);  | 
              |
| 45 | 
                   | 
              |
| 46 | 
                  void test_download_queue_two_servers_equal_prio_all_available_on_one(void *data, gconstpointer user_data);  | 
              |
| 47 | 
                  void test_download_queue_two_servers_equal_prio_all_available_on_one_server_two_added_between(void *data, gconstpointer user_data);  | 
              |
| 48 | 
                   | 
              |
| 49 | 
                  void test_download_queue_two_servers_equal_prio_some_available_on_one_all_on_two(void *data, gconstpointer user_data);  | 
              |
| 50 | 
                  void test_download_queue_two_servers_equal_prio_some_available_on_one_all_on_two_server_two_added_between(void *data, gconstpointer user_data);  | 
              |
| 51 | 
                   | 
              |
| 52 | 
                  void test_download_queue_two_servers_equal_prio_some_available_on_one_some_on_two(void *data, gconstpointer user_data);  | 
              |
| 53 | 
                  void test_download_queue_two_servers_equal_prio_some_available_on_one_some_on_two_server_two_added_between(void *data, gconstpointer user_data);  | 
              |
| 54 | 
                   | 
              |
| 55 | 
                  void test_download_queue_two_servers_different_prio_all_available_on_one(void *data, gconstpointer user_data);  | 
              |
| 56 | 
                  void test_download_queue_two_servers_different_prio_all_available_on_one_server_two_added_between(void *data, gconstpointer user_data);  | 
              |
| 57 | 
                   | 
              |
| 58 | 
                  void test_download_queue_two_servers_different_prio_some_available_on_one_all_on_two(void *data, gconstpointer user_data);  | 
              |
| 59 | 
                  void test_download_queue_two_servers_different_prio_some_available_on_one_all_on_two_server_two_added_between(void *data, gconstpointer user_data);  | 
              |
| 60 | 
                   | 
              |
| 61 | 
                  void test_download_queue_two_servers_different_prio_some_available_on_one_some_on_two(void *data, gconstpointer user_data);  | 
              |
| 62 | 
                  void test_download_queue_two_servers_different_prio_some_available_on_one_some_on_two_server_two_added_between(void *data, gconstpointer user_data);  | 
              |
| 63 | 
                   | 
              |
| 64 | 
                  #endif /* _TEST_DOWNLOAD_QUEUE_H_ */  | 
              |
| trunk/tests/common.c (revision 1847) | ||
|---|---|---|
| 28 | 28 | 
                  #include  | 
              
| 29 | 29 | 
                  #endif  | 
              
| 30 | 30 | 
                   | 
              
| 31 | 
                  #include "common.h"  | 
              |
| 32 | 
                   | 
              |
| 33 | 
                  Configuration *config = NULL;  | 
              |
| 34 | 
                   | 
              |
| 31 | 35 | 
                  static char *  | 
              
| 32 | 36 | 
                  generate_tmpdir(void)  | 
              
| 33 | 37 | 
                  {
                 | 
              
| trunk/tests/Makefile.am (revision 1847) | ||
|---|---|---|
| 66 | 66 | 
                  test_download_queue_CFLAGS = -DDOWNLOAD_QUEUE_DONT_SET_TMP_FILENAME  | 
              
| 67 | 67 | 
                  test_download_queue_LDADD = $(GLIB_LIBS) $(top_srcdir)/base/libnntpgrab_utils.la  | 
              
| 68 | 68 | 
                  test_download_queue_SOURCES = test_download_queue.c \  | 
              
| 69 | 
                  test_download_queue_one_server.c \  | 
              |
| 70 | 
                  test_download_queue_two_servers.c \  | 
              |
| 69 | 71 | 
                  common.c \  | 
              
| 70 | 72 | 
                  $(top_srcdir)/nntpgrab_core/core_signals.c \  | 
              
| 71 | 73 | 
                  $(top_srcdir)/nntpgrab_core/collection_alloc.c \  | 
              
| ... | ... | |
| 75 | 77 | 
                   | 
              
| 76 | 78 | 
                  TEST_PROGS += test_nzbcreator test_nntpconnection_backend test_jsonrpc test_download_queue  | 
              
| 77 | 79 | 
                   | 
              
| 80 | 
                  noinst_HEADERS = common.h test_download_queue.h  | 
              |
| trunk/tests/common.h (revision 1847) | ||
|---|---|---|
| 19 | 19 | 
                  #ifndef _TESTS_COMMON_H_  | 
              
| 20 | 20 | 
                  #define _TESTS_COMMON_H_  | 
              
| 21 | 21 | 
                   | 
              
| 22 | 
                  #include "configuration.h"  | 
              |
| 23 | 
                   | 
              |
| 22 | 24 | 
                  void initialize_tests(void);  | 
              
| 23 | 25 | 
                  void cleanup_tests(void);  | 
              
| 24 | 26 | 
                  char *get_location_of_download_queue(void);  | 
              
| ... | ... | |
| 32 | 34 | 
                  g_error(format, ## args);  | 
              
| 33 | 35 | 
                  #endif  | 
              
| 34 | 36 | 
                   | 
              
| 37 | 
                  extern Configuration *config;  | 
              |
| 38 | 
                   | 
              |
| 35 | 39 | 
                  #endif /* _TESTS_COMMON_H_ */  | 
              
| trunk/po/fr.po (revision 1847) | ||
|---|---|---|
| 7 | 7 | 
                  msgstr ""  | 
              
| 8 | 8 | 
                  "Project-Id-Version: nntpgrab 0.2.90\n"  | 
              
| 9 | 9 | 
                  "Report-Msgid-Bugs-To: \n"  | 
              
| 10 | 
                  "POT-Creation-Date: 2011-06-25 15:40+0200\n"  | 
              |
| 10 | 
                  "POT-Creation-Date: 2011-07-08 18:11+0200\n"  | 
              |
| 11 | 11 | 
                  "PO-Revision-Date: 2009-10-07 07:43+0100\n"  | 
              
| 12 | 12 | 
                  "Last-Translator: \n"  | 
              
| 13 | 13 | 
                  "Language-Team: French\n"  | 
              
| ... | ... | |
| 1657 | 1657 | 
                  "configuration_save(): Erreur lors de l'ouverture du fichier '%s'\n"  | 
              
| 1658 | 1658 | 
                  "%s"  | 
              
| 1659 | 1659 | 
                   | 
              
| 1660 | 
                  #: ../nntpgrab_core/decoder_thread.c:55  | 
              |
| 1660 | 
                  #: ../nntpgrab_core/decoder_thread.c:54  | 
              |
| 1661 | 1661 | 
                  #, c-format  | 
              
| 1662 | 1662 | 
                  msgid "Trying to decode file with from collection '%s' with subject = '%s'"  | 
              
| 1663 | 1663 | 
                  msgstr ""  | 
              
| 1664 | 1664 | 
                  "Tentative de décodage du fichier de la collection '%s' ayant pour sujet = "  | 
              
| 1665 | 1665 | 
                  "'%s'"  | 
              
| 1666 | 1666 | 
                   | 
              
| 1667 | 
                  #: ../nntpgrab_core/decoder_thread.c:59  | 
              |
| 1667 | 
                  #: ../nntpgrab_core/decoder_thread.c:58  | 
              |
| 1668 | 1668 | 
                  #, c-format  | 
              
| 1669 | 1669 | 
                  msgid "Decoder returned %i"  | 
              
| 1670 | 1670 | 
                  msgstr "Le décodeur a retourné %i"  | 
              
| 1671 | 1671 | 
                   | 
              
| 1672 | 
                  #: ../nntpgrab_core/decoder_thread.c:139  | 
              |
| 1672 | 
                  #: ../nntpgrab_core/decoder_thread.c:111  | 
              |
| 1673 | 1673 | 
                  #, c-format  | 
              
| 1674 | 1674 | 
                  msgid "Unknown decode error occured, %s (%i)"  | 
              
| 1675 | 1675 | 
                  msgstr "Une erreur inconnue est survenue lors du décodage, %s (%i)"  | 
              
| 1676 | 1676 | 
                   | 
              
| 1677 | 
                  #: ../nntpgrab_core/download_queue.c:569  | 
              |
| 1677 | 
                  #: ../nntpgrab_core/download_queue.c:881  | 
              |
| 1678 | 1678 | 
                  #, c-format  | 
              
| 1679 | 1679 | 
                  msgid "There already is a file with subject '%s' part of collection '%s'"  | 
              
| 1680 | 1680 | 
                  msgstr ""  | 
              
| 1681 | 1681 | 
                  "Il existe déjà un fichier avec le sujet '%s' qui fait partie de la "  | 
              
| 1682 | 1682 | 
                  "collection '%s'"  | 
              
| 1683 | 1683 | 
                   | 
              
| 1684 | 
                  #: ../nntpgrab_core/download_queue.c:979  | 
              |
| 1685 | 
                  #: ../nntpgrab_core/download_queue.c:1119  | 
              |
| 1684 | 
                  #: ../nntpgrab_core/download_queue.c:1293  | 
              |
| 1685 | 
                  #: ../nntpgrab_core/download_queue.c:1440  | 
              |
| 1686 | 1686 | 
                  #, c-format  | 
              
| 1687 | 1687 | 
                  msgid "Subject '%s' was not found in collection '%s'"  | 
              
| 1688 | 1688 | 
                  msgstr "Le sujet '%s' n'a pu être trouvé dans la collection '%s'"  | 
              
| 1689 | 1689 | 
                   | 
              
| 1690 | 
                  #: ../nntpgrab_core/download_queue.c:1445  | 
              |
| 1690 | 
                  #: ../nntpgrab_core/download_queue.c:1759  | 
              |
| 1691 | 1691 | 
                  #, c-format  | 
              
| 1692 | 1692 | 
                  msgid "File '%s' of collection '%s' was marked optional"  | 
              
| 1693 | 1693 | 
                  msgstr ""  | 
              
| 1694 | 1694 | 
                   | 
              
| 1695 | 
                  #: ../nntpgrab_core/download_queue.c:1456  | 
              |
| 1695 | 
                  #: ../nntpgrab_core/download_queue.c:1770  | 
              |
| 1696 | 1696 | 
                  #, c-format  | 
              
| 1697 | 1697 | 
                  msgid "File '%s' of collection '%s' was marked non-optional"  | 
              
| 1698 | 1698 | 
                  msgstr ""  | 
              
| 1699 | 1699 | 
                   | 
              
| 1700 | 
                  #: ../nntpgrab_core/download_queue.c:1643  | 
              |
| 1700 | 
                  #: ../nntpgrab_core/download_queue.c:1957  | 
              |
| 1701 | 1701 | 
                  #, c-format  | 
              
| 1702 | 1702 | 
                  msgid "Collection '%s' has been completely downloaded without the PAR2 files"  | 
              
| 1703 | 1703 | 
                  msgstr ""  | 
              
| 1704 | 1704 | 
                   | 
              
| 1705 | 1705 | 
                  #. All files downloaded, allow other plugins to do post-processing (like automatic PAR2 repair and unpack)  | 
              
| 1706 | 
                  #: ../nntpgrab_core/download_queue.c:1650  | 
              |
| 1706 | 
                  #: ../nntpgrab_core/download_queue.c:1964  | 
              |
| 1707 | 1707 | 
                  #, c-format  | 
              
| 1708 | 1708 | 
                  msgid "Collection '%s' has been completely downloaded"  | 
              
| 1709 | 1709 | 
                  msgstr ""  | 
              
| 1710 | 1710 | 
                   | 
              
| 1711 | 
                  #: ../nntpgrab_core/download_queue.c:1686  | 
              |
| 1711 | 
                  #: ../nntpgrab_core/download_queue.c:2000  | 
              |
| 1712 | 1712 | 
                  #, fuzzy  | 
              
| 1713 | 1713 | 
                  msgid "All downloads are completed"  | 
              
| 1714 | 1714 | 
                  msgstr "Lorsque le téléchargement est terminé"  | 
              
| 1715 | 1715 | 
                   | 
              
| 1716 | 
                  #: ../nntpgrab_core/download_queue.c:1706  | 
              |
| 1716 | 
                  #: ../nntpgrab_core/download_queue.c:2020  | 
              |
| 1717 | 1717 | 
                  #, c-format  | 
              
| 1718 | 1718 | 
                  msgid ""  | 
              
| 1719 | 1719 | 
                  "%s:%i A PAR2 repair failure has occured but it's being ignored as the "  | 
              
| 1720 | 1720 | 
                  "configuration option 'Only download PAR2 files when needed' is disabled"  | 
              
| 1721 | 1721 | 
                  msgstr ""  | 
              
| 1722 | 1722 | 
                   | 
              
| 1723 | 
                  #: ../nntpgrab_core/download_queue.c:1711  | 
              |
| 1723 | 
                  #: ../nntpgrab_core/download_queue.c:2025  | 
              |
| 1724 | 1724 | 
                  #, c-format  | 
              
| 1725 | 1725 | 
                  msgid ""  | 
              
| 1726 | 1726 | 
                  "%s:%i No PAR2 files will be enabled automatically as the par2 recovery "  | 
              
| 1727 | 1727 | 
                  "failed due to an unknown error"  | 
              
| 1728 | 1728 | 
                  msgstr ""  | 
              
| 1729 | 1729 | 
                   | 
              
| 1730 | 
                  #: ../nntpgrab_core/download_queue.c:1719  | 
              |
| 1731 | 
                  #: ../nntpgrab_core/download_queue.c:1762  | 
              |
| 1730 | 
                  #: ../nntpgrab_core/download_queue.c:2033  | 
              |
| 1731 | 
                  #: ../nntpgrab_core/download_queue.c:2076  | 
              |
| 1732 | 1732 | 
                  #, fuzzy, c-format  | 
              
| 1733 | 1733 | 
                  msgid "%s:%i Unable to extract the name of the PAR2 set belonging to file '%s'"  | 
              
| 1734 | 1734 | 
                  msgstr "Échec de la sauvegarde de la partie dans le fichier '%s'"  | 
              
| 1735 | 1735 | 
                   | 
              
| 1736 | 
                  #: ../nntpgrab_core/download_queue.c:1754  | 
              |
| 1736 | 
                  #: ../nntpgrab_core/download_queue.c:2068  | 
              |
| 1737 | 1737 | 
                  #, fuzzy, c-format  | 
              
| 1738 | 1738 | 
                  msgid "%s:%i Unable to extract filename from subject '%s'"  | 
              
| 1739 | 1739 | 
                  msgstr "Échec de l'ajout du fichier : %s"  | 
              
| 1740 | 1740 | 
                   | 
              
| 1741 | 
                  #: ../nntpgrab_core/download_queue.c:1791  | 
              |
| 1741 | 
                  #: ../nntpgrab_core/download_queue.c:2105  | 
              |
| 1742 | 1742 | 
                  #, c-format  | 
              
| 1743 | 1743 | 
                  msgid "%s:%i %i PAR2 files were enabled by the intelligent PAR2 downloader"  | 
              
| 1744 | 1744 | 
                  msgstr ""  | 
              
| 1745 | 1745 | 
                   | 
              
| 1746 | 
                  #: ../nntpgrab_core/download_thread.c:504  | 
              |
| 1746 | 
                  #: ../nntpgrab_core/download_thread.c:507  | 
              |
| 1747 | 1747 | 
                  #, c-format  | 
              
| 1748 | 1748 | 
                  msgid "Unable to detect the IP address belonging to '%s' (servername = %s)"  | 
              
| 1749 | 1749 | 
                  msgstr ""  | 
              
| 1750 | 1750 | 
                  "Échec de la détection de l'adresse IP appartenant à '%s' (nom de serveur = "  | 
              
| 1751 | 1751 | 
                  "%s)"  | 
              
| 1752 | 1752 | 
                   | 
              
| 1753 | 
                  #: ../nntpgrab_core/download_thread.c:578  | 
              |
| 1753 | 
                  #: ../nntpgrab_core/download_thread.c:581  | 
              |
| 1754 | 1754 | 
                  #, fuzzy  | 
              
| 1755 | 1755 | 
                  msgid "Unexpected error occured while polling connection"  | 
              
| 1756 | 1756 | 
                  msgstr "Une erreur inconnue est survenue lors de l'exécution de la commande"  | 
              
| ... | ... | |
| 1844 | 1844 | 
                  msgid "Unknown error occured while reading the download queue: %s"  | 
              
| 1845 | 1845 | 
                  msgstr "Une erreur inconnue est survenue lors de l'exécution de la commande"  | 
              
| 1846 | 1846 | 
                   | 
              
| 1847 | 
                  #: ../nntpgrab_core/queue_rawfile.c:368 ../nntpgrab_core/queue_rawfile.c:370  | 
              |
| 1847 | 
                  #: ../nntpgrab_core/queue_rawfile.c:371 ../nntpgrab_core/queue_rawfile.c:373  | 
              |
| 1848 | 1848 | 
                  #, c-format  | 
              
| 1849 | 1849 | 
                  msgid "Malformed download queue detected"  | 
              
| 1850 | 1850 | 
                  msgstr ""  | 
              
| ... | ... | |
| 1939 | 1939 | 
                  "continue"  | 
              
| 1940 | 1940 | 
                  msgstr ""  | 
              
| 1941 | 1941 | 
                   | 
              
| 1942 | 
                  #: ../plugins/decoder/decoder.c:572 ../plugins/decoder/decoder.c:891  | 
              |
| 1942 | 
                  #: ../plugins/decoder/decoder.c:572 ../plugins/decoder/decoder.c:892  | 
              |
| 1943 | 1943 | 
                  #, fuzzy, c-format  | 
              
| 1944 | 1944 | 
                  msgid "%s:%i Unable to close file '%s': %s"  | 
              
| 1945 | 1945 | 
                  msgstr "Échec de l'ajout du fichier : %s"  | 
              
| ... | ... | |
| 1959 | 1959 | 
                  msgid "%s:%i The decoder wasn't able to write to file '%s': %s"  | 
              
| 1960 | 1960 | 
                  msgstr ""  | 
              
| 1961 | 1961 | 
                   | 
              
| 1962 | 
                  #: ../plugins/decoder/decoder.c:797  | 
              |
| 1962 | 
                  #: ../plugins/decoder/decoder.c:798  | 
              |
| 1963 | 1963 | 
                  #, c-format  | 
              
| 1964 | 1964 | 
                  msgid "File '%s' of collection '%s' is now being decoded to directory '%s'"  | 
              
| 1965 | 1965 | 
                  msgstr ""  | 
              
| 1966 | 1966 | 
                   | 
              
| 1967 | 
                  #: ../plugins/decoder/decoder.c:800  | 
              |
| 1967 | 
                  #: ../plugins/decoder/decoder.c:801  | 
              |
| 1968 | 1968 | 
                  #, c-format  | 
              
| 1969 | 1969 | 
                  msgid "Creation of folder '%s' failed, errno = %i, %s\n"  | 
              
| 1970 | 1970 | 
                  msgstr "Échec de la création du dossier '%s', errno = %i, %s\n"  | 
              
| 1971 | 1971 | 
                   | 
              
| 1972 | 
                  #: ../plugins/decoder/decoder.c:807 ../plugins/decoder/decoder.c:811  | 
              |
| 1972 | 
                  #: ../plugins/decoder/decoder.c:808 ../plugins/decoder/decoder.c:812  | 
              |
| 1973 | 1973 | 
                  #, fuzzy, c-format  | 
              
| 1974 | 1974 | 
                  msgid "Unable to navigate to folder '%s': %s"  | 
              
| 1975 | 1975 | 
                  msgstr "Échec de la navigation vers le dossier '%s'"  | 
              
| 1976 | 1976 | 
                   | 
              
| 1977 | 
                  #: ../plugins/decoder/decoder.c:944  | 
              |
| 1977 | 
                  #: ../plugins/decoder/decoder.c:945  | 
              |
| 1978 | 1978 | 
                  msgid "No data to decode"  | 
              
| 1979 | 1979 | 
                  msgstr "Aucune donnée à décoder"  | 
              
| 1980 | 1980 | 
                   | 
              
| 1981 | 
                  #: ../plugins/decoder/decoder.c:966  | 
              |
| 1981 | 
                  #: ../plugins/decoder/decoder.c:967  | 
              |
| 1982 | 1982 | 
                  #, c-format  | 
              
| 1983 | 1983 | 
                  msgid "Decoding completed with return value %i"  | 
              
Also available in: Unified diff
NNTPGrab

