Module: xenomai-jki
Branch: for-upstream
Commit: dede8fde31b175ddccaee610b7b0ff21560872a5
URL:    
http://git.xenomai.org/?p=xenomai-jki.git;a=commit;h=dede8fde31b175ddccaee610b7b0ff21560872a5

Author: Jan Kiszka <jan.kis...@siemens.com>
Date:   Sun Apr 11 17:35:51 2010 +0200

rttest: Resolved test device conflicts via separate name spaces

Usually, all devices of some RTDM class use the same naming scheme. But
as test devices are different as they do not provide compatible APIs,
let's give them separate name space for their device names. That finally
resolves all the detection troubles that showed up once more than one
test device was registered.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>

---

 include/rtdm/rttesting.h              |   10 ++++--
 ksrc/drivers/testing/irqbench.c       |    4 +-
 ksrc/drivers/testing/switchtest.c     |    4 +-
 ksrc/drivers/testing/timerbench.c     |    4 +-
 src/testsuite/irqbench/irqloop.c      |    3 +-
 src/testsuite/latency/latency.c       |    2 +-
 src/testsuite/switchtest/switchtest.c |   50 +++++++-------------------------
 7 files changed, 27 insertions(+), 50 deletions(-)

diff --git a/include/rtdm/rttesting.h b/include/rtdm/rttesting.h
index ce0418e..56df43b 100644
--- a/include/rtdm/rttesting.h
+++ b/include/rtdm/rttesting.h
@@ -29,13 +29,14 @@
  * Feel free to comment on this profile via the Xenomai mailing list
  * (xenomai-c...@gna.org) or directly to the author (jan.kis...@web.de).
  *
- * @b Profile @b Revision: 1
+ * @b Profile @b Revision: 2
  * @n
  * @n
  * @par Device Characteristics
  * @ref rtdm_device.device_flags "Device Flags": @c RTDM_NAMED_DEVICE @n
  * @n
- * @ref rtdm_device.device_name "Device Name": @c "rttest<N>", N >= 0 @n
+ * @ref rtdm_device.device_name "Device Name": @c "rttest[-<subclass>]<N>",
+ * N >= 0, optional subclass name to simplify device discovery @n
  * @n
  * @ref rtdm_device.device_class "Device Class": @c RTDM_CLASS_TESTING @n
  * @n
@@ -61,7 +62,7 @@
 
 #include <rtdm/rtdm.h>
 
-#define RTTST_PROFILE_VER              1
+#define RTTST_PROFILE_VER              2
 
 typedef struct rttst_bench_res {
        long long avg;
@@ -145,8 +146,11 @@ struct rttst_swtest_error {
 /*!
  * @name Sub-Classes of RTDM_CLASS_TESTING
  * @{ */
+/** subclass name: "tmbench" */
 #define RTDM_SUBCLASS_TIMERBENCH       0
+/** subclass name: "irqbench" */
 #define RTDM_SUBCLASS_IRQBENCH         1
+/** subclass name: "switchtst" */
 #define RTDM_SUBCLASS_SWITCHTEST       2
 /** @} */
 
diff --git a/ksrc/drivers/testing/irqbench.c b/ksrc/drivers/testing/irqbench.c
index 3dfb646..db520cb 100644
--- a/ksrc/drivers/testing/irqbench.c
+++ b/ksrc/drivers/testing/irqbench.c
@@ -515,8 +515,8 @@ static int __init __irqbench_init(void)
        int err;
 
        do {
-               snprintf(device.device_name, RTDM_MAX_DEVNAME_LEN, "rttest%d",
-                        start_index);
+               snprintf(device.device_name, RTDM_MAX_DEVNAME_LEN,
+                        "rttest-irqbench%d", start_index);
                err = rtdm_dev_register(&device);
 
                start_index++;
diff --git a/ksrc/drivers/testing/switchtest.c 
b/ksrc/drivers/testing/switchtest.c
index 057094b..47702fc 100644
--- a/ksrc/drivers/testing/switchtest.c
+++ b/ksrc/drivers/testing/switchtest.c
@@ -750,8 +750,8 @@ int __init __switchtest_init(void)
        int err;
 
        do {
-               snprintf(device.device_name, RTDM_MAX_DEVNAME_LEN, "rttest%d",
-                        start_index);
+               snprintf(device.device_name, RTDM_MAX_DEVNAME_LEN,
+                        "rttest-switchtst%d", start_index);
                err = rtdm_dev_register(&device);
 
                start_index++;
diff --git a/ksrc/drivers/testing/timerbench.c 
b/ksrc/drivers/testing/timerbench.c
index 0946a04..792f515 100644
--- a/ksrc/drivers/testing/timerbench.c
+++ b/ksrc/drivers/testing/timerbench.c
@@ -508,8 +508,8 @@ static int __init __timerbench_init(void)
        int err;
 
        do {
-               snprintf(device.device_name, RTDM_MAX_DEVNAME_LEN, "rttest%d",
-                        start_index);
+               snprintf(device.device_name, RTDM_MAX_DEVNAME_LEN,
+                        "rttest-tmbench%d", start_index);
                err = rtdm_dev_register(&device);
 
                start_index++;
diff --git a/src/testsuite/irqbench/irqloop.c b/src/testsuite/irqbench/irqloop.c
index d4623b4..d2527ae 100644
--- a/src/testsuite/irqbench/irqloop.c
+++ b/src/testsuite/irqbench/irqloop.c
@@ -136,7 +136,8 @@ int main(int argc, char *argv[])
 
        mlockall(MCL_CURRENT|MCL_FUTURE);
 
-       snprintf(devname, RTDM_MAX_DEVNAME_LEN, "/dev/rttest%d", benchdev_no);
+       snprintf(devname, RTDM_MAX_DEVNAME_LEN, "/dev/rttest-irqbench%d",
+                benchdev_no);
        benchdev = open(devname, O_RDWR);
        if (benchdev < 0) {
                perror("irqloop: failed to open benchmark device");
diff --git a/src/testsuite/latency/latency.c b/src/testsuite/latency/latency.c
index e9e741e..288472e 100644
--- a/src/testsuite/latency/latency.c
+++ b/src/testsuite/latency/latency.c
@@ -622,7 +622,7 @@ int main(int argc, char **argv)
        if (test_mode != USER_TASK) {
                char devname[RTDM_MAX_DEVNAME_LEN];
 
-               snprintf(devname, RTDM_MAX_DEVNAME_LEN, "rttest%d",
+               snprintf(devname, RTDM_MAX_DEVNAME_LEN, "rttest-tmbench%d",
                         benchdev_no);
                benchdev = rt_dev_open(devname, O_RDWR);
 
diff --git a/src/testsuite/switchtest/switchtest.c 
b/src/testsuite/switchtest/switchtest.c
index 9e4df10..19fe05a 100644
--- a/src/testsuite/switchtest/switchtest.c
+++ b/src/testsuite/switchtest/switchtest.c
@@ -886,42 +886,6 @@ static int task_create(struct cpu_tasks *cpu,
        return err;
 }
 
-#define DEV_NR_MAX 256
-
-static int open_rttest(char *buf, size_t size, unsigned count)
-{
-       static unsigned dev_nr = 0;
-       int fd, status;
-
-       do {
-               snprintf(buf, size, "/dev/rttest%u", dev_nr);
-
-               status = fd = open(buf, O_RDWR);
-
-               if (fd == -1)
-                       goto next_dev;
-
-               status = ioctl(fd, RTTST_RTIOC_SWTEST_SET_TASKS_COUNT, count);
-
-               if (status == 0)
-                       break;
-
-         next_dev:
-               if (fd != -1)
-                       close(fd);
-
-               if (++dev_nr != DEV_NR_MAX)
-                       continue;
-
-               fprintf(stderr, "switchtest: Unable to open switchtest 
device.\n"
-                       "(modprobe xeno_switchtest ?)\n");
-
-               return -1;
-       } while (status == -1);
-
-       return fd;
-}
-
 const char *all_nofp [] = {
        "rtk",
        "rtk",
@@ -1110,7 +1074,6 @@ int main(int argc, const char *argv[])
        const char *progname = argv[0];
        struct cpu_tasks *cpus;
        struct sched_param sp;
-       char devname[21];
        sigset_t mask;
        int sig;
 
@@ -1368,10 +1331,19 @@ int main(int argc, const char *argv[])
                struct cpu_tasks *cpu = &cpus[i];
                char buffer[64];
 
-               cpu->fd = open_rttest(devname,sizeof(devname),cpu->tasks_count);
+               cpu->fd = open("/dev/rttest-switchtst0", O_RDWR);
+               if (cpu->fd == -1) {
+                       fprintf(stderr, "switchtest: Unable to open "
+                               "switchtest device.\n"
+                               "(modprobe xeno_switchtest ?)\n");
+                       goto failure;
+               }
 
-               if (cpu->fd == -1)
+               if (ioctl(cpu->fd, RTTST_RTIOC_SWTEST_SET_TASKS_COUNT,
+                         cpu->tasks_count)) {
+                       perror("ioctl(RTTST_RTIOC_SWTEST_SET_TASKS_COUNT)");
                        goto failure;
+               }
 
                if (ioctl(cpu->fd, RTTST_RTIOC_SWTEST_SET_CPU, i)) {
                        perror("ioctl(RTTST_RTIOC_SWTEST_SET_CPU)");


_______________________________________________
Xenomai-git mailing list
Xenomai-git@gna.org
https://mail.gna.org/listinfo/xenomai-git

Reply via email to