* Introduce a sleep() to wait until udev creates /dev/tbio * Fix typos * Clean /dev/tbio after test execution, if /dev/tbio was created manually.
Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmansk...@oracle.com> --- .../kernel/device-drivers/tbio/tbio_user/tbio.c | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-) diff --git a/testcases/kernel/device-drivers/tbio/tbio_user/tbio.c b/testcases/kernel/device-drivers/tbio/tbio_user/tbio.c index 81085a3..8249054 100644 --- a/testcases/kernel/device-drivers/tbio/tbio_user/tbio.c +++ b/testcases/kernel/device-drivers/tbio/tbio_user/tbio.c @@ -75,6 +75,9 @@ void cleanup(void) if (module_loaded) tst_module_unload(NULL, module_name); + if ((!unlink(DEVICE_NAME)) && (errno != ENOENT)) + tst_brkm(TBROK | TERRNO, NULL, "unlink failed"); + TEST_CLEANUP; } @@ -91,6 +94,13 @@ void setup(void) tst_module_load(cleanup, module_name, NULL); module_loaded = 1; + /* + * Wait until udev creates the device node. + * If the node is not created, we will create it manually, + * see below. + */ + sleep(5); + dev_t devt; struct stat st; @@ -99,14 +109,14 @@ void setup(void) devt = makedev(TBIO_MAJOR, 0); /* - * Check for the /dev/tbase node, and create if it does not + * Check for the /dev/tbio node, and create if it does not * exist. */ errno = 0; if (stat(DEVICE_NAME, &st)) { if (errno == ENOENT) { /* dev node does not exist */ - if (mknod(DEVICE_NAME, S_IFCHR | S_IRUSR | S_IWUSR | + if (mknod(DEVICE_NAME, S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, devt)) { tst_brkm(TBROK | TERRNO, cleanup, "mknod failed at %s:%d", @@ -118,13 +128,13 @@ void setup(void) } } else { /* - * /dev/tbio CHR device exists. Check to make sure it is for a + * /dev/tbio device exists. Check to make sure it is for a * block device and that it has the right major and minor. */ - if ((!(st.st_mode & S_IFCHR)) || (st.st_rdev != devt)) { + if ((!(st.st_mode & S_IFBLK)) || (st.st_rdev != devt)) { /* Recreate the dev node */ if (!unlink(DEVICE_NAME)) { - if (mknod(DEVICE_NAME, S_IFCHR | S_IRUSR | + if (mknod(DEVICE_NAME, S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, devt)) { tst_brkm(TBROK | TERRNO, cleanup, "mknod failed at %s:%d", -- 1.7.1 ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list