diff --git a/src/runtime_src/core/tools/common/Process.cpp b/src/runtime_src/core/tools/common/Process.cpp index 73a6841696f..c73648f9c9f 100644 --- a/src/runtime_src/core/tools/common/Process.cpp +++ b/src/runtime_src/core/tools/common/Process.cpp @@ -34,7 +34,6 @@ #endif // Local - Include Files -#include "BusyBar.h" #include "EscapeCodes.h" #include "Process.h" #include "XBUtilitiesCore.h" @@ -138,8 +137,6 @@ unsigned int XBUtilities::runScript( const std::string & env, const std::string & script, const std::vector & args, - const std::string & running_description, - const std::chrono::seconds & max_duration_s, std::ostringstream & os_stdout, std::ostringstream & os_stderr) { @@ -158,25 +155,15 @@ XBUtilities::runScript( const std::string & env, } cmd += script + " " + args_str.str(); - BusyBar busy_bar(running_description, std::cout); - busy_bar.start(XBUtilities::is_escape_codes_disabled()); bool is_thread_running = true; // Start the test process - // std::thread test_thread(run_script, cmd, std::ref(os_stdout), std::ref(os_stderr), std::ref(is_thread_running)); std::thread test_thread([&] { run_script(cmd, os_stdout, os_stderr, is_thread_running); }); // Wait for the test process to finish while (is_thread_running) { std::this_thread::sleep_for(std::chrono::seconds(1)); - try { - busy_bar.check_timeout(max_duration_s); - } catch (const std::exception& ex) { - test_thread.detach(); - throw; - } } test_thread.join(); - busy_bar.finish(); bool passed = (os_stdout.str().find("PASS") != std::string::npos) ? true : false; bool skipped = (os_stdout.str().find("NOT SUPPORTED") != std::string::npos) ? true : false; @@ -214,8 +201,6 @@ unsigned int XBUtilities::runScript( const std::string & env, const std::string & script, const std::vector & args, - const std::string & running_description, - const std::chrono::seconds& max_running_duration, std::ostringstream & os_stdout, std::ostringstream & os_stderr) { @@ -239,9 +224,6 @@ XBUtilities::runScript( const std::string & env, boost::process::environment _env = boost::this_process::environment(); _env.erase("XCL_EMULATION_MODE"); - BusyBar run_test(running_description, std::cout); - run_test.start(XBUtilities::is_escape_codes_disabled()); - // Execute the python script and capture the outputs boost::process::ipstream ip_stdout; boost::process::ipstream ip_stderr; @@ -254,12 +236,10 @@ XBUtilities::runScript( const std::string & env, // Wait for the process to finish while (runningProcess.running()) { std::this_thread::sleep_for(std::chrono::seconds(1)); - run_test.check_timeout(max_running_duration); } // Not really needed, but should be added for completeness runningProcess.wait(); - run_test.finish(); // boost::process::ipstream::rdbuf() gives conversion error in // 1.65.1 Base class is constructed with underlying buffer so just diff --git a/src/runtime_src/core/tools/common/Process.h b/src/runtime_src/core/tools/common/Process.h index 2ce56118e7d..0c6cff03b2c 100644 --- a/src/runtime_src/core/tools/common/Process.h +++ b/src/runtime_src/core/tools/common/Process.h @@ -24,8 +24,6 @@ namespace XBUtilities { runScript(const std::string & env, const std::string & script, const std::vector & args, - const std::string & running_description, - const std::chrono::seconds& max_running_duration, std::ostringstream & os_stdout, std::ostringstream & os_stderr); }; diff --git a/src/runtime_src/core/tools/common/TestRunner.cpp b/src/runtime_src/core/tools/common/TestRunner.cpp index 3e4699a8756..4f9270bb745 100644 --- a/src/runtime_src/core/tools/common/TestRunner.cpp +++ b/src/runtime_src/core/tools/common/TestRunner.cpp @@ -243,7 +243,7 @@ TestRunner::searchLegacyXclbin(const uint16_t vendor, const std::string& dev_nam } /* - * helper funtion for kernel and bandwidth test cases + * helper funtion for kernel and bandwidth python test cases when there is no platform.json * Steps: * 1. Find xclbin after determining if the shell is 1RP or 2RP * 2. Find testcase @@ -251,7 +251,7 @@ TestRunner::searchLegacyXclbin(const uint16_t vendor, const std::string& dev_nam * 4. Check results */ void -TestRunner::runTestCase( const std::shared_ptr& _dev, const std::string& py, +TestRunner::runPyTestCase( const std::shared_ptr& _dev, const std::string& py, boost::property_tree::ptree& _ptTest) { const auto xclbin = _ptTest.get("xclbin", ""); @@ -273,11 +273,6 @@ TestRunner::runTestCase( const std::shared_ptr& _dev, const st logger(_ptTest, "Xclbin", xclbin_parent_path); std::string platform_path = findPlatformPath(_dev, _ptTest); - auto json_exists = [platform_path]() { - const static std::string platform_metadata = "/platform.json"; - std::string platform_json_path(platform_path + platform_metadata); - return std::filesystem::exists(platform_json_path) ? true : false; - }; // Some testcases require additional binaries to be present on the device std::string dependency_args; @@ -294,101 +289,38 @@ TestRunner::runTestCase( const std::shared_ptr& _dev, const st #define XRT_TEST_CASE_DIR "/opt/xilinx/xrt/test/" #endif - if (json_exists()) { - //map old testcase names to new testcase names - static const std::map test_map = { - { "22_verify.py", "validate.exe" }, - { "23_bandwidth.py", "kernel_bw.exe" }, - { "versal_23_bandwidth.py", "kernel_bw.exe" }, - { "host_mem_23_bandwidth.py", "hostmemory.exe" }, - { "xcl_vcu_test.exe", "xcl_vcu_test.exe"}, - { "xcl_iops_test.exe", "xcl_iops_test.exe"}, - { "aie_pl.exe", "aie_pl.exe"} - }; - - // Validate the legacy names - // If no legacy name exists use the passed in test name - std::string test_name = py; - if (test_map.find(py) != test_map.end()) - test_name = test_map.find(py)->second; - - // Parse if the file exists here - std::string xrtTestCasePath = XRT_TEST_CASE_DIR + test_name; - std::filesystem::path xrt_path(xrtTestCasePath); - if (!std::filesystem::exists(xrt_path)) { - logger(_ptTest, "Error", boost::str(boost::format("Failed to find %s") % xrtTestCasePath)); - logger(_ptTest, "Error", "Please check if the platform package is installed correctly"); - _ptTest.put("status", test_token_failed); - return; - } - - // log testcase path for debugging purposes - logger(_ptTest, "Testcase", xrtTestCasePath); - - std::vector args = { "-x", xclbinPath, - "-p", platform_path, - "-d", xrt_core::query::pcie_bdf::to_string(xrt_core::device_query(_dev)) }; + //Check if testcase is present + std::string xrtTestCasePath = XRT_TEST_CASE_DIR + py; + std::filesystem::path xrt_path(xrtTestCasePath); + if (!std::filesystem::exists(xrt_path)) { + logger(_ptTest, "Error", boost::str(boost::format("Failed to find %s") % xrtTestCasePath)); + logger(_ptTest, "Error", "Please check if the platform package is installed correctly"); + _ptTest.put("status", test_token_failed); + return; + } + // log testcase path for debugging purposes + logger(_ptTest, "Testcase", xrtTestCasePath); - if (!dependency_args.empty()) { - args.push_back("-i"); - args.push_back(dependency_args); - } + std::vector args = { "-k", xclbinPath, + "-d", xrt_core::query::pcie_bdf::to_string(xrt_core::device_query(_dev)) }; + int exit_code; + try { + exit_code = XBU::runScript("python", xrtTestCasePath, args, os_stdout, os_stderr); - try { - int exit_code = XBU::runScript("sh", xrtTestCasePath, args, "Running Test", max_test_duration, os_stdout, os_stderr); - if (exit_code == EOPNOTSUPP) { - _ptTest.put("status", test_token_skipped); - } - else if (exit_code == EXIT_SUCCESS) { - _ptTest.put("status", test_token_passed); - } - else { - logger(_ptTest, "Error", os_stdout.str()); - logger(_ptTest, "Error", os_stderr.str()); - _ptTest.put("status", test_token_failed); - } - } catch (const std::exception& e) { - logger(_ptTest, "Error", e.what()); - _ptTest.put("status", test_token_failed); + if (exit_code == EOPNOTSUPP) { + _ptTest.put("status", test_token_skipped); } - } - else { - //check if testcase is present - std::string xrtTestCasePath = XRT_TEST_CASE_DIR + py; - std::filesystem::path xrt_path(xrtTestCasePath); - if (!std::filesystem::exists(xrt_path)) { - logger(_ptTest, "Error", boost::str(boost::format("Failed to find %s") % xrtTestCasePath)); - logger(_ptTest, "Error", "Please check if the platform package is installed correctly"); - _ptTest.put("status", test_token_failed); - return; + else if (exit_code == EXIT_SUCCESS) { + _ptTest.put("status", test_token_passed); } - // log testcase path for debugging purposes - logger(_ptTest, "Testcase", xrtTestCasePath); - - std::vector args = { "-k", xclbinPath, - "-d", xrt_core::query::pcie_bdf::to_string(xrt_core::device_query(_dev)) }; - int exit_code; - try { - if (py.find(".exe") != std::string::npos) - exit_code = XBU::runScript("", xrtTestCasePath, args, "Running Test", max_test_duration, os_stdout, os_stderr); - else - exit_code = XBU::runScript("python", xrtTestCasePath, args, "Running Test", max_test_duration, os_stdout, os_stderr); - - if (exit_code == EOPNOTSUPP) { - _ptTest.put("status", test_token_skipped); - } - else if (exit_code == EXIT_SUCCESS) { - _ptTest.put("status", test_token_passed); - } - else { - logger(_ptTest, "Error", os_stdout.str()); - logger(_ptTest, "Error", os_stderr.str()); - _ptTest.put("status", test_token_failed); - } - } catch (const std::exception& e) { - logger(_ptTest, "Error", e.what()); + else { + logger(_ptTest, "Error", os_stdout.str()); + logger(_ptTest, "Error", os_stderr.str()); _ptTest.put("status", test_token_failed); } + } catch (const std::exception& e) { + logger(_ptTest, "Error", e.what()); + _ptTest.put("status", test_token_failed); } // Get out max thruput for bandwidth testcase @@ -409,14 +341,6 @@ TestRunner::runTestCase( const std::shared_ptr& _dev, const st } } } - - if (py.compare("xcl_iops_test.exe") == 0) { - auto st = os_stdout.str().find("IOPS:"); - if (st != std::string::npos) { - size_t end = os_stdout.str().find("\n", st); - logger(_ptTest, "Details", os_stdout.str().substr(st, end - st)); - } - } } int diff --git a/src/runtime_src/core/tools/common/TestRunner.h b/src/runtime_src/core/tools/common/TestRunner.h index d7ddfd94a04..cdcfc0a3e0e 100644 --- a/src/runtime_src/core/tools/common/TestRunner.h +++ b/src/runtime_src/core/tools/common/TestRunner.h @@ -35,7 +35,7 @@ class TestRunner : public JSONConfigurable { protected: TestRunner(const std::string & test_name, const std::string & description, const std::string & xclbin = "", bool is_explicit = false); - void runTestCase( const std::shared_ptr& _dev, const std::string& py, + void runPyTestCase( const std::shared_ptr& _dev, const std::string& py, boost::property_tree::ptree& _ptTest); void logger(boost::property_tree::ptree& ptree, const std::string& tag, const std::string& msg); bool search_and_program_xclbin(const std::shared_ptr& dev, boost::property_tree::ptree& ptTest); diff --git a/src/runtime_src/core/tools/common/tests/TestBandwidthKernel.cpp b/src/runtime_src/core/tools/common/tests/TestBandwidthKernel.cpp index 6661cd9cd1d..ddb4ea8b18d 100644 --- a/src/runtime_src/core/tools/common/tests/TestBandwidthKernel.cpp +++ b/src/runtime_src/core/tools/common/tests/TestBandwidthKernel.cpp @@ -246,6 +246,16 @@ TestBandwidthKernel::runTest(std::shared_ptr dev, boost::prope ptree.put("status", test_token_failed); return; } + auto json_exists = [test_path]() { + const static std::string platform_metadata = "/platform.json"; + std::string platform_json_path(test_path + platform_metadata); + return std::filesystem::exists(platform_json_path) ? true : false; + }; + if (!json_exists()) { + // Without a platform.json, we need to run the python test file. + runPyTestCase(dev, "23_bandwidth.py", ptree); + return; + } int num_kernel = 0; int num_kernel_ddr = 0;