diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml index 33b5b7245..e3595b310 100644 --- a/.github/actions/test/action.yml +++ b/.github/actions/test/action.yml @@ -45,7 +45,6 @@ runs: if [[ "01234567" == *"${JOBID}"* ]]; then export PDI_PLUGIN_PATH=/tmp/pdi_plugins; fi export MAKEFLAGS='-j 4' export CTEST_FLAGS="--output-junit /tmp/tests.xml" - export TEST_DIR="/tmp_dir_test" /src/bin/build_and_run_all_tests EOF docker run \ diff --git a/plugins/decl_netcdf/CHANGELOG.md b/plugins/decl_netcdf/CHANGELOG.md index ffa0df3c3..0b382d7d8 100644 --- a/plugins/decl_netcdf/CHANGELOG.md +++ b/plugins/decl_netcdf/CHANGELOG.md @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Removed ### Fixed +* Bug(typo) fixed: Config error raised when using the scalar format for the yaml write configuration. ### Security diff --git a/plugins/decl_netcdf/dnc_file_context.cxx b/plugins/decl_netcdf/dnc_file_context.cxx index b0d9fc441..d0c8ee7e7 100644 --- a/plugins/decl_netcdf/dnc_file_context.cxx +++ b/plugins/decl_netcdf/dnc_file_context.cxx @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (C) 2015-2024 Commissariat a l'energie atomique et aux energies alternatives (CEA) + * Copyright (C) 2015-2025 Commissariat a l'energie atomique et aux energies alternatives (CEA) * Copyright (C) 2019-2021 Institute of Bioorganic Chemistry Polish Academy of Science (PSNC) * All rights reserved. * @@ -127,7 +127,7 @@ Dnc_file_context::Dnc_file_context(PDI::Context& ctx, PC_tree_t config) PC_tree_t write_node = PC_get(config, ".write"); if (!PC_status(write_node)) { - if (PDI::is_scalar(read_node)) { + if (PDI::is_scalar(write_node)) { std::string write_desc = PDI::to_string(write_node); m_ctx.logger().trace("Creating new empty write info for: {}", write_desc); m_write.emplace(write_desc, Dnc_io{this->m_ctx, PC_tree_t{}}); @@ -138,12 +138,14 @@ Dnc_file_context::Dnc_file_context(PDI::Context& ctx, PC_tree_t config) m_ctx.logger().trace("Creating new empty write info for: {}", write_desc); m_write.emplace(write_desc, Dnc_io{this->m_ctx, PC_tree_t{}}); } - } else { + } else if (PDI::is_map(write_node)) { PDI::each(write_node, [this](PC_tree_t desc_name, PC_tree_t write_value) { std::string write_desc = PDI::to_string(desc_name); m_ctx.logger().trace("Creating new write info for: {}", write_desc); this->m_write.emplace(PDI::to_string(desc_name), Dnc_io{this->m_ctx, write_value}); }); + } else { + throw PDI::Error{PDI_ERR_CONFIG, "write node is not parsed correctly"}; } } diff --git a/plugins/decl_netcdf/tests/decl_netcdf_tests.cxx b/plugins/decl_netcdf/tests/decl_netcdf_tests.cxx index e77246f19..15f98d028 100644 --- a/plugins/decl_netcdf/tests/decl_netcdf_tests.cxx +++ b/plugins/decl_netcdf/tests/decl_netcdf_tests.cxx @@ -1,6 +1,6 @@ /******************************************************************************* * Copyright (C) 2020-2021 Institute of Bioorganic Chemistry Polish Academy of Science (PSNC) - * Copyright (C) 2024 Commissariat a l'energie atomique et aux energies alternatives (CEA) + * Copyright (C) 2024-2025 Commissariat a l'energie atomique et aux energies alternatives (CEA) * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -680,7 +680,7 @@ TEST(decl_netcdf_test, 06) " \n" "plugins: \n" " decl_netcdf: \n" - " - file: 'test_07.nc' \n" + " - file: 'test_06.nc' \n" " on_event: 'write' \n" " variables: \n" " int_matrix_var: \n" @@ -694,7 +694,7 @@ TEST(decl_netcdf_test, 06) " variable_selection: \n" " start: ['$iter', 0, 0] \n" " subsize: [1, 8, 8] \n" - " - file: 'test_07.nc' \n" + " - file: 'test_06.nc' \n" " on_event: 'read' \n" " variables: \n" " int_matrix_var: \n" @@ -739,6 +739,48 @@ TEST(decl_netcdf_test, 06) PDI_finalize(); } +/* + * Name: decl_netcdf_test.07 + * + * Description: Tests yaml syntaxe with `write: data` + */ +TEST(decl_netcdf_test, 07) +{ + const char* CONFIG_YAML + = "logging: trace \n" + "data: \n" + " int_matrix: \n" + " type: array \n" + " subtype: int \n" + " size: [8, 8] \n" + " \n" + "plugins: \n" + " decl_netcdf: \n" + " - file: 'test_07.nc' \n" + " on_event: 'write' \n" + " write: int_matrix \n"; + + // Use the null error handle explicitly. Otherwise, the error is not captured. + // Need further investigation + PDI_errhandler(PDI_NULL_HANDLER); + + ASSERT_EQ(PDI_OK, PDI_init(PC_parse_string(CONFIG_YAML))); + + int int_matrix[8][8]; + + // init data + for (int i = 0; i < 8; i++) { + for (int j = 0; j < 8; j++) { + int_matrix[i][j] = 100 + i * 8 + j; + } + } + + // write data + ASSERT_EQ(PDI_OK, PDI_multi_expose("write", "int_matrix", int_matrix, PDI_OUT, NULL)); + + PDI_finalize(); +} + /* * Name: decl_netcdf_test.size_of *