| 210 |
// printf("Loaded %d articles into section %d\n", p_section[i]->article_count, i); |
// printf("Loaded %d articles into section %d\n", p_section[i]->article_count, i); |
| 211 |
} |
} |
| 212 |
|
|
| 213 |
|
if (last_aid != article_block_last_aid()) |
| 214 |
|
{ |
| 215 |
|
printf("last_aid != %d\n", article_block_last_aid()); |
| 216 |
|
} |
| 217 |
|
|
| 218 |
|
if (article_block_article_count() != section_count * BBS_article_limit_per_section) |
| 219 |
|
{ |
| 220 |
|
printf("article_block_article_count() error %d != %d * %d\n", |
| 221 |
|
article_block_article_count(), section_count, BBS_article_limit_per_section); |
| 222 |
|
} |
| 223 |
|
|
| 224 |
last_aid = 0; |
last_aid = 0; |
| 225 |
|
|
| 226 |
for (j = 0; j < BBS_article_limit_per_section; j++) |
for (j = 0; j < BBS_article_limit_per_section; j++) |
| 921 |
} |
} |
| 922 |
} |
} |
| 923 |
|
|
| 924 |
|
printf("Testing #6 ...\n"); |
| 925 |
|
|
| 926 |
|
for (i = 0; i < section_count; i++) |
| 927 |
|
{ |
| 928 |
|
if (section_list_rd_lock(p_section[i]) < 0) |
| 929 |
|
{ |
| 930 |
|
printf("section_list_rd_lock(sid = %d) error\n", p_section[i]->sid); |
| 931 |
|
break; |
| 932 |
|
} |
| 933 |
|
} |
| 934 |
|
|
| 935 |
|
printf("Try rw_lock for 5 sec...\n"); |
| 936 |
|
if (section_list_try_rw_lock(NULL, 5) == 0) |
| 937 |
|
{ |
| 938 |
|
printf("section_list_try_rw_lock(sid = %d) error, expectation is timeout\n", p_section[i]->sid); |
| 939 |
|
} |
| 940 |
|
|
| 941 |
|
for (i = 0; i < section_count; i++) |
| 942 |
|
{ |
| 943 |
|
if (section_list_rd_unlock(p_section[i]) < 0) |
| 944 |
|
{ |
| 945 |
|
printf("section_list_rd_unlock(sid = %d) error\n", p_section[i]->sid); |
| 946 |
|
break; |
| 947 |
|
} |
| 948 |
|
} |
| 949 |
|
|
| 950 |
|
if (section_list_try_rw_lock(NULL, 5) < 0) |
| 951 |
|
{ |
| 952 |
|
printf("section_list_rd_lock(sid = %d) error\n", p_section[i]->sid); |
| 953 |
|
} |
| 954 |
|
|
| 955 |
|
for (i = 0; i < section_count; i++) |
| 956 |
|
{ |
| 957 |
|
if (section_list_try_rd_lock(p_section[i], 0) == 0) |
| 958 |
|
{ |
| 959 |
|
printf("section_list_try_rd_lock(sid = %d) error, expectation is timeout\n", p_section[i]->sid); |
| 960 |
|
break; |
| 961 |
|
} |
| 962 |
|
} |
| 963 |
|
|
| 964 |
|
if (section_list_rw_unlock(NULL) < 0) |
| 965 |
|
{ |
| 966 |
|
printf("section_list_rw_unlock(sid = %d) error\n", p_section[i]->sid); |
| 967 |
|
} |
| 968 |
|
|
| 969 |
printf("Press ENTER to exit..."); |
printf("Press ENTER to exit..."); |
| 970 |
getchar(); |
getchar(); |
| 971 |
|
|