11import os
2+ import pathlib
3+
4+ import yaml
25from ci_utils .common .remote_session import RemoteSession
36import pytest
47from ci_utils .common .logger import get_logger
@@ -26,6 +29,20 @@ def server_node():
2629 session_data = read_json_file (SESSION_FILE )
2730 return session_data .get ("nodes" )[0 ]
2831
32+ @pytest .fixture (scope = "session" )
33+ def cmake_config ():
34+ # Find repo root based on THIS file's location
35+ this_file = pathlib .Path (__file__ ).resolve ()
36+
37+ # Navigate to ci_utils/config/cmake_flags.yml relative to this conftest
38+ config_path = this_file .parent .parent / "ci_utils" / "config" / "cmake_flags.yml"
39+
40+ if not config_path .exists ():
41+ raise FileNotFoundError (f"CMake flag config not found: { config_path } " )
42+
43+ with config_path .open () as f :
44+ return yaml .safe_load (f )
45+
2946# -----------------------
3047# Fixtures - Test level
3148# -----------------------
@@ -50,6 +67,26 @@ def create_session(server_node, request):
5067 yield session , default_dir # Yield both session and default dir
5168 session .close ()
5269
70+ @pytest .fixture
71+ def cmake_flags (request , cmake_config ):
72+ test_name = request .node .name
73+ yaml_default = cmake_config .get ("default" , [])
74+ yaml_test_specific = cmake_config .get ("tests" , {}).get (test_name , [])
75+ logger .info (f"Getting default values: { os .environ } " )
76+
77+ # ENV variable: general flags
78+ env_flags = os .getenv ("CMAKE_FLAGS" , "" )
79+ env_flags_list = env_flags .split ("," ) if env_flags else []
80+
81+ # ENV override?
82+ override = os .getenv ("CMAKE_OVERRIDE" , "" ).lower () in ("1" , "true" , "yes" )
83+
84+ if override :
85+ # Jenkins wants to ignore YAML entirely
86+ return env_flags_list
87+
88+ # Merge YAML and CLI (YAML first, then CLI append / override)
89+ return yaml_default + yaml_test_specific + env_flags_list
5390# ---------------------------------------------------------
5491# Helper function to log results to summary file
5592# ---------------------------------------------------------
@@ -219,18 +256,21 @@ def test_clang_format(create_session, server_node):
219256# TEST 3: FSAL build tests - CephFS
220257# Required Node: 1
221258# -----------------------
222- def test_fsal_cephfs (create_session ):
259+ def test_fsal_cephfs (create_session , cmake_flags ):
223260 logger .info ("[TEST] Running FSAL CephFS test" )
224261 remote_session , test_workspace = create_session
225262 logger .info ("TEST WORKSPACE: %s" , test_workspace )
226263
264+ flag_str = " " .join (cmake_flags )
265+ logger .info ("Using CMake flags: %s" , flag_str )
266+
227267 out , code = run_cmd (
228268 remote_session ,
229269 f"cd { test_workspace } /nfs-ganesha && "
230270 "rm -rf build && "
231271 "mkdir -p build && "
232272 "cd build && "
233- "cmake ../src -DCMAKE_BUILD_TYPE=Maintainer -DUSE_FSAL_GLUSTER=OFF -DUSE_FSAL_CEPH=ON -DUSE_FSAL_RGW=OFF -DUSE_DBUS=ON -DUSE_ADMIN_TOOLS=ON && "
273+ f "cmake ../src { flag_str } && "
234274 "make" , check = False
235275 )
236276
@@ -248,18 +288,21 @@ def test_fsal_cephfs(create_session):
248288# TEST 4: FSAL build tests - GPFS
249289# Required Node: 1
250290# -----------------------
251- def test_fsal_gpfs (create_session ):
291+ def test_fsal_gpfs (create_session , cmake_flags ):
252292 logger .info ("[TEST] Running FSAL GPFS test" )
253293 remote_session , test_workspace = create_session
254294 logger .info ("TEST WORKSPACE: %s" , test_workspace )
255295
296+ flag_str = " " .join (cmake_flags )
297+ logger .info ("Using CMake flags: %s" , flag_str )
298+
256299 out , code = run_cmd (
257300 remote_session ,
258301 f"cd { test_workspace } /nfs-ganesha && "
259302 "rm -rf build && "
260303 "mkdir -p build && "
261304 "cd build && "
262- "cmake ../src -DCMAKE_BUILD_TYPE=Maintainer -DUSE_FSAL_GLUSTER=OFF -DUSE_FSAL_CEPH=OFF -DUSE_FSAL_RGW=OFF -DUSE_FSAL_GPFS=ON -DUSE_DBUS=ON -DUSE_ADMIN_TOOLS=ON && "
305+ f "cmake ../src { flag_str } && "
263306 "make" , check = False
264307 )
265308
@@ -277,18 +320,21 @@ def test_fsal_gpfs(create_session):
277320# TEST 5: FSAL build tests - RGW
278321# Required Node: 1
279322# -----------------------
280- def test_fsal_rgw (create_session ):
323+ def test_fsal_rgw (create_session , cmake_flags ):
281324 logger .info ("[TEST] Running FSAL RGW test" )
282325 remote_session , test_workspace = create_session # Unpack the tuple
283326 logger .info ("TEST WORKSPACE: %s" , test_workspace )
284327
328+ flag_str = " " .join (cmake_flags )
329+ logger .info ("Using CMake flags: %s" , flag_str )
330+
285331 out , code = run_cmd (
286332 remote_session ,
287333 f"cd { test_workspace } /nfs-ganesha && "
288334 "rm -rf build && "
289335 "mkdir -p build && "
290336 "cd build && "
291- "cmake ../src -DCMAKE_BUILD_TYPE=Maintainer -DUSE_FSAL_GLUSTER=OFF -DUSE_FSAL_CEPH=OFF -DUSE_FSAL_RGW=ON -DUSE_DBUS=ON -DUSE_ADMIN_TOOLS=ON && "
337+ f "cmake ../src { flag_str } && "
292338 "make" , check = False
293339 )
294340
@@ -306,18 +352,21 @@ def test_fsal_rgw(create_session):
306352# TEST 6: FSAL build tests - VFS
307353# Required Node: 1
308354# -----------------------
309- def test_fsal_vfs (create_session ):
355+ def test_fsal_vfs (create_session , cmake_flags ):
310356 logger .info ("[TEST] Running FSAL VFS test" )
311357 remote_session , test_workspace = create_session
312358 logger .info ("TEST WORKSPACE: %s" , test_workspace )
313359
360+ flag_str = " " .join (cmake_flags )
361+ logger .info ("Using CMake flags: %s" , flag_str )
362+
314363 out , code = run_cmd (
315364 remote_session ,
316365 f"cd { test_workspace } /nfs-ganesha && "
317366 "rm -rf build && "
318367 "mkdir -p build && "
319368 "cd build && "
320- "cmake ../src -DCMAKE_BUILD_TYPE=Maintainer -DUSE_FSAL_VFS=ON -DUSE_FSAL_GLUSTER=OFF -DUSE_FSAL_CEPH=OFF -DUSE_FSAL_RGW=OFF -DUSE_FSAL_GPFS=OFF -DUSE_MONITORING=ON && "
369+ f "cmake ../src { flag_str } && "
321370 "make" , check = False
322371 )
323372
0 commit comments