diff options
| author | 杨威 <[email protected]> | 2023-01-17 13:40:02 +0800 |
|---|---|---|
| committer | 杨威 <[email protected]> | 2023-01-17 13:40:02 +0800 |
| commit | a7432658be53c1bdb461e834af1e2e3b5bcf44ff (patch) | |
| tree | 42a9af54a7b675920dc93849102671b1389c21a0 | |
| parent | 5135323f384f2e8e38b6710aa34ec2c07a818def (diff) | |
🧪 test(test_app_sapp): 更新timed示例插件
| -rw-r--r-- | bin/plug/business/test_app/test_app.inf | 6 | ||||
| -rw-r--r-- | test/test_app_sapp.c | 52 |
2 files changed, 45 insertions, 13 deletions
diff --git a/bin/plug/business/test_app/test_app.inf b/bin/plug/business/test_app/test_app.inf index 476f417..da85bc9 100644 --- a/bin/plug/business/test_app/test_app.inf +++ b/bin/plug/business/test_app/test_app.inf @@ -49,6 +49,8 @@ INIT_FUNC=CHAR_INIT #FUNC_NAME=test_set_stream_timeout #FUNC_NAME=test_tcp_uni_stream_stats #FUNC_NAME=print_vxlan_info +#FUNC_NAME=test_app_stream_timed_1s +#FUNC_NAME=test_app_stream_timed_2s [TCP_ALL] FUNC_FLAG=ALL @@ -63,6 +65,8 @@ FUNC_NAME=testtcpApp_allpkt #FUNC_NAME=TCP_ENTRY_ALL #FUNC_NAME=test_allpkt_stream #FUNC_NAME=test_get_stream_tcp_opts +#FUNC_NAME=test_tcpall_stream_timed_1s +#FUNC_NAME=test_tcpall_stream_timed_2s [UDP] FUNC_FLAG=ALL @@ -77,6 +81,8 @@ FUNC_NAME=testudpApp_1 #FUNC_NAME=test_get_rawpkt_opt_from_streaminfo #FUNC_NAME=test_set_stream_timeout #FUNC_NAME=print_vxlan_info +#FUNC_NAME=test_app_stream_timed_1s +#FUNC_NAME=test_app_stream_timed_2s #[POLLING] #FUNC_FLAG=ALL diff --git a/test/test_app_sapp.c b/test/test_app_sapp.c index 7eecd3a..bc22e38 100644 --- a/test/test_app_sapp.c +++ b/test/test_app_sapp.c @@ -495,40 +495,66 @@ char test_set_stream_timeout(struct streaminfo *pstream, void **pme, int thread return APP_STATE_GIVEME; } -char test_set_stream_timed(struct streaminfo *pstream, void **pme, int thread_seq,void *a_packet) + + +static char set_stream_timed(struct streaminfo *pstream, void **pme, int thread_seq,void *a_packet, unsigned char opstate, int timed_s) { int ret; - int tout_val; - static int timed_cnt=0; + int tout_val = timed_s; + + long timed_cnt = *(long *)pme; - if (pstream->pktstate == OP_STATE_PENDING) + if (opstate == OP_STATE_PENDING) { - tout_val = 1; ret = MESA_set_stream_opt(pstream, MSO_STREAM_TIMED, &tout_val, sizeof(int)); if (ret < 0) { - DPRINT("stream:%p, MESA_set_stream_opt error:\n", pstream); + DPRINT("stream:%p, MESA_set_stream_opt %ds error:\n", pstream, timed_s); return APP_STATE_DROPME; } - DPRINT("stream: %p %s set timer at %ld!\n", pstream, printaddr(&pstream->addr, thread_seq), time(NULL)); + DPRINT("timed_%d_stream: %p %s set timer %d at %ld!\n", timed_s, pstream, printaddr(&pstream->addr, thread_seq), timed_s, time(NULL)); } - if (pstream->pktstate == OP_STATE_TIMED) + if (opstate == OP_STATE_TIMED) { timed_cnt+=1; - DPRINT("stream timed callback: %p %s, cnt=%d at %ld!\n", pstream, printaddr(&pstream->addr, thread_seq), timed_cnt, time(NULL)); - if(timed_cnt >= 5) + DPRINT("timed_%d_stream timed callback: %p %s, cnt=%ld at %ld!\n", timed_s, pstream, printaddr(&pstream->addr, thread_seq), timed_cnt, time(NULL)); + if(timed_cnt >= 3) { - DPRINT("stream timed callback: %p %s, cnt=%d >= 5, dropme!\n", pstream, printaddr(&pstream->addr, thread_seq), timed_cnt); + DPRINT("timed_%d_stream timed callback: %p %s, cnt=%ld >= 3, dropme!\n", timed_s, pstream, printaddr(&pstream->addr, thread_seq), timed_cnt); return APP_STATE_DROPME; } + *(long *)pme = timed_cnt; } - if (pstream->pktstate == OP_STATE_CLOSE) + if (opstate == OP_STATE_CLOSE) { - DPRINT("stream close: %p %s at %ld!\n", pstream, printaddr(&pstream->addr, thread_seq), time(NULL)); + DPRINT("timed_%d_stream close: %p %s at %ld!\n",timed_s, pstream, printaddr(&pstream->addr, thread_seq), time(NULL)); } return APP_STATE_GIVEME; } +char test_tcpall_stream_timed_1s(struct streaminfo *pstream, void **pme, int thread_seq,void *a_packet) +{ + return set_stream_timed(pstream, pme, thread_seq, a_packet, pstream->pktstate, 1); +} + + +char test_tcpall_stream_timed_2s(struct streaminfo *pstream, void **pme, int thread_seq,void *a_packet) +{ + return set_stream_timed(pstream, pme, thread_seq, a_packet, pstream->pktstate, 2); +} + +char test_app_stream_timed_1s(struct streaminfo *pstream, void **pme, int thread_seq,void *a_packet) +{ + return set_stream_timed(pstream, pme, thread_seq, a_packet, pstream->opstate, 1); +} + + +char test_app_stream_timed_2s(struct streaminfo *pstream, void **pme, int thread_seq,void *a_packet) +{ + return set_stream_timed(pstream, pme, thread_seq, a_packet, pstream->opstate, 2); +} + + char test_sapp_get_platform_opt(struct streaminfo *pstream, void **pme, int thread_seq,void *a_packet) { unsigned long long totpkt, totbyte, rand_num; |
