You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-commits@axis.apache.org by ro...@apache.org on 2026/01/25 05:12:26 UTC

(axis-axis2-c-core) 06/06: Fix test file paths for axiom util and xpath tests

This is an automated email from the ASF dual-hosted git repository.

robertlazarski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-c-core.git

commit f9129f5185ec7f92155369a819c677c6e2829348
Author: Robert Lazarski <ro...@gmail.com>
AuthorDate: Sat Jan 24 19:10:21 2026 -1000

    Fix test file paths for axiom util and xpath tests
    
    Update test_util.cc and test_xpath.cc to search multiple paths for
    test resource files, allowing tests to pass when run from:
    - The test directory (axiom/test/util/ or axiom/test/xpath/)
    - The .libs/ subdirectory (direct execution of libtool wrapper)
    - The project root directory (running full test suite)
    
    This follows the same pattern used for test_om_build.
    
    Co-Authored-By: Claude Opus 4.5 <no...@anthropic.com>
---
 axiom/test/util/test_util.cc   | 16 +++++++++++++---
 axiom/test/xpath/test_xpath.cc | 34 +++++++++++++++++++++++++---------
 2 files changed, 38 insertions(+), 12 deletions(-)

diff --git a/axiom/test/util/test_util.cc b/axiom/test/util/test_util.cc
index 5143c7d2f..c129e1176 100644
--- a/axiom/test/util/test_util.cc
+++ b/axiom/test/util/test_util.cc
@@ -121,12 +121,22 @@ TEST_F(TestUtil, test_build_and_serialize_om) {
     axiom_node_t *temp_node = NULL;
     axis2_char_t *temp_str = NULL;
 
+    /* Try multiple paths to find test.xml from various working directories */
+    const char *paths[] = {
+        "test.xml",                      /* from axiom/test/util/ */
+        "../util/test.xml",              /* from axiom/test/util/.libs/ */
+        "axiom/test/util/test.xml",      /* from project root */
+        NULL
+    };
+    for (int i = 0; paths[i] != NULL; i++) {
+        f = fopen(paths[i], "r");
+        if (f) break;
+    }
+    ASSERT_NE(f, nullptr) << "Could not find test.xml in any expected location";
+
     names = axutil_array_list_create(m_env, 1);
     axutil_array_list_add(names, m_env, "language");
 
-	f = fopen("test.xml","r");
-    ASSERT_NE(f, nullptr);
-
     xml_reader = axiom_xml_reader_create_for_io(m_env, read_input_callback, close_input_callback, NULL, NULL);
     ASSERT_NE(xml_reader, nullptr);
 
diff --git a/axiom/test/xpath/test_xpath.cc b/axiom/test/xpath/test_xpath.cc
index e88423c21..62d2d3cc5 100644
--- a/axiom/test/xpath/test_xpath.cc
+++ b/axiom/test/xpath/test_xpath.cc
@@ -179,21 +179,37 @@ TEST_F(TestXPath, test_xpath) {
 
     axiom_node_t *test_tree = NULL;
     axis2_char_t *test_tree_str;
-    char *xml_file = "test.xml";
-    char *xpath_file = "test.xpath";
-    char *ns_file = "test.ns";
-    char *cor_file = "results.txt";
     axiom_xpath_context_t *context = NULL;
 
+    /* Try multiple paths to find test files from various working directories */
+    const char *base_paths[] = {
+        "",                          /* from axiom/test/xpath/ */
+        "../xpath/",                 /* from axiom/test/xpath/.libs/ */
+        "axiom/test/xpath/",         /* from project root */
+        NULL
+    };
+
+    char xml_file[256] = "";
+    char xpath_file[256] = "";
+    char ns_file[256] = "";
+    char cor_file[256] = "";
+
+    for (int i = 0; base_paths[i] != NULL; i++) {
+        snprintf(cor_file, sizeof(cor_file), "%sresults.txt", base_paths[i]);
+        fcor = fopen(cor_file, "r");
+        if (fcor) {
+            snprintf(xml_file, sizeof(xml_file), "%stest.xml", base_paths[i]);
+            snprintf(xpath_file, sizeof(xpath_file), "%stest.xpath", base_paths[i]);
+            snprintf(ns_file, sizeof(ns_file), "%stest.ns", base_paths[i]);
+            break;
+        }
+    }
+    ASSERT_NE(fcor, nullptr) << "Could not find test files in any expected location";
+
     /*Create the request */
     /* test_tree = build_test_xml(env); */
     test_tree = read_test_xml(m_env, (axis2_char_t *)xml_file);
 
-    fcor = fopen(cor_file, "r");
-    /*ftemp = fopen("temp.txt", "w");*/
-
-    ASSERT_NE(fcor, nullptr);
-
     ASSERT_NE(test_tree, nullptr);
 
     test_tree_str = axiom_node_to_string(test_tree, m_env);