(t *testing.T)
| 58 | } |
| 59 | |
| 60 | func Test_parseNetIPSocketLine(t *testing.T) { |
| 61 | tests := []struct { |
| 62 | fields []string |
| 63 | name string |
| 64 | want *netIPSocketLine |
| 65 | wantErr bool |
| 66 | isUDP bool |
| 67 | }{ |
| 68 | { |
| 69 | name: "reading valid lines, no issue should happened", |
| 70 | fields: []string{"11:", "00000000:0000", "00000000:0000", "0A", "00000017:0000002A", "0:0", "0", "1000", "0", "39309"}, |
| 71 | want: &netIPSocketLine{ |
| 72 | Sl: 11, |
| 73 | LocalAddr: net.IP{0, 0, 0, 0}, |
| 74 | LocalPort: 0, |
| 75 | RemAddr: net.IP{0, 0, 0, 0}, |
| 76 | RemPort: 0, |
| 77 | St: 10, |
| 78 | TxQueue: 23, |
| 79 | RxQueue: 42, |
| 80 | UID: 1000, |
| 81 | Inode: 39309, |
| 82 | }, |
| 83 | }, |
| 84 | { |
| 85 | name: "error case - invalid line - number of fields/columns < 10", |
| 86 | fields: []string{"1:", "00000000:0000", "00000000:0000", "07", "0:0", "0", "0"}, |
| 87 | want: nil, |
| 88 | wantErr: true, |
| 89 | }, |
| 90 | { |
| 91 | name: "error case - parse sl - not a valid uint", |
| 92 | fields: []string{"a:", "00000000:0000", "00000000:0000", "07", "00000000:00000001", "0:0", "0", "0", "0", "39309"}, |
| 93 | want: nil, |
| 94 | wantErr: true, |
| 95 | }, |
| 96 | { |
| 97 | name: "error case - parse local_address - not a valid hex", |
| 98 | fields: []string{"1:", "0000000O:0000", "00000000:0000", "07", "00000000:00000001", "0:0", "0", "0", "0", "39309"}, |
| 99 | want: nil, |
| 100 | wantErr: true, |
| 101 | }, |
| 102 | { |
| 103 | name: "error case - parse rem_address - not a valid hex", |
| 104 | fields: []string{"1:", "00000000:0000", "0000000O:0000", "07", "00000000:00000001", "0:0", "0", "0", "0", "39309"}, |
| 105 | want: nil, |
| 106 | wantErr: true, |
| 107 | }, |
| 108 | { |
| 109 | name: "error case - cannot parse line - missing colon", |
| 110 | fields: []string{"1:", "00000000:0000", "00000000:0000", "07", "0000000000000001", "0:0", "0", "0", "0", "39309"}, |
| 111 | want: nil, |
| 112 | wantErr: true, |
| 113 | }, |
| 114 | { |
| 115 | name: "error case - parse tx_queue - not a valid hex", |
| 116 | fields: []string{"1:", "00000000:0000", "00000000:0000", "07", "DEADCODE:00000001", "0:0", "0", "0", "0", "39309"}, |
| 117 | want: nil, |
nothing calls this directly
no test coverage detected