From: Dylan Jhong <dylan@andestech.com>
To: <ltp@lists.linux.it>
Cc: alankao@andestech.com, minachou@andestech.com,
dminus@andestech.com, x5710999x@gmail.com
Subject: [LTP] [PATCH] kernel/uevent: Adjust the number of uevents dynamically in uevent02
Date: Wed, 14 Sep 2022 21:19:50 +0800 [thread overview]
Message-ID: <20220914131950.1783054-1-dylan@andestech.com> (raw)
When CONFIG_SMP is not selected, CONFIG_RPS will not be enabled. Causes the
kernel to not create rx queues in sysfs[*1] when creating tun devices.
uevent02 will check if the rx queue exists, so we have to dynamically adjust
the number of uevents to pass this testcase.
[*1]: https://github.com/torvalds/linux/blob/3245cb65fd91cd514801bf91f5a3066d562f0ac4/net/core/net-sysfs.c#L1109
Signed-off-by: Dylan Jhong <dylan@andestech.com>
---
testcases/kernel/uevents/uevent02.c | 146 ++++++++++++++--------------
1 file changed, 73 insertions(+), 73 deletions(-)
diff --git a/testcases/kernel/uevents/uevent02.c b/testcases/kernel/uevents/uevent02.c
index ce0cf757d..059320f1c 100644
--- a/testcases/kernel/uevents/uevent02.c
+++ b/testcases/kernel/uevents/uevent02.c
@@ -19,11 +19,71 @@
#include <linux/if_tun.h>
#include "tst_test.h"
+#include "tst_private.h"
#include "uevent.h"
#define TUN_PATH "/dev/net/tun"
+#define MAX_UEVENT 7
+
+struct uevent_desc add = {
+ .msg = "add@/devices/virtual/net/ltp-tun0",
+ .value_cnt = 4,
+ .values = (const char*[]) {
+ "ACTION=add",
+ "DEVPATH=/devices/virtual/net/ltp-tun0",
+ "SUBSYSTEM=net",
+ "INTERFACE=ltp-tun0",
+ }
+};
+struct uevent_desc add_rx = {
+ .msg = "add@/devices/virtual/net/ltp-tun0/queues/rx-0",
+ .value_cnt = 3,
+ .values = (const char*[]) {
+ "ACTION=add",
+ "DEVPATH=/devices/virtual/net/ltp-tun0/queues/rx-0",
+ "SUBSYSTEM=queues",
+ }
+};
+struct uevent_desc add_tx = {
+ .msg = "add@/devices/virtual/net/ltp-tun0/queues/tx-0",
+ .value_cnt = 3,
+ .values = (const char*[]) {
+ "ACTION=add",
+ "DEVPATH=/devices/virtual/net/ltp-tun0/queues/tx-0",
+ "SUBSYSTEM=queues",
+ }
+};
+struct uevent_desc rem_rx = {
+ .msg = "remove@/devices/virtual/net/ltp-tun0/queues/rx-0",
+ .value_cnt = 3,
+ .values = (const char*[]) {
+ "ACTION=remove",
+ "DEVPATH=/devices/virtual/net/ltp-tun0/queues/rx-0",
+ "SUBSYSTEM=queues",
+ }
+};
+struct uevent_desc rem_tx = {
+ .msg = "remove@/devices/virtual/net/ltp-tun0/queues/tx-0",
+ .value_cnt = 3,
+ .values = (const char*[]) {
+ "ACTION=remove",
+ "DEVPATH=/devices/virtual/net/ltp-tun0/queues/tx-0",
+ "SUBSYSTEM=queues",
+ }
+};
+struct uevent_desc rem = {
+ .msg = "remove@/devices/virtual/net/ltp-tun0",
+ .value_cnt = 4,
+ .values = (const char*[]) {
+ "ACTION=remove",
+ "DEVPATH=/devices/virtual/net/ltp-tun0",
+ "SUBSYSTEM=net",
+ "INTERFACE=ltp-tun0",
+ }
+};
+
static void generate_tun_uevents(void)
{
int fd = SAFE_OPEN(TUN_PATH, O_RDWR);
@@ -42,79 +102,19 @@ static void generate_tun_uevents(void)
static void verify_uevent(void)
{
- int pid, fd;
-
- struct uevent_desc add = {
- .msg = "add@/devices/virtual/net/ltp-tun0",
- .value_cnt = 4,
- .values = (const char*[]) {
- "ACTION=add",
- "DEVPATH=/devices/virtual/net/ltp-tun0",
- "SUBSYSTEM=net",
- "INTERFACE=ltp-tun0",
- }
- };
-
- struct uevent_desc add_rx = {
- .msg = "add@/devices/virtual/net/ltp-tun0/queues/rx-0",
- .value_cnt = 3,
- .values = (const char*[]) {
- "ACTION=add",
- "DEVPATH=/devices/virtual/net/ltp-tun0/queues/rx-0",
- "SUBSYSTEM=queues",
- }
- };
-
- struct uevent_desc add_tx = {
- .msg = "add@/devices/virtual/net/ltp-tun0/queues/tx-0",
- .value_cnt = 3,
- .values = (const char*[]) {
- "ACTION=add",
- "DEVPATH=/devices/virtual/net/ltp-tun0/queues/tx-0",
- "SUBSYSTEM=queues",
- }
- };
-
- struct uevent_desc rem_rx = {
- .msg = "remove@/devices/virtual/net/ltp-tun0/queues/rx-0",
- .value_cnt = 3,
- .values = (const char*[]) {
- "ACTION=remove",
- "DEVPATH=/devices/virtual/net/ltp-tun0/queues/rx-0",
- "SUBSYSTEM=queues",
- }
- };
-
- struct uevent_desc rem_tx = {
- .msg = "remove@/devices/virtual/net/ltp-tun0/queues/tx-0",
- .value_cnt = 3,
- .values = (const char*[]) {
- "ACTION=remove",
- "DEVPATH=/devices/virtual/net/ltp-tun0/queues/tx-0",
- "SUBSYSTEM=queues",
- }
- };
-
- struct uevent_desc rem = {
- .msg = "remove@/devices/virtual/net/ltp-tun0",
- .value_cnt = 4,
- .values = (const char*[]) {
- "ACTION=remove",
- "DEVPATH=/devices/virtual/net/ltp-tun0",
- "SUBSYSTEM=net",
- "INTERFACE=ltp-tun0",
- }
- };
-
- const struct uevent_desc *const uevents[] = {
- &add,
- &add_rx,
- &add_tx,
- &rem_rx,
- &rem_tx,
- &rem,
- NULL
- };
+ const struct uevent_desc *uevents[MAX_UEVENT];
+ int pid, fd, i = 0;
+ int has_RPS = tst_kconfig_get("CONFIG_RPS");
+
+ uevents[i++] = &add;
+ if (has_RPS)
+ uevents[i++] = &add_rx;
+ uevents[i++] = &add_tx;
+ if (has_RPS)
+ uevents[i++] = &rem_rx;
+ uevents[i++] = &rem_tx;
+ uevents[i++] = &rem;
+ uevents[i++] = NULL;
pid = SAFE_FORK();
if (!pid) {
--
2.34.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next reply other threads:[~2022-09-14 13:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-14 13:19 Dylan Jhong [this message]
2022-09-15 8:58 ` [LTP] [PATCH] kernel/uevent: Adjust the number of uevents dynamically in uevent02 Cyril Hrubis
2022-09-15 10:03 ` Dylan Jhong
2022-09-15 10:09 ` Cyril Hrubis
2022-09-15 10:32 ` Dylan Jhong
2022-09-15 11:06 ` Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220914131950.1783054-1-dylan@andestech.com \
--to=dylan@andestech.com \
--cc=alankao@andestech.com \
--cc=dminus@andestech.com \
--cc=ltp@lists.linux.it \
--cc=minachou@andestech.com \
--cc=x5710999x@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox