/[LeafOK_CVS]/lbbs/src/test_section_list.c
ViewVC logotype

Diff of /lbbs/src/test_section_list.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.2 by sysadm, Wed May 21 05:36:04 2025 UTC Revision 1.3 by sysadm, Wed May 21 06:17:52 2025 UTC
# Line 44  int main(int argc, char *argv[]) Line 44  int main(int argc, char *argv[])
44          SECTION_DATA *p_section[BBS_max_section];          SECTION_DATA *p_section[BBS_max_section];
45          ARTICLE *p_article;          ARTICLE *p_article;
46          ARTICLE article;          ARTICLE article;
47            int block_count;
48          int i, j;          int i, j;
49          int last_aid;          int last_aid;
50          int group_count;          int group_count;
51            int article_count;
52    
53          if (log_begin("../log/bbsd.log", "../log/error.log") < 0)          if (log_begin("../log/bbsd.log", "../log/error.log") < 0)
54          {          {
# Line 57  int main(int argc, char *argv[]) Line 59  int main(int argc, char *argv[])
59          log_std_redirect(STDOUT_FILENO);          log_std_redirect(STDOUT_FILENO);
60          log_err_redirect(STDERR_FILENO);          log_err_redirect(STDERR_FILENO);
61    
62          if (section_data_pool_init("../conf/menu.conf", BBS_article_block_limit_per_section * BBS_max_section) < 0)          block_count = BBS_article_block_limit_per_section * BBS_max_section - 1;
63    
64            if (section_data_pool_init("../conf/menu.conf", block_count) < 0)
65          {          {
66                  log_error("section_data_pool_init() error\n");                  log_error("section_data_pool_init() error\n");
67                  return -2;                  return -2;
# Line 92  int main(int argc, char *argv[]) Line 96  int main(int argc, char *argv[])
96                          article.ontop = 0;                          article.ontop = 0;
97                          article.lock = 0;                          article.lock = 0;
98    
99                          section_data_append_article(p_section[i], &article);                          if (section_data_append_article(p_section[i], &article) < 0)
100                            {
101                                    printf("append article (aid = %d) error\n", article.aid);
102                                    break;
103                            }
104                  }                  }
105    
106                  printf("Load %d articles into section %d\n", p_section[i]->article_count, i);                  printf("Load %d articles into section %d\n", p_section[i]->article_count, i);
# Line 102  int main(int argc, char *argv[]) Line 110  int main(int argc, char *argv[])
110    
111          for (i = 0; i < section_count; i++)          for (i = 0; i < section_count; i++)
112          {          {
113                    if (p_section[i]->article_count == 0)
114                    {
115                            continue;
116                    }
117    
118                  for (j = 0; j < p_section[i]->article_count; j++)                  for (j = 0; j < p_section[i]->article_count; j++)
119                  {                  {
120                          last_aid++;                          last_aid++;
# Line 144  int main(int argc, char *argv[]) Line 157  int main(int argc, char *argv[])
157                          article.ontop = 0;                          article.ontop = 0;
158                          article.lock = 0;                          article.lock = 0;
159    
160                          section_data_append_article(p_section[i], &article);                          if (section_data_append_article(p_section[i], &article) < 0)
161                            {
162                                    printf("append article (aid = %d) error\n", article.aid);
163                                    break;
164                            }
165                  }                  }
166    
167                  printf("Load %d articles into section %d\n", p_section[i]->article_count, i);                  printf("Load %d articles into section %d\n", p_section[i]->article_count, i);
# Line 152  int main(int argc, char *argv[]) Line 169  int main(int argc, char *argv[])
169    
170          for (i = 0; i < section_count; i++)          for (i = 0; i < section_count; i++)
171          {          {
172                    if (p_section[i]->article_count == 0)
173                    {
174                            continue;
175                    }
176    
177                  for (j = 0; j < group_count; j++)                  for (j = 0; j < group_count; j++)
178                  {                  {
179                          p_article = section_data_find_article_by_index(p_section[i], j);                          p_article = section_data_find_article_by_index(p_section[i], j);
# Line 166  int main(int argc, char *argv[]) Line 188  int main(int argc, char *argv[])
188                                  break;                                  break;
189                          }                          }
190    
191                            article_count = 1;
192    
193                          do                          do
194                          {                          {
195                                  if (p_article->next_aid <= p_article->aid && p_article->next_aid != p_article->tid)                                  if (p_article->next_aid <= p_article->aid && p_article->next_aid != p_article->tid)
# Line 190  int main(int argc, char *argv[]) Line 214  int main(int argc, char *argv[])
214                                          printf("Inconsistent tid at aid %d != %d\n", last_aid, j + 1);                                          printf("Inconsistent tid at aid %d != %d\n", last_aid, j + 1);
215                                          break;                                          break;
216                                  }                                  }
217                                    article_count++;
218                          } while (1);                          } while (1);
219    
220                            if (article_count != p_section[i]->article_count / group_count)
221                            {
222                                    printf("Count of articles in topic %d is less than expected %d < %d\n",
223                                               j + 1, article_count, p_section[i]->article_count / group_count);
224                            }
225                  }                  }
226    
227                  printf("Verify %d topics in section %d\n", group_count, i);                  printf("Verify %d topics in section %d\n", group_count, i);


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1