Tests: Add helpers fro preventallow/startstopunit

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Ronnie Sahlberg
2016-02-21 11:43:58 -08:00
parent d910bab852
commit 23a9278e23
13 changed files with 131 additions and 197 deletions
+28
View File
@@ -251,6 +251,20 @@ do { \
CU_ASSERT_EQUAL(_r, 0); \ CU_ASSERT_EQUAL(_r, 0); \
} while (0); } while (0);
#define PREVENTALLOW(...) \
do { \
int _r; \
_r = preventallow(__VA_ARGS__); \
if (_r == -2) { \
logging(LOG_NORMAL, "[SKIPPED] PREVENTALLOW " \
"is not implemented."); \
CU_PASS("[SKIPPED] Target does not support " \
"PREVENTALLOW. Skipping test"); \
return; \
} \
CU_ASSERT_EQUAL(_r, 0); \
} while (0);
#define READ6(...) \ #define READ6(...) \
do { \ do { \
int _r; \ int _r; \
@@ -392,6 +406,20 @@ do { \
CU_ASSERT_EQUAL(_r, 0); \ CU_ASSERT_EQUAL(_r, 0); \
} while (0); } while (0);
#define STARTSTOPUNIT(...) \
do { \
int _r; \
_r = startstopunit(__VA_ARGS__); \
if (_r == -2) { \
logging(LOG_NORMAL, "[SKIPPED] STARTSTOPUNIT " \
"is not implemented."); \
CU_PASS("[SKIPPED] Target does not support " \
"STARTSTOPUNIT. Skipping test"); \
return; \
} \
CU_ASSERT_EQUAL(_r, 0); \
} while (0);
#define VERIFY10(...) \ #define VERIFY10(...) \
do { \ do { \
int _r; \ int _r; \
+8 -14
View File
@@ -47,13 +47,11 @@ test_preventallow_2_itnexuses(void)
} }
logging(LOG_VERBOSE, "Set the PREVENT flag"); logging(LOG_VERBOSE, "Set the PREVENT flag");
ret = preventallow(sd, 1); PREVENTALLOW(sd, 1);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 0, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED); EXPECT_REMOVAL_PREVENTED);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can still access the media."); logging(LOG_VERBOSE, "Verify we can still access the media.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -67,21 +65,17 @@ test_preventallow_2_itnexuses(void)
return; return;
logging(LOG_VERBOSE, "Try to eject the medium on the second connection"); logging(LOG_VERBOSE, "Try to eject the medium on the second connection");
ret = startstopunit(sd2, 0, 0, 0, 0, 1, 0, STARTSTOPUNIT(sd2, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED); EXPECT_REMOVAL_PREVENTED);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Logout the second connection from target"); logging(LOG_VERBOSE, "Logout the second connection from target");
mpath_sd2_put(sd2); mpath_sd2_put(sd2);
logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed"); logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
logging(LOG_VERBOSE, "Test we can clear PREVENT flag"); logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
ret = preventallow(sd, 0); PREVENTALLOW(sd, 0);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 1, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} }
+10 -18
View File
@@ -45,13 +45,11 @@ test_preventallow_cold_reset(void)
} }
logging(LOG_VERBOSE, "Set the PREVENT flag"); logging(LOG_VERBOSE, "Set the PREVENT flag");
ret = preventallow(sd, 1); PREVENTALLOW(sd, 1);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 0, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED); EXPECT_REMOVAL_PREVENTED);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can still access the media."); logging(LOG_VERBOSE, "Verify we can still access the media.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -68,9 +66,8 @@ test_preventallow_cold_reset(void)
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 0, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can not access the media."); logging(LOG_VERBOSE, "Verify we can not access the media.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -78,19 +75,14 @@ test_preventallow_cold_reset(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 0, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed"); logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
logging(LOG_VERBOSE, "Test we can clear PREVENT flag"); logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
ret = preventallow(sd, 0); PREVENTALLOW(sd, 0);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 1, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} }
+13 -26
View File
@@ -28,7 +28,7 @@
void void
test_preventallow_eject(void) test_preventallow_eject(void)
{ {
int ret; int ret;
CHECK_FOR_SBC; CHECK_FOR_SBC;
CHECK_FOR_REMOVABLE; CHECK_FOR_REMOVABLE;
@@ -37,18 +37,11 @@ test_preventallow_eject(void)
logging(LOG_VERBOSE, "Test that we can not eject medium when PREVENT is active"); logging(LOG_VERBOSE, "Test that we can not eject medium when PREVENT is active");
logging(LOG_VERBOSE, "Set the PREVENT flag"); logging(LOG_VERBOSE, "Set the PREVENT flag");
ret = preventallow(sd, 1); PREVENTALLOW(sd, 1);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] PREVENTALLOW is not implemented");
CU_PASS("PREVENTALLOW is not implemented");
return;
}
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 0, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED); EXPECT_REMOVAL_PREVENTED);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can still access the media."); logging(LOG_VERBOSE, "Verify we can still access the media.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -56,12 +49,11 @@ test_preventallow_eject(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test we can clear PREVENT flag"); logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
ret = preventallow(sd, 0); PREVENTALLOW(sd, 0);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 0, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can not access the media."); logging(LOG_VERBOSE, "Verify we can not access the media.");
@@ -70,21 +62,16 @@ test_preventallow_eject(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Set the PREVENT flag"); logging(LOG_VERBOSE, "Set the PREVENT flag");
ret = preventallow(sd, 1); PREVENTALLOW(sd, 1);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Try to load the medium"); logging(LOG_VERBOSE, "Try to load the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 1, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
EXPECT_REMOVAL_PREVENTED); EXPECT_REMOVAL_PREVENTED);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Clear PREVENT flag"); logging(LOG_VERBOSE, "Clear PREVENT flag");
ret = preventallow(sd, 0); PREVENTALLOW(sd, 0);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium again"); logging(LOG_VERBOSE, "Load the medium again");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 1, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} }
+10 -16
View File
@@ -45,11 +45,11 @@ test_preventallow_itnexus_loss(void)
} }
logging(LOG_VERBOSE, "Set the PREVENT flag"); logging(LOG_VERBOSE, "Set the PREVENT flag");
PREVENTALLOW(sd, 1);
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 0, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED); EXPECT_REMOVAL_PREVENTED);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can still access the media."); logging(LOG_VERBOSE, "Verify we can still access the media.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -68,9 +68,8 @@ test_preventallow_itnexus_loss(void)
} }
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 0, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can not access the media."); logging(LOG_VERBOSE, "Verify we can not access the media.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -78,19 +77,14 @@ test_preventallow_itnexus_loss(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 0, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed"); logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
logging(LOG_VERBOSE, "Test we can clear PREVENT flag"); logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
ret = preventallow(sd, 0); PREVENTALLOW(sd, 0);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 1, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} }
+10 -19
View File
@@ -45,20 +45,17 @@ test_preventallow_logout(void)
} }
logging(LOG_VERBOSE, "Set the PREVENT flag"); logging(LOG_VERBOSE, "Set the PREVENT flag");
ret = preventallow(sd, 1); PREVENTALLOW(sd, 1);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 0, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED); EXPECT_REMOVAL_PREVENTED);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can still access the media."); logging(LOG_VERBOSE, "Verify we can still access the media.");
ret = testunitready(sd, ret = testunitready(sd,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Logout from target"); logging(LOG_VERBOSE, "Logout from target");
iscsi_logout_sync(sd->iscsi_ctx); iscsi_logout_sync(sd->iscsi_ctx);
iscsi_destroy_context(sd->iscsi_ctx); iscsi_destroy_context(sd->iscsi_ctx);
@@ -71,9 +68,8 @@ test_preventallow_logout(void)
} }
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 0, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can not access the media."); logging(LOG_VERBOSE, "Verify we can not access the media.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -81,19 +77,14 @@ test_preventallow_logout(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 0, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed"); logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
logging(LOG_VERBOSE, "Test we can clear PREVENT flag"); logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
ret = preventallow(sd, 0); PREVENTALLOW(sd, 0);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 1, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} }
+10 -17
View File
@@ -45,13 +45,11 @@ test_preventallow_lun_reset(void)
} }
logging(LOG_VERBOSE, "Set the PREVENT flag"); logging(LOG_VERBOSE, "Set the PREVENT flag");
ret = preventallow(sd, 1); PREVENTALLOW(sd, 1);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 0, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED); EXPECT_REMOVAL_PREVENTED);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can still access the media."); logging(LOG_VERBOSE, "Verify we can still access the media.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -68,9 +66,8 @@ test_preventallow_lun_reset(void)
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 0, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can not access the media."); logging(LOG_VERBOSE, "Verify we can not access the media.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -78,18 +75,14 @@ test_preventallow_lun_reset(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 0, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed"); logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
logging(LOG_VERBOSE, "Test we can clear PREVENT flag"); logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
ret = preventallow(sd, 0); PREVENTALLOW(sd, 0);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 1, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} }
+2 -11
View File
@@ -28,8 +28,6 @@
void void
test_preventallow_simple(void) test_preventallow_simple(void)
{ {
int ret;
CHECK_FOR_SBC; CHECK_FOR_SBC;
CHECK_FOR_REMOVABLE; CHECK_FOR_REMOVABLE;
@@ -37,15 +35,8 @@ test_preventallow_simple(void)
logging(LOG_VERBOSE, "Test PREVENTALLOW basics"); logging(LOG_VERBOSE, "Test PREVENTALLOW basics");
logging(LOG_VERBOSE, "Test we can set PREVENT flag"); logging(LOG_VERBOSE, "Test we can set PREVENT flag");
ret = preventallow(sd, 1); PREVENTALLOW(sd, 1);
if (ret == -2) {
logging(LOG_NORMAL, "[SKIPPED] PREVENTALLOW is not implemented");
CU_PASS("PREVENTALLOW is not implemented");
return;
}
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test we can clear PREVENT flag"); logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
ret = preventallow(sd, 0); PREVENTALLOW(sd, 0);
CU_ASSERT_EQUAL(ret, 0);
} }
+10 -18
View File
@@ -45,13 +45,11 @@ test_preventallow_warm_reset(void)
} }
logging(LOG_VERBOSE, "Set the PREVENT flag"); logging(LOG_VERBOSE, "Set the PREVENT flag");
ret = preventallow(sd, 1); PREVENTALLOW(sd, 1);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 0, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_REMOVAL_PREVENTED); EXPECT_REMOVAL_PREVENTED);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can still access the media."); logging(LOG_VERBOSE, "Verify we can still access the media.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -68,9 +66,8 @@ test_preventallow_warm_reset(void)
logging(LOG_VERBOSE, "Try to eject the medium"); logging(LOG_VERBOSE, "Try to eject the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 0, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can not access the media."); logging(LOG_VERBOSE, "Verify we can not access the media.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -78,19 +75,14 @@ test_preventallow_warm_reset(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 0, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed"); logging(LOG_VERBOSE, "Clear PREVENT and load medium in case target failed");
logging(LOG_VERBOSE, "Test we can clear PREVENT flag"); logging(LOG_VERBOSE, "Test we can clear PREVENT flag");
ret = preventallow(sd, 0); PREVENTALLOW(sd, 0);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Load the medium"); logging(LOG_VERBOSE, "Load the medium");
ret = startstopunit(sd, 0, 0, 0, 0, 1, 1, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
} }
+2 -3
View File
@@ -101,9 +101,8 @@ test_sanitize_reset(void)
logging(LOG_VERBOSE, "Verify that STARTSTOPUNIT fails with " logging(LOG_VERBOSE, "Verify that STARTSTOPUNIT fails with "
"SANITIZE_IN_PROGRESS"); "SANITIZE_IN_PROGRESS");
ret = startstopunit(sd, 1, 0, 1, 0, 1, 0, STARTSTOPUNIT(sd, 1, 0, 1, 0, 1, 0,
EXPECT_SANITIZE); EXPECT_SANITIZE);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify that READ16 fails with " logging(LOG_VERBOSE, "Verify that READ16 fails with "
"SANITIZE_IN_PROGRESS"); "SANITIZE_IN_PROGRESS");
+17 -33
View File
@@ -40,10 +40,8 @@ test_startstopunit_noloej(void)
} }
logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==0 START==0"); logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==0 START==0");
ret = startstopunit(sd, STARTSTOPUNIT(sd, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, EXPECT_STATUS_GOOD);
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected."); logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -51,10 +49,8 @@ test_startstopunit_noloej(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==0 START==1"); logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==0 START==1");
ret = startstopunit(sd, STARTSTOPUNIT(sd, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 1, EXPECT_STATUS_GOOD);
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected."); logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -62,10 +58,8 @@ test_startstopunit_noloej(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==0 START==0"); logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==0 START==0");
ret = startstopunit(sd, STARTSTOPUNIT(sd, 1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, EXPECT_STATUS_GOOD);
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected."); logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -73,10 +67,8 @@ test_startstopunit_noloej(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==0 START==1"); logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==0 START==1");
ret = startstopunit(sd, STARTSTOPUNIT(sd, 1, 0, 0, 0, 0, 1,
1, 0, 0, 0, 0, 1, EXPECT_STATUS_GOOD);
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected."); logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -84,10 +76,8 @@ test_startstopunit_noloej(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==1 START==0"); logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==1 START==0");
ret = startstopunit(sd, STARTSTOPUNIT(sd, 0, 0, 0, 1, 0, 0,
0, 0, 0, 1, 0, 0, EXPECT_STATUS_GOOD);
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected."); logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -95,10 +85,8 @@ test_startstopunit_noloej(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==1 START==1"); logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==0 NO_FLUSH==1 START==1");
ret = startstopunit(sd, STARTSTOPUNIT(sd, 0, 0, 0, 1, 0, 1,
0, 0, 0, 1, 0, 1, EXPECT_STATUS_GOOD);
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected."); logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -106,10 +94,8 @@ test_startstopunit_noloej(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==1 START==0"); logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==1 START==0");
ret = startstopunit(sd, STARTSTOPUNIT(sd, 1, 0, 0, 1, 0, 0,
1, 0, 0, 1, 0, 0, EXPECT_STATUS_GOOD);
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected."); logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -117,10 +103,8 @@ test_startstopunit_noloej(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==1 START==1"); logging(LOG_VERBOSE, "Test that media is not ejected when LOEJ==0 IMMED==1 NO_FLUSH==1 START==1");
ret = startstopunit(sd, STARTSTOPUNIT(sd, 1, 0, 0, 1, 0, 1,
1, 0, 0, 1, 0, 1, EXPECT_STATUS_GOOD);
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected."); logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -129,6 +113,6 @@ test_startstopunit_noloej(void)
logging(LOG_VERBOSE, "In case the target did eject the medium, load it again."); logging(LOG_VERBOSE, "In case the target did eject the medium, load it again.");
startstopunit(sd, 1, 0, 0, 0, 1, 1, STARTSTOPUNIT(sd, 1, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
} }
+3 -5
View File
@@ -41,10 +41,8 @@ test_startstopunit_pwrcnd(void)
logging(LOG_VERBOSE, "Test that media is not ejected when PC!=0"); logging(LOG_VERBOSE, "Test that media is not ejected when PC!=0");
for (i = 1; i < 16; i++) { for (i = 1; i < 16; i++) {
ret = startstopunit(sd, STARTSTOPUNIT(sd, 1, 0, i, 0, 1, 0,
1, 0, i, 0, 1, 0, EXPECT_STATUS_GOOD);
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected."); logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is not ejected.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -53,6 +51,6 @@ test_startstopunit_pwrcnd(void)
} }
logging(LOG_VERBOSE, "In case the target did eject the medium, load it again."); logging(LOG_VERBOSE, "In case the target did eject the medium, load it again.");
startstopunit(sd, 1, 0, 0, 0, 1, 1, STARTSTOPUNIT(sd, 1, 0, 0, 0, 1, 1,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
} }
+7 -16
View File
@@ -42,8 +42,7 @@ test_startstopunit_simple(void)
logging(LOG_VERBOSE, "Media is not removable. STARTSTOPUNIT should fail"); logging(LOG_VERBOSE, "Media is not removable. STARTSTOPUNIT should fail");
} }
ret = startstopunit(sd, ret = startstopunit(sd, 1, 0, 0, 0, 1, 0,
1, 0, 0, 0, 1, 0,
EXPECT_STATUS_GOOD); EXPECT_STATUS_GOOD);
if (!inq->rmb) { if (!inq->rmb) {
CU_ASSERT_NOT_EQUAL(ret, 0); CU_ASSERT_NOT_EQUAL(ret, 0);
@@ -59,10 +58,8 @@ test_startstopunit_simple(void)
logging(LOG_VERBOSE, "Test we can load the removable the media with IMMED==1"); logging(LOG_VERBOSE, "Test we can load the removable the media with IMMED==1");
ret = startstopunit(sd, STARTSTOPUNIT(sd, 1, 0, 0, 0, 1, 1,
1, 0, 0, 0, 1, 1, EXPECT_STATUS_GOOD);
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can read from the media."); logging(LOG_VERBOSE, "Verify we can read from the media.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -70,13 +67,9 @@ test_startstopunit_simple(void)
CU_ASSERT_EQUAL(ret, 0); CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test we can eject removable the media with IMMED==1"); logging(LOG_VERBOSE, "Test we can eject removable the media with IMMED==1");
ret = startstopunit(sd, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 1, 0, EXPECT_STATUS_GOOD);
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is ejected."); logging(LOG_VERBOSE, "Test TESTUNITREADY that medium is ejected.");
ret = testunitready(sd, ret = testunitready(sd,
@@ -85,10 +78,8 @@ test_startstopunit_simple(void)
logging(LOG_VERBOSE, "Test we can load the removable the media with IMMED==1"); logging(LOG_VERBOSE, "Test we can load the removable the media with IMMED==1");
ret = startstopunit(sd, STARTSTOPUNIT(sd, 0, 0, 0, 0, 1, 1,
0, 0, 0, 0, 1, 1, EXPECT_STATUS_GOOD);
EXPECT_STATUS_GOOD);
CU_ASSERT_EQUAL(ret, 0);
logging(LOG_VERBOSE, "Verify we can access the media again."); logging(LOG_VERBOSE, "Verify we can access the media again.");
ret = testunitready(sd, ret = testunitready(sd,