diff --git a/src/tests/ras/unsafe_shutdown/local_move_tests.cc b/src/tests/ras/unsafe_shutdown/local_move_tests.cc index b7f21bf..ecce8cd 100644 --- a/src/tests/ras/unsafe_shutdown/local_move_tests.cc +++ b/src/tests/ras/unsafe_shutdown/local_move_tests.cc @@ -37,14 +37,7 @@ std::ostream& operator<<(std::ostream& stream, move_param const& m) { return stream; } -/* Change the status of the shutdown state */ -void set_sds_at_create_func(bool state) { - int ret = pmemobj_ctl_set(NULL, "sds.at_create", &state); - if (ret) { - std::cerr << "Failed to set sds.at_create: " << pmemobj_errormsg() << std::endl; - exit(1); - } -} +bool pmem; std::vector GetMoveParams() { std::vector ret_vec; @@ -60,6 +53,7 @@ std::vector GetMoveParams() { tc.enough_dimms = true; tc.src_pool_dir = unsafe_dn[0].GetTestDir(); tc.dest_pool_dir = test_phase.GetTestDir(); + tc.pmem = true; } else { tc.enough_dimms = false; } @@ -74,6 +68,7 @@ std::vector GetMoveParams() { tc.enough_dimms = true; tc.src_pool_dir = test_phase.GetTestDir(); tc.dest_pool_dir = unsafe_dn[0].GetTestDir(); + tc.pmem = false; } else { tc.enough_dimms = false; } @@ -84,6 +79,7 @@ std::vector GetMoveParams() { { move_param tc; tc.description = "from unsafely shutdown DIMM to safely shutdown DIMM"; + tc.pmem = true; if (unsafe_dn.size() >= 1 && safe_dn.size() >= 1) { tc.enough_dimms = true; tc.src_pool_dir = unsafe_dn[0].GetTestDir(); @@ -98,6 +94,7 @@ std::vector GetMoveParams() { { move_param tc; tc.description = "from unsafely shutdown DIMM to unsafely shutdown DIMM"; + tc.pmem = true; if (unsafe_dn.size() >= 2) { tc.enough_dimms = true; tc.src_pool_dir = unsafe_dn[1].GetTestDir(); @@ -112,6 +109,7 @@ std::vector GetMoveParams() { { move_param tc; tc.description = "From safely shutdown DIMM to non-pmem"; + tc.pmem = true; if (safe_dn.size() >= 1) { tc.enough_dimms = true; tc.src_pool_dir = safe_dn[0].GetTestDir(); @@ -126,6 +124,7 @@ std::vector GetMoveParams() { { move_param tc; tc.description = "From non-pmem to safely shutdown DIMM"; + tc.pmem = false; if (safe_dn.size() >= 1) { tc.enough_dimms = true; tc.src_pool_dir = test_phase.GetTestDir(); @@ -145,6 +144,7 @@ void MovePoolClean::SetUp() { << "Insufficient number of DIMMs to run this test"; src_pool_path_ = param.src_pool_dir + GetNormalizedTestName() + "_pool"; dest_pool_path_ = param.dest_pool_dir + GetNormalizedTestName() + "_pool"; + pmem = param.pmem; } /** @@ -165,12 +165,14 @@ void MovePoolClean::SetUp() { */ TEST_P(MovePoolClean, TC_MOVE_POOL_CLEAN_phase_1) { /* Step1 */ - set_sds_at_create_func(false); + if (pmem == false) + set_sds_at_create_func(false); pop_ = pmemobj_create(src_pool_path_.c_str(), nullptr, PMEMOBJ_MIN_POOL, 0644); ASSERT_TRUE(pop_ != nullptr) << "Pool creating failed. Errno: " << errno << std::endl << pmemobj_errormsg(); - set_sds_at_create_func(true); + if (pmem == false) + set_sds_at_create_func(true); /* Step2 */ ObjData pd{pop_}; @@ -227,9 +229,13 @@ void MovePoolDirty::SetUp() { */ TEST_P(MovePoolDirty, TC_MOVE_POOL_DIRTY_phase_1) { /* Step1 */ + if (pmem == false) + set_sds_at_create_func(false); pop_ = pmemobj_create(src_pool_path_.c_str(), nullptr, PMEMOBJ_MIN_POOL, 0644); ASSERT_TRUE(pop_ != nullptr) << "Pool creating failed" << std::endl << pmemobj_errormsg(); + if (pmem == false) + set_sds_at_create_func(true); /* Step2 */ ObjData pd{pop_}; diff --git a/src/tests/ras/unsafe_shutdown/local_move_tests.h b/src/tests/ras/unsafe_shutdown/local_move_tests.h index d6a7014..60ef437 100644 --- a/src/tests/ras/unsafe_shutdown/local_move_tests.h +++ b/src/tests/ras/unsafe_shutdown/local_move_tests.h @@ -1,5 +1,5 @@ /* - * Copyright 2018, Intel Corporation + * Copyright 2018-2024, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -40,6 +40,7 @@ struct move_param { std::string src_pool_dir; std::string dest_pool_dir; bool enough_dimms; + bool pmem; }; std::ostream& operator<<(std::ostream& stream, move_param const& m); diff --git a/src/tests/ras/unsafe_shutdown/local_replicas_tests.cc b/src/tests/ras/unsafe_shutdown/local_replicas_tests.cc index 188cb32..9e03a6b 100644 --- a/src/tests/ras/unsafe_shutdown/local_replicas_tests.cc +++ b/src/tests/ras/unsafe_shutdown/local_replicas_tests.cc @@ -1,5 +1,5 @@ /* - * Copyright 2018-2023, Intel Corporation + * Copyright 2018-2024, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -43,6 +43,8 @@ void SyncLocalReplica::SetUp() { << "Insufficient number of DIMMs to run this test"; } +bool pmem; + /** * TC_SYNC_LOCAL_REPLICA * Create poolset with local replicas specified by parameter write data, @@ -71,10 +73,14 @@ TEST_P(SyncLocalReplica, TC_SYNC_LOCAL_REPLICA_phase_1) { ASSERT_TRUE(p_mgmt.PoolsetFileExists(ps)) << "Poolset file " << ps.GetFullPath() << " does not exist"; + if (pmem == false) + set_sds_at_create_func(true); pop_ = pmemobj_create(ps.GetFullPath().c_str(), nullptr, 0, 0644); ASSERT_TRUE(pop_ != nullptr) << "Error while creating the pool. Errno:" << errno << std::endl << pmemobj_errormsg(); + if (pmem == false) + set_sds_at_create_func(false); /* Step2 */ ObjData pd{pop_}; @@ -135,6 +141,7 @@ std::vector GetSyncLocalReplicaParams() { tc.description = "Master replica on unsafely shutdown DIMM, secondary replica " "on safely shutdown DIMM."; + tc.pmem = true; if (unsafe_dn.size() > 0 && safe_dn.size() > 0) { tc.enough_dimms = true; tc.poolset = Poolset{ @@ -159,6 +166,7 @@ std::vector GetSyncLocalReplicaParams() { tc.description = "Master replica on unsafely shutdown DIMM, healthy secondary replica " "on non-pmem device."; + tc.pmem = false; if (unsafe_dn.size() > 0) { tc.enough_dimms = true; tc.poolset = Poolset{ @@ -184,6 +192,7 @@ std::vector GetSyncLocalReplicaParams() { tc.description = "Healthy secondary replica on safely shutdown DIMM; replica partially " "on unsafely shutdown DIMM "; + tc.pmem = true; if (unsafe_dn.size() > 0 && safe_dn.size() > 0) { tc.enough_dimms = true; tc.poolset = Poolset{ @@ -209,6 +218,7 @@ std::vector GetSyncLocalReplicaParams() { sync_local_replica_tc tc; tc.description = "Master and secondary replicas on same unsafely shutdown DIMM."; + tc.pmem = false; if (unsafe_dn.size() > 0) { tc.enough_dimms = true; tc.poolset = Poolset{ @@ -233,6 +243,7 @@ std::vector GetSyncLocalReplicaParams() { tc.description = "Master and secondary replica partially interleaved on unsafely and " "safely shutdown DIMMs."; + tc.pmem = false; if (unsafe_dn.size() > 0 && safe_dn.size() > 0) { tc.enough_dimms = true; tc.poolset = Poolset{ @@ -255,6 +266,7 @@ std::vector GetSyncLocalReplicaParams() { sync_local_replica_tc tc; tc.description = "Master and secondary replica on different unsafely shutdown DIMMs."; + tc.pmem = false; if (unsafe_dn.size() > 1) { tc.enough_dimms = true; tc.poolset = Poolset{ @@ -280,6 +292,7 @@ std::vector GetSyncLocalReplicaParams() { tc.description = "Master and secondary replica partially on two unsafely shutdown " "dimms."; + tc.pmem = false; if (unsafe_dn.size() >= 2) { tc.enough_dimms = true; tc.poolset = Poolset{ @@ -304,6 +317,7 @@ std::vector GetSyncLocalReplicaParams() { tc.description = "Master and secondary replica partially on non-pmem, partially on two " "unsafely shutdown dimms."; + tc.pmem = false; if (unsafe_dn.size() >= 2) { tc.enough_dimms = true; tc.poolset = Poolset{ @@ -328,6 +342,7 @@ std::vector GetSyncLocalReplicaParams() { "Master replica on unsafely shutdown DIMM 1, secondary replica on " "unsafely shutdown DIMM 1, secondary replica on unsafely shutdown DIMM " "2"; + tc.pmem = false; if (unsafe_dn.size() >= 2) { tc.enough_dimms = true; tc.poolset = Poolset{ diff --git a/src/tests/ras/unsafe_shutdown/local_replicas_tests.h b/src/tests/ras/unsafe_shutdown/local_replicas_tests.h index 829c703..fd7da64 100644 --- a/src/tests/ras/unsafe_shutdown/local_replicas_tests.h +++ b/src/tests/ras/unsafe_shutdown/local_replicas_tests.h @@ -40,6 +40,7 @@ struct sync_local_replica_tc { Poolset poolset; bool enough_dimms; bool is_syncable; + bool pmem; }; class SyncLocalReplica diff --git a/src/tests/ras/unsafe_shutdown/unsafe_shutdown.cc b/src/tests/ras/unsafe_shutdown/unsafe_shutdown.cc index e28aa85..e386253 100644 --- a/src/tests/ras/unsafe_shutdown/unsafe_shutdown.cc +++ b/src/tests/ras/unsafe_shutdown/unsafe_shutdown.cc @@ -86,3 +86,12 @@ int UnsafeShutdown::PmempoolRepair(std::string pool_file_path) const { return pmempool_check_end(ppc); } + +/* Change the status of the shutdown state */ +void set_sds_at_create_func(bool state) { + int ret = pmemobj_ctl_set(NULL, "sds.at_create", &state); + if (ret) { + std::cerr << "Failed to set sds.at_create: " << pmemobj_errormsg() << std::endl; + exit(1); + } +} diff --git a/src/tests/ras/unsafe_shutdown/unsafe_shutdown.h b/src/tests/ras/unsafe_shutdown/unsafe_shutdown.h index 28ba6f1..f0e201d 100644 --- a/src/tests/ras/unsafe_shutdown/unsafe_shutdown.h +++ b/src/tests/ras/unsafe_shutdown/unsafe_shutdown.h @@ -80,4 +80,6 @@ class UnsafeShutdown : public ::testing::Test { void StampPassedResult() const; }; +void set_sds_at_create_func(bool state); + #endif // UNSAFE_SHUTDOWN_H