@@ -18,7 +18,7 @@ class UtilAdditionalTest : public ::testing::Test {
1818};
1919
2020// Tests for GetAbsoluteTaskPath - understand it creates full absolute paths
21- TEST_F (UtilAdditionalTest, GetAbsoluteTaskPath_ValidPaths ) {
21+ TEST_F (UtilAdditionalTest, GetAbsoluteTaskPath_WithValidPaths_ReturnsCorrectPath ) {
2222 std::string result = ppc::util::GetAbsoluteTaskPath (" task1" , " src/main.cpp" );
2323 // The function adds PPC_PATH_TO_PROJECT/tasks/task1/data/src/main.cpp
2424 // Use platform-agnostic path checking - simplified to reduce complexity
@@ -27,31 +27,31 @@ TEST_F(UtilAdditionalTest, GetAbsoluteTaskPath_ValidPaths) {
2727 EXPECT_TRUE (result.find (" task1" ) != std::string::npos);
2828}
2929
30- TEST_F (UtilAdditionalTest, GetAbsoluteTaskPath_EmptyIdPath ) {
30+ TEST_F (UtilAdditionalTest, GetAbsoluteTaskPath_WithEmptyIdPath_ReturnsDefaultPath ) {
3131 std::string result = ppc::util::GetAbsoluteTaskPath (" " , " src/main.cpp" );
3232 // The function adds PPC_PATH_TO_PROJECT/tasks/data/src/main.cpp
3333 EXPECT_TRUE (result.find (" tasks" ) != std::string::npos);
3434 EXPECT_TRUE (result.find (" data" ) != std::string::npos);
3535 EXPECT_TRUE (result.find (" main.cpp" ) != std::string::npos);
3636}
3737
38- TEST_F (UtilAdditionalTest, GetAbsoluteTaskPath_EmptyRelativePath ) {
38+ TEST_F (UtilAdditionalTest, GetAbsoluteTaskPath_WithEmptyRelativePath_ReturnsTaskDataPath ) {
3939 std::string result = ppc::util::GetAbsoluteTaskPath (" task1" , " " );
4040 // The function adds PPC_PATH_TO_PROJECT/tasks/task1/data/
4141 EXPECT_TRUE (result.find (" tasks" ) != std::string::npos);
4242 EXPECT_TRUE (result.find (" task1" ) != std::string::npos);
4343 EXPECT_TRUE (result.find (" data" ) != std::string::npos);
4444}
4545
46- TEST_F (UtilAdditionalTest, GetAbsoluteTaskPath_BothEmpty ) {
46+ TEST_F (UtilAdditionalTest, GetAbsoluteTaskPath_WithBothEmpty_ReturnsTasksDataPath ) {
4747 std::string result = ppc::util::GetAbsoluteTaskPath (" " , " " );
4848 // The function adds PPC_PATH_TO_PROJECT/tasks/data/
4949 EXPECT_TRUE (result.find (" tasks" ) != std::string::npos);
5050 EXPECT_TRUE (result.find (" data" ) != std::string::npos);
5151}
5252
5353// Tests for GetNumThreads - returns 1 by default if no env var, otherwise returns env var value
54- TEST_F (UtilAdditionalTest, GetNumThreads_EnvironmentVariableNotSet ) {
54+ TEST_F (UtilAdditionalTest, GetNumThreads_WithEnvironmentVariableNotSet_ReturnsDefaultValue ) {
5555 // Ensure PPC_NUM_THREADS is not set in the system environment
5656 env::detail::delete_environment_variable (" PPC_NUM_THREADS" );
5757
@@ -62,123 +62,123 @@ TEST_F(UtilAdditionalTest, GetNumThreads_EnvironmentVariableNotSet) {
6262 EXPECT_EQ (result, 1 ); // Default value when no environment variable is set
6363}
6464
65- TEST_F (UtilAdditionalTest, GetNumThreads_EnvironmentVariableSet ) {
65+ TEST_F (UtilAdditionalTest, GetNumThreads_WithEnvironmentVariableSet_ReturnsEnvironmentValue ) {
6666 // Create a scoped environment with PPC_NUM_THREADS=4
6767 env::scoped_test_environment test_env (" PPC_NUM_THREADS" , " 4" );
6868
6969 int result = ppc::util::GetNumThreads ();
7070 EXPECT_EQ (result, 4 );
7171}
7272
73- TEST_F (UtilAdditionalTest, GetNumThreads_EnvironmentVariableZero ) {
73+ TEST_F (UtilAdditionalTest, GetNumThreads_WithEnvironmentVariableZero_ReturnsZero ) {
7474 env::scoped_test_environment test_env (" PPC_NUM_THREADS" , " 0" );
7575
7676 int result = ppc::util::GetNumThreads ();
7777 EXPECT_EQ (result, 0 );
7878}
7979
80- TEST_F (UtilAdditionalTest, GetNumThreads_EnvironmentVariableNegative ) {
80+ TEST_F (UtilAdditionalTest, GetNumThreads_WithEnvironmentVariableNegative_ReturnsNegativeValue ) {
8181 env::scoped_test_environment test_env (" PPC_NUM_THREADS" , " -1" );
8282
8383 int result = ppc::util::GetNumThreads ();
8484 EXPECT_EQ (result, -1 );
8585}
8686
87- TEST_F (UtilAdditionalTest, GetNumThreads_EnvironmentVariableInvalid ) {
87+ TEST_F (UtilAdditionalTest, GetNumThreads_WithEnvironmentVariableInvalid_ReturnsDefaultValue ) {
8888 env::scoped_test_environment test_env (" PPC_NUM_THREADS" , " invalid" );
8989
9090 int result = ppc::util::GetNumThreads ();
9191 EXPECT_EQ (result, 1 ); // Returns default when parsing fails
9292}
9393
9494// Tests for IsUnderMpirun - checks specific environment variables from the kMpiEnvVars array
95- TEST_F (UtilAdditionalTest, IsUnderMpirun_NoEnvironmentVariables ) {
95+ TEST_F (UtilAdditionalTest, IsUnderMpirun_WithNoEnvironmentVariables_ReturnsFalse ) {
9696 // Create an empty environment to ensure no MPI vars are set
9797 env::scoped_test_environment test_env ({});
9898
9999 bool result = ppc::util::IsUnderMpirun ();
100100 EXPECT_FALSE (result);
101101}
102102
103- TEST_F (UtilAdditionalTest, IsUnderMpirun_OMPI_COMM_WORLD_SIZE ) {
103+ TEST_F (UtilAdditionalTest, IsUnderMpirun_WithOMPICommWorldSize_ReturnsTrue ) {
104104 env::scoped_test_environment test_env (" OMPI_COMM_WORLD_SIZE" , " 4" );
105105
106106 bool result = ppc::util::IsUnderMpirun ();
107107 EXPECT_TRUE (result);
108108}
109109
110- TEST_F (UtilAdditionalTest, IsUnderMpirun_OMPI_UNIVERSE_SIZE ) {
110+ TEST_F (UtilAdditionalTest, IsUnderMpirun_WithOMPIUniverseSize_ReturnsTrue ) {
111111 env::scoped_test_environment test_env (" OMPI_UNIVERSE_SIZE" , " 8" );
112112
113113 bool result = ppc::util::IsUnderMpirun ();
114114 EXPECT_TRUE (result);
115115}
116116
117- TEST_F (UtilAdditionalTest, IsUnderMpirun_PMI_SIZE ) {
117+ TEST_F (UtilAdditionalTest, IsUnderMpirun_WithPMISize_ReturnsTrue ) {
118118 env::scoped_test_environment test_env (" PMI_SIZE" , " 2" );
119119
120120 bool result = ppc::util::IsUnderMpirun ();
121121 EXPECT_TRUE (result);
122122}
123123
124- TEST_F (UtilAdditionalTest, IsUnderMpirun_PMI_RANK ) {
124+ TEST_F (UtilAdditionalTest, IsUnderMpirun_WithPMIRank_ReturnsTrue ) {
125125 env::scoped_test_environment test_env (" PMI_RANK" , " 0" );
126126
127127 bool result = ppc::util::IsUnderMpirun ();
128128 EXPECT_TRUE (result);
129129}
130130
131- TEST_F (UtilAdditionalTest, IsUnderMpirun_PMI_FD ) {
131+ TEST_F (UtilAdditionalTest, IsUnderMpirun_WithPMIFd_ReturnsTrue ) {
132132 env::scoped_test_environment test_env (" PMI_FD" , " 3" );
133133
134134 bool result = ppc::util::IsUnderMpirun ();
135135 EXPECT_TRUE (result);
136136}
137137
138- TEST_F (UtilAdditionalTest, IsUnderMpirun_HYDRA_CONTROL_FD ) {
138+ TEST_F (UtilAdditionalTest, IsUnderMpirun_WithHydraControlFd_ReturnsTrue ) {
139139 env::scoped_test_environment test_env (" HYDRA_CONTROL_FD" , " 4" );
140140
141141 bool result = ppc::util::IsUnderMpirun ();
142142 EXPECT_TRUE (result);
143143}
144144
145- TEST_F (UtilAdditionalTest, IsUnderMpirun_PMIX_RANK ) {
145+ TEST_F (UtilAdditionalTest, IsUnderMpirun_WithPMIXRank_ReturnsTrue ) {
146146 env::scoped_test_environment test_env (" PMIX_RANK" , " 1" );
147147
148148 bool result = ppc::util::IsUnderMpirun ();
149149 EXPECT_TRUE (result);
150150}
151151
152- TEST_F (UtilAdditionalTest, IsUnderMpirun_SLURM_PROCID ) {
152+ TEST_F (UtilAdditionalTest, IsUnderMpirun_WithSlurmProcid_ReturnsTrue ) {
153153 env::scoped_test_environment test_env (" SLURM_PROCID" , " 0" );
154154
155155 bool result = ppc::util::IsUnderMpirun ();
156156 EXPECT_TRUE (result);
157157}
158158
159- TEST_F (UtilAdditionalTest, IsUnderMpirun_MSMPI_RANK ) {
159+ TEST_F (UtilAdditionalTest, IsUnderMpirun_WithMSMPIRank_ReturnsTrue ) {
160160 env::scoped_test_environment test_env (" MSMPI_RANK" , " 2" );
161161
162162 bool result = ppc::util::IsUnderMpirun ();
163163 EXPECT_TRUE (result);
164164}
165165
166- TEST_F (UtilAdditionalTest, IsUnderMpirun_MSMPI_LOCALRANK ) {
166+ TEST_F (UtilAdditionalTest, IsUnderMpirun_WithMSMPILocalRank_ReturnsTrue ) {
167167 env::scoped_test_environment test_env (" MSMPI_LOCALRANK" , " 0" );
168168
169169 bool result = ppc::util::IsUnderMpirun ();
170170 EXPECT_TRUE (result);
171171}
172172
173- TEST_F (UtilAdditionalTest, IsUnderMpirun_MultipleEnvironmentVariables ) {
173+ TEST_F (UtilAdditionalTest, IsUnderMpirun_WithMultipleEnvironmentVariables_ReturnsTrue ) {
174174 // Test with multiple MPI environment variables set
175175 env::scoped_test_environment test_env ({{" OMPI_COMM_WORLD_SIZE" , " 4" }, {" PMI_SIZE" , " 4" }, {" SLURM_PROCID" , " 0" }});
176176
177177 bool result = ppc::util::IsUnderMpirun ();
178178 EXPECT_TRUE (result);
179179}
180180
181- TEST_F (UtilAdditionalTest, IsUnderMpirun_EmptyEnvironmentVariable ) {
181+ TEST_F (UtilAdditionalTest, IsUnderMpirun_WithEmptyEnvironmentVariable_DoesNotCrash ) {
182182 // Test with empty value - behavior is implementation-dependent
183183 env::scoped_test_environment test_env (" OMPI_COMM_WORLD_SIZE" , " " );
184184
0 commit comments