Add two functions tst_acquire_device() and tst_release_device()
Signed-off-by: Zhang Jin <[email protected]>
Signed-off-by: Zeng Linggang <[email protected]>
---
testcases/lib/test.sh | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/testcases/lib/test.sh b/testcases/lib/test.sh
index 163c54b..3d20a04 100644
--- a/testcases/lib/test.sh
+++ b/testcases/lib/test.sh
@@ -193,6 +193,45 @@ ROD()
fi
}
+tst_acquire_device()
+{
+ if [ -n "${LTP_DEV}" ]; then
+ tst_resm TINFO "Using test device LTP_DEV='${LTP_DEV}'"
+ stat ${LTP_DEV} | grep -q "block special file"
+ if [ $? -ne 0 ]; then
+ tst_brkm TBROK "${LTP_DEV} is not a block device"
+ fi
+ TST_DEVICE=${LTP_DEV}
+ return
+ fi
+
+ ROD_SILENT dd if=/dev/zero of=test_dev.img bs=1024 count=20480
+
+ TST_DEVICE=$(losetup -f)
+ if [ $? -ne 0 ]; then
+ tst_brkm TBROK "Couldn't find free loop device"
+ fi
+
+ tst_resm TINFO "Found free device '${TST_DEVICE}'"
+
+ ROD_SILENT losetup ${TST_DEVICE} test_dev.img
+}
+
+tst_release_device()
+{
+ losetup -a | grep -q ${TST_DEVICE}
+ if [ $? -eq 0 ]; then
+ losetup -d ${TST_DEVICE}
+ if [ $? -ne 0 ];then
+ tst_resm TWARN "'losetup -d ${TST_DEVICE}' failed"
+ fi
+ fi
+
+ if [ -f "test_dev.img" ]; then
+ rm test_dev.img
+ fi
+}
+
# Check that test name is set
if [ -z "$TCID" ]; then
tst_brkm TBROK "TCID is not defined"
--
1.9.3
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list