Skip to content

Commit 3099f9e

Browse files
pseidererkuba-moo
authored andcommitted
selftest: net: update proc_net_pktgen (add more imix_weights test cases)
Add more imix_weights test cases (for incomplete input). Signed-off-by: Peter Seiderer <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7151062 commit 3099f9e

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tools/testing/selftests/net/proc_net_pktgen.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ static const char dev_cmd_pkt_size_0[] = "pkt_size 300";
3939
static const char dev_cmd_imix_weights_0[] = "imix_weights 0,7 576,4 1500,1";
4040
static const char dev_cmd_imix_weights_1[] = "imix_weights 101,1 102,2 103,3 104,4 105,5 106,6 107,7 108,8 109,9 110,10 111,11 112,12 113,13 114,14 115,15 116,16 117,17 118,18 119,19 120,20";
4141
static const char dev_cmd_imix_weights_2[] = "imix_weights 100,1 102,2 103,3 104,4 105,5 106,6 107,7 108,8 109,9 110,10 111,11 112,12 113,13 114,14 115,15 116,16 117,17 118,18 119,19 120,20 121,21";
42+
static const char dev_cmd_imix_weights_3[] = "imix_weights";
43+
static const char dev_cmd_imix_weights_4[] = "imix_weights ";
44+
static const char dev_cmd_imix_weights_5[] = "imix_weights 0";
45+
static const char dev_cmd_imix_weights_6[] = "imix_weights 0,";
4246
static const char dev_cmd_debug_0[] = "debug 1";
4347
static const char dev_cmd_debug_1[] = "debug 0";
4448
static const char dev_cmd_frags_0[] = "frags 100";
@@ -284,6 +288,46 @@ TEST_F(proc_net_pktgen, dev_cmd_imix_weights) {
284288
len = write(self->dev_fd, dev_cmd_imix_weights_2, sizeof(dev_cmd_imix_weights_2));
285289
EXPECT_EQ(len, -1);
286290
EXPECT_EQ(errno, E2BIG);
291+
292+
/* with trailing '\0' */
293+
len = write(self->dev_fd, dev_cmd_imix_weights_3, sizeof(dev_cmd_imix_weights_3));
294+
EXPECT_EQ(len, -1);
295+
EXPECT_EQ(errno, EINVAL);
296+
297+
/* without trailing '\0' */
298+
len = write(self->dev_fd, dev_cmd_imix_weights_3, sizeof(dev_cmd_imix_weights_3) - 1);
299+
EXPECT_EQ(len, -1);
300+
EXPECT_EQ(errno, EINVAL);
301+
302+
/* with trailing '\0' */
303+
len = write(self->dev_fd, dev_cmd_imix_weights_4, sizeof(dev_cmd_imix_weights_4));
304+
EXPECT_EQ(len, -1);
305+
EXPECT_EQ(errno, EINVAL);
306+
307+
/* without trailing '\0' */
308+
len = write(self->dev_fd, dev_cmd_imix_weights_4, sizeof(dev_cmd_imix_weights_4) - 1);
309+
EXPECT_EQ(len, -1);
310+
EXPECT_EQ(errno, EINVAL);
311+
312+
/* with trailing '\0' */
313+
len = write(self->dev_fd, dev_cmd_imix_weights_5, sizeof(dev_cmd_imix_weights_5));
314+
EXPECT_EQ(len, -1);
315+
EXPECT_EQ(errno, EINVAL);
316+
317+
/* without trailing '\0' */
318+
len = write(self->dev_fd, dev_cmd_imix_weights_5, sizeof(dev_cmd_imix_weights_5) - 1);
319+
EXPECT_EQ(len, -1);
320+
EXPECT_EQ(errno, EINVAL);
321+
322+
/* with trailing '\0' */
323+
len = write(self->dev_fd, dev_cmd_imix_weights_6, sizeof(dev_cmd_imix_weights_6));
324+
EXPECT_EQ(len, -1);
325+
EXPECT_EQ(errno, EINVAL);
326+
327+
/* without trailing '\0' */
328+
len = write(self->dev_fd, dev_cmd_imix_weights_6, sizeof(dev_cmd_imix_weights_6) - 1);
329+
EXPECT_EQ(len, -1);
330+
EXPECT_EQ(errno, EINVAL);
287331
}
288332

289333
TEST_F(proc_net_pktgen, dev_cmd_debug) {

0 commit comments

Comments
 (0)