Revision: 75908
http://sourceforge.net/p/brlcad/code/75908
Author: starseeker
Date: 2020-05-24 03:30:16 +0000 (Sun, 24 May 2020)
Log Message:
-----------
get ged mater test working
Modified Paths:
--------------
brlcad/branches/bioh/misc/CMake/BRLCAD_Targets.cmake
brlcad/branches/bioh/regress/CMakeLists.txt
brlcad/branches/bioh/regress/ged/CMakeLists.txt
brlcad/branches/bioh/src/libged/tests/CMakeLists.txt
Added Paths:
-----------
brlcad/branches/bioh/regress/ged/mater.c
brlcad/branches/bioh/regress/ged/regress-ged_mater.cmake.in
Removed Paths:
-------------
brlcad/branches/bioh/regress/ged/regress-mater.cmake.in
brlcad/branches/bioh/src/libged/tests/mater.c
Modified: brlcad/branches/bioh/misc/CMake/BRLCAD_Targets.cmake
===================================================================
--- brlcad/branches/bioh/misc/CMake/BRLCAD_Targets.cmake 2020-05-24
02:32:16 UTC (rev 75907)
+++ brlcad/branches/bioh/misc/CMake/BRLCAD_Targets.cmake 2020-05-24
03:30:16 UTC (rev 75908)
@@ -906,6 +906,14 @@
# convention of ${testname}.cmake.in in the current source directory is assumed
# to specify the input test script.
#
+# Particularly when configuration dependent builds are in play, a test
+# executable's location needs special handling to ensure the scripts run the
+# correct version of a program. The standard mechanism is to specify the CMake
+# target name of the executable by supplying it via the EXEC option and then
+# pass the output of $<TARGET_FILE:${${testname}_EXEC}> to the running CMake
+# script. (Note that the script must in turn post-process this value to unquote
+# it in case of special characters in pathnames.)
+#
# To allow for more customized test execution, the option TEST_DEFINED may be
# passed to the function to instruct it to skip all setup for add_test and
# custom command definitions. It is the callers responsibility to define an
@@ -938,7 +946,7 @@
function(BRLCAD_REGRESSION_TEST testname depends_list)
- cmake_parse_arguments(${testname} "TEST_DEFINED;STAND_ALONE"
"TEST_SCRIPT;TIMEOUT" "" ${ARGN})
+ cmake_parse_arguments(${testname} "TEST_DEFINED;STAND_ALONE"
"TEST_SCRIPT;TIMEOUT;EXEC" "" ${ARGN})
if (NOT ${testname}_TEST_DEFINED)
@@ -949,7 +957,11 @@
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${testname}.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${testname}.cmake" @ONLY)
endif (${testname}_TEST_SCRIPT)
- add_test(NAME ${testname} COMMAND "${CMAKE_COMMAND}" -P
"${CMAKE_CURRENT_BINARY_DIR}/${testname}.cmake")
+ if (TARGET ${${testname}_EXEC})
+ add_test(NAME ${testname} COMMAND "${CMAKE_COMMAND}"
-DEXEC=$<TARGET_FILE:${${testname}_EXEC}> -P
"${CMAKE_CURRENT_BINARY_DIR}/${testname}.cmake")
+ else (TARGET ${${testname}_EXEC})
+ add_test(NAME ${testname} COMMAND "${CMAKE_COMMAND}" -P
"${CMAKE_CURRENT_BINARY_DIR}/${testname}.cmake")
+ endif (TARGET ${${testname}_EXEC})
endif (NOT ${testname}_TEST_DEFINED)
@@ -960,6 +972,9 @@
else (CMAKE_CONFIGURATION_TYPES)
add_custom_target(${testname} COMMAND ${CMAKE_CTEST_COMMAND} -R
^${testname} --output-on-failure)
endif (CMAKE_CONFIGURATION_TYPES)
+ if (depends_list)
+ add_dependencies(${testname} ${depends_list})
+ endif (depends_list)
# Make sure we at least get this into the regression test folder - local
# subdirectories may override this if they have more specific locations
Modified: brlcad/branches/bioh/regress/CMakeLists.txt
===================================================================
--- brlcad/branches/bioh/regress/CMakeLists.txt 2020-05-24 02:32:16 UTC (rev
75907)
+++ brlcad/branches/bioh/regress/CMakeLists.txt 2020-05-24 03:30:16 UTC (rev
75908)
@@ -15,7 +15,7 @@
add_subdirectory(icv)
# Geometry Editing Library Regression Tests
-#add_subdirectory(ged)
+add_subdirectory(ged)
# Geometry Conversion Regression Tests
#add_subdirectory(gcv)
Modified: brlcad/branches/bioh/regress/ged/CMakeLists.txt
===================================================================
--- brlcad/branches/bioh/regress/ged/CMakeLists.txt 2020-05-24 02:32:16 UTC
(rev 75907)
+++ brlcad/branches/bioh/regress/ged/CMakeLists.txt 2020-05-24 03:30:16 UTC
(rev 75908)
@@ -3,44 +3,18 @@
include_directories(${GED_INCLUDE_DIRS})
-if(CMAKE_CONFIGURATION_TYPES)
- set(cfg_testname "-${CMAKE_CFG_INTDIR}")
-else(CMAKE_CONFIGURATION_TYPES)
- set(cfg_testname "")
-endif(CMAKE_CONFIGURATION_TYPES)
+add_definitions(
+ -DHAVE_CONFIG_H
+ -DBRLCADBUILD
+ )
-macro(ADD_GED_Test testname depends_list)
- set(LOG_FILE
"${CMAKE_CURRENT_BINARY_DIR}/regress${cfg_testname}-${testname}.log")
- set(STAMP_FILE "${CMAKE_CURRENT_BINARY_DIR}/${testname}${cfg_testname}.done")
- configure_file("${CMAKE_CURRENT_SOURCE_DIR}/regress-${testname}.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/regress-${testname}.cmake" @ONLY)
- add_custom_command(
- OUTPUT "${STAMP_FILE}"
- COMMAND "${CMAKE_COMMAND}" -P
"${CMAKE_CURRENT_BINARY_DIR}/regress-${testname}.cmake"
- DEPENDS ${depends_list}
- )
- add_test(NAME regress-ged-${testname} COMMAND "${CMAKE_COMMAND}" -P
"${CMAKE_CURRENT_BINARY_DIR}/regress-${testname}.cmake")
- add_custom_target(regress-ged-${testname} DEPENDS ${depends_list}
${STAMP_FILE})
- set_target_properties(regress-ged-${testname} PROPERTIES FOLDER "BRL-CAD
Regression Tests")
- Add_Regression_Test(ged-${testname} "${depends_list}")
+BRLCAD_ADDEXEC(regress_mater mater.c libged TEST_USESDATA)
- add_dependencies(regress-ged regress-ged-${testname})
+BRLCAD_REGRESSION_TEST(regress-ged_mater "regress_mater;density_DATAFILES_cp"
EXEC regress_mater)
- DISTCLEAN(
- ${STAMP_FILE}
- ${LOG_FILE}
- ${TARGET_IMAGE}
- )
-endmacro()
-
-add_custom_target(regress-ged)
-set_target_properties(regress-ged PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
-set_target_properties(regress-ged PROPERTIES FOLDER "BRL-CAD Regression Tests")
-
-Add_GED_Test(mater "regress_ged_mater;density_DATAFILES_cp")
-
CMAKEFILES(
CMakeLists.txt
- regress-mater.cmake.in
+ regress-ged_mater.cmake.in
)
DISTCLEAN(
Copied: brlcad/branches/bioh/regress/ged/mater.c (from rev 75907,
brlcad/branches/bioh/src/libged/tests/mater.c)
===================================================================
--- brlcad/branches/bioh/regress/ged/mater.c (rev 0)
+++ brlcad/branches/bioh/regress/ged/mater.c 2020-05-24 03:30:16 UTC (rev
75908)
@@ -0,0 +1,511 @@
+/* M A T E R . C
+ * BRL-CAD
+ *
+ * Copyright (c) 2018-2020 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file mater.c
+ *
+ * Brief description
+ *
+ */
+
+#include "common.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <bu.h>
+#include <ged.h>
+
+const char *basic_density =
+"15 0.920000 Rubber\n"
+"16 1.230000 Rubber, Neoprene\n";
+
+const char *nist_to_basic =
+"\"Rubber, Butyl\" Rubber\n"
+"\"Rubber, Natural\" Rubber\n";
+
+const char *basic_to_nist =
+"\"Rubber\" \"Rubber, Natural\"\n";
+
+
+int
+check_for_data_exported(const char *filename, const char *key)
+{
+ struct bu_mapped_file *efile = bu_open_mapped_file(filename, "exported
densities data");
+ if (!strstr((char *)efile->buf, key)) {
+ bu_log("Error: 'mater -d export' file %s does not contain all expected
data\n", filename);
+ bu_close_mapped_file(efile);
+ return -1;
+ }
+ bu_close_mapped_file(efile);
+ return 0;
+}
+
+int
+check_for_data_present(struct ged *gedp, const char *key, const char *expected)
+{
+ const char *mater_cmd[10] = {"mater", "-d", NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL};
+ mater_cmd[1] = "-d";
+ mater_cmd[2] = "get";
+ mater_cmd[3] = "--name";
+ mater_cmd[4] = key;
+ if (ged_mater(gedp, 5, (const char **)mater_cmd) != GED_OK) {
+ bu_log("Error: 'mater -d get --name %s' failed\n", key);
+ return -1;
+ }
+ if (!BU_STR_EQUAL(bu_vls_cstr(gedp->ged_result_str), expected)) {
+ bu_log("Error: expected '%s', got: '%s'\n", expected,
bu_vls_cstr(gedp->ged_result_str));
+ return -1;
+ }
+ return 0;
+}
+
+
+int
+check_for_data_not_present(struct ged *gedp, const char *key)
+{
+ const char *mater_cmd[10] = {"mater", "-d", NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL};
+ mater_cmd[1] = "-d";
+ mater_cmd[2] = "get";
+ mater_cmd[3] = "--name";
+ mater_cmd[4] = key;
+ if (ged_mater(gedp, 5, (const char **)mater_cmd) != GED_OK) {
+ bu_log("Error: 'mater -d get --name %s' failed\n", key);
+ return -1;
+ }
+ if (bu_vls_strlen(gedp->ged_result_str)) {
+ bu_log("Error: unexpected result found for key %s: '%s'\n", key,
bu_vls_cstr(gedp->ged_result_str));
+ return -1;
+ }
+ return 0;
+}
+
+int
+attr_val_check(struct ged *gedp, const char *obj, const char *key, const char
*expected)
+{
+ const char *attr_cmd[5] = {"attr", "get", NULL, NULL, NULL};
+ attr_cmd[2] = obj;
+ attr_cmd[3] = key;
+ if (ged_attr(gedp, 4, (const char **)attr_cmd) != GED_OK) {
+ bu_log("Error: 'attr get %s %s' failed\n", obj, key);
+ return -1;
+ }
+ if (!BU_STR_EQUAL(bu_vls_cstr(gedp->ged_result_str), expected)) {
+ bu_log("Error: expected '%s', got: '%s'\n", expected,
bu_vls_cstr(gedp->ged_result_str));
+ return -1;
+ }
+ return 0;
+}
+
+
+int
+main(int ac, char *av[]) {
+ struct ged *gedp;
+ const char *gname = "ged_mater_test.g";
+ const char *exp_data = "ged_mater_density_export.txt";
+ const char *d_data = "ged_mater_density_data.txt";
+ const char *m_data = "ged_mater_density_map.txt";
+ const char *b_data = "ged_mater_density_reverse_map.txt";
+ char mdata[MAXPATHLEN];
+ const char *mater_cmd[10] = {"mater", "-d", NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL};
+ const char *make_cmd[10] = {"make", NULL, "sph", NULL, NULL, NULL, NULL,
NULL, NULL, NULL};
+ const char *reg_cmd[10] = {"r", NULL, "u", NULL, NULL, NULL, NULL, NULL,
NULL, NULL};
+ const char *attr_cmd[10] = {"attr", "set", NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL};
+ const char *mat1 = "1,0.0001,Material01";
+ const char *mat2 = "2,1.1e-1,Material02";
+ const char *mat1_reassign = "1,2.0,Material 03";
+
+ /* Need this for bu_dir to work correctly */
+ bu_setprogname(av[0]);
+
+ if (ac != 2) {
+ printf("Usage: %s test_name\n", av[0]);
+ return 1;
+ }
+
+ if (bu_file_exists(gname, NULL)) {
+ printf("Error: %s already exists\n", gname);
+ return 1;
+ }
+
+ gedp = ged_open("db", gname, 0);
+
+ if (BU_STR_EQUAL(av[1], "dnull")) {
+ if (ged_mater(gedp, 2, (const char **)mater_cmd) != GED_HELP) {
+ bu_log("Error: bare 'mater -d' doesn't return GED_HELP\n");
+ goto ged_test_fail;
+ }
+ }
+
+ if (BU_STR_EQUAL(av[1], "dstd")) {
+
+ if (bu_file_exists(exp_data, NULL)) {
+ printf("ERROR: %s already exists, aborting\n", exp_data);
+ return 2;
+ }
+
+ (void)bu_dir(mdata, MAXPATHLEN, BU_DIR_DATA, "data",
"NIST_DENSITIES", NULL);
+ if (!bu_file_exists(mdata, NULL)) {
+ bu_log("Error: density file %s not found.\n", mdata);
+ goto ged_test_fail;
+ }
+
+ mater_cmd[1] = "-d";
+ mater_cmd[2] = "validate";
+ mater_cmd[3] = mdata;
+ if (ged_mater(gedp, 4, (const char **)mater_cmd) != GED_OK) {
+ bu_log("Error: 'mater -d import' failed to validate %s\n", mdata);
+ goto ged_test_fail;
+ }
+
+ mater_cmd[1] = "-d";
+ mater_cmd[2] = "import";
+ mater_cmd[3] = "-v";
+ mater_cmd[4] = mdata;
+ if (ged_mater(gedp, 5, (const char **)mater_cmd) != GED_OK) {
+ bu_log("Error: 'mater -d import' failed to load %s\n", mdata);
+ goto ged_test_fail;
+ }
+
+ mater_cmd[1] = "-d";
+ mater_cmd[2] = "source";
+ mater_cmd[3] = NULL;
+ if (ged_mater(gedp, 4, (const char **)mater_cmd) != GED_OK) {
+ bu_log("Error: 'mater -d source' failed to run correctly\n");
+ goto ged_test_fail;
+ } else {
+ if (bu_strncmp(bu_vls_cstr(gedp->ged_result_str),
gedp->ged_wdbp->dbip->dbi_filename,
strlen(gedp->ged_wdbp->dbip->dbi_filename))) {
+ bu_log("Error: 'mater -d source' reports a location of %s
instead of %s\n", bu_vls_cstr(gedp->ged_result_str),
gedp->ged_wdbp->dbip->dbi_filename);
+ goto ged_test_fail;
+ }
+ }
+
+ mater_cmd[1] = "-d";
+ mater_cmd[2] = "export";
+ mater_cmd[3] = exp_data;
+ if (ged_mater(gedp, 4, (const char **)mater_cmd) != GED_OK ||
!bu_file_exists(exp_data, NULL)) {
+ bu_log("Error: 'mater -d export' failed to export to %s\n",
exp_data);
+ goto ged_test_fail;
+ }
+ if (check_for_data_exported(exp_data, "Xylene")) {
+ goto ged_test_fail;
+ }
+
+ mater_cmd[1] = "-d";
+ mater_cmd[2] = "clear";
+ if (ged_mater(gedp, 3, (const char **)mater_cmd) != GED_OK) {
+ bu_log("Error: 'mater -d clear' failed\n");
+ goto ged_test_fail;
+ }
+
+ mater_cmd[1] = "-d";
+ mater_cmd[2] = "set";
+ mater_cmd[3] = mat1;
+ if (ged_mater(gedp, 4, (const char **)mater_cmd) != GED_OK) {
+ bu_log("Error: 'mater -d set %s' failed\n", mat1);
+ goto ged_test_fail;
+ }
+ if (check_for_data_present(gedp, "Material01", "1 0.0001
Material01\n")) {
+ goto ged_test_fail;
+ }
+ if (check_for_data_not_present(gedp, "Xylene")) {
+ goto ged_test_fail;
+ }
+
+ mater_cmd[1] = "-d";
+ mater_cmd[2] = "set";
+ mater_cmd[3] = mat2;
+ if (ged_mater(gedp, 4, (const char **)mater_cmd) != GED_OK) {
+ bu_log("Error: 'mater -d set %s' failed\n", mat2);
+ goto ged_test_fail;
+ }
+ if (check_for_data_present(gedp, "Material01", "1 0.0001
Material01\n")) {
+ goto ged_test_fail;
+ }
+ if (check_for_data_present(gedp, "Material02", "2 0.11
Material02\n")) {
+ goto ged_test_fail;
+ }
+
+ mater_cmd[1] = "-d";
+ mater_cmd[2] = "set";
+ mater_cmd[3] = mat1_reassign;
+ if (ged_mater(gedp, 4, (const char **)mater_cmd) != GED_OK) {
+ bu_log("Error: 'mater -d set %s' failed\n", mat1_reassign);
+ goto ged_test_fail;
+ }
+ if (check_for_data_present(gedp, "Material02", "2 0.11
Material02\n")) {
+ goto ged_test_fail;
+ }
+ if (check_for_data_present(gedp, "Material 03", "1 2
Material 03\n")) {
+ goto ged_test_fail;
+ }
+ if (check_for_data_not_present(gedp, "Material01")) {
+ goto ged_test_fail;
+ }
+
+ // Now, test the mapping logic
+
+ mater_cmd[1] = "-d";
+ mater_cmd[2] = "clear";
+ if (ged_mater(gedp, 3, (const char **)mater_cmd) != GED_OK) {
+ bu_log("Error: 'mater -d clear' failed\n");
+ goto ged_test_fail;
+ }
+
+ mater_cmd[1] = "-d";
+ mater_cmd[2] = "import";
+ mater_cmd[3] = "-v";
+ mater_cmd[4] = mdata;
+ if (ged_mater(gedp, 5, (const char **)mater_cmd) != GED_OK) {
+ bu_log("Error: 'mater -d import' failed to load %s\n", mdata);
+ goto ged_test_fail;
+ }
+
+ // Make the initial geometry objects on which the mappings will
+ // operate.
+ make_cmd[1] = "sph1.s";
+ if (ged_make(gedp, 3, (const char **)make_cmd) != GED_OK) {
+ bu_log("Error: failed to make object\n");
+ goto ged_test_fail;
+ }
+ make_cmd[1] = "sph2.s";
+ if (ged_make(gedp, 3, (const char **)make_cmd) != GED_OK) {
+ bu_log("Error: failed to make object\n");
+ goto ged_test_fail;
+ }
+ make_cmd[1] = "sph3.s";
+ if (ged_make(gedp, 3, (const char **)make_cmd) != GED_OK) {
+ bu_log("Error: failed to make object\n");
+ goto ged_test_fail;
+ }
+ reg_cmd[1] = "reg1.r";
+ reg_cmd[3] = "sph1.s";
+ if (ged_region(gedp, 4, (const char **)reg_cmd) != GED_OK) {
+ bu_log("Error: failed to make region\n");
+ goto ged_test_fail;
+ }
+ reg_cmd[1] = "reg2.r";
+ reg_cmd[3] = "sph2.s";
+ if (ged_region(gedp, 4, (const char **)reg_cmd) != GED_OK) {
+ bu_log("Error: failed to make region\n");
+ goto ged_test_fail;
+ }
+ reg_cmd[1] = "reg3.r";
+ reg_cmd[3] = "sph3.s";
+ if (ged_region(gedp, 4, (const char **)reg_cmd) != GED_OK) {
+ bu_log("Error: failed to make region\n");
+ goto ged_test_fail;
+ }
+
+ // Set the seed attributes.
+ attr_cmd[2] = "reg1.r";
+ attr_cmd[3] = "material_id";
+ attr_cmd[4] = "12242";
+ if (ged_attr(gedp, 5, (const char **)attr_cmd) != GED_OK) {
+ bu_log("Error: failed to set attribute\n");
+ goto ged_test_fail;
+ }
+ attr_cmd[2] = "reg2.r";
+ attr_cmd[3] = "material_name";
+ attr_cmd[4] = "Rubber, Natural";
+ if (ged_attr(gedp, 5, (const char **)attr_cmd) != GED_OK) {
+ bu_log("Error: failed to set attribute\n");
+ goto ged_test_fail;
+ }
+ attr_cmd[2] = "reg3.r";
+ attr_cmd[3] = "material_id";
+ attr_cmd[4] = "12244";
+ if (ged_attr(gedp, 5, (const char **)attr_cmd) != GED_OK) {
+ bu_log("Error: failed to set attribute\n");
+ goto ged_test_fail;
+ }
+
+ // In-memory name updates.
+ mater_cmd[1] = "-d";
+ mater_cmd[2] = "map";
+ mater_cmd[3] = "--names-from-ids";
+ if (ged_mater(gedp, 4, (const char **)mater_cmd) != GED_OK) {
+ bu_log("Error: 'mater -d map --names-from-ids' failed to run\n");
+ goto ged_test_fail;
+ }
+ if (attr_val_check(gedp, "reg1.r", "material_name", "Rubber, Butyl")) {
+ goto ged_test_fail;
+ }
+ if (attr_val_check(gedp, "reg2.r", "material_name", "Rubber, Natural"))
{
+ goto ged_test_fail;
+ }
+ if (attr_val_check(gedp, "reg3.r", "material_name", "Rubber,
Neoprene")) {
+ goto ged_test_fail;
+ }
+
+ // In-memory id updates.
+ mater_cmd[1] = "-d";
+ mater_cmd[2] = "map";
+ mater_cmd[3] = "--ids-from-names";
+ if (ged_mater(gedp, 4, (const char **)mater_cmd) != GED_OK) {
+ bu_log("Error: 'mater -d map --ids-from-names' failed to run\n");
+ goto ged_test_fail;
+ }
+ if (attr_val_check(gedp, "reg1.r", "material_id", "12242")) {
+ goto ged_test_fail;
+ }
+ if (attr_val_check(gedp, "reg2.r", "material_id", "12243")) {
+ goto ged_test_fail;
+ }
+ if (attr_val_check(gedp, "reg3.r", "material_id", "12244")) {
+ goto ged_test_fail;
+ }
+
+ // Create files to use for mapping inputs
+ {
+ FILE *dd, *dm, *db;
+ if (((dd = fopen(d_data, "wb")) == NULL) ||
+ ((dm = fopen(m_data, "wb")) == NULL) ||
+ ((db = fopen(b_data, "wb")) == NULL)) {
+ bu_log("Error: could not open mapping input files for
writing\n");
+ goto ged_test_fail;
+ }
+ fprintf(dd, "%s", basic_density);
+ fprintf(dm, "%s", nist_to_basic);
+ fprintf(db, "%s", basic_to_nist);
+ (void)fclose(dd);
+ (void)fclose(dm);
+ (void)fclose(db);
+ }
+
+ // File-based id updates.
+ mater_cmd[1] = "-d";
+ mater_cmd[2] = "map";
+ mater_cmd[3] = "--ids-from-names";
+ mater_cmd[4] = d_data;
+ if (ged_mater(gedp, 5, (const char **)mater_cmd) != GED_OK) {
+ bu_log("Error: 'mater -d map --ids-from-names %s' failed to run\n",
d_data);
+ goto ged_test_fail;
+ }
+ if (attr_val_check(gedp, "reg1.r", "material_id", "12242")) {
+ goto ged_test_fail;
+ }
+ if (attr_val_check(gedp, "reg2.r", "material_id", "12243")) {
+ goto ged_test_fail;
+ }
+ if (attr_val_check(gedp, "reg3.r", "material_id", "16")) {
+ goto ged_test_fail;
+ }
+
+
+ // File-based id updates, with map file.
+ mater_cmd[1] = "-d";
+ mater_cmd[2] = "map";
+ mater_cmd[3] = "--ids-from-names";
+ mater_cmd[4] = d_data;
+ mater_cmd[5] = m_data;
+ if (ged_mater(gedp, 6, (const char **)mater_cmd) != GED_OK) {
+ bu_log("Error: 'mater -d map --ids-from-names %s %s' failed to
run\n", d_data, m_data);
+ goto ged_test_fail;
+ }
+ if (attr_val_check(gedp, "reg1.r", "material_id", "15")) {
+ goto ged_test_fail;
+ }
+ if (attr_val_check(gedp, "reg2.r", "material_id", "15")) {
+ goto ged_test_fail;
+ }
+ if (attr_val_check(gedp, "reg3.r", "material_id", "16")) {
+ goto ged_test_fail;
+ }
+
+ // File-based name updates.
+ mater_cmd[1] = "-d";
+ mater_cmd[2] = "map";
+ mater_cmd[3] = "--names-from-ids";
+ mater_cmd[4] = d_data;
+ if (ged_mater(gedp, 5, (const char **)mater_cmd) != GED_OK) {
+ bu_log("Error: 'mater -d map --names-from-ids %s' failed to run\n",
d_data);
+ goto ged_test_fail;
+ }
+ if (attr_val_check(gedp, "reg1.r", "material_name", "Rubber")) {
+ goto ged_test_fail;
+ }
+ if (attr_val_check(gedp, "reg2.r", "material_name", "Rubber")) {
+ goto ged_test_fail;
+ }
+ if (attr_val_check(gedp, "reg3.r", "material_name", "Rubber,
Neoprene")) {
+ goto ged_test_fail;
+ }
+
+
+ // File-based id updates, with map file, after name update.
+ mater_cmd[1] = "-d";
+ mater_cmd[2] = "map";
+ mater_cmd[3] = "--ids-from-names";
+ mater_cmd[4] = d_data;
+ mater_cmd[5] = m_data;
+ if (ged_mater(gedp, 5, (const char **)mater_cmd) != GED_OK) {
+ bu_log("Error: 'mater -d map --ids-from-names %s %s' failed to
run\n", d_data, m_data);
+ goto ged_test_fail;
+ }
+ if (attr_val_check(gedp, "reg1.r", "material_id", "15")) {
+ goto ged_test_fail;
+ }
+ if (attr_val_check(gedp, "reg2.r", "material_id", "15")) {
+ goto ged_test_fail;
+ }
+ if (attr_val_check(gedp, "reg3.r", "material_id", "16")) {
+ goto ged_test_fail;
+ }
+
+
+ // Map file only id updates.
+ mater_cmd[1] = "-d";
+ mater_cmd[2] = "map";
+ mater_cmd[3] = "--ids-from-names";
+ mater_cmd[4] = b_data;
+ if (ged_mater(gedp, 5, (const char **)mater_cmd) != GED_OK) {
+ bu_log("Error: 'mater -d map --ids-from-names %s' failed to run\n",
b_data);
+ goto ged_test_fail;
+ }
+ if (attr_val_check(gedp, "reg1.r", "material_id", "12243")) {
+ goto ged_test_fail;
+ }
+ if (attr_val_check(gedp, "reg2.r", "material_id", "12243")) {
+ goto ged_test_fail;
+ }
+ if (attr_val_check(gedp, "reg3.r", "material_id", "12244")) {
+ goto ged_test_fail;
+ }
+
+
+ }
+
+ ged_close(gedp);
+ BU_PUT(gedp, struct ged);
+ return 0;
+
+ged_test_fail:
+ ged_close(gedp);
+ BU_PUT(gedp, struct ged);
+ return 1;
+}
+
+/*
+ * Local Variables:
+ * tab-width: 8
+ * mode: C
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */
Copied: brlcad/branches/bioh/regress/ged/regress-ged_mater.cmake.in (from rev
75907, brlcad/branches/bioh/regress/ged/regress-mater.cmake.in)
===================================================================
--- brlcad/branches/bioh/regress/ged/regress-ged_mater.cmake.in
(rev 0)
+++ brlcad/branches/bioh/regress/ged/regress-ged_mater.cmake.in 2020-05-24
03:30:16 UTC (rev 75908)
@@ -0,0 +1,56 @@
+string(REPLACE "\\" "" MATER_EXEC "${EXEC}")
+
+set(CBDIR "@CMAKE_CURRENT_BINARY_DIR@")
+set(CSDIR "@CMAKE_CURRENT_SOURCE_DIR@")
+
+set(OUTPUT_FILES
+ "${CBDIR}/ged_mater_density_data.txt"
+ "${CBDIR}/ged_mater_density_export.txt"
+ "${CBDIR}/ged_mater_density_map.txt"
+ "${CBDIR}/ged_mater_density_reverse_map.txt"
+ "${CBDIR}/ged_mater_test.g"
+ )
+
+# Clean up in case we've run before unsuccessfully
+foreach(of ${OUTPUT_FILES})
+ execute_process(COMMAND "@CMAKE_COMMAND@" -E remove -f "${of}")
+endforeach(of ${OUTPUT_FILES})
+
+file(WRITE "${CBDIR}/regress-ged_mater.log" "Running ${MATER_EXEC} dnull\n")
+execute_process(
+ COMMAND "${MATER_EXEC}" "dnull" RESULT_VARIABLE ged_mater_result
+ OUTPUT_VARIABLE ged_mater_log ERROR_VARIABLE ged_mater_log
+ WORKING_DIRECTORY ${CBDIR}
+ )
+file(APPEND "${CBDIR}/regress-ged_mater.log" "${ged_mater_log}")
+if(ged_mater_result)
+ message(FATAL_ERROR "[regress-ged_mater] Failure: ${ged_mater_result}. See
${CBDIR}/regress-ged_mater.log for more info.\n")
+endif(ged_mater_result)
+
+execute_process(COMMAND "@CMAKE_COMMAND@" -E remove
"${CBDIR}/ged_mater_test.g")
+
+file(APPEND "${CBDIR}/regress-ged_mater.log" "Running ${MATER_EXEC} dstd\n")
+execute_process(
+ COMMAND "${MATER_EXEC}" "dstd" RESULT_VARIABLE ged_mater_result
+ OUTPUT_VARIABLE ged_mater_log ERROR_VARIABLE ged_mater_log
+ WORKING_DIRECTORY ${CBDIR}
+ )
+file(APPEND "${CBDIR}/regress-ged_mater.log" "${ged_mater_log}")
+
+if(ged_mater_result)
+ message(FATAL_ERROR "[regress-ged_mater] Failure: ${ged_mater_result}. See
${CBDIR}/regress-ged_mater.log for more info.\n")
+endif(ged_mater_result)
+
+# Clean up
+foreach(of ${OUTPUT_FILES})
+ file(APPEND "${CBDIR}/regress-ged_mater.log" "Removing ${of}\n")
+ execute_process(COMMAND "@CMAKE_COMMAND@" -E remove -f "${of}")
+endforeach(of ${OUTPUT_FILES})
+
+# Local Variables:
+# tab-width: 8
+# mode: cmake
+# indent-tabs-mode: t
+# End:
+# ex: shiftwidth=2 tabstop=8
+
Deleted: brlcad/branches/bioh/regress/ged/regress-mater.cmake.in
===================================================================
--- brlcad/branches/bioh/regress/ged/regress-mater.cmake.in 2020-05-24
02:32:16 UTC (rev 75907)
+++ brlcad/branches/bioh/regress/ged/regress-mater.cmake.in 2020-05-24
03:30:16 UTC (rev 75908)
@@ -1,65 +0,0 @@
-set(CBDIR "@CMAKE_CURRENT_BINARY_DIR@")
-set(CSDIR "@CMAKE_CURRENT_SOURCE_DIR@")
-
-set(SBDIR "@CMAKE_RUNTIME_OUTPUT_DIRECTORY@")
-set(DBDIR "@CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG@")
-set(RBDIR "@CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE@")
-# Use the mechanism created to allow multiconfig builds to
-# know what the current build type is.
-if(EXISTS "@CMAKE_BINARY_DIR@/CMakeTmp/CURRENT_PATH/Release")
- set(BDIR "${RBDIR}")
- set(test_suffix "-Release")
-elseif(EXISTS "@CMAKE_BINARY_DIR@/CMakeTmp/CURRENT_PATH/Debug")
- set(BDIR "${DBDIR}")
- set(test_suffix "-Debug")
-else(EXISTS "@CMAKE_BINARY_DIR@/CMakeTmp/CURRENT_PATH/Release")
- set(BDIR "${SBDIR}")
- set(test_suffix)
-endif(EXISTS "@CMAKE_BINARY_DIR@/CMakeTmp/CURRENT_PATH/Release")
-
-get_filename_component(EXE "@CMAKE_COMMAND@" EXT)
-set(GED_TEST_MATER "${BDIR}/regress_ged_mater${EXE}")
-
-# Clean up in case we've run before
-execute_process(COMMAND "@CMAKE_COMMAND@" -E remove
"${CBDIR}/ged_mater_test.g")
-execute_process(COMMAND "@CMAKE_COMMAND@" -E remove
"${CBDIR}/ged_mater_density_export.txt")
-execute_process(COMMAND "@CMAKE_COMMAND@" -E remove
"${CBDIR}/ged_mater_density_data.txt")
-execute_process(COMMAND "@CMAKE_COMMAND@" -E remove
"${CBDIR}/ged_mater_density_map.txt")
-execute_process(COMMAND "@CMAKE_COMMAND@" -E remove
"${CBDIR}/ged_mater_density_reverse_map.txt")
-
-execute_process(
- COMMAND "${GED_TEST_MATER}" "dnull" RESULT_VARIABLE ged_mater_result
- OUTPUT_VARIABLE ged_mater_log ERROR_VARIABLE ged_mater_log
- WORKING_DIRECTORY ${CBDIR}
- )
-file(APPEND "${CBDIR}/regress_ged_mater.log" "${ged_mater_log}")
-
-execute_process(COMMAND "@CMAKE_COMMAND@" -E remove
"${CBDIR}/ged_mater_test.g")
-
-execute_process(
- COMMAND "${GED_TEST_MATER}" "dstd" RESULT_VARIABLE ged_mater_result
- OUTPUT_VARIABLE ged_mater_log ERROR_VARIABLE ged_mater_log
- WORKING_DIRECTORY ${CBDIR}
- )
-file(APPEND "${CBDIR}/regress_ged_mater.log" "${ged_mater_log}")
-
-# Clean up
-execute_process(COMMAND "@CMAKE_COMMAND@" -E remove
"${CBDIR}/ged_mater_test.g")
-execute_process(COMMAND "@CMAKE_COMMAND@" -E remove
"${CBDIR}/ged_mater_density_export.txt")
-execute_process(COMMAND "@CMAKE_COMMAND@" -E remove
"${CBDIR}/ged_mater_density_data.txt")
-execute_process(COMMAND "@CMAKE_COMMAND@" -E remove
"${CBDIR}/ged_mater_density_map.txt")
-execute_process(COMMAND "@CMAKE_COMMAND@" -E remove
"${CBDIR}/ged_mater_density_reverse_map.txt")
-
-if(ged_mater_result)
- message(FATAL_ERROR "[regress-ged-mater] Failure, see
${CBDIR}/regress_ged_mater.log for more info.\n")
-else(ged_mater_result)
- execute_process(COMMAND "@CMAKE_COMMAND@" -E touch
"@CMAKE_CURRENT_BINARY_DIR@/regress_ged_mater${test_suffix}.done")
-endif(ged_mater_result)
-
-# Local Variables:
-# tab-width: 8
-# mode: cmake
-# indent-tabs-mode: t
-# End:
-# ex: shiftwidth=2 tabstop=8
-
Modified: brlcad/branches/bioh/src/libged/tests/CMakeLists.txt
===================================================================
--- brlcad/branches/bioh/src/libged/tests/CMakeLists.txt 2020-05-24
02:32:16 UTC (rev 75907)
+++ brlcad/branches/bioh/src/libged/tests/CMakeLists.txt 2020-05-24
03:30:16 UTC (rev 75908)
@@ -4,9 +4,6 @@
BRLCAD_ADDEXEC(ged_test_list test_list.c libged TEST)
add_test(NAME ged_test_list COMMAND ged_test_list 2)
-# This is a bit much for a unit test, so it is run as a regression test
-BRLCAD_ADDEXEC(regress_ged_mater mater.c libged TEST_USESDATA)
-
# Note: it is particularly important that the lint tests in particular are kept
# in a separate file, since its bad input examples stand an excellent chance of
# breaking commands.
Deleted: brlcad/branches/bioh/src/libged/tests/mater.c
===================================================================
--- brlcad/branches/bioh/src/libged/tests/mater.c 2020-05-24 02:32:16 UTC
(rev 75907)
+++ brlcad/branches/bioh/src/libged/tests/mater.c 2020-05-24 03:30:16 UTC
(rev 75908)
@@ -1,511 +0,0 @@
-/* M A T E R . C
- * BRL-CAD
- *
- * Copyright (c) 2018-2020 United States Government as represented by
- * the U.S. Army Research Laboratory.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this file; see the file named COPYING for more
- * information.
- */
-/** @file mater.c
- *
- * Brief description
- *
- */
-
-#include "common.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <bu.h>
-#include <ged.h>
-
-const char *basic_density =
-"15 0.920000 Rubber\n"
-"16 1.230000 Rubber, Neoprene\n";
-
-const char *nist_to_basic =
-"\"Rubber, Butyl\" Rubber\n"
-"\"Rubber, Natural\" Rubber\n";
-
-const char *basic_to_nist =
-"\"Rubber\" \"Rubber, Natural\"\n";
-
-
-int
-check_for_data_exported(const char *filename, const char *key)
-{
- struct bu_mapped_file *efile = bu_open_mapped_file(filename, "exported
densities data");
- if (!strstr((char *)efile->buf, key)) {
- bu_log("Error: 'mater -d export' file %s does not contain all expected
data\n", filename);
- bu_close_mapped_file(efile);
- return -1;
- }
- bu_close_mapped_file(efile);
- return 0;
-}
-
-int
-check_for_data_present(struct ged *gedp, const char *key, const char *expected)
-{
- const char *mater_cmd[10] = {"mater", "-d", NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL};
- mater_cmd[1] = "-d";
- mater_cmd[2] = "get";
- mater_cmd[3] = "--name";
- mater_cmd[4] = key;
- if (ged_mater(gedp, 5, (const char **)mater_cmd) != GED_OK) {
- bu_log("Error: 'mater -d get --name %s' failed\n", key);
- return -1;
- }
- if (!BU_STR_EQUAL(bu_vls_cstr(gedp->ged_result_str), expected)) {
- bu_log("Error: expected '%s', got: '%s'\n", expected,
bu_vls_cstr(gedp->ged_result_str));
- return -1;
- }
- return 0;
-}
-
-
-int
-check_for_data_not_present(struct ged *gedp, const char *key)
-{
- const char *mater_cmd[10] = {"mater", "-d", NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL};
- mater_cmd[1] = "-d";
- mater_cmd[2] = "get";
- mater_cmd[3] = "--name";
- mater_cmd[4] = key;
- if (ged_mater(gedp, 5, (const char **)mater_cmd) != GED_OK) {
- bu_log("Error: 'mater -d get --name %s' failed\n", key);
- return -1;
- }
- if (bu_vls_strlen(gedp->ged_result_str)) {
- bu_log("Error: unexpected result found for key %s: '%s'\n", key,
bu_vls_cstr(gedp->ged_result_str));
- return -1;
- }
- return 0;
-}
-
-int
-attr_val_check(struct ged *gedp, const char *obj, const char *key, const char
*expected)
-{
- const char *attr_cmd[5] = {"attr", "get", NULL, NULL, NULL};
- attr_cmd[2] = obj;
- attr_cmd[3] = key;
- if (ged_attr(gedp, 4, (const char **)attr_cmd) != GED_OK) {
- bu_log("Error: 'attr get %s %s' failed\n", obj, key);
- return -1;
- }
- if (!BU_STR_EQUAL(bu_vls_cstr(gedp->ged_result_str), expected)) {
- bu_log("Error: expected '%s', got: '%s'\n", expected,
bu_vls_cstr(gedp->ged_result_str));
- return -1;
- }
- return 0;
-}
-
-
-int
-main(int ac, char *av[]) {
- struct ged *gedp;
- const char *gname = "ged_mater_test.g";
- const char *exp_data = "ged_mater_density_export.txt";
- const char *d_data = "ged_mater_density_data.txt";
- const char *m_data = "ged_mater_density_map.txt";
- const char *b_data = "ged_mater_density_reverse_map.txt";
- char mdata[MAXPATHLEN];
- const char *mater_cmd[10] = {"mater", "-d", NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL};
- const char *make_cmd[10] = {"make", NULL, "sph", NULL, NULL, NULL, NULL,
NULL, NULL, NULL};
- const char *reg_cmd[10] = {"r", NULL, "u", NULL, NULL, NULL, NULL, NULL,
NULL, NULL};
- const char *attr_cmd[10] = {"attr", "set", NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL};
- const char *mat1 = "1,0.0001,Material01";
- const char *mat2 = "2,1.1e-1,Material02";
- const char *mat1_reassign = "1,2.0,Material 03";
-
- /* Need this for bu_dir to work correctly */
- bu_setprogname(av[0]);
-
- if (ac != 2) {
- printf("Usage: %s test_name\n", av[0]);
- return 1;
- }
-
- if (bu_file_exists(gname, NULL)) {
- printf("Error: %s already exists\n", gname);
- return 1;
- }
-
- gedp = ged_open("db", gname, 0);
-
- if (BU_STR_EQUAL(av[1], "dnull")) {
- if (ged_mater(gedp, 2, (const char **)mater_cmd) != GED_HELP) {
- bu_log("Error: bare 'mater -d' doesn't return GED_HELP\n");
- goto ged_test_fail;
- }
- }
-
- if (BU_STR_EQUAL(av[1], "dstd")) {
-
- if (bu_file_exists(exp_data, NULL)) {
- printf("ERROR: %s already exists, aborting\n", exp_data);
- return 2;
- }
-
- (void)bu_dir(mdata, MAXPATHLEN, BU_DIR_DATA, "data",
"NIST_DENSITIES", NULL);
- if (!bu_file_exists(mdata, NULL)) {
- bu_log("Error: density file %s not found.\n", mdata);
- goto ged_test_fail;
- }
-
- mater_cmd[1] = "-d";
- mater_cmd[2] = "validate";
- mater_cmd[3] = mdata;
- if (ged_mater(gedp, 4, (const char **)mater_cmd) != GED_OK) {
- bu_log("Error: 'mater -d import' failed to validate %s\n", mdata);
- goto ged_test_fail;
- }
-
- mater_cmd[1] = "-d";
- mater_cmd[2] = "import";
- mater_cmd[3] = "-v";
- mater_cmd[4] = mdata;
- if (ged_mater(gedp, 5, (const char **)mater_cmd) != GED_OK) {
- bu_log("Error: 'mater -d import' failed to load %s\n", mdata);
- goto ged_test_fail;
- }
-
- mater_cmd[1] = "-d";
- mater_cmd[2] = "source";
- mater_cmd[3] = NULL;
- if (ged_mater(gedp, 4, (const char **)mater_cmd) != GED_OK) {
- bu_log("Error: 'mater -d source' failed to run correctly\n");
- goto ged_test_fail;
- } else {
- if (bu_strncmp(bu_vls_cstr(gedp->ged_result_str),
gedp->ged_wdbp->dbip->dbi_filename,
strlen(gedp->ged_wdbp->dbip->dbi_filename))) {
- bu_log("Error: 'mater -d source' reports a location of %s
instead of %s\n", bu_vls_cstr(gedp->ged_result_str),
gedp->ged_wdbp->dbip->dbi_filename);
- goto ged_test_fail;
- }
- }
-
- mater_cmd[1] = "-d";
- mater_cmd[2] = "export";
- mater_cmd[3] = exp_data;
- if (ged_mater(gedp, 4, (const char **)mater_cmd) != GED_OK ||
!bu_file_exists(exp_data, NULL)) {
- bu_log("Error: 'mater -d export' failed to export to %s\n",
exp_data);
- goto ged_test_fail;
- }
- if (check_for_data_exported(exp_data, "Xylene")) {
- goto ged_test_fail;
- }
-
- mater_cmd[1] = "-d";
- mater_cmd[2] = "clear";
- if (ged_mater(gedp, 3, (const char **)mater_cmd) != GED_OK) {
- bu_log("Error: 'mater -d clear' failed\n");
- goto ged_test_fail;
- }
-
- mater_cmd[1] = "-d";
- mater_cmd[2] = "set";
- mater_cmd[3] = mat1;
- if (ged_mater(gedp, 4, (const char **)mater_cmd) != GED_OK) {
- bu_log("Error: 'mater -d set %s' failed\n", mat1);
- goto ged_test_fail;
- }
- if (check_for_data_present(gedp, "Material01", "1 0.0001
Material01\n")) {
- goto ged_test_fail;
- }
- if (check_for_data_not_present(gedp, "Xylene")) {
- goto ged_test_fail;
- }
-
- mater_cmd[1] = "-d";
- mater_cmd[2] = "set";
- mater_cmd[3] = mat2;
- if (ged_mater(gedp, 4, (const char **)mater_cmd) != GED_OK) {
- bu_log("Error: 'mater -d set %s' failed\n", mat2);
- goto ged_test_fail;
- }
- if (check_for_data_present(gedp, "Material01", "1 0.0001
Material01\n")) {
- goto ged_test_fail;
- }
- if (check_for_data_present(gedp, "Material02", "2 0.11
Material02\n")) {
- goto ged_test_fail;
- }
-
- mater_cmd[1] = "-d";
- mater_cmd[2] = "set";
- mater_cmd[3] = mat1_reassign;
- if (ged_mater(gedp, 4, (const char **)mater_cmd) != GED_OK) {
- bu_log("Error: 'mater -d set %s' failed\n", mat1_reassign);
- goto ged_test_fail;
- }
- if (check_for_data_present(gedp, "Material02", "2 0.11
Material02\n")) {
- goto ged_test_fail;
- }
- if (check_for_data_present(gedp, "Material 03", "1 2
Material 03\n")) {
- goto ged_test_fail;
- }
- if (check_for_data_not_present(gedp, "Material01")) {
- goto ged_test_fail;
- }
-
- // Now, test the mapping logic
-
- mater_cmd[1] = "-d";
- mater_cmd[2] = "clear";
- if (ged_mater(gedp, 3, (const char **)mater_cmd) != GED_OK) {
- bu_log("Error: 'mater -d clear' failed\n");
- goto ged_test_fail;
- }
-
- mater_cmd[1] = "-d";
- mater_cmd[2] = "import";
- mater_cmd[3] = "-v";
- mater_cmd[4] = mdata;
- if (ged_mater(gedp, 5, (const char **)mater_cmd) != GED_OK) {
- bu_log("Error: 'mater -d import' failed to load %s\n", mdata);
- goto ged_test_fail;
- }
-
- // Make the initial geometry objects on which the mappings will
- // operate.
- make_cmd[1] = "sph1.s";
- if (ged_make(gedp, 3, (const char **)make_cmd) != GED_OK) {
- bu_log("Error: failed to make object\n");
- goto ged_test_fail;
- }
- make_cmd[1] = "sph2.s";
- if (ged_make(gedp, 3, (const char **)make_cmd) != GED_OK) {
- bu_log("Error: failed to make object\n");
- goto ged_test_fail;
- }
- make_cmd[1] = "sph3.s";
- if (ged_make(gedp, 3, (const char **)make_cmd) != GED_OK) {
- bu_log("Error: failed to make object\n");
- goto ged_test_fail;
- }
- reg_cmd[1] = "reg1.r";
- reg_cmd[3] = "sph1.s";
- if (ged_region(gedp, 4, (const char **)reg_cmd) != GED_OK) {
- bu_log("Error: failed to make region\n");
- goto ged_test_fail;
- }
- reg_cmd[1] = "reg2.r";
- reg_cmd[3] = "sph2.s";
- if (ged_region(gedp, 4, (const char **)reg_cmd) != GED_OK) {
- bu_log("Error: failed to make region\n");
- goto ged_test_fail;
- }
- reg_cmd[1] = "reg3.r";
- reg_cmd[3] = "sph3.s";
- if (ged_region(gedp, 4, (const char **)reg_cmd) != GED_OK) {
- bu_log("Error: failed to make region\n");
- goto ged_test_fail;
- }
-
- // Set the seed attributes.
- attr_cmd[2] = "reg1.r";
- attr_cmd[3] = "material_id";
- attr_cmd[4] = "12242";
- if (ged_attr(gedp, 5, (const char **)attr_cmd) != GED_OK) {
- bu_log("Error: failed to set attribute\n");
- goto ged_test_fail;
- }
- attr_cmd[2] = "reg2.r";
- attr_cmd[3] = "material_name";
- attr_cmd[4] = "Rubber, Natural";
- if (ged_attr(gedp, 5, (const char **)attr_cmd) != GED_OK) {
- bu_log("Error: failed to set attribute\n");
- goto ged_test_fail;
- }
- attr_cmd[2] = "reg3.r";
- attr_cmd[3] = "material_id";
- attr_cmd[4] = "12244";
- if (ged_attr(gedp, 5, (const char **)attr_cmd) != GED_OK) {
- bu_log("Error: failed to set attribute\n");
- goto ged_test_fail;
- }
-
- // In-memory name updates.
- mater_cmd[1] = "-d";
- mater_cmd[2] = "map";
- mater_cmd[3] = "--names-from-ids";
- if (ged_mater(gedp, 4, (const char **)mater_cmd) != GED_OK) {
- bu_log("Error: 'mater -d map --names-from-ids' failed to run\n");
- goto ged_test_fail;
- }
- if (attr_val_check(gedp, "reg1.r", "material_name", "Rubber, Butyl")) {
- goto ged_test_fail;
- }
- if (attr_val_check(gedp, "reg2.r", "material_name", "Rubber, Natural"))
{
- goto ged_test_fail;
- }
- if (attr_val_check(gedp, "reg3.r", "material_name", "Rubber,
Neoprene")) {
- goto ged_test_fail;
- }
-
- // In-memory id updates.
- mater_cmd[1] = "-d";
- mater_cmd[2] = "map";
- mater_cmd[3] = "--ids-from-names";
- if (ged_mater(gedp, 4, (const char **)mater_cmd) != GED_OK) {
- bu_log("Error: 'mater -d map --ids-from-names' failed to run\n");
- goto ged_test_fail;
- }
- if (attr_val_check(gedp, "reg1.r", "material_id", "12242")) {
- goto ged_test_fail;
- }
- if (attr_val_check(gedp, "reg2.r", "material_id", "12243")) {
- goto ged_test_fail;
- }
- if (attr_val_check(gedp, "reg3.r", "material_id", "12244")) {
- goto ged_test_fail;
- }
-
- // Create files to use for mapping inputs
- {
- FILE *dd, *dm, *db;
- if (((dd = fopen(d_data, "wb")) == NULL) ||
- ((dm = fopen(m_data, "wb")) == NULL) ||
- ((db = fopen(b_data, "wb")) == NULL)) {
- bu_log("Error: could not open mapping input files for
writing\n");
- goto ged_test_fail;
- }
- fprintf(dd, "%s", basic_density);
- fprintf(dm, "%s", nist_to_basic);
- fprintf(db, "%s", basic_to_nist);
- (void)fclose(dd);
- (void)fclose(dm);
- (void)fclose(db);
- }
-
- // File-based id updates.
- mater_cmd[1] = "-d";
- mater_cmd[2] = "map";
- mater_cmd[3] = "--ids-from-names";
- mater_cmd[4] = d_data;
- if (ged_mater(gedp, 5, (const char **)mater_cmd) != GED_OK) {
- bu_log("Error: 'mater -d map --ids-from-names %s' failed to run\n",
d_data);
- goto ged_test_fail;
- }
- if (attr_val_check(gedp, "reg1.r", "material_id", "12242")) {
- goto ged_test_fail;
- }
- if (attr_val_check(gedp, "reg2.r", "material_id", "12243")) {
- goto ged_test_fail;
- }
- if (attr_val_check(gedp, "reg3.r", "material_id", "16")) {
- goto ged_test_fail;
- }
-
-
- // File-based id updates, with map file.
- mater_cmd[1] = "-d";
- mater_cmd[2] = "map";
- mater_cmd[3] = "--ids-from-names";
- mater_cmd[4] = d_data;
- mater_cmd[5] = m_data;
- if (ged_mater(gedp, 6, (const char **)mater_cmd) != GED_OK) {
- bu_log("Error: 'mater -d map --ids-from-names %s %s' failed to
run\n", d_data, m_data);
- goto ged_test_fail;
- }
- if (attr_val_check(gedp, "reg1.r", "material_id", "15")) {
- goto ged_test_fail;
- }
- if (attr_val_check(gedp, "reg2.r", "material_id", "15")) {
- goto ged_test_fail;
- }
- if (attr_val_check(gedp, "reg3.r", "material_id", "16")) {
- goto ged_test_fail;
- }
-
- // File-based name updates.
- mater_cmd[1] = "-d";
- mater_cmd[2] = "map";
- mater_cmd[3] = "--names-from-ids";
- mater_cmd[4] = d_data;
- if (ged_mater(gedp, 5, (const char **)mater_cmd) != GED_OK) {
- bu_log("Error: 'mater -d map --names-from-ids %s' failed to run\n",
d_data);
- goto ged_test_fail;
- }
- if (attr_val_check(gedp, "reg1.r", "material_name", "Rubber")) {
- goto ged_test_fail;
- }
- if (attr_val_check(gedp, "reg2.r", "material_name", "Rubber")) {
- goto ged_test_fail;
- }
- if (attr_val_check(gedp, "reg3.r", "material_name", "Rubber,
Neoprene")) {
- goto ged_test_fail;
- }
-
-
- // File-based id updates, with map file, after name update.
- mater_cmd[1] = "-d";
- mater_cmd[2] = "map";
- mater_cmd[3] = "--ids-from-names";
- mater_cmd[4] = d_data;
- mater_cmd[5] = m_data;
- if (ged_mater(gedp, 5, (const char **)mater_cmd) != GED_OK) {
- bu_log("Error: 'mater -d map --ids-from-names %s %s' failed to
run\n", d_data, m_data);
- goto ged_test_fail;
- }
- if (attr_val_check(gedp, "reg1.r", "material_id", "15")) {
- goto ged_test_fail;
- }
- if (attr_val_check(gedp, "reg2.r", "material_id", "15")) {
- goto ged_test_fail;
- }
- if (attr_val_check(gedp, "reg3.r", "material_id", "16")) {
- goto ged_test_fail;
- }
-
-
- // Map file only id updates.
- mater_cmd[1] = "-d";
- mater_cmd[2] = "map";
- mater_cmd[3] = "--ids-from-names";
- mater_cmd[4] = b_data;
- if (ged_mater(gedp, 5, (const char **)mater_cmd) != GED_OK) {
- bu_log("Error: 'mater -d map --ids-from-names %s' failed to run\n",
b_data);
- goto ged_test_fail;
- }
- if (attr_val_check(gedp, "reg1.r", "material_id", "12243")) {
- goto ged_test_fail;
- }
- if (attr_val_check(gedp, "reg2.r", "material_id", "12243")) {
- goto ged_test_fail;
- }
- if (attr_val_check(gedp, "reg3.r", "material_id", "12244")) {
- goto ged_test_fail;
- }
-
-
- }
-
- ged_close(gedp);
- BU_PUT(gedp, struct ged);
- return 0;
-
-ged_test_fail:
- ged_close(gedp);
- BU_PUT(gedp, struct ged);
- return 1;
-}
-
-/*
- * Local Variables:
- * tab-width: 8
- * mode: C
- * indent-tabs-mode: t
- * c-file-style: "stroustrup"
- * End:
- * ex: shiftwidth=4 tabstop=8
- */
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits