[LTP] [PATCH 1/1] commands: Remove eject test
Petr Vorel
pvorel@suse.cz
Mon Aug 4 11:35:20 CEST 2025
CD-ROM is not much used device nowadays. Also the test is not in
runtest/commands nor in any other runtest command.
The main reason to remove is that this mostly test user space
implementation which barely touches kernel. Test should be in the
in user space projects (e.g. util-linux or BusyBox).
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Hi,
util-linux has some eject related testsuite:
https://github.com/util-linux/util-linux/tree/master/tests/ts/eject/umount
https://github.com/util-linux/util-linux/tree/master/tests/expected/eject
BusyBox does not have it
https://git.busybox.net/busybox/tree/testsuite
testcases/commands/eject/Makefile | 11 --
testcases/commands/eject/eject-tests.sh | 147 --------------------
testcases/commands/eject/eject_check_tray.c | 53 -------
3 files changed, 211 deletions(-)
delete mode 100644 testcases/commands/eject/Makefile
delete mode 100755 testcases/commands/eject/eject-tests.sh
delete mode 100644 testcases/commands/eject/eject_check_tray.c
diff --git a/testcases/commands/eject/Makefile b/testcases/commands/eject/Makefile
deleted file mode 100644
index f33b5117f9..0000000000
--- a/testcases/commands/eject/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-or-later
-# Copyright (C) 2009, Cisco Systems Inc.
-# Ngie Cooper, July 2009
-
-top_srcdir ?= ../../..
-
-include $(top_srcdir)/include/mk/testcases.mk
-
-INSTALL_TARGETS := eject-tests.sh
-
-include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/eject/eject-tests.sh b/testcases/commands/eject/eject-tests.sh
deleted file mode 100755
index 76a667aa33..0000000000
--- a/testcases/commands/eject/eject-tests.sh
+++ /dev/null
@@ -1,147 +0,0 @@
-#!/bin/sh
-# SPDX-License-Identifier: GPL-2.0-or-later
-# Copyright (c) International Business Machines Corp., 2001
-# Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz>
-# Author: Manoj Iyer <manjo@mail.utexas.edu>
-#
-# Tests basic functionality of eject command.
-
-TST_CNT=4
-TST_SETUP=setup
-TST_CLEANUP=cleanup
-TST_TESTFUNC=test
-TST_NEEDS_TMPDIR=1
-TST_NEEDS_ROOT=1
-TST_NEEDS_CMDS="eject"
-
-setup()
-{
- CD_DRIVE="/dev/cdrom"
-
- if ! [ -e "$CD_DRIVE" ]; then
- tst_brk TCONF "There is no "$CD_DRIVE""
- fi
-
- if grep -q "$CD_DRIVE" /proc/mounts; then
- tst_brk TCONF "$CD_DRIVE is already mounted"
- fi
-
- ROD mkdir "cdrom"
-}
-
-cleanup()
-{
- # We have to use the mount point since /dev/cdrom may be link to
- # /dev/sr0 and because of that /dev/cdrom is not listed in /proc/mounts
- tst_umount "$PWD/cdrom"
-}
-
-test1()
-{
- EXPECT_PASS eject -d \> eject.out
-
- if grep -q "eject: default device:" eject.out; then
- tst_res TPASS "Eject listed default device"
- else
- tst_res TFAIL "Eject failed to list default device"
- cat eject.out
- fi
-}
-
-test2()
-{
- EXPECT_PASS eject -v $CD_DRIVE \> eject.out
-
- if grep -q "CD-ROM eject command succeeded" eject.out; then
- # Close the tray if it is supported.
- eject -t $CD_DRIVE > /dev/null 2>&1
- tst_res TPASS "Drive successfully ejected"
- else
- tst_res TFAIL "Eject failed"
- cat eject.out
- fi
-}
-
-mount_cdrom()
-{
- local tries=100
-
- # Wait for the drive to spin up the disk
- while [ $tries -gt 0 ]; do
- eject_check_tray $CD_DRIVE
- if [ $? -eq 4 ]; then
- break
- fi
- tst_sleep 100ms
- tries=$((tries-1))
- done
-
- mount "$CD_DRIVE" cdrom/ > mount.out 2>&1
- if [ $? -eq 32 ]; then
- tst_res TCONF "Failed to mount $CD_DRIVE, no disk in drive?"
- cat mount.out
- return 0
- fi
-
- tst_res TINFO "$CD_DRIVE mounted sucessfully"
-
- return 1
-}
-
-test3()
-{
- if mount_cdrom; then
- return
- fi
-
- test2
-
- if grep -q "$CD_DRIVE" /proc/mounts; then
- tst_res TFAIL "$CD_DRIVE is stil moutned"
- else
- tst_res TPASS "$CD_DRIVE umounted successfully"
- fi
-}
-
-test4()
-{
- if mount_cdrom; then
- return
- fi
-
- EXPECT_PASS eject -a on $CD_DRIVE
-
- eject_check_tray $CD_DRIVE
- if [ $? -eq 2 ]; then
- tst_brk TBROK "$CD_DRIVE is mounted but tray is open"
- fi
-
- EXPECT_PASS umount $CD_DRIVE
-
- eject_check_tray $CD_DRIVE
- if [ $? -eq 2 ]; then
- tst_res TPASS "$CD_DRIVE was auto-ejected"
- else
- tst_res TFAIL "$CD_DRIVE was not auto-ejected"
- fi
-
- EXPECT_PASS eject -a off $CD_DRIVE
-
- eject -t $CD_DRIVE > /dev/null 2>&1
-
- if mount_cdrom; then
- return
- fi
-
- EXPECT_PASS umount $CD_DRIVE
-
- eject_check_tray $CD_DRIVE
- if [ $? -eq 2 ]; then
- tst_res TFAIL "$CD_DRIVE was auto-ejected"
- else
- tst_res TPASS "$CD_DRIVE was not auto-ejected"
- fi
-}
-
-. tst_test.sh
-tst_run
diff --git a/testcases/commands/eject/eject_check_tray.c b/testcases/commands/eject/eject_check_tray.c
deleted file mode 100644
index 07e81534bb..0000000000
--- a/testcases/commands/eject/eject_check_tray.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/******************************************************************************/
-/* */
-/* Copyright (c) International Business Machines Corp., 2001 */
-/* Jan 8 2003 - Created - Manoj Iyer manjo@mail.utexas.edu */
-/* */
-/* This program is free software; you can redistribute it and/or modify */
-/* it under the terms of the GNU General Public License as published by */
-/* the Free Software Foundation; either version 2 of the License, or */
-/* (at your option) any later version. */
-/* */
-/* This program is distributed in the hope that it will be useful, but */
-/* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY */
-/* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License */
-/* for more details. */
-/* */
-/* You should have received a copy of the GNU General Public License */
-/* along with this program; if not, write to the Free Software Foundation, */
-/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
-/******************************************************************************/
-
-/*
- *
- * Description: This program checks the status of the cdrom drive, it will
- * return the status as to if the cdrom device is open or is
- * ready for use.
- */
-
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <linux/cdrom.h>
-#include <sys/ioctl.h>
-#include <stdlib.h>
-
-/*
- * Exit Vaules:
- * 0 - No information.
- * 1 - No disk in the drive.
- * 2 - CD tray is open.
- * 3 - CD drive not ready.
- * 4 - CD disk in drive & drive closed.
- */
-int main(int argc, char *argv[])
-{
- int fd;
-
- if (argc != 2)
- exit(-1);
-
- if ((fd = open(argv[1], O_RDONLY | O_NONBLOCK)) == -1)
- exit(-2);
-
- exit(ioctl(fd, CDROM_DRIVE_STATUS));
-}
--
2.50.1
More information about the ltp
mailing list