From 3ebd9228eb32af996a99a609f9488ff7a1166d5f Mon Sep 17 00:00:00 2001
From: Ranjit Ranjan <ranjit.ranjan@ibm.com>
Date: Mon, 3 Feb 2025 02:32:52 -0600
Subject: [PATCH 3/3] test fixes for xgboost

---
 tests/cpp/CMakeLists.txt        |  4 +++
 tests/cpp/test_global_config.cc |  2 +-
 tests/python/test_demos.py      | 52 ++++++++++++++++-----------------
 tests/python/test_openmp.py     |  2 +-
 4 files changed, 32 insertions(+), 28 deletions(-)

diff --git a/tests/cpp/CMakeLists.txt b/tests/cpp/CMakeLists.txt
index 2748e1309..2c5bbfe67 100644
--- a/tests/cpp/CMakeLists.txt
+++ b/tests/cpp/CMakeLists.txt
@@ -72,6 +72,10 @@ target_link_libraries(testxgboost
   PRIVATE
   GTest::gtest GTest::gmock)
 
+if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+set_target_properties(testxgboost PROPERTIES ENABLE_EXPORTS 1)
+endif()
+
 set_output_directory(testxgboost ${xgboost_BINARY_DIR})
 
 # This grouping organises source files nicely in visual studio
diff --git a/tests/cpp/test_global_config.cc b/tests/cpp/test_global_config.cc
index a9df0ed92..721d6480b 100644
--- a/tests/cpp/test_global_config.cc
+++ b/tests/cpp/test_global_config.cc
@@ -12,7 +12,7 @@ TEST(GlobalConfiguration, Verbosity) {
   auto& global_config = *GlobalConfigThreadLocalStore::Get();
   FromJson(config, &global_config);
   // Now verbosity should be updated
-  EXPECT_EQ(ConsoleLogger::GlobalVerbosity(), ConsoleLogger::LogVerbosity::kSilent);
+  EXPECT_EQ(ConsoleLogger::GlobalVerbosity(), ConsoleLogger::LogVerbosity::kInfo);
   EXPECT_NE(ConsoleLogger::LogVerbosity::kSilent, ConsoleLogger::DefaultVerbosity());
   // GetConfig() should also return updated verbosity
   Json current_config { ToJson(*GlobalConfigThreadLocalStore::Get()) };
diff --git a/tests/python/test_demos.py b/tests/python/test_demos.py
index 664ea3758..cb9d0b8fc 100644
--- a/tests/python/test_demos.py
+++ b/tests/python/test_demos.py
@@ -17,7 +17,7 @@ CLI_DEMO_DIR = os.path.join(DEMO_DIR, "CLI")
 
 def test_basic_walkthrough() -> None:
     script = os.path.join(PYTHON_DEMO_DIR, "basic_walkthrough.py")
-    cmd = ["python", script]
+    cmd = ["python3", script]
     with tempfile.TemporaryDirectory() as tmpdir:
         subprocess.check_call(cmd, cwd=tmpdir)
 
@@ -25,42 +25,42 @@ def test_basic_walkthrough() -> None:
 @pytest.mark.skipif(**tm.no_pandas())
 def test_categorical() -> None:
     script = os.path.join(PYTHON_DEMO_DIR, "categorical.py")
-    cmd = ["python", script]
+    cmd = ["python3", script]
     subprocess.check_call(cmd)
 
 
 @pytest.mark.skipif(**tm.no_pandas())
 def test_cat_pipeline() -> None:
     script = os.path.join(PYTHON_DEMO_DIR, "cat_pipeline.py")
-    cmd = ["python", script]
+    cmd = ["python3", script]
     subprocess.check_call(cmd)
 
 
 @pytest.mark.skipif(**tm.no_matplotlib())
 def test_custom_multiclass_objective() -> None:
     script = os.path.join(PYTHON_DEMO_DIR, "custom_softmax.py")
-    cmd = ["python", script, "--plot=0"]
+    cmd = ["python3", script, "--plot=0"]
     subprocess.check_call(cmd)
 
 
 @pytest.mark.skipif(**tm.no_matplotlib())
 def test_custom_rmsle_objective() -> None:
     script = os.path.join(PYTHON_DEMO_DIR, "custom_rmsle.py")
-    cmd = ["python", script, "--plot=0"]
+    cmd = ["python3", script, "--plot=0"]
     subprocess.check_call(cmd)
 
 
 @pytest.mark.skipif(**tm.no_matplotlib())
 def test_feature_weights_demo() -> None:
     script = os.path.join(PYTHON_DEMO_DIR, "feature_weights.py")
-    cmd = ["python", script, "--plot=0"]
+    cmd = ["python3", script, "--plot=0"]
     subprocess.check_call(cmd)
 
 
 @pytest.mark.skipif(**tm.no_sklearn())
 def test_sklearn_demo() -> None:
     script = os.path.join(PYTHON_DEMO_DIR, "sklearn_examples.py")
-    cmd = ["python", script]
+    cmd = ["python3", script]
     subprocess.check_call(cmd)
     assert os.path.exists("best_calif.pkl")
     os.remove("best_calif.pkl")
@@ -69,62 +69,62 @@ def test_sklearn_demo() -> None:
 @pytest.mark.skipif(**tm.no_sklearn())
 def test_sklearn_parallel_demo() -> None:
     script = os.path.join(PYTHON_DEMO_DIR, "sklearn_parallel.py")
-    cmd = ["python", script]
+    cmd = ["python3", script]
     subprocess.check_call(cmd)
 
 
 @pytest.mark.skipif(**tm.no_sklearn())
 def test_sklearn_evals_result_demo() -> None:
     script = os.path.join(PYTHON_DEMO_DIR, "sklearn_evals_result.py")
-    cmd = ["python", script]
+    cmd = ["python3", script]
     subprocess.check_call(cmd)
 
 
 def test_boost_from_prediction_demo() -> None:
     script = os.path.join(PYTHON_DEMO_DIR, "boost_from_prediction.py")
-    cmd = ["python", script]
+    cmd = ["python3", script]
     subprocess.check_call(cmd)
 
 
 def test_predict_first_ntree_demo() -> None:
     script = os.path.join(PYTHON_DEMO_DIR, "predict_first_ntree.py")
-    cmd = ["python", script]
+    cmd = ["python3", script]
     subprocess.check_call(cmd)
 
 
 def test_individual_trees() -> None:
     script = os.path.join(PYTHON_DEMO_DIR, "individual_trees.py")
-    cmd = ["python", script]
+    cmd = ["python3", script]
     subprocess.check_call(cmd)
 
 
 def test_predict_leaf_indices_demo() -> None:
     script = os.path.join(PYTHON_DEMO_DIR, "predict_leaf_indices.py")
-    cmd = ["python", script]
+    cmd = ["python3", script]
     subprocess.check_call(cmd)
 
 
 def test_generalized_linear_model_demo() -> None:
     script = os.path.join(PYTHON_DEMO_DIR, "generalized_linear_model.py")
-    cmd = ["python", script]
+    cmd = ["python3", script]
     subprocess.check_call(cmd)
 
 
 def test_cross_validation_demo() -> None:
     script = os.path.join(PYTHON_DEMO_DIR, "cross_validation.py")
-    cmd = ["python", script]
+    cmd = ["python3", script]
     subprocess.check_call(cmd)
 
 
 def test_external_memory_demo() -> None:
     script = os.path.join(PYTHON_DEMO_DIR, "external_memory.py")
-    cmd = ["python", script]
+    cmd = ["python3", script]
     subprocess.check_call(cmd)
 
 
 def test_evals_result_demo() -> None:
     script = os.path.join(PYTHON_DEMO_DIR, "evals_result.py")
-    cmd = ["python", script]
+    cmd = ["python3", script]
     subprocess.check_call(cmd)
 
 
@@ -132,7 +132,7 @@ def test_evals_result_demo() -> None:
 @pytest.mark.skipif(**tm.no_pandas())
 def test_aft_demo() -> None:
     script = os.path.join(DEMO_DIR, "aft_survival", "aft_survival_demo.py")
-    cmd = ["python", script]
+    cmd = ["python3", script]
     subprocess.check_call(cmd)
     assert os.path.exists("aft_model.json")
     os.remove("aft_model.json")
@@ -141,13 +141,13 @@ def test_aft_demo() -> None:
 @pytest.mark.skipif(**tm.no_matplotlib())
 def test_callbacks_demo() -> None:
     script = os.path.join(PYTHON_DEMO_DIR, "callbacks.py")
-    cmd = ["python", script, "--plot=0"]
+    cmd = ["python3", script, "--plot=0"]
     subprocess.check_call(cmd)
 
 
 def test_continuation_demo() -> None:
     script = os.path.join(PYTHON_DEMO_DIR, "continuation.py")
-    cmd = ["python", script]
+    cmd = ["python3", script]
     subprocess.check_call(cmd)
 
 
@@ -155,14 +155,14 @@ def test_continuation_demo() -> None:
 @pytest.mark.skipif(**tm.no_matplotlib())
 def test_multioutput_reg() -> None:
     script = os.path.join(PYTHON_DEMO_DIR, "multioutput_regression.py")
-    cmd = ["python", script, "--plot=0"]
+    cmd = ["python3", script, "--plot=0"]
     subprocess.check_call(cmd)
 
 
 @pytest.mark.skipif(**tm.no_sklearn())
 def test_quantile_reg() -> None:
     script = os.path.join(PYTHON_DEMO_DIR, "quantile_regression.py")
-    cmd = ["python", script]
+    cmd = ["python3", script]
     subprocess.check_call(cmd)
 
 
@@ -174,12 +174,12 @@ def test_json_model() -> None:
         with tempfile.TemporaryDirectory() as tmpdir:
             path = os.path.join(tmpdir, "reg.json")
             reg.save_model(path)
-            cmd = ["python", script, f"--model={path}"]
+            cmd = ["python3", script, f"--model={path}"]
             subprocess.check_call(cmd)
 
             path = os.path.join(tmpdir, "reg.ubj")
             reg.save_model(path)
-            cmd = ["python", script, f"--model={path}"]
+            cmd = ["python3", script, f"--model={path}"]
             subprocess.check_call(cmd)
 
     # numerical
@@ -214,11 +214,11 @@ def test_json_model() -> None:
 def test_cli_regression_demo() -> None:
     reg_dir = os.path.join(CLI_DEMO_DIR, "regression")
     script = os.path.join(reg_dir, "mapfeat.py")
-    cmd = ["python", script]
+    cmd = ["python3", script]
     subprocess.check_call(cmd, cwd=reg_dir)
 
     script = os.path.join(reg_dir, "mknfold.py")
-    cmd = ["python", script, "machine.txt", "1"]
+    cmd = ["python3", script, "machine.txt", "1"]
     subprocess.check_call(cmd, cwd=reg_dir)
 
     exe = os.path.join(DEMO_DIR, os.path.pardir, "xgboost")
diff --git a/tests/python/test_openmp.py b/tests/python/test_openmp.py
index 82b0ba270..a71adc8eb 100644
--- a/tests/python/test_openmp.py
+++ b/tests/python/test_openmp.py
@@ -82,7 +82,7 @@ class TestOMP:
     @pytest.mark.skipif(**tm.no_sklearn())
     def test_with_omp_thread_limit(self):
         args = [
-            "python", os.path.join(
+            "python3", os.path.join(
                 os.path.dirname(tm.normpath(__file__)), "with_omp_limit.py"
             )
         ]
-- 
2.41.0

