linux-test-project / ltp

Linux Test Project (mailing list: https://lists.linux.it/listinfo/ltp)
https://linux-test-project.readthedocs.io/
GNU General Public License v2.0
2.32k stars 1.02k forks source link

fix ping output of ltpClient with dump-like format #439

Open sugarfillet opened 5 years ago

sugarfillet commented 5 years ago

Hi, everyone I found the testcases/network/sockets/ltpClient ping output is messy. And that made my uncomfortable. So I fix it with dump-like format. output before the fixing:

[0]:  [69] [0] [0] [84] [230] [245] [0] [0] [64] [1] [107] [54] [9] [41] [11] [22]
[16]:  [9] [41] [11] [22] [0] [0] [236] [161] [208] [108] [7] [0] [48] [49] [50] [51]
[32]:  [52] [53] [54] [55] [56] [57] [58] [59] [60] [61] [62] [63] [64] [65] [66] [67]
[48]:  [68] [69] [70] [71] [72] [73] [74] [75] [76] [77] [78] [79] [80] [81] [82] [83]
[64]:  [84] [85] [86] [87] [88] [89] [90] [91] [92] [93] [94] [95] [96] [97] [98] [99]
[80]:  [100] [101] [102] [0]

output after the fixing:

[ 0]:   45  00  00  54  bf  b3  00  00  40  01  92  78  09  29  0b  16
[16]:   09  29  0b  16  00  00  a5  c1  16  4d  08  00  30  31  32  33
[32]:   34  35  36  37  38  39  3a  3b  3c  3d  3e  3f  40  41  42  43
[48]:   44  45  46  47  48  49  4a  4b  4c  4d  4e  4f  50  51  52  53
[64]:   54  55  56  57  58  59  5a  5b  5c  5d  5e  5f  60  61  62  63
[80]:   64  65  66  00

here is the patch:

 diff --git a/testcases/network/sockets/ltpClient.c b/testcases/network/sockets/ltpClient.c
 index 2981737..cb2a681 100644
 --- a/testcases/network/sockets/ltpClient.c
 +++ b/testcases/network/sockets/ltpClient.c
 @@ -449,10 +449,10 @@ void output_to_display(void *netPacket, int bytes, int pid)

         for (i = 0; i < bytes; i++) {
                 if (!(i & 15)) {
 -                       printf("\n[%d]:  ", i);
 +                       printf("\n[%2d]:  ", i);
                 }

 -               printf("[%d] ", ((unsigned char *)netPacket)[i]);
 +               printf("[%02x] ", ((unsigned char *)netPacket)[i]);
         }

         printf("\n");

Hope it will be merged. :)

Thanks.

pevik commented 5 years ago

This script is not in any runtest file, so it's probably hidden for most of users. Change make sense. Can you please send it via mailing list (http://lists.linux.it/listinfo/ltp)? See more info in https://github.com/linux-test-project/ltp#developers-corner. We also accept PR, but sending patch to mailing list is preferable way.